Skip to content

Commit cf8e16e

Browse files
authored
Merge pull request #1921 from Kobzol/ci-merge-queue
Switch CI to use a merge queue
2 parents a7a29cf + c5efaef commit cf8e16e

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

.github/workflows/ci.yml

+27-19
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
name: CI
22
on:
3-
push: {}
4-
pull_request: {}
5-
schedule:
6-
- cron: "0 12 * * 1" # Every Monday at 12:00 UTC
3+
pull_request:
4+
merge_group:
75

86
env:
97
AWS_ACCESS_KEY_ID: AKIA46X5W6CZEAQSMRH7
108

119
jobs:
12-
rustfmt:
13-
name: Rustfmt
14-
runs-on: ubuntu-latest
15-
steps:
16-
- uses: actions/checkout@master
17-
- name: Install Rust
18-
run: rustup update stable && rustup default stable && rustup component add rustfmt
19-
- run: cargo fmt --all --check
20-
2110
test:
2211
name: Test
2312
runs-on: ubuntu-latest
@@ -38,15 +27,16 @@ jobs:
3827
- uses: Swatinem/rust-cache@v2
3928
- name: Run tests
4029
run: cargo test --workspace --all-targets
30+
- name: Check formatting
31+
run: cargo fmt --all --check
4132

42-
ci:
43-
name: CI
33+
deploy:
34+
name: Deploy
4435
runs-on: ubuntu-latest
36+
if: github.event_name == 'merge_group'
4537
steps:
4638
- name: Checkout the source code
47-
uses: actions/checkout@v2
48-
with:
49-
fetch-depth: 1
39+
uses: actions/checkout@v4
5040

5141
- name: Test and build
5242
run: docker build -t triagebot .
@@ -61,4 +51,22 @@ jobs:
6151
redeploy_ecs_service: triagebot
6252
aws_access_key_id: "${{ env.AWS_ACCESS_KEY_ID }}"
6353
aws_secret_access_key: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
64-
if: github.ref == 'refs/heads/master'
54+
55+
# Summary job for the merge queue.
56+
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
57+
ci:
58+
needs: [ test, deploy ]
59+
# We need to ensure this job does *not* get skipped if its dependencies fail,
60+
# because a skipped job is considered a success by GitHub. So we have to
61+
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
62+
# when the workflow is canceled manually.
63+
if: ${{ !cancelled() }}
64+
runs-on: ubuntu-latest
65+
steps:
66+
# Manually check the status of all dependencies. `if: failure()` does not work.
67+
- name: Conclusion
68+
run: |
69+
# Print the dependent jobs to see them in the CI log
70+
jq -C <<< '${{ toJson(needs) }}'
71+
# Check if all jobs that we depend on (in the needs array) were successful.
72+
jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'

0 commit comments

Comments
 (0)