Skip to content

Commit 6e65270

Browse files
Use concurrency to prevent multiple workflow runs
See [`concurrency`](https://docs.github.com/en/actions/using-jobs/using-concurrency) for more information. The goal was to limit multiple workflow runs on a given PR. This will cancel previous runs and make the workflows run on the most up-to-date code.
1 parent 8fa8b39 commit 6e65270

File tree

7 files changed

+63
-1
lines changed

7 files changed

+63
-1
lines changed

.github/workflows/ci-python.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ on:
44
workflow_call:
55
workflow_dispatch:
66

7+
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
8+
# But on the main branch, we don't want that behavior.
9+
# Having the workflow run on each merge commit is something we would like, that could help us where a regression was made and missed by previous checks.
10+
#
11+
# For that we use `head_ref` that is only defined on `pull-request` and fallback to `run_id` (this is a counter, so it's value is unique between workflow call).
12+
concurrency:
13+
group: ci-python-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
716
env:
817
python-version: 3.9
918
poetry-version: 1.3.2

.github/workflows/ci-rust.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ on:
44
workflow_call:
55
workflow_dispatch:
66

7+
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
8+
# But on the main branch, we don't want that behavior.
9+
# Having the workflow run on each merge commit is something we would like, that could help us where a regression was made and missed by previous checks.
10+
#
11+
# For that we use `head_ref` that is only defined on `pull-request` and fallback to `run_id` (this is a counter, so it's value is unique between workflow call).
12+
concurrency:
13+
group: ci-rust-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
716
env:
817
cargo-exclude-unused-crates: >-
918
--exclude=parsec

.github/workflows/ci-web.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ on:
44
workflow_call:
55
workflow_dispatch:
66

7+
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
8+
# But on the main branch, we don't want that behavior.
9+
# Having the workflow run on each merge commit is something we would like, that could help us where a regression was made and missed by previous checks.
10+
#
11+
# For that we use `head_ref` that is only defined on `pull-request` and fallback to `run_id` (this is a counter, so it's value is unique between workflow call).
12+
concurrency:
13+
group: ci-web-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
716
env:
817
# We use the version 18.12 because the version >= 18.13 have some breaking changes on how they format the date.
918
# That would break our unit test if we don't update them.

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@ on:
88
branches:
99
- master
1010

11-
jobs:
11+
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
12+
# But on the main branch, we don't want that behavior.
13+
# Having the workflow run on each merge commit is something we would like, that could help us where a regression was made and missed by previous checks.
14+
#
15+
# For that we use `head_ref` that is only defined on `pull-request` and fallback to `run_id` (this is a counter, so it's value is unique between workflow call).
16+
concurrency:
17+
group: ci-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
1219

20+
jobs:
1321
# Github PR merging is configured to only require this job to pass
1422
ci-is-happy:
1523
name: ⭐ CI is happy ⭐

.github/workflows/codeql.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ on:
1313
# Every Wednesday at 04:20
1414
- cron: 20 4 * * 3
1515

16+
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
17+
# But on the main branch, we don't want that behavior.
18+
# Having the workflow run on each merge commit is something we would like, that could help us where a regression was made and missed by previous checks.
19+
#
20+
# For that we use `head_ref` that is only defined on `pull-request` and fallback to `run_id` (this is a counter, so it's value is unique between workflow call).
21+
concurrency:
22+
group: codeql-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
23+
cancel-in-progress: true
24+
1625
jobs:
1726
python-analyze:
1827
name: 🐍 Python static code Analysis

.github/workflows/cspell.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ on:
44
workflow_call:
55
workflow_dispatch:
66

7+
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
8+
# But on the main branch, we don't want that behavior.
9+
# Having the workflow run on each merge commit is something we would like, that could help us where a regression was made and missed by previous checks.
10+
#
11+
# For that we use `head_ref` that is only defined on `pull-request` and fallback to `run_id` (this is a counter, so it's value is unique between workflow call).
12+
concurrency:
13+
group: cspell-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
716
jobs:
817
cpsell:
918
runs-on: ubuntu-20.04

.github/workflows/package-ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ on:
1515
tags:
1616
- v[0-9]+.[0-9]+.[0-9]+*
1717

18+
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
19+
# But on the main branch, we don't want that behavior.
20+
# Having the workflow run on each merge commit is something we would like, that could help us where a regression was made and missed by previous checks.
21+
#
22+
# For that we use `head_ref` that is only defined on `pull-request` and fallback to `run_id` (this is a counter, so it's value is unique between workflow call).
23+
concurrency:
24+
group: package-ci-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
25+
cancel-in-progress: true
26+
1827
env:
1928
node-version: 18.12.0
2029
python-version: 3.9

0 commit comments

Comments
 (0)