Skip to content

Commit e01eeb0

Browse files
committed
Auto merge of #13317 - Urgau:improve-ci, r=epage
Improve GitHub Actions CI config This pull request improves Cargo CI by: 1. Explicitly listing the branches the main CI should be run on (to avoid running on unwanted branches, particularly in forks) 2. By adding a [concurrency](https://docs.github.com/en/actions/using-jobs/using-concurrency) config so that only one "CI" runs for each "group" (one by PR), very inspired by rust-lang/rust [one](https://github.com/rust-lang/rust/blob/c485ee71477a29041895c47cc441b364670f3772/.github/workflows/ci.yml#L35) 3. ~~By making all the jobs run only if triggered from this repository (to avoid having forks unnecessarily run CI jobs)~~ 4. ~~By making all the checkouts take `fetch-depth: 2` like done in [rust-lang/rust](https://github.com/rust-lang/rust/blob/c485ee71477a29041895c47cc441b364670f3772/.github/workflows/ci.yml#L452-L455) (to avoid unnecessary work, saves bandwidth and maybe a bit of time)~~ 5. Included `refs/heads/try` in the `success` and `failure` bors job gates (to fix `bors try` from timing out) The main motivation for this PR was (at first) to make the CI jobs not run on forks since it's a waste of CI resources as well as always failing (like [this](https://github.com/Urgau/cargo/actions/runs/7567435677/job/20606586124)); but after looking at the `main.yml` config I took the opportunity to improve the situation by using rust-lang/rust [ci.yml](https://github.com/rust-lang/rust/blob/master/.github/workflows/ci.yml) as reference.
2 parents 9574120 + 2739b6d commit e01eeb0

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
name: CI
22
on:
33
push:
4-
branches-ignore: [master]
4+
branches:
5+
- auto-cargo
6+
- try
7+
- automation/bors/try
58
pull_request:
6-
branches: ['*']
9+
branches:
10+
- "**"
711

812
defaults:
913
run:
@@ -12,6 +16,10 @@ defaults:
1216
permissions:
1317
contents: read
1418

19+
concurrency:
20+
group: "${{ github.workflow }}-${{ (github.ref == 'refs/heads/try' && github.sha) || github.ref }}"
21+
cancel-in-progress: true
22+
1523
jobs:
1624
success:
1725
permissions:
@@ -28,7 +36,7 @@ jobs:
2836
- test
2937
- test_gitoxide
3038
runs-on: ubuntu-latest
31-
if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
39+
if: "success() && github.event_name == 'push' && (github.ref == 'refs/heads/auto-cargo' || github.ref == 'refs/heads/try') && github.repository == 'rust-lang/cargo'"
3240
steps:
3341
- run: echo ok
3442
failure:
@@ -46,7 +54,7 @@ jobs:
4654
- test
4755
- test_gitoxide
4856
runs-on: ubuntu-latest
49-
if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
57+
if: "!success() && github.event_name == 'push' && (github.ref == 'refs/heads/auto-cargo' || github.ref == 'refs/heads/try') && github.repository == 'rust-lang/cargo'"
5058
steps:
5159
- run: exit 1
5260

0 commit comments

Comments
 (0)