Skip to content

Commit faf6d35

Browse files
committed
Verify using post step
1 parent 3b94cfe commit faf6d35

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
@@ -58,6 +58,8 @@ jobs:
5858
uses: actions/setup-dotnet@v5
5959
with:
6060
dotnet-version: '9.x'
61+
- name: Assert best-effort artifact scan completed
62+
uses: ./../action/.github/actions/verify-debug-artifact-scan-completed
6163
- uses: ./../action/init
6264
with:
6365
tools: ${{ steps.prepare-test.outputs.tools-url }}
@@ -73,14 +75,6 @@ jobs:
7375
CODEQL_ACTION_EXTRA_OPTIONS: '{ "database": { "finalize": ["--invalid-option"] } }'
7476
with:
7577
expect-error: true
76-
- name: Verify artifact scan ran
77-
shell: bash
78-
run: |
79-
if [[ "$CODEQL_ACTION_ARTIFACT_SCAN_FINISHED" != "true" ]]; then
80-
echo "Error: Best effort artifact scan did not run"
81-
exit 1
82-
fi
83-
echo "✓ Best effort artifact scan completed successfully"
8478
download-and-check-artifacts:
8579
name: Download and check debug artifacts after failure in analyze
8680
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
@@ -54,6 +54,8 @@ jobs:
5454
uses: actions/setup-dotnet@v5
5555
with:
5656
dotnet-version: '9.x'
57+
- name: Assert best-effort artifact scan completed
58+
uses: ./../action/.github/actions/verify-debug-artifact-scan-completed
5759
- uses: ./../action/init
5860
id: init
5961
with:
@@ -67,14 +69,6 @@ jobs:
6769
run: ./build.sh
6870
- uses: ./../action/analyze
6971
id: analysis
70-
- name: Verify artifact scan ran
71-
shell: bash
72-
run: |
73-
if [[ "$CODEQL_ACTION_ARTIFACT_SCAN_FINISHED" != "true" ]]; then
74-
echo "Error: Best effort artifact scan did not run"
75-
exit 1
76-
fi
77-
echo "✓ Best effort artifact scan completed successfully"
7872
download-and-check-artifacts:
7973
name: Download and check debug artifacts
8074
if: github.triggering_actor != 'dependabot[bot]'

0 commit comments

Comments
 (0)