From 0e4c3e8c3007fa08708335c9ea18d8ac3c6f2bcb Mon Sep 17 00:00:00 2001 From: Bolaji Olajide <25608335+BolajiOlajide@users.noreply.github.com> Date: Tue, 28 Jan 2025 10:09:05 +0100 Subject: [PATCH] chore(ci): handle concurrency with github actions (#6798) Closes [DINF-644](https://linear.app/sourcegraph/issue/DINF-644/improve-github-actions-concurrency-in-cody-repo) This helps save some GitHub action minutes by ensuring we kill previous jobs belonging to the same workflow. ## Test plan CI ## Changelog --- .github/workflows/agent-bindings.yml | 11 +++++++---- .github/workflows/agent-release.yml | 4 ++++ .github/workflows/backport.yml | 6 +++++- .github/workflows/ci.yml | 4 ++++ .github/workflows/e2e-flakiness-detector.yml | 6 +++++- .github/workflows/experimental-release.yml | 9 +++++++-- .github/workflows/generate-changelog.yml | 6 +++++- .github/workflows/integration-stability.yml | 7 ++++++- .github/workflows/labeler.yml | 16 ++++++++++------ .github/workflows/lints.yml | 4 ++++ .github/workflows/nightly-release.yml | 7 ++++++- .github/workflows/pr-auditor.yml | 11 +++++++---- .github/workflows/scip-java.yml | 15 ++++++++++----- .github/workflows/scip-typescript.yml | 10 +++++++--- .github/workflows/semgrep.yml | 4 ++++ .github/workflows/stable-release.yml | 8 ++++++-- .github/workflows/stale.yml | 16 ++++++++++------ .github/workflows/test.yml | 12 ++++++++---- .github/workflows/vscode-insiders-release.yml | 14 +++++++++----- .github/workflows/vscode-stable-release.yml | 6 +++++- 20 files changed, 129 insertions(+), 47 deletions(-) diff --git a/.github/workflows/agent-bindings.yml b/.github/workflows/agent-bindings.yml index 7a15a792d99d..ef29b8705f59 100644 --- a/.github/workflows/agent-bindings.yml +++ b/.github/workflows/agent-bindings.yml @@ -2,12 +2,15 @@ # Worst-case: feel free to disable this workflow here https://github.com/sourcegraph/cody/actions/workflows/agent-bindings.yml name: agent-bindings on: - pull_request: paths: - - '**.ts' - - '**.tsx' - - '**.js' + - "**.ts" + - "**.tsx" + - "**.js" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: kotlin: diff --git a/.github/workflows/agent-release.yml b/.github/workflows/agent-release.yml index 9cd3fc551cec..c750cef605e2 100644 --- a/.github/workflows/agent-release.yml +++ b/.github/workflows/agent-release.yml @@ -5,6 +5,10 @@ on: tags: - agent-v* +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: release: if: github.repository == 'sourcegraph/cody' diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 5fae43595905..a6b2af14ec9c 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -5,6 +5,10 @@ on: - closed - labeled +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: backport: name: Backport @@ -25,4 +29,4 @@ jobs: with: github_token: ${{ secrets.BACKPORT_GITHUB_TOKEN }} label_pattern: '^backport (?(jb|vscode)-v\d+\.\d+\.x)$' - team_reviews: 'cody-core' + team_reviews: "cody-core" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f48b59028b34..4e1eacf5f464 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,10 @@ on: types: [opened, reopened, synchronize, ready_for_review] workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: # Sets a variable that is used to determine the matrix to run fast tests (unit & integration) on. # Everything runs on ubuntu and windows, only commits to main run on macos. diff --git a/.github/workflows/e2e-flakiness-detector.yml b/.github/workflows/e2e-flakiness-detector.yml index 96be0b3b90e2..e3848370fde7 100644 --- a/.github/workflows/e2e-flakiness-detector.yml +++ b/.github/workflows/e2e-flakiness-detector.yml @@ -4,9 +4,13 @@ name: e2e-flakiness-detector on: schedule: - - cron: '0 14 * * *' # daily at 1400 UTC + - cron: "0 14 * * *" # daily at 1400 UTC workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test-e2e: strategy: diff --git a/.github/workflows/experimental-release.yml b/.github/workflows/experimental-release.yml index 49531536074a..5c3049307275 100644 --- a/.github/workflows/experimental-release.yml +++ b/.github/workflows/experimental-release.yml @@ -1,8 +1,13 @@ name: Experimental Release on: push: - tags: [ "jb-*-experimental" ] - workflow_dispatch: + tags: ["jb-*-experimental"] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: publish: runs-on: ubuntu-latest diff --git a/.github/workflows/generate-changelog.yml b/.github/workflows/generate-changelog.yml index 3ab525276cbc..1431090a117d 100644 --- a/.github/workflows/generate-changelog.yml +++ b/.github/workflows/generate-changelog.yml @@ -4,10 +4,14 @@ on: workflow_dispatch: inputs: version: - description: 'The version to be released, for example: 1.60.0' + description: "The version to be released, for example: 1.60.0" required: true type: string +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: changelog: runs-on: ubuntu-latest diff --git a/.github/workflows/integration-stability.yml b/.github/workflows/integration-stability.yml index a59dae0a9cd9..4fb134394718 100644 --- a/.github/workflows/integration-stability.yml +++ b/.github/workflows/integration-stability.yml @@ -3,9 +3,14 @@ on: workflow_dispatch: inputs: repetitions: - description: 'How many times to repeat each test' + description: "How many times to repeat each test" type: number default: 10 + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: test: name: Build and run tests diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 68db0f787a4d..e5f427b30e20 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -3,6 +3,10 @@ on: issues: types: [opened, edited] +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + permissions: issues: write contents: read @@ -11,9 +15,9 @@ jobs: triage: runs-on: ubuntu-latest steps: - - uses: github/issue-labeler@v3.4 - with: - configuration-path: .github/labeler.yml - enable-versioned-regex: 0 - repo-token: ${{ github.token }} - include-title: 1 + - uses: github/issue-labeler@v3.4 + with: + configuration-path: .github/labeler.yml + enable-versioned-regex: 0 + repo-token: ${{ github.token }} + include-title: 1 diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml index 4b7c17f73872..37fc4e99f2ae 100644 --- a/.github/workflows/lints.yml +++ b/.github/workflows/lints.yml @@ -5,6 +5,10 @@ on: types: [opened, reopened, synchronize, ready_for_review] workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: safe-prompts-lint: runs-on: ubuntu-latest diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 52e819b5361b..463511b2a0b2 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -1,7 +1,12 @@ name: Nightly Release on: push: - tags: [ "jb-*-nightly" ] + tags: ["jb-*-nightly"] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: publish: runs-on: ubuntu-latest diff --git a/.github/workflows/pr-auditor.yml b/.github/workflows/pr-auditor.yml index baf129ae6d2a..ae5144f0ecf3 100644 --- a/.github/workflows/pr-auditor.yml +++ b/.github/workflows/pr-auditor.yml @@ -2,8 +2,11 @@ name: pr-auditor on: pull_request_target: - types: [ closed, edited, opened, synchronize, ready_for_review ] + types: [closed, edited, opened, synchronize, ready_for_review] +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: check-pr: @@ -11,12 +14,12 @@ jobs: steps: - uses: actions/checkout@v4 with: - repository: 'sourcegraph/devx-service' + repository: "sourcegraph/devx-service" token: ${{ secrets.PR_AUDITOR_TOKEN }} - uses: actions/setup-go@v4 - with: { go-version: '1.22' } + with: { go-version: "1.22" } - - run: 'go run ./cmd/pr-auditor' + - run: "go run ./cmd/pr-auditor" env: GITHUB_EVENT_PATH: ${{ env.GITHUB_EVENT_PATH }} GITHUB_TOKEN: ${{ secrets.PR_AUDITOR_TOKEN }} diff --git a/.github/workflows/scip-java.yml b/.github/workflows/scip-java.yml index 8aacc24c3643..5a006131a7bb 100644 --- a/.github/workflows/scip-java.yml +++ b/.github/workflows/scip-java.yml @@ -2,10 +2,15 @@ name: Sourcegraph on: push: paths: - - '**.kt' - - '**.java' - - '**.kts' - - '.github/workflows/scip-java.yml' + - "**.kt" + - "**.java" + - "**.kts" + - ".github/workflows/scip-java.yml" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: scip-java: if: github.repository == 'sourcegraph/cody' @@ -33,7 +38,7 @@ jobs: ${{ runner.os }}-gradle- - uses: coursier/setup-action@v1 with: - jvm: 'zulu:17' + jvm: "zulu:17" apps: scip-java - name: Generate SCIP File run: | diff --git a/.github/workflows/scip-typescript.yml b/.github/workflows/scip-typescript.yml index 838225956f93..9906fc760ff4 100644 --- a/.github/workflows/scip-typescript.yml +++ b/.github/workflows/scip-typescript.yml @@ -6,9 +6,13 @@ on: pull_request: types: [opened, reopened, synchronize, ready_for_review] paths: - - '**.ts' - - '**.tsx' - - '**.js' + - "**.ts" + - "**.tsx" + - "**.js" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: scip-typescript: diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml index 351c3748eb24..547d485eeb04 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/semgrep.yml @@ -4,6 +4,10 @@ on: pull_request_target: types: [edited, opened, synchronize, ready_for_review] +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: semgrep: permissions: diff --git a/.github/workflows/stable-release.yml b/.github/workflows/stable-release.yml index 06cabd7b2bc1..5d58fc830ab7 100644 --- a/.github/workflows/stable-release.yml +++ b/.github/workflows/stable-release.yml @@ -1,6 +1,10 @@ name: Stable Release -on: - workflow_dispatch +on: workflow_dispatch + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: publish: runs-on: ubuntu-latest diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index c65e883d4b06..056e8b71fd9d 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,7 +1,11 @@ -name: 'Close stale issues and PRs' +name: "Close stale issues and PRs" on: schedule: - - cron: '30 1 * * *' + - cron: "30 1 * * *" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: stale: @@ -9,9 +13,9 @@ jobs: steps: - uses: actions/stale@v9 with: - stale-issue-message: 'This issue is marked as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed automatically in 5 days.' - stale-pr-message: 'This PR is marked as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed automatically in 5 days.' + stale-issue-message: "This issue is marked as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed automatically in 5 days." + stale-pr-message: "This PR is marked as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed automatically in 5 days." days-before-stale: 60 days-before-close: 5 - exempt-issue-labels: 'neverstale' - exempt-pr-labels: 'neverstale' + exempt-issue-labels: "neverstale" + exempt-pr-labels: "neverstale" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cdcdd700ab62..399e388b6f7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,11 @@ on: push: branches: - main + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: test: name: JetBrains tests @@ -65,7 +70,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: plugin - path: './jetbrains/build/distributions/Sourcegraph-*.zip' + path: "./jetbrains/build/distributions/Sourcegraph-*.zip" compression-level: 0 retention-days: 7 plugin-verifier: @@ -83,7 +88,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - plugin-location: '*.zip' + plugin-location: "*.zip" # TODO (pkukielka): Upper range should be bumped to 251.14649.49-EAP-SNAPSHOT # as soon as problem with Git4Idea dependencies will get resolved ide-versions: | @@ -100,6 +105,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: plugin-verifier-reports - path: 'verification-*' + path: "verification-*" compression-level: 9 - diff --git a/.github/workflows/vscode-insiders-release.yml b/.github/workflows/vscode-insiders-release.yml index 7913fad1a846..b5bd31674096 100644 --- a/.github/workflows/vscode-insiders-release.yml +++ b/.github/workflows/vscode-insiders-release.yml @@ -3,6 +3,10 @@ name: vscode-insiders-release on: workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: release: if: github.repository == 'sourcegraph/cody' @@ -37,11 +41,11 @@ jobs: GITHUB_ENV: $GITHUB_ENV - name: Authenticate to Google Cloud id: auth - uses: 'google-github-actions/auth@v2' + uses: "google-github-actions/auth@v2" with: - project_id: 'cody-core-dev' - workload_identity_provider: 'projects/39257127245/locations/global/workloadIdentityPools/github/providers/cody' - service_account: 'bundle-size-tracker@cody-core-dev.iam.gserviceaccount.com' + project_id: "cody-core-dev" + workload_identity_provider: "projects/39257127245/locations/global/workloadIdentityPools/github/providers/cody" + service_account: "bundle-size-tracker@cody-core-dev.iam.gserviceaccount.com" create_credentials_file: true export_environment_variables: true - run: CODY_RELEASE_TYPE=insiders pnpm -C vscode run release @@ -54,7 +58,7 @@ jobs: run: | # Compute the current date current_date=$(date +'%Y-%m-%d') - + # Now create the JSON and insert into BigQuery echo "{\"release_version\": \"${{ steps.create_release.outputs.version_tag }}\", \"extension_bundle_size_mb\": $EXTENSION_BUNDLE_SIZE_MB, \"webview_bundle_size_mb\": $WEBVIEW_BUNDLE_SIZE_MB, \"date\": \"$current_date\"}" > data.json bq load \ diff --git a/.github/workflows/vscode-stable-release.yml b/.github/workflows/vscode-stable-release.yml index ad326e714088..8416b7d21ddc 100644 --- a/.github/workflows/vscode-stable-release.yml +++ b/.github/workflows/vscode-stable-release.yml @@ -5,6 +5,10 @@ on: tags: - vscode-v* +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: release: if: github.repository == 'sourcegraph/cody' @@ -78,7 +82,7 @@ jobs: echo "VERSION_ANCHOR=$version_anchor" >> $GITHUB_ENV echo "CURRENT_RELEASE_BRANCH=vscode-v$major.$minor.x" >> $GITHUB_ENV echo "NEXT_RELEASE_BRANCH=vscode-v$major.$next_minor.x" >> $GITHUB_ENV - - name: 'Slack notification' + - name: "Slack notification" run: | echo "Posting release announcement to Slack" ANNOUNCE_EDITORS_SLACK_WEBHOOK_URL=${{ secrets.ANNOUNCE_EDITORS_SLACK_WEBHOOK_URL }}