Skip to content

Commit

Permalink
Optimize workflow runs with concurrency settings (github#23811)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JamesMGreene authored Dec 17, 2021
1 parent 65ce874 commit d6405ec
Show file tree
Hide file tree
Showing 24 changed files with 118 additions and 27 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/autoupdate-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/browser-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/code-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ name: Lint code

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
paths:
- '**.js'
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/content-changes-table-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/crowdin-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/enterprise-release-sync-search-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-<PLAN@RELEASE>`
jobs:
updateIndices:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/link-check-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }}
Expand Down Expand Up @@ -55,7 +60,6 @@ jobs:
- name: Link check (critical, all files)
run: |
./script/rendered-content-link-checker.mjs \
--language en \
--exit \
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/link-check-dotcom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/link-check-ghae.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/link-check-ghec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/link-check-ghes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/openapi-decorate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >-
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/openapi-schema-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/package-lock-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/prod-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/staging-build-and-deploy-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/staging-build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/staging-undeploy-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/sync-search-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/triage-unallowed-internal-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/workflow-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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' }}
Expand Down

0 comments on commit d6405ec

Please sign in to comment.