test: cancel workflows on same branch when new commit is added (#9771)

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).
This commit is contained in:
Gus Eggert 2023-03-30 07:58:12 -04:00 committed by GitHub
parent a24cfb89a5
commit ebdca5cf02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 0 deletions

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'