Skip to content

Commit

Permalink
Require approval before starting a CI run
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Mar 15, 2021
1 parent d551fe4 commit e097b19
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@ name: Validate everything
push:
branches:
- master
pull_request:
pull_request_target:
types:
- labeled
branches:
- master
- hack
env:
DOCKER_HUB_USERNAME: shepmaster
GH_CONTAINER_REGISTRY_USERNAME: shepmaster
AWS_ACCESS_KEY_ID: AKIAWESVHZ3J6SV43YWE
jobs:
debug:
runs-on: ubuntu-latest
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
steps:
- run: echo '${{ secrets.AWS_SECRET_ACCESS_KEY }}' | wc
- run: echo '${{ secrets.DOCKER_HUB_TOKEN }}' | wc
- run: echo '${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}' | wc
- run: echo '${{ secrets.PLAYGROUND_GITHUB_TOKEN }}' | wc
build_compiler_containers:
name: Build ${{ matrix.channel }} compiler container
runs-on: ubuntu-latest
Expand All @@ -22,11 +33,14 @@ jobs:
- stable
- beta
- nightly
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
env:
IMAGE_NAME: ghcr.io/integer32llc/rust-playground-ci-rust-${{ matrix.channel }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
Expand Down Expand Up @@ -124,11 +138,14 @@ jobs:
- clippy
- miri
- rustfmt
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
env:
IMAGE_NAME: ghcr.io/integer32llc/rust-playground-ci-tool-${{ matrix.tool }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
Expand All @@ -155,9 +172,12 @@ jobs:
build_backend:
name: Build backend
runs-on: ubuntu-latest
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Cache Cargo intermediate products
uses: actions/cache@v2
with:
Expand All @@ -182,9 +202,12 @@ jobs:
build_frontend:
name: Build frontend
runs-on: ubuntu-latest
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand Down Expand Up @@ -214,6 +237,7 @@ jobs:
run_integration_tests:
name: Running integration tests
runs-on: ubuntu-latest
if: 'contains(github.event.pull_request.labels.*.name, ''CI: approved'')'
needs:
- build_compiler_containers
- build_tool_containers
Expand All @@ -225,6 +249,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: "${{ github.event.pull_request.head.sha }}"
- name: Configure Ruby
uses: actions/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
name: Scheduled rebuild
'on':
workflow_dispatch:
workflow_dispatch:
schedule:
- cron: 7 2 * * *
env:
Expand Down
36 changes: 30 additions & 6 deletions ci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ components:
name: "Checkout code"
uses: actions/checkout@v2

# This should only be used when we know that the code being tested
# doesn't make use of our secrets or elevated GitHub token.
- checkout_pr: &checkout_pr
name: "Checkout code"
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- docker_buildx: &docker_buildx
name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v1
Expand Down Expand Up @@ -212,20 +220,32 @@ workflows:
push:
branches:
- master
pull_request:
pull_request_target:
types: [labeled]
branches:
- master
- hack

<<: *global_env

jobs:
debug:
runs-on: ubuntu-latest
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
steps:
- run: echo '${{ secrets.AWS_SECRET_ACCESS_KEY }}' | wc
- run: echo '${{ secrets.DOCKER_HUB_TOKEN }}' | wc
- run: echo '${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}' | wc
- run: echo '${{ secrets.PLAYGROUND_GITHUB_TOKEN }}' | wc

build_compiler_containers:
<<: *build_compiler_containers_job
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
env:
<<: *build_compiler_containers_job_env

steps:
- *checkout
- *checkout_pr
- *docker_buildx
- *login_ghcr
- *build_compiler_containers_toolchain
Expand All @@ -236,21 +256,23 @@ workflows:

build_tool_containers:
<<: *build_tool_containers_job
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
env:
<<: *build_tool_containers_job_env

steps:
- *checkout
- *checkout_pr
- *docker_buildx
- *login_ghcr
- *build_tool_containers_final

build_backend:
name: "Build backend"
runs-on: ubuntu-latest
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"

steps:
- *checkout
- *checkout_pr

- name: "Cache Cargo intermediate products"
uses: actions/cache@v2
Expand Down Expand Up @@ -290,9 +312,10 @@ workflows:
build_frontend:
name: "Build frontend"
runs-on: ubuntu-latest
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"

steps:
- *checkout
- *checkout_pr

- name: "Get yarn cache directory path"
id: yarn-cache-dir-path
Expand Down Expand Up @@ -336,6 +359,7 @@ workflows:
run_integration_tests:
name: "Running integration tests"
runs-on: ubuntu-latest
if: "contains(github.event.pull_request.labels.*.name, 'CI: approved')"
needs:
- build_compiler_containers
- build_tool_containers
Expand All @@ -347,7 +371,7 @@ workflows:
working-directory: tests

steps:
- *checkout
- *checkout_pr

- name: "Configure Ruby"
uses: actions/setup-ruby@v1
Expand Down

0 comments on commit e097b19

Please sign in to comment.