Skip to content

Commit

Permalink
test: cancel workflows on same branch when new commit is added (#9771)
Browse files Browse the repository at this point in the history
This is pretty common when working through PRs and ends up causing
tons of in-flight GitHub Actions workflows running because they aren't
currently canceled when a new commit is added. This will cancel
previous runs if a new commit is added on a branch (which is the
behavior we had on CircleCI).
  • Loading branch information
guseggert authored Mar 30, 2023
1 parent a24cfb8 commit ebdca5c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
env:
GO_VERSION: 1.19.1

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
interop-prep:
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ permissions:
contents: read # to fetch code (actions/checkout)
security-events: write # (github/codeql-action/autobuild)

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
codeql:
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches:
- 'master'

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
docker-build:
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/gobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches:
- 'master'

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
go-build-runner:
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/golang-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
permissions:
contents: read # to fetch code (actions/checkout)

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
go-check:
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/golint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches:
- 'master'

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
go-lint:
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/gotest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches:
- 'master'

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
go-test:
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/sharness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches:
- 'master'

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
sharness-runner:
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
Expand Down

0 comments on commit ebdca5c

Please sign in to comment.