From d6405ecb45af471c50e8d45ee804c3d7518fdf32 Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Fri, 17 Dec 2021 10:00:52 -0600 Subject: [PATCH] Optimize workflow runs with `concurrency` settings (#23811) * Add concurrency settings for a bunch of workflows * Restrict prod deployments to one at a time but disallow interrupting * Remove redundant pull_request.types specification --- .github/workflows/autoupdate-branch.yml | 6 ++++++ .github/workflows/browser-test.yml | 8 ++++++-- .github/workflows/code-lint.yml | 8 +++++--- .github/workflows/codeql.yml | 5 +++++ .github/workflows/content-changes-table-comment.yml | 6 +++++- .github/workflows/crowdin-cleanup.yml | 5 +++++ .../enterprise-release-sync-search-index.yml | 5 +++++ .github/workflows/link-check-all.yml | 6 +++++- .github/workflows/link-check-dotcom.yml | 5 +++++ .github/workflows/link-check-ghae.yml | 5 +++++ .github/workflows/link-check-ghec.yml | 5 +++++ .github/workflows/link-check-ghes.yml | 5 +++++ .github/workflows/openapi-decorate.yml | 5 +++++ .github/workflows/openapi-schema-check.yml | 5 +++++ .github/workflows/package-lock-lint.yml | 5 +++++ .github/workflows/prod-build-deploy.yml | 4 +++- .github/workflows/staging-build-and-deploy-pr.yml | 6 +++--- .github/workflows/staging-build-pr.yml | 13 ++++++------- .github/workflows/staging-undeploy-pr.yml | 7 ++++--- .github/workflows/sync-search-pr.yml | 5 +++++ .github/workflows/test-windows.yml | 5 +++++ .github/workflows/test.yml | 5 +++++ .../workflows/triage-unallowed-internal-changes.yml | 5 +++++ .github/workflows/workflow-lint.yml | 11 +++++------ 24 files changed, 118 insertions(+), 27 deletions(-) diff --git a/.github/workflows/autoupdate-branch.yml b/.github/workflows/autoupdate-branch.yml index ba126fbf25f2..489c2e5d91b6 100644 --- a/.github/workflows/autoupdate-branch.yml +++ b/.github/workflows/autoupdate-branch.yml @@ -27,6 +27,12 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to take priority over +# previously queued runs but NOT interrupt currently executing runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: false + jobs: autoupdate: if: github.repository == 'github/docs-internal' || github.repository == 'github/docs' diff --git a/.github/workflows/browser-test.yml b/.github/workflows/browser-test.yml index 5f42fbab5d79..14a6efc8f34f 100644 --- a/.github/workflows/browser-test.yml +++ b/.github/workflows/browser-test.yml @@ -22,16 +22,20 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: build: runs-on: ubuntu-latest steps: - # Each of these ifs needs to be repeated at each step to make sure the required check still runs - # Even if if doesn't do anything - name: Checkout uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 with: lfs: true + - name: Checkout LFS objects run: git lfs checkout diff --git a/.github/workflows/code-lint.yml b/.github/workflows/code-lint.yml index dffadffb7de2..b8a361b4111a 100644 --- a/.github/workflows/code-lint.yml +++ b/.github/workflows/code-lint.yml @@ -6,9 +6,6 @@ name: Lint code on: workflow_dispatch: - push: - branches: - - main pull_request: paths: - '**.js' @@ -27,6 +24,11 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: lint: runs-on: ubuntu-latest diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 8eeaceedbcea..c2335b211328 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -20,6 +20,11 @@ permissions: contents: read security-events: write +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: build: if: github.repository == 'github/docs-internal' || github.repository == 'github/docs' diff --git a/.github/workflows/content-changes-table-comment.yml b/.github/workflows/content-changes-table-comment.yml index 8ca2e3b084fe..326924bd5989 100644 --- a/.github/workflows/content-changes-table-comment.yml +++ b/.github/workflows/content-changes-table-comment.yml @@ -7,12 +7,16 @@ name: Content Changes Table Comment on: workflow_dispatch: pull_request_target: - types: [opened, synchronize, reopened] permissions: contents: read pull-requests: write +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: PR-Preview-Links: if: github.event.pull_request.user.login != 'Octomerger' diff --git a/.github/workflows/crowdin-cleanup.yml b/.github/workflows/crowdin-cleanup.yml index 7552713ab65f..2ad2cedba7f7 100644 --- a/.github/workflows/crowdin-cleanup.yml +++ b/.github/workflows/crowdin-cleanup.yml @@ -13,6 +13,11 @@ on: permissions: contents: write +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: homogenize_frontmatter: name: Homogenize frontmatter diff --git a/.github/workflows/enterprise-release-sync-search-index.yml b/.github/workflows/enterprise-release-sync-search-index.yml index d426432e4143..312c06af6bdd 100644 --- a/.github/workflows/enterprise-release-sync-search-index.yml +++ b/.github/workflows/enterprise-release-sync-search-index.yml @@ -29,6 +29,11 @@ on: permissions: contents: write +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + # This workflow requires a label in the format `sync-english-index-for-` jobs: updateIndices: diff --git a/.github/workflows/link-check-all.yml b/.github/workflows/link-check-all.yml index 53cdbff0462f..03e3817aaec0 100644 --- a/.github/workflows/link-check-all.yml +++ b/.github/workflows/link-check-all.yml @@ -16,6 +16,11 @@ permissions: # Needed for the 'trilom/file-changes-action' action pull-requests: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: build: runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }} @@ -55,7 +60,6 @@ jobs: - name: Link check (critical, all files) run: | - ./script/rendered-content-link-checker.mjs \ --language en \ --exit \ diff --git a/.github/workflows/link-check-dotcom.yml b/.github/workflows/link-check-dotcom.yml index 09403d7cc18b..bd4beac60cd8 100644 --- a/.github/workflows/link-check-dotcom.yml +++ b/.github/workflows/link-check-dotcom.yml @@ -11,6 +11,11 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: build: runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }} diff --git a/.github/workflows/link-check-ghae.yml b/.github/workflows/link-check-ghae.yml index 384284a4cf59..bd64871be18a 100644 --- a/.github/workflows/link-check-ghae.yml +++ b/.github/workflows/link-check-ghae.yml @@ -11,6 +11,11 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: build: runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }} diff --git a/.github/workflows/link-check-ghec.yml b/.github/workflows/link-check-ghec.yml index 36449f5beaee..4056e3c19a00 100644 --- a/.github/workflows/link-check-ghec.yml +++ b/.github/workflows/link-check-ghec.yml @@ -11,6 +11,11 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: build: runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }} diff --git a/.github/workflows/link-check-ghes.yml b/.github/workflows/link-check-ghes.yml index c0893d7275da..5bf0f84fce97 100644 --- a/.github/workflows/link-check-ghes.yml +++ b/.github/workflows/link-check-ghes.yml @@ -11,6 +11,11 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: build: runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }} diff --git a/.github/workflows/openapi-decorate.yml b/.github/workflows/openapi-decorate.yml index bd775277d672..1c01d3fac551 100644 --- a/.github/workflows/openapi-decorate.yml +++ b/.github/workflows/openapi-decorate.yml @@ -11,6 +11,11 @@ permissions: contents: write pull-requests: write +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: generate-decorated-files: if: >- diff --git a/.github/workflows/openapi-schema-check.yml b/.github/workflows/openapi-schema-check.yml index 01dd710a7847..fafc3a74fe28 100644 --- a/.github/workflows/openapi-schema-check.yml +++ b/.github/workflows/openapi-schema-check.yml @@ -26,6 +26,11 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: check-schema-versions: if: ${{ github.repository == 'github/docs-internal' }} diff --git a/.github/workflows/package-lock-lint.yml b/.github/workflows/package-lock-lint.yml index b5967c2c4180..cf800fc55abe 100644 --- a/.github/workflows/package-lock-lint.yml +++ b/.github/workflows/package-lock-lint.yml @@ -14,6 +14,11 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: lint: runs-on: ubuntu-latest diff --git a/.github/workflows/prod-build-deploy.yml b/.github/workflows/prod-build-deploy.yml index 98101a18a839..e8689c3e751c 100644 --- a/.github/workflows/prod-build-deploy.yml +++ b/.github/workflows/prod-build-deploy.yml @@ -14,9 +14,11 @@ permissions: contents: read deployments: write +# This allows a subsequently queued workflow run to take priority over +# previously queued runs but NOT interrupt currently executing runs concurrency: group: '${{ github.workflow }}' - cancel-in-progress: true + cancel-in-progress: false jobs: build-and-deploy: diff --git a/.github/workflows/staging-build-and-deploy-pr.yml b/.github/workflows/staging-build-and-deploy-pr.yml index 1de1fb050309..69cb8195e6b3 100644 --- a/.github/workflows/staging-build-and-deploy-pr.yml +++ b/.github/workflows/staging-build-and-deploy-pr.yml @@ -24,12 +24,12 @@ permissions: pull-requests: read statuses: write -# This allows one Build workflow run to interrupt another +# This allows a subsequently queued workflow run to interrupt previous runs # These are different from the concurrency in that here it checks if the # whole workflow runs again. The "inner concurrency" is used for # undeployments to cleaning up resources. concurrency: - group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label }}' + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' cancel-in-progress: true jobs: @@ -47,7 +47,7 @@ jobs: # This interrupts Build, Deploy, and pre-write Undeploy workflow runs in # progress for this PR branch. concurrency: - group: 'PR Staging @ ${{ github.event.pull_request.head.label }}' + group: 'PR Staging @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' cancel-in-progress: true steps: - name: Check out repo diff --git a/.github/workflows/staging-build-pr.yml b/.github/workflows/staging-build-pr.yml index 4be4fb1b23c0..2cfc7c763ad1 100644 --- a/.github/workflows/staging-build-pr.yml +++ b/.github/workflows/staging-build-pr.yml @@ -8,17 +8,16 @@ name: Staging - Build PR on: pull_request: - types: - - opened - - reopened - - synchronize permissions: contents: read -# This allows one Build workflow run to interrupt another +# This allows a subsequently queued workflow run to interrupt previous runs +# These are different from the concurrency in that here it checks if the +# whole workflow runs again. The "inner concurrency" is used for +# undeployments to cleaning up resources. concurrency: - group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label }}' + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' cancel-in-progress: true jobs: @@ -31,7 +30,7 @@ jobs: # This interrupts Build, Deploy, and pre-write Undeploy workflow runs in # progress for this PR branch. concurrency: - group: 'PR Staging @ ${{ github.event.pull_request.head.label }}' + group: 'PR Staging @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' cancel-in-progress: true steps: - name: Check out repo diff --git a/.github/workflows/staging-undeploy-pr.yml b/.github/workflows/staging-undeploy-pr.yml index 79be38213c45..bcc4217a0246 100644 --- a/.github/workflows/staging-undeploy-pr.yml +++ b/.github/workflows/staging-undeploy-pr.yml @@ -14,9 +14,10 @@ permissions: deployments: write pull-requests: write -# This prevents one Undeploy workflow run from interrupting another +# This allows a subsequently queued workflow run to take priority over +# previously queued runs but NOT interrupt currently executing runs concurrency: - group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label }}' + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' cancel-in-progress: false jobs: @@ -35,7 +36,7 @@ jobs: # branch. However, it does so with an intentionally short, independent job # so that the following `undeploy` job cannot be cancelled once started! concurrency: - group: 'PR Staging @ ${{ github.event.pull_request.head.label }}' + group: 'PR Staging @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' cancel-in-progress: true steps: - name: Cancelling other deployments via concurrency configuration diff --git a/.github/workflows/sync-search-pr.yml b/.github/workflows/sync-search-pr.yml index 41b2cc014511..16bfa7c16e92 100644 --- a/.github/workflows/sync-search-pr.yml +++ b/.github/workflows/sync-search-pr.yml @@ -16,6 +16,11 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: lint: runs-on: ubuntu-latest diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 969b0c61e6e5..ff5314224096 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -15,6 +15,11 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + env: CI: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3c319871286..1f2664188ef9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,11 @@ permissions: # Needed for the 'trilom/file-changes-action' action pull-requests: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + env: CI: true diff --git a/.github/workflows/triage-unallowed-internal-changes.yml b/.github/workflows/triage-unallowed-internal-changes.yml index f184606f7a05..168517fc0f6d 100644 --- a/.github/workflows/triage-unallowed-internal-changes.yml +++ b/.github/workflows/triage-unallowed-internal-changes.yml @@ -17,6 +17,11 @@ permissions: # This is needed by dorny/paths-filter pull-requests: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: check-internal-changes: if: github.repository == 'github/docs-internal' && github.event.pull_request.user.login != 'Octomerger' diff --git a/.github/workflows/workflow-lint.yml b/.github/workflows/workflow-lint.yml index d2e55b215c48..a62dc5b23e3a 100644 --- a/.github/workflows/workflow-lint.yml +++ b/.github/workflows/workflow-lint.yml @@ -6,12 +6,6 @@ name: Lint workflows on: workflow_dispatch: - push: - branches: - - main - paths: - - '.github/workflows/*.yml' - - '.github/workflows/*.yaml' pull_request: paths: - '.github/workflows/*.yml' @@ -20,6 +14,11 @@ on: permissions: contents: read +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + jobs: lint: if: ${{ github.repository == 'github/docs-internal' }}