Skip to content

Commit 08643f8

Browse files
authored
Merge branch 'main' into henrymercer/runner-image-coverage
2 parents a6827a3 + b2b7b36 commit 08643f8

10 files changed

Lines changed: 681 additions & 66 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Post comment"
2+
description: "Create or update a sticky PR comment identified by a caller-provided marker."
3+
inputs:
4+
marker:
5+
description: >
6+
Non-empty plain-text identifier for the comment. Use a unique, stable value
7+
for each distinct comment; it is automatically wrapped in a hidden HTML comment.
8+
required: true
9+
body:
10+
description: "Full comment markdown."
11+
required: true
12+
update-only:
13+
description: Do nothing if no comment with the specified marker exists.
14+
required: false
15+
default: "false"
16+
issue-id:
17+
description: >
18+
The issue or pull request number to post/update the comment on.
19+
Defaults to the current pull request if not provided.
20+
required: false
21+
token:
22+
description: "The GitHub token to authenticate with."
23+
required: true
24+
runs:
25+
using: composite
26+
steps:
27+
- name: Post comment
28+
shell: bash
29+
env:
30+
BODY: ${{ inputs.body }}
31+
MARKER: ${{ inputs.marker }}
32+
UPDATE_ONLY: ${{ case(inputs.update-only == 'true', '--update-only', '') }}
33+
GH_TOKEN: ${{ inputs.token }}
34+
ISSUE_ID: ${{ inputs.issue-id || github.event.pull_request.number }}
35+
run: |
36+
npx tsx ./pr-checks/post-comment.ts \
37+
--body "$BODY" \
38+
--marker "$MARKER" \
39+
$UPDATE_ONLY \
40+
--issue-id "$ISSUE_ID" \
41+
--repository "$GITHUB_REPOSITORY"

‎.github/actions/prepare-test/action.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ runs:
3636
set -e # Fail this Action if `gh release list` fails.
3737
3838
if [[ "$VERSION" == "nightly" || "$VERSION" == "nightly-latest" ]]; then
39-
echo "tools-url=nightly" >> "$GITHUB_OUTPUT"
39+
if [[ "$USE_ALL_PLATFORM_BUNDLE" == "true" ]]; then
40+
# With `tools: nightly`, the Action downloads the bundle for the runner's platform, so look
41+
# up the latest nightly release here to get its all-platform bundle instead.
42+
tag=$(gh release list --repo dsp-testing/codeql-cli-nightlies --limit 1 --json tagName --jq '.[0].tagName')
43+
echo "tools-url=https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/$tag/codeql-bundle.tar.gz" >> "$GITHUB_OUTPUT"
44+
else
45+
echo "tools-url=nightly" >> "$GITHUB_OUTPUT"
46+
fi
4047
exit 0
4148
elif [[ "$VERSION" == "linked" ]]; then
4249
echo "tools-url=linked" >> "$GITHUB_OUTPUT"

‎.github/workflows/__all-platform-bundle.yml‎

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.github/workflows/deflake.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ on:
3131
- "PR Check - C/C\\+\\+: autoinstalling dependencies is skipped (macOS)"
3232
- "PR Check - C/C\\+\\+: disabling autoinstalling dependencies (Linux)"
3333
- "PR Check - Clean up database cluster directory"
34-
- "PR Check - CodeQL Bundle All"
3534
- "PR Check - Config export"
3635
- "PR Check - Config input"
3736
- "PR Check - Custom source root"

‎.github/workflows/pr-checks.yml‎

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ jobs:
9595
contents: read
9696
runs-on: ubuntu-26.04
9797
timeout-minutes: 10
98+
outputs:
99+
changelog-modified: ${{ steps.changelog-check.outputs.modified }}
98100

99101
concurrency:
100102
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
@@ -191,6 +193,20 @@ jobs:
191193
path: ${{ runner.temp }}/repo-size/
192194
if-no-files-found: error
193195

196+
- name: Check for CHANGELOG.md changes
197+
id: changelog-check
198+
if: steps.fetch-base.outcome == 'success'
199+
env:
200+
BASE_SHA: ${{ steps.fetch-base.outputs.merge_base }}
201+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
202+
run: |
203+
if ! git diff --exit-code --quiet "$BASE_SHA" "$HEAD_SHA" -- CHANGELOG.md; then
204+
echo "CHANGELOG.md was modified in this PR."
205+
echo "modified=true" >> "$GITHUB_OUTPUT"
206+
else
207+
echo "modified=false" >> "$GITHUB_OUTPUT"
208+
fi
209+
194210
- name: "Backport: Check out base ref"
195211
id: checkout-base
196212
if: ${{ startsWith(github.head_ref, 'backport-') }}
@@ -211,8 +227,8 @@ jobs:
211227
exit 1
212228
fi
213229
214-
post-repo-size-comment:
215-
name: Post repo size comment
230+
post-pr-comments:
231+
name: Post PR comments
216232
needs: other-checks
217233
# Keep write permissions isolated from the job that checks out and tests PR code. This job only
218234
# posts the candidate comment body produced by the read-only `pr-checks` job.
@@ -232,6 +248,22 @@ jobs:
232248
group: check-repo-size-${{ github.event.pull_request.number }}
233249

234250
steps:
251+
- name: Checkout repository
252+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
253+
with:
254+
# Check out main, not the PR's head, since this job runs with
255+
# `pull-requests: write` permissions and must not execute untrusted code from the PR.
256+
ref: main
257+
258+
- name: Set up Node.js
259+
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
260+
with:
261+
node-version: 24
262+
cache: "npm"
263+
264+
- name: Install dependencies
265+
run: npm ci --workspace=pr-checks --include-workspace-root
266+
235267
- name: Download repo size comment
236268
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
237269
with:
@@ -261,3 +293,42 @@ jobs:
261293
else
262294
echo "Skipping repo size comment because the delta is below the threshold and no sticky comment exists."
263295
fi
296+
297+
- name: Post a warning about modifying CHANGELOG.md
298+
# Release, backport, mergeback, and bundle-update PRs deliberately modify CHANGELOG.md,
299+
# so skip comment management entirely for these automation flows.
300+
if: >-
301+
needs.other-checks.outputs.changelog-modified == 'true' &&
302+
!startsWith(github.event.pull_request.head.ref, 'update-v') &&
303+
!startsWith(github.event.pull_request.head.ref, 'backport-v') &&
304+
!startsWith(github.event.pull_request.head.ref, 'mergeback/') &&
305+
!startsWith(github.event.pull_request.head.ref, 'update-bundle/')
306+
uses: ./.github/actions/post-comment
307+
with:
308+
marker: "post-comment:CHANGELOG.md"
309+
body: |
310+
⚠️ `CHANGELOG.md` has been modified in this PR. Please do not modify `CHANGELOG.md` directly.
311+
Instead, create a change-note file in `unreleased-change-notes/`. The `CHANGELOG.md`
312+
file will be automatically generated from those change-notes.
313+
See [`unreleased-change-notes/README.md`](https://github.com/github/codeql-action/blob/main/unreleased-change-notes/README.md) for more information.
314+
token: ${{ secrets.GITHUB_TOKEN }}
315+
316+
- name: Mark the CHANGELOG.md concern as resolved
317+
if: >-
318+
needs.other-checks.outputs.changelog-modified == 'false' &&
319+
!startsWith(github.event.pull_request.head.ref, 'update-v') &&
320+
!startsWith(github.event.pull_request.head.ref, 'backport-v') &&
321+
!startsWith(github.event.pull_request.head.ref, 'mergeback/') &&
322+
!startsWith(github.event.pull_request.head.ref, 'update-bundle/')
323+
uses: ./.github/actions/post-comment
324+
with:
325+
marker: "post-comment:CHANGELOG.md"
326+
update-only: true
327+
body: |
328+
⚠️ `CHANGELOG.md` has been modified in this PR. Please do not modify `CHANGELOG.md` directly.
329+
Instead, create a change-note file in `unreleased-change-notes/`. The `CHANGELOG.md`
330+
file will be automatically generated from those change-notes.
331+
See [`unreleased-change-notes/README.md`](https://github.com/github/codeql-action/blob/main/unreleased-change-notes/README.md) for more information.
332+
333+
**Edit:** `CHANGELOG.md` is no longer modified in this PR. This concern is resolved.
334+
token: ${{ secrets.GITHUB_TOKEN }}

‎.github/workflows/test-codeql-bundle-all.yml‎

Lines changed: 0 additions & 62 deletions
This file was deleted.

‎pr-checks/api-client.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,14 @@ export function getApiClient(token: string): ApiClient {
88
const opts = githubUtils.getOctokitOptions(token);
99
return new githubUtils.GitHub(opts);
1010
}
11+
12+
/** Resolves the GitHub API token to use, from `GH_TOKEN` or `GITHUB_TOKEN`. */
13+
export function resolveToken(env: NodeJS.ProcessEnv): string {
14+
const token = env.GH_TOKEN?.trim() || env.GITHUB_TOKEN?.trim();
15+
if (!token) {
16+
throw new Error(
17+
"Missing authentication token. Set GH_TOKEN or GITHUB_TOKEN.",
18+
);
19+
}
20+
return token;
21+
}

‎pr-checks/checks/all-platform-bundle.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ steps:
1717
# Swift is not supported on Ubuntu so we manually exclude it from the list here
1818
languages: cpp,csharp,go,java,javascript,python,ruby
1919
tools: ${{ steps.prepare-test.outputs.tools-url }}
20+
- name: Check that the bundle contains tools for all platforms
21+
env:
22+
CODEQL_PATH: ${{ steps.init.outputs.codeql-path }}
23+
run: |
24+
# Platform-specific bundles only contain the tools for their own platform.
25+
tools_dir="$(dirname "$CODEQL_PATH")/tools"
26+
for platform in linux64 osx64 win64; do
27+
if [[ ! -d "$tools_dir/$platform" ]]; then
28+
echo "::error::Expected an all-platform CodeQL bundle, but '$tools_dir' does not contain a '$platform' directory."
29+
exit 1
30+
fi
31+
done
2032
- name: Build code
2133
run: ./build.sh
2234
- uses: ./../action/analyze

0 commit comments

Comments
 (0)