Skip to content

Commit 662c71a

Browse files
committed
Check telemetry in PR check to ensure .tar.zst downloaded
1 parent a7a6a69 commit 662c71a

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

.github/workflows/__zstd-bundle.yml

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

pr-checks/checks/zstd-bundle.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
name: "Zstandard bundle"
2-
description: "Tests using a CodeQL Bundle compressed using Zstandard"
2+
description: "Tests the feature flag that downloads a Zstandard-compressed CodeQL Bundle by default"
33
versions:
44
- linked
55
operatingSystems:
66
- ubuntu
77
env:
88
CODEQL_ACTION_ZSTD_BUNDLE: true
99
steps:
10+
- name: Remove CodeQL from toolcache
11+
run: |
12+
rm -rf $RUNNER_TOOL_CACHE/CodeQL
1013
- id: init
1114
uses: ./../action/init
1215
with:
@@ -17,3 +20,44 @@ steps:
1720
shell: bash
1821
run: ./build.sh
1922
- uses: ./../action/analyze
23+
with:
24+
output: ${{ runner.temp }}/results
25+
upload-database: false
26+
- name: Upload SARIF
27+
uses: actions/upload-artifact@v3
28+
with:
29+
name: zstd-bundle.sarif
30+
path: ${{ runner.temp }}/results/cpp.sarif
31+
retention-days: 7
32+
- name: Check diagnostic with expected tools URL appears in SARIF
33+
uses: actions/github-script@v7
34+
env:
35+
SARIF_PATH: ${{ runner.temp }}/results/cpp.sarif
36+
with:
37+
script: |
38+
const fs = require('fs');
39+
40+
const sarif = JSON.parse(fs.readFileSync(process.env['SARIF_PATH'], 'utf8'));
41+
const run = sarif.runs[0];
42+
43+
const toolExecutionNotifications = run.invocations[0].toolExecutionNotifications;
44+
const downloadTelemetryNotifications = toolExecutionNotifications.filter(n =>
45+
n.descriptor.id === 'codeql-action/bundle-download-telemetry'
46+
);
47+
if (downloadTelemetryNotifications.length !== 1) {
48+
core.setFailed(
49+
'Expected exactly one reporting descriptor in the ' +
50+
`'runs[].invocations[].toolExecutionNotifications[]' SARIF property, but found ` +
51+
`${downloadTelemetryNotifications.length}. All notification reporting descriptors: ` +
52+
`${JSON.stringify(toolExecutionNotifications)}.`
53+
);
54+
}
55+
56+
const toolsUrl = downloadTelemetryNotifications[0].properties.attributes.toolsUrl;
57+
console.log(`Found tools URL: ${toolsUrl}`);
58+
59+
if (!toolsUrl.endsWith('.tar.zst')) {
60+
core.setFailed(
61+
`Expected the tools URL to be a .tar.zst file, but found ${toolsUrl}.`
62+
);
63+
}

0 commit comments

Comments
 (0)