Skip to content

ci: advanced CodeQL setup with PR concurrency (disable default setup first) - #595

Closed
bastionstack wants to merge 2 commits into
mainfrom
ci/codeql-advanced-concurrency
Closed

bastionstack wants to merge 2 commits into
mainfrom
ci/codeql-advanced-concurrency

Conversation

@bastionstack

Copy link
Copy Markdown
Contributor

Summary

Replaces GitHub's default CodeQL code-scanning setup with an advanced
setup (.github/workflows/codeql.yml) so we can add a concurrency group.

Why: default setup starts a fresh scan on every push to an open PR and
cannot be coalesced (there's no workflow file to attach concurrency to).
The Figma design-token plugin pushes one commit per token file, so a single
sync is a burst of 5 pushes to the sync PR — and default setup spawns
2 scans × 5 pushes = 10 parallel CodeQL runs that all run to completion.
We saw exactly this on #592.

Advanced setup, keyed by github.ref, cancels only superseded runs of the
same PR
— mirroring what ci.yml already does for full-pr:

concurrency:
  group: codeql-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

github.ref is unique per PR (refs/pull/N/merge) and per branch, so this
never cancels another person's PR. cancel-in-progress is scoped to
pull_request, so pushes to main and scheduled scans always run to
completion. Job names (Analyze (actions|go|javascript-typescript)) are
unchanged, so branch-protection required checks keep matching.

⚠️ Admin action required BEFORE merge — disable default CodeQL setup

GitHub does not allow default and advanced CodeQL setups to coexist. You must
turn off default setup first
, or the advanced runs fail with
"default setup is enabled".

  1. Repo Settings → Code security → CodeQL analysis.
  2. On the Default setup, open the ⋯ menu and choose Disable
    CodeQL
    (this only disables default setup; advanced takes over on merge).
  3. Comment here (or ping me) once it's off — then this PR can merge.
  4. After merge, confirm the three Analyze (...) checks are still the ones
    listed under Settings → Branches → branch protection → required status
    checks
    (names match, but worth a glance).

Expected on this PR: while default setup is still enabled, the Analyze (...)
checks on this PR will be red. That is the intended signal that step 2
hasn't happened yet — they go green once default setup is disabled.

Validation

  • actionlint .github/workflows/codeql.yml — clean.
  • Concurrency block is a copy of the pattern ci.yml has run in production.
  • Language matrix (actions, go autobuild, javascript-typescript) mirrors
    the languages default setup currently analyzes.

Release notes / changeset

None — CI-only change, no published package behavior affected (per the
changeset decision table).

Notes

Pairs with the design-token sync coalescing change (cancel-in-progress: true
on sync-design-tokens.yml, riding to main via #592). Together they stop a
one-commit-per-file plugin push from fanning out into a scan/CI storm.

Default code-scanning setup cannot be coalesced, so a burst of pushes to a
PR (e.g. the Figma token plugin's one-commit-per-file pushes) spawns N
parallel scans. Advanced setup keyed by github.ref cancels only superseded
runs of the same PR, mirroring ci.yml.

Requires disabling default CodeQL setup before merge, else both run.
Copilot AI review requested due to automatic review settings July 22, 2026 12:52
@vercel

vercel Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nextgen Ready Ready Preview, Comment Jul 22, 2026 12:54pm
nextgen-docs Ready Ready Preview, Comment Jul 22, 2026 12:54pm
nextgen-mock-zitadel Ready Ready Preview, Comment Jul 22, 2026 12:54pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ No Changeset found

Latest commit: ab54017

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces an advanced CodeQL workflow (.github/workflows/codeql.yml) to replace GitHub’s default CodeQL setup, enabling PR-scoped concurrency so repeated pushes to the same PR coalesce into a single active scan run.

Changes:

  • Adds a new CodeQL workflow that runs on pull_request, push to main, and a weekly schedule.
  • Adds concurrency keyed by github.ref and cancels superseded PR runs only.
  • Configures a language matrix for actions, go (autobuild), and javascript-typescript.

Comment on lines +13 to +18
on:
push:
branches: [main]
pull_request:
schedule:
- cron: "27 3 * * 1"
Comment on lines +51 to +58
- name: Checkout
uses: actions/checkout@v6

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
@bastionstack

Copy link
Copy Markdown
Contributor Author

Closing in favour of GitHub's built-in generator. Rather than hand-maintain this file, the right move is Switch to advanced in Settings (it disables default setup atomically and generates the canonical codeql.yml with the language matrix auto-detected), then add just the concurrency block. Captured as #597.

@bastionstack
bastionstack deleted the ci/codeql-advanced-concurrency branch July 22, 2026 12:57
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Jul 22, 2026

This branch was successfully deployed

2 active and 1 inactive deployments
Preview – nextgen-docs — ab540175 Deployed Jul 22, 2026 by vercel[bot]
Preview – nextgen-mock-zitadel — ab540175 Deployed Jul 22, 2026 by vercel[bot]
Preview – nextgen — ab540175 Deployed Jul 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants