gha: Cancel previous jobs if a PR is updated

Let's make sure we cancel previous runs, mainly as we have some of those
that take a lot of time to run, whenever the PR is updated.

This is based on the following stack overflow suggestion:
https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre

This is very much needed as we don't want to wait for a long time to
have access to a runner because of other runners are still being used
performing a task that's meaningless due to the PR update.

Fixes: #7298

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2023-07-11 14:32:42 +02:00
parent b61b15aab6
commit fbc2a91ab5
15 changed files with 63 additions and 0 deletions

View File

@ -9,6 +9,10 @@ on:
- labeled - labeled
- unlabeled - unlabeled
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
pr_wip_check: pr_wip_check:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -10,6 +10,10 @@ on:
- labeled - labeled
- unlabeled - unlabeled
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
check-issues: check-issues:
if: ${{ github.event.label.name != 'auto-backport' }} if: ${{ github.event.label.name != 'auto-backport' }}

View File

@ -11,6 +11,10 @@ on:
- opened - opened
- reopened - reopened
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
add-new-issues-to-backlog: add-new-issues-to-backlog:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -12,6 +12,10 @@ on:
- reopened - reopened
- synchronize - synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
add-pr-size-label: add-pr-size-label:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -2,6 +2,10 @@ on:
pull_request_target: pull_request_target:
types: ["labeled", "closed"] types: ["labeled", "closed"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
backport: backport:
name: Backport PR name: Backport PR

View File

@ -7,6 +7,11 @@ on:
- reopened - reopened
- synchronize - synchronize
paths-ignore: [ '**.md', '**.png', '**.jpg', '**.jpeg', '**.svg', '/docs/**' ] paths-ignore: [ '**.md', '**.png', '**.jpg', '**.jpeg', '**.svg', '/docs/**' ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
cargo-deny-runner: cargo-deny-runner:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -3,6 +3,10 @@ on:
schedule: schedule:
- cron: '0 0 * * *' - cron: '0 0 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
kata-containers-ci-on-push: kata-containers-ci-on-push:
uses: ./.github/workflows/ci.yaml uses: ./.github/workflows/ci.yaml

View File

@ -14,6 +14,11 @@ on:
- labeled - labeled
paths-ignore: paths-ignore:
- 'docs/**' - 'docs/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
kata-containers-ci-on-push: kata-containers-ci-on-push:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }} if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }}

View File

@ -6,6 +6,10 @@ on:
- reopened - reopened
- synchronize - synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env: env:
error_msg: |+ error_msg: |+
See the document below for help on formatting commits for the project. See the document below for help on formatting commits for the project.

View File

@ -6,6 +6,11 @@ on:
- reopened - reopened
- synchronize - synchronize
paths-ignore: [ '**.md', '**.png', '**.jpg', '**.jpeg', '**.svg', '/docs/**' ] paths-ignore: [ '**.md', '**.png', '**.jpg', '**.jpeg', '**.svg', '/docs/**' ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
name: Darwin tests name: Darwin tests
jobs: jobs:
test: test:

View File

@ -5,6 +5,10 @@ on:
- main - main
- stable-* - stable-*
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
build-assets-amd64: build-assets-amd64:
uses: ./.github/workflows/build-kata-static-tarball-amd64.yaml uses: ./.github/workflows/build-kata-static-tarball-amd64.yaml

View File

@ -4,6 +4,10 @@ on:
tags: tags:
- '[0-9]+.[0-9]+.[0-9]+*' - '[0-9]+.[0-9]+.[0-9]+*'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
build-and-push-assets-amd64: build-and-push-assets-amd64:
uses: ./.github/workflows/release-amd64.yaml uses: ./.github/workflows/release-amd64.yaml

View File

@ -15,6 +15,10 @@ on:
branches: branches:
- main - main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs: jobs:
check-pr-porting-labels: check-pr-porting-labels:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -7,6 +7,10 @@ on:
- synchronize - synchronize
paths-ignore: [ '**.md', '**.png', '**.jpg', '**.jpeg', '**.svg', '/docs/**' ] paths-ignore: [ '**.md', '**.png', '**.jpg', '**.jpeg', '**.svg', '/docs/**' ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
name: Static checks dragonball name: Static checks dragonball
jobs: jobs:
test-dragonball: test-dragonball:

View File

@ -6,6 +6,10 @@ on:
- reopened - reopened
- synchronize - synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
name: Static checks name: Static checks
jobs: jobs:
static-checks: static-checks: