Skip to content

Commit d504113

Browse files
committed
Auto merge of #13317 - Urgau:improve-ci, r=<try>
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)~~ 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 + e30dac4 commit d504113

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

.github/workflows/main.yml

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

813
defaults:
914
run:
@@ -12,6 +17,10 @@ defaults:
1217
permissions:
1318
contents: read
1419

20+
concurrency:
21+
group: "${{ github.workflow }}-${{ (github.ref == 'refs/heads/try' && github.sha) || github.ref }}"
22+
cancel-in-progress: true
23+
1524
jobs:
1625
success:
1726
permissions:
@@ -28,7 +37,7 @@ jobs:
2837
- test
2938
- test_gitoxide
3039
runs-on: ubuntu-latest
31-
if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
40+
if: "success() && github.event_name == 'push' && (github.ref == 'refs/heads/auto-cargo' || github.ref == 'refs/heads/try') && github.repository == 'rust-lang/cargo'"
3241
steps:
3342
- run: echo ok
3443
failure:
@@ -46,7 +55,7 @@ jobs:
4655
- test
4756
- test_gitoxide
4857
runs-on: ubuntu-latest
49-
if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
58+
if: "!success() && github.event_name == 'push' && (github.ref == 'refs/heads/auto-cargo' || github.ref == 'refs/heads/try') && github.repository == 'rust-lang/cargo'"
5059
steps:
5160
- run: exit 1
5261

0 commit comments

Comments
 (0)