Skip to content

Commit ea6fd03

Browse files
rkm1claude
andauthored
ci(codeql): move CodeQL to advanced setup so it reports on merge groups (#229)
Code scanning ran through GitHub's DEFAULT setup, whose single `CodeQL` check is posted by the github-advanced-security App (integration id 57789). That check does not report on `merge_group` refs (github/codeql-action#1537, open since 2023): with a merge queue enabled, every queued pull request would wait on a required context that never arrives, look queued rather than broken, and be evicted on timeout. Advanced setup runs the same analysis as an ordinary Actions workflow, so its checks come from github-actions (integration id 15368) and do run on merge groups. This commit adds the workflow only. Languages and query suite reproduce the live default-setup configuration exactly (actions + javascript-typescript, default suite, weekly schedule); `queries:` is left unset so the suite does not change. The two `Analyze (…)` job names become required contexts on `main` once the ruleset is switched over, which is why the file header spells out that renaming the job or changing the language matrix must happen in the same change as the ruleset and the repo register. Co-authored-by: Claude Opus 5 <[email protected]>
1 parent df1250a commit ea6fd03

2 files changed

Lines changed: 106 additions & 3 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,11 @@ jobs:
537537
# checkout means no third-party code in the path of the one check that
538538
# authorises every merge.
539539
#
540-
# NOT AGGREGATED HERE: `CodeQL`. It comes from GitHub's code-scanning default
541-
# setup, which is a separate workflow, so it cannot be a `needs:` of a job in
542-
# this file. It stays a separately required context.
540+
# NOT AGGREGATED HERE: CodeQL. It lives in its own workflow
541+
# (.github/workflows/codeql.yml, advanced setup), so its jobs cannot be a
542+
# `needs:` of a job in this file. Its `Analyze (…)` checks stay separately
543+
# required contexts — see the header of that file for why the job names are
544+
# load-bearing.
543545
# ===========================================================================
544546
ci-required:
545547
name: ci-required

‎.github/workflows/codeql.yml‎

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: CodeQL
2+
3+
# =============================================================================
4+
# CodeQL — ADVANCED setup.
5+
#
6+
# WHY THIS FILE EXISTS AT ALL. Until now CodeQL ran through GitHub's
7+
# code-scanning DEFAULT setup: no workflow in the repo, and a single check
8+
# named `CodeQL` posted by the `github-advanced-security` App (integration id
9+
# 57789). That check has one disqualifying property — it does not report on
10+
# `merge_group` refs (github/codeql-action#1537, open since 2023). A merge
11+
# queue therefore waits forever on a required `CodeQL` context that will never
12+
# arrive, and the pull request looks queued rather than broken until it is
13+
# evicted. Advanced setup runs CodeQL as an ordinary Actions workflow, so its
14+
# checks are posted by `github-actions` (integration id 15368) and DO run on
15+
# merge groups. Same analysis, same alerts, a check the queue can see.
16+
#
17+
# THE JOB NAME IS A LOAD-BEARING STRING. Each matrix job publishes a check run
18+
# named after the job — `Analyze (actions)`, `Analyze (javascript-typescript)`
19+
# — and those exact names are what the `byo-full-public` ruleset requires on
20+
# `main` (recorded in de-otio/dot-work `inventory/repo-register.json` under
21+
# trellis's `extra_required_checks`, which is what asserts they have not
22+
# drifted). Renaming the job, or adding/removing a language, CHANGES THE CHECK
23+
# NAMES: a removed name is a required context nothing will ever report and
24+
# every pull request hangs with no error anywhere. Change this matrix and the
25+
# ruleset + register in the same change, never one without the other.
26+
#
27+
# NO `paths:` FILTER, DELIBERATELY. Same rule as ci.yml: a skipped JOB
28+
# satisfies a required check, a skipped WORKFLOW reports nothing at all. For as
29+
# long as these are required contexts this workflow must fire on every pull
30+
# request to `main`.
31+
#
32+
# LANGUAGES AND SUITE reproduce what default setup was configured with, read
33+
# live from `GET /repos/de-otio/trellis/code-scanning/default-setup` before the
34+
# switch: languages `actions`, `javascript`, `javascript-typescript`,
35+
# `typescript` (the last three are aliases of the one `javascript-typescript`
36+
# extractor), query suite `default`, threat model `remote`. `queries:` is
37+
# therefore deliberately unset — setting it would change the suite — and the
38+
# weekly `schedule:` below reproduces default setup's weekly full scan.
39+
# =============================================================================
40+
41+
on:
42+
push:
43+
branches: [main]
44+
pull_request:
45+
branches: [main]
46+
# See ci.yml: the merge queue validates a speculative merge on a
47+
# `refs/heads/gh-readonly-queue/main/...` ref. Without this trigger the
48+
# workflow never fires there and the required contexts never arrive.
49+
merge_group:
50+
schedule:
51+
# Weekly full scan, matching what default setup ran. Catches newly
52+
# published queries against code that has not changed.
53+
- cron: "27 4 * * 1"
54+
workflow_dispatch:
55+
56+
permissions:
57+
contents: read
58+
59+
concurrency:
60+
group: codeql-${{ github.ref }}
61+
# A cancelled merge-queue run reports no result, which the queue reads the
62+
# same way as a failure — so merge_group is never cancel-eligible, alongside
63+
# main. Identical reasoning to ci.yml.
64+
cancel-in-progress: ${{ github.event_name != 'merge_group' && github.ref != 'refs/heads/main' }}
65+
66+
jobs:
67+
analyze:
68+
name: Analyze (${{ matrix.language }})
69+
runs-on: ubuntu-latest
70+
timeout-minutes: 30
71+
72+
permissions:
73+
# Least privilege, per language job: read the tree, read workflow run
74+
# metadata (the action queries it), write the SARIF back as code-scanning
75+
# alerts. Nothing else.
76+
contents: read
77+
actions: read
78+
security-events: write
79+
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
include:
84+
- language: actions
85+
build-mode: none
86+
- language: javascript-typescript
87+
build-mode: none
88+
89+
steps:
90+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
91+
92+
- name: Initialize CodeQL
93+
uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
94+
with:
95+
languages: ${{ matrix.language }}
96+
build-mode: ${{ matrix.build-mode }}
97+
98+
- name: Perform CodeQL analysis
99+
uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
100+
with:
101+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)