Skip to content

Commit 1f1b2e7

Browse files
committed
improvement(ci): move CodeQL off default setup onto Blacksmith
Default setup pinned every scan to a 4-vCPU GitHub-hosted runner with no cancel-in-progress: PR scans ran 30-125 min and re-ran on every push (#6183 burned six overlapping runs). None of that is reachable from the settings UI, so the config moves into the repo. - Blacksmith 8-vCPU via the same CI_PROVIDER escape hatch as ci.yml - cancel-in-progress scoped to pull_request so push/schedule scans finish - push to main + PR to main/staging + nightly safety net - paths filter so doc-only PRs skip the run entirely - paths-ignore config drops tests/mocks/fixtures: 12,716 -> 11,128 files - languages: javascript-typescript + actions; python dropped (7 files in tree) Default setup has been disabled; the two cannot both be active.
1 parent 0bc4fb4 commit 1f1b2e7

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

.github/codeql/codeql-config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Sim CodeQL config
2+
3+
# Trims the extraction surface. CodeQL parses every matching file into a
4+
# database before a single query runs, and that phase dominates runtime on a
5+
# ~12.7k-file JS/TS tree. Test and fixture code is not attacker-reachable, so
6+
# excluding it costs no real coverage.
7+
#
8+
# paths-ignore applies to analysis. The workflow's `on.pull_request.paths`
9+
# filter is separate and decides whether the run happens at all.
10+
paths-ignore:
11+
- '**/*.test.ts'
12+
- '**/*.test.tsx'
13+
- '**/*.test.js'
14+
- '**/*.spec.ts'
15+
- '**/*.spec.tsx'
16+
- '**/__tests__/**'
17+
- '**/__mocks__/**'
18+
- '**/__fixtures__/**'
19+
- '**/test/**'
20+
- '**/tests/**'
21+
- '**/testing/**'
22+
- '**/e2e/**'
23+
- '**/*.d.ts'
24+
- '**/node_modules/**'
25+
- '**/dist/**'
26+
- '**/.next/**'
27+
- 'apps/docs/content/**'

.github/workflows/codeql.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: CodeQL
2+
3+
# Advanced setup, replacing the repo-settings "default setup".
4+
#
5+
# Default setup pinned every scan to a 4-vCPU GitHub-hosted runner with no
6+
# cancel-in-progress, which put PR scans at 30-125 min and re-ran them on every
7+
# push (PR #6183 burned six overlapping runs). None of that is configurable from
8+
# the settings UI, so the config moves into the repo.
9+
#
10+
# Before enabling this, disable default setup or the two will both run:
11+
# gh api -X PATCH repos/:owner/:repo/code-scanning/default-setup -f state=not-configured
12+
#
13+
# The runs-on expression is the same CI_PROVIDER escape hatch as ci.yml and must
14+
# change together with it.
15+
16+
on:
17+
# Pushes to main are infrequent (merges only), so a full scan per push is
18+
# affordable and is what GitHub recommends pairing with the PR trigger:
19+
# "Scanning code when someone pushes a change, and whenever a pull request is
20+
# created, prevents developers from introducing new vulnerabilities."
21+
push:
22+
branches: [main]
23+
pull_request:
24+
branches: [main, staging]
25+
# Draft PRs are excluded via the job-level `if`, not here: `types` would
26+
# also have to re-list the default event types to keep synchronize working.
27+
paths:
28+
- '**/*.ts'
29+
- '**/*.tsx'
30+
- '**/*.js'
31+
- '**/*.jsx'
32+
- '**/*.mjs'
33+
- '**/*.cjs'
34+
- '.github/workflows/**'
35+
- '.github/actions/**'
36+
- '.github/codeql/**'
37+
schedule:
38+
# Safety net behind the push trigger, and the thing that keeps the
39+
# default-branch alert view fresh when main is quiet. Only fires once this
40+
# file is on the default branch — schedule events ignore other branches.
41+
- cron: '17 8 * * *'
42+
workflow_dispatch:
43+
44+
# Scheduled main scans must run to completion — only PR pushes supersede.
45+
concurrency:
46+
group: codeql-${{ github.ref }}
47+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
48+
49+
permissions:
50+
contents: read
51+
52+
jobs:
53+
analyze:
54+
name: Analyze ${{ matrix.language }}
55+
runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-latest' }}
56+
timeout-minutes: 60
57+
if: github.event.pull_request.draft != true
58+
permissions:
59+
security-events: write
60+
contents: read
61+
actions: read
62+
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
# One entry covers both JS and TS — `javascript`, `typescript` and
67+
# `javascript-typescript` all resolve to the same extractor
68+
# (github/codeql-action src/languages/builtin.json), so the three
69+
# entries default setup listed were one analysis, not three.
70+
# `javascript-typescript` is the documented spelling. Python dropped:
71+
# 7 files in the tree.
72+
language: [javascript-typescript, actions]
73+
74+
steps:
75+
- name: Checkout repository
76+
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
77+
with:
78+
persist-credentials: false
79+
80+
- name: Initialize CodeQL
81+
uses: github/codeql-action/init@18420e3271f74589575af831a523c833acda327f # codeql-bundle-v2.26.2
82+
with:
83+
languages: ${{ matrix.language }}
84+
config-file: ./.github/codeql/codeql-config.yml
85+
86+
- name: Perform CodeQL Analysis
87+
uses: github/codeql-action/analyze@18420e3271f74589575af831a523c833acda327f # codeql-bundle-v2.26.2
88+
env:
89+
NODE_OPTIONS: --max-old-space-size=8192
90+
with:
91+
category: /language:${{ matrix.language }}

0 commit comments

Comments
 (0)