From e0b513b852447157201361d29daf2673a88e7892 Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Fri, 4 Feb 2022 21:09:34 -0500 Subject: [PATCH 1/4] CI: Cancel in-progress runs on update for PR Using GitHub Actions concurrency, runs from the previous commits are canceled within the same group which is defined by workflow and head_ref/branch name. It explicitly checks for event being pull request and if it is not, it uses commit hash which makes it unique, so commits to the main and release branches will not be canceled. See also #1794. --- .github/workflows/osgeo4w.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/osgeo4w.yml b/.github/workflows/osgeo4w.yml index ca70041f896..256fbecd0d1 100644 --- a/.github/workflows/osgeo4w.yml +++ b/.github/workflows/osgeo4w.yml @@ -4,6 +4,14 @@ on: - push - pull_request +# Cancel previous workflow runs for pull requests. +# The concurrency group is workflow name and the branch name for pull requests, +# but it is the commit hash for any other events, so the group is unique and no +# runs jobs are canceled. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: build: name: ${{ matrix.os }} build and tests From 3593666d99f0c225be192f4b62f2862379df3c9f Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Fri, 4 Feb 2022 21:38:04 -0500 Subject: [PATCH 2/4] Fix jobs/runs --- .github/workflows/osgeo4w.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/osgeo4w.yml b/.github/workflows/osgeo4w.yml index 256fbecd0d1..d26340e63d5 100644 --- a/.github/workflows/osgeo4w.yml +++ b/.github/workflows/osgeo4w.yml @@ -7,7 +7,7 @@ on: # Cancel previous workflow runs for pull requests. # The concurrency group is workflow name and the branch name for pull requests, # but it is the commit hash for any other events, so the group is unique and no -# runs jobs are canceled. +# runs are canceled. concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true From 331ab17ce6ca1f41fb0e71235746b600e53a475f Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Sat, 5 Feb 2022 15:11:39 -0500 Subject: [PATCH 3/4] Add cancel-in-progress to CodeQL workflow --- .github/workflows/codeql-analysis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3ab09abefa1..602202fa3b2 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,6 +13,14 @@ on: # Check every Saturday at 18:36 - cron: "36 18 * * 6" +# Cancel previous workflow runs for pull requests. +# The concurrency group is workflow name and the branch name for pull requests, +# but it is the commit hash for any other events, so the group is unique and no +# runs are canceled. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: analyze: name: ${{ matrix.language }} From ad882bf9b4939b12dc90a7b4150e1488ef23be27 Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Sat, 5 Feb 2022 17:11:34 -0500 Subject: [PATCH 4/4] Add cancel-in-progress to Ubuntu workflow --- .github/workflows/ubuntu.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 9f5b8dae44e..95dc0c88a6f 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -5,6 +5,14 @@ on: - push - pull_request +# Cancel previous workflow runs for pull requests. +# The concurrency group is workflow name and the branch name for pull requests, +# but it is the commit hash for any other events, so the group is unique and no +# runs are canceled. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: build-and-test: name: ${{ matrix.os }} tests