From 4a11642cee3c8aec976d305d51a86e60e5d70522 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 4 Jul 2022 16:14:47 -0700 Subject: [PATCH] ci: Replace cancel-previous-runs job with concurrency configuration. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using ‘github.head_ref || github.run_id’ makes this only cancel in-progress jobs for pull_request events. https://docs.github.com/en/actions/using-jobs/using-concurrency Signed-off-by: Anders Kaseorg --- .github/workflows/cancel-previous-runs.yml | 43 ---------------------- .github/workflows/codeql-analysis.yml | 4 ++ .github/workflows/production-suite.yml | 4 ++ .github/workflows/zulip-ci.yml | 4 ++ 4 files changed, 12 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/cancel-previous-runs.yml diff --git a/.github/workflows/cancel-previous-runs.yml b/.github/workflows/cancel-previous-runs.yml deleted file mode 100644 index 83a864afad..0000000000 --- a/.github/workflows/cancel-previous-runs.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Cancel previous runs -on: [push, pull_request] - -defaults: - run: - shell: bash - -jobs: - cancel: - name: Cancel previous runs - runs-on: ubuntu-latest - timeout-minutes: 3 - - # Don't run this job for zulip/zulip pushes since we - # want to run those jobs. - if: ${{ github.event_name != 'push' || github.event.repository.full_name != 'zulip/zulip' }} - - steps: - # We get workflow IDs from GitHub API so we don't have to maintain - # a hard-coded list of IDs which need to be updated when a workflow - # is added or removed. And, workflow IDs are different for other forks - # so this is required. - - name: Get workflow IDs. - id: workflow_ids - continue-on-error: true # Don't fail this job on failure - env: - # This is in / format e.g. zulip/zulip - REPOSITORY: ${{ github.repository }} - run: | - workflow_api_url=https://api.github.com/repos/$REPOSITORY/actions/workflows - curl -fL $workflow_api_url -o workflows.json - - script="const {workflows} = require('./workflows'); \ - const ids = workflows.map(workflow => workflow.id); \ - console.log(ids.join(','));" - ids=$(node -e "$script") - echo "::set-output name=ids::$ids" - - - uses: styfle/cancel-workflow-action@0.9.0 - continue-on-error: true # Don't fail this job on failure - with: - workflow_id: ${{ steps.workflow_ids.outputs.ids }} - access_token: ${{ github.token }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 6d106d584e..69bc80f936 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -6,6 +6,10 @@ on: - dependabot/** # https://github.com/github/codeql-action/pull/435 pull_request: {} +concurrency: + group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}" + cancel-in-progress: true + jobs: CodeQL: if: ${{!github.event.repository.private}} diff --git a/.github/workflows/production-suite.yml b/.github/workflows/production-suite.yml index 40e053cb58..b602dbf417 100644 --- a/.github/workflows/production-suite.yml +++ b/.github/workflows/production-suite.yml @@ -22,6 +22,10 @@ on: - zerver/decorator.py - zproject/** +concurrency: + group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}" + cancel-in-progress: true + defaults: run: shell: bash diff --git a/.github/workflows/zulip-ci.yml b/.github/workflows/zulip-ci.yml index 46227a495e..8c9a71af2b 100644 --- a/.github/workflows/zulip-ci.yml +++ b/.github/workflows/zulip-ci.yml @@ -6,6 +6,10 @@ name: Zulip CI on: [push, pull_request] +concurrency: + group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}" + cancel-in-progress: true + defaults: run: shell: bash