From e21fbb19554e9193201182c82415c101e1bc23d5 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 2 Jul 2024 20:46:57 +0300 Subject: [PATCH] CI: use GitHub native concurrency to cancel workflows (#124) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't install/use custom [styfle/cancel-workflow-action](https://github.com/styfle/cancel-workflow-action) actions. Instead, use the GitHub native [concurrency](https://github.blog/changelog/2021-04-19-github-actions-limit-workflow-run-or-job-concurrency/) property to cancel workflows. - [x] Does not require a CHANGELOG entry Signed-off-by: Adrian Catangiu Co-authored-by: Bastian Köcher --- .github/workflows/changelog.yml | 1 + .github/workflows/fmt.yml | 6 ++++++ .github/workflows/test.yml | 5 ----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 7aa221a8ba..5e955521b8 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -7,6 +7,7 @@ on: push: branches: ["main", "release-*"] pull_request: + types: [opened, reopened, synchronize, edited] workflow_dispatch: # cancel previous runs diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml index e5853d15b0..11e1139cf5 100644 --- a/.github/workflows/fmt.yml +++ b/.github/workflows/fmt.yml @@ -6,6 +6,12 @@ on: pull_request: workflow_dispatch: +# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is +# triggered (ref https://stackoverflow.com/a/72408109) +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: rustfmt: runs-on: ubuntu-22.04 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 37d64a5b3f..57135cf99f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,11 +51,6 @@ jobs: matrix: runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }} steps: - - name: Cancel previous runs - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # v0.11.0 - with: - access_token: ${{ github.token }} - - name: Install updates and protobuf-compiler run: sudo apt update && sudo apt install --assume-yes cmake protobuf-compiler