Skip to content

Commit

Permalink
Auto merge of #13317 - Urgau:improve-ci, r=epage
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Jan 18, 2024
2 parents 9574120 + 2739b6d commit e01eeb0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: CI
on:
push:
branches-ignore: [master]
branches:
- auto-cargo
- try
- automation/bors/try
pull_request:
branches: ['*']
branches:
- "**"

defaults:
run:
Expand All @@ -12,6 +16,10 @@ defaults:
permissions:
contents: read

concurrency:
group: "${{ github.workflow }}-${{ (github.ref == 'refs/heads/try' && github.sha) || github.ref }}"
cancel-in-progress: true

jobs:
success:
permissions:
Expand All @@ -28,7 +36,7 @@ jobs:
- test
- test_gitoxide
runs-on: ubuntu-latest
if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
if: "success() && github.event_name == 'push' && (github.ref == 'refs/heads/auto-cargo' || github.ref == 'refs/heads/try') && github.repository == 'rust-lang/cargo'"
steps:
- run: echo ok
failure:
Expand All @@ -46,7 +54,7 @@ jobs:
- test
- test_gitoxide
runs-on: ubuntu-latest
if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
if: "!success() && github.event_name == 'push' && (github.ref == 'refs/heads/auto-cargo' || github.ref == 'refs/heads/try') && github.repository == 'rust-lang/cargo'"
steps:
- run: exit 1

Expand Down

0 comments on commit e01eeb0

Please sign in to comment.