From 7b39dd71905cb7e546857741e3d52e977ec36691 Mon Sep 17 00:00:00 2001 From: Jon Desrosiers Date: Wed, 19 May 2021 20:42:12 -0400 Subject: [PATCH] Replace the Cancel workflow with native GitHub Action functionality. (#32016) * Replace the Cancel workflow with native GitHub Action functionality. Recently, GitHub introduced the `concurrency` option for ensuring that only a single job or workflow using the same concurrency group will run at a time. Currently, there is a Cancel workflow in the repo that aims to accomplish the same thing. However, when a backlog exists, the Cancel workflow for each commit does not run until its turn in the queue is reached. This can result in the backlog ballooning. The `concurrency` option in GitHub Actions runs a check when a workflow is queued, skipping the need to wait for an available runner to cancel old workflows. --- .github/workflows/build-plugin-zip.yml | 7 +++++++ .github/workflows/bundle-size.yml | 7 +++++++ .github/workflows/cancel.yml | 15 --------------- .github/workflows/create-block.yml | 7 +++++++ .github/workflows/end2end-test.yml | 7 +++++++ .github/workflows/performance.yml | 7 +++++++ .github/workflows/rnmobile-android-runner.yml | 7 +++++++ .github/workflows/rnmobile-ios-runner.yml | 7 +++++++ .github/workflows/static-checks.yml | 7 +++++++ .github/workflows/unit-test.yml | 7 +++++++ 10 files changed, 63 insertions(+), 15 deletions(-) delete mode 100644 .github/workflows/cancel.yml diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index e2707e81f5d7cb..9d376e0ea6e2fe 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -10,6 +10,13 @@ on: description: 'rc or stable?' required: true +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: bump-version: name: Bump version diff --git a/.github/workflows/bundle-size.yml b/.github/workflows/bundle-size.yml index f6111b9fb49324..cd3f591a04910f 100644 --- a/.github/workflows/bundle-size.yml +++ b/.github/workflows/bundle-size.yml @@ -2,6 +2,13 @@ name: Compressed Size on: [pull_request] +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: build: name: Check diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 919a8a4691db8c..00000000000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Cancel -on: pull_request -jobs: - cancel: - name: 'Cancel Previous Runs' - runs-on: ubuntu-latest - timeout-minutes: 3 - steps: - - name: Get all workflow ids and set to env variable - run: echo "WORKFLOW_IDS_TO_CANCEL=$(curl https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/workflows -s | jq -r '.workflows | map(.id|tostring) | join(",")')" >> $GITHUB_ENV - - - uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0 - with: - workflow_id: ${{ env.WORKFLOW_IDS_TO_CANCEL }} - access_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/create-block.yml b/.github/workflows/create-block.yml index 435c418a86139a..76a11ff6ad69b1 100644 --- a/.github/workflows/create-block.yml +++ b/.github/workflows/create-block.yml @@ -5,6 +5,13 @@ on: push: branches: [trunk, wp/trunk] +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: checks: name: Checks diff --git a/.github/workflows/end2end-test.yml b/.github/workflows/end2end-test.yml index 97faf7f5a183d4..a6ab7b73e85a0b 100644 --- a/.github/workflows/end2end-test.yml +++ b/.github/workflows/end2end-test.yml @@ -8,6 +8,13 @@ on: - 'release/**' - 'wp/**' +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: admin: name: Admin - ${{ matrix.part }} diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index f438981e6125fa..649f9155ad5e87 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -5,6 +5,13 @@ on: release: types: [published] +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: performance: name: Run performance tests diff --git a/.github/workflows/rnmobile-android-runner.yml b/.github/workflows/rnmobile-android-runner.yml index 6fa1009201bc6b..e6404c34208595 100644 --- a/.github/workflows/rnmobile-android-runner.yml +++ b/.github/workflows/rnmobile-android-runner.yml @@ -5,6 +5,13 @@ on: push: branches: [trunk] +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: test: runs-on: macos-latest diff --git a/.github/workflows/rnmobile-ios-runner.yml b/.github/workflows/rnmobile-ios-runner.yml index 36584173a0ccad..971ef150e01260 100644 --- a/.github/workflows/rnmobile-ios-runner.yml +++ b/.github/workflows/rnmobile-ios-runner.yml @@ -5,6 +5,13 @@ on: push: branches: [trunk] +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: test: runs-on: macos-latest diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml index a5bc053d4c8e24..32508611082d69 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -8,6 +8,13 @@ on: - 'release/**' - 'wp/**' +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: check: name: All diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 87a598a1646e49..d5d4b06c6bcfd0 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -10,6 +10,13 @@ on: - 'release/**' - 'wp/**' +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: unit-js: name: JavaScript