Skip to content

Commit 24fd4c0

Browse files
committed
Generate the "Submit SARIF after failure" workflow
1 parent d0517be commit 24fd4c0

4 files changed

Lines changed: 104 additions & 35 deletions

File tree

.github/workflows/__submit-sarif-failure.yml

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

.github/workflows/submit-sarif-failure.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Submit SARIF after failure
2+
description: Check that a SARIF file is submitted for the workflow run if it fails
3+
versions: ["latest", "cached", "nightly-latest"]
4+
operatingSystems: ["ubuntu"]
5+
6+
env:
7+
# Internal-only environment variable used to indicate that the post-init Action
8+
# should expect to upload a SARIF file for the failed run.
9+
CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF: true
10+
# Make sure the uploading SARIF files feature is enabled.
11+
CODEQL_ACTION_UPLOAD_FAILED_SARIF: true
12+
# Upload the failed SARIF file as an integration test of the API endpoint.
13+
CODEQL_ACTION_TEST_MODE: false
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: ./init
18+
with:
19+
languages: javascript
20+
- name: Fail
21+
# We want this job to pass if the Action correctly uploads the SARIF file for
22+
# the failed run.
23+
# Setting this step to continue on error means that it is marked as completing
24+
# successfully, so will not fail the job.
25+
continue-on-error: true
26+
run: exit 1
27+
- uses: ./analyze
28+
# In a real workflow, this step wouldn't run. Since we used `continue-on-error`
29+
# above, we manually disable it with an `if` condition.
30+
if: false
31+
with:
32+
category: "/test-codeql-version:${{ matrix.version }}"

pr-checks/sync.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ def writeHeader(checkStream):
115115
checkJob[key] = checkSpecification[key]
116116

117117
checkJob['env'] = checkJob.get('env', {})
118-
checkJob['env']['CODEQL_ACTION_TEST_MODE'] = True
118+
if 'CODEQL_ACTION_TEST_MODE' not in checkJob['env']:
119+
checkJob['env']['CODEQL_ACTION_TEST_MODE'] = True
119120
checkName = file[:len(file) - 4]
120121

121122
with open(f"../.github/workflows/__{checkName}.yml", 'w') as output_stream:

0 commit comments

Comments
 (0)