Skip to content

Commit dca1fd6

Browse files
authored
improvement(ci): scan CodeQL PRs at the promotion boundary, refresh main daily (#7213)
Feature PRs land on staging and are ~90% of PR scan volume (90 of the last 100 PRs target staging, 4 target main). Every one of them is scanned again — against the exact tree being promoted — when the staging->main PR opens, so restricting PR scans to main defers the signal to the promotion boundary rather than dropping it. No ruleset or branch protection requires a CodeQL check, and the alert view is fed by the push-to-main and scheduled analyses, not by PR runs. Deliberately a branch cut rather than an activity-type cut. Dropping `synchronize` would have cut a similar share of runs, but it scans a PR's first commit and never its final state — backwards, since review fixups land in later pushes. The scheduled scan moves from weekly to daily. Pushes to main are rare, so with PR scans limited to main the default-branch alert view leans on the cron more than it used to, and a week is too long to leave it stale. It also reseeds the overlay-base database that PR runs restore from: that cache key embeds the CodeQL bundle version, so a bundle bump invalidates it, and an unused Actions cache is evicted after 7 days. Also records, in codeql-config.yml, why the obvious speed-up is a trap: adding `queries:`/`packs:`/`query-filters:` trips OverlayDisabledReason.NonDefaultQueries and permanently disables overlay analysis, trading a documented up-to-10x win on the extraction phase (~53% of a run) for a few percent off the query phase.
1 parent 9e79dd2 commit dca1fd6

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

.github/codeql/codeql-config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ paths-ignore:
3131
- '**/dist/**'
3232
- '**/.next/**'
3333
- 'apps/docs/content/**'
34+
35+
# Do NOT add `queries:`, `packs:`, `query-filters:`, or `disable-default-queries`
36+
# here to try to speed the scan up. Under the code-scanning feature flag the
37+
# action's checkOverlayAnalysisFeatureEnabled treats any of those as
38+
# OverlayDisabledReason.NonDefaultQueries and permanently turns off overlay
39+
# (incremental) analysis. Extraction is ~53% of a run and is exactly what overlay
40+
# skips, so scoping the queries trades a documented up-to-10x win for a few
41+
# percent off the 27% query phase.

.github/workflows/codeql.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,16 @@ on:
2020
# created, prevents developers from introducing new vulnerabilities."
2121
push:
2222
branches: [main]
23+
# main only, not staging. Feature PRs land on staging and are ~90% of PR scan
24+
# volume, and every one of them is scanned again — against the exact tree being
25+
# promoted — when the staging->main PR opens. Scanning at the promotion
26+
# boundary defers the signal rather than dropping it.
27+
#
28+
# Deliberately a branch cut and not an activity-type cut: dropping
29+
# `synchronize` would have scanned each PR's first commit and never its final
30+
# state, which is backwards, since review fixups land in later pushes.
2331
pull_request:
24-
branches: [main, staging]
32+
branches: [main]
2533
# `ready_for_review` is not a default activity type, so it has to be listed
2634
# alongside the defaults it replaces. Without it, a PR opened as a draft and
2735
# then marked ready is skipped by the job-level draft guard and never
@@ -41,7 +49,15 @@ on:
4149
# Safety net behind the push trigger, and the thing that keeps the
4250
# default-branch alert view fresh when main is quiet. Only fires once this
4351
# file is on the default branch — schedule events ignore other branches.
44-
- cron: '17 8 * * 1'
52+
#
53+
# Daily rather than weekly. Pushes to main are rare, and with PR scans now
54+
# limited to main the alert view leans on this more than it used to; a week
55+
# is too long to leave it stale. It also reseeds the overlay-base database
56+
# that PR runs restore from — that cache key embeds the CodeQL bundle
57+
# version, so a bundle bump invalidates it, and an unused Actions cache is
58+
# evicted after 7 days. One 8 vCPU default-branch scan a day is a few
59+
# dollars a month against a PR scan that halves when the base is warm.
60+
- cron: '17 8 * * *'
4561
workflow_dispatch:
4662

4763
concurrency:

0 commit comments

Comments
 (0)