Skip to content

Commit 02755cd

Browse files
committed
Verify using post step
1 parent 94155a7 commit 02755cd

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: Verify that the best-effort debug artifact scan completed
2+
description: Verifies that the best-effort debug artifact scan completed successfully during tests
3+
runs:
4+
using: node20
5+
main: index.js
6+
post: post.js
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// The main step is a no-op, since we can only verify artifact scan completion in the post step.
2+
console.log("Will verify artifact scan completion in the post step.");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Post step - runs after the workflow completes, when artifact scan has finished
2+
const process = require("process");
3+
4+
const scanFinished = process.env.CODEQL_ACTION_ARTIFACT_SCAN_FINISHED;
5+
6+
if (scanFinished !== "true") {
7+
console.error("Error: Best-effort artifact scan did not complete. Expected CODEQL_ACTION_ARTIFACT_SCAN_FINISHED=true");
8+
process.exit(1);
9+
}
10+
11+
console.log("✓ Best-effort artifact scan completed successfully");

.github/workflows/debug-artifacts-failure-safe.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ jobs:
5555
uses: actions/setup-dotnet@v5
5656
with:
5757
dotnet-version: '9.x'
58+
- name: Assert best-effort artifact scan completed
59+
uses: ./../action/.github/actions/verify-debug-artifact-scan-completed
5860
- uses: ./../action/init
5961
with:
6062
tools: ${{ steps.prepare-test.outputs.tools-url }}
@@ -70,14 +72,6 @@ jobs:
7072
CODEQL_ACTION_EXTRA_OPTIONS: '{ "database": { "finalize": ["--invalid-option"] } }'
7173
with:
7274
expect-error: true
73-
- name: Verify artifact scan ran
74-
shell: bash
75-
run: |
76-
if [[ "$CODEQL_ACTION_ARTIFACT_SCAN_FINISHED" != "true" ]]; then
77-
echo "Error: Best effort artifact scan did not run"
78-
exit 1
79-
fi
80-
echo "✓ Best effort artifact scan completed successfully"
8175
download-and-check-artifacts:
8276
name: Download and check debug artifacts after failure in analyze
8377
if: github.triggering_actor != 'dependabot[bot]'

.github/workflows/debug-artifacts-safe.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
uses: actions/setup-dotnet@v5
5252
with:
5353
dotnet-version: '9.x'
54+
- name: Assert best-effort artifact scan completed
55+
uses: ./../action/.github/actions/verify-debug-artifact-scan-completed
5456
- uses: ./../action/init
5557
id: init
5658
with:
@@ -64,14 +66,6 @@ jobs:
6466
run: ./build.sh
6567
- uses: ./../action/analyze
6668
id: analysis
67-
- name: Verify artifact scan ran
68-
shell: bash
69-
run: |
70-
if [[ "$CODEQL_ACTION_ARTIFACT_SCAN_FINISHED" != "true" ]]; then
71-
echo "Error: Best effort artifact scan did not run"
72-
exit 1
73-
fi
74-
echo "✓ Best effort artifact scan completed successfully"
7569
download-and-check-artifacts:
7670
name: Download and check debug artifacts
7771
if: github.triggering_actor != 'dependabot[bot]'

0 commit comments

Comments
 (0)