Skip to content

Commit 61493eb

Browse files
mhuckapavoljuhas
andauthored
Remove CodeQL scanner & move others to new weekly schedule (#1109)
GitHub enhanced their CodeQL scanner and its configuration options since the time I originally wrote the custom workflow file here. It's now easier to simply use GitHub's repository options for setting up CodeQL. No need to maintain our own workflow anymore. Also, the other scanners (OSV and Scorecard) are run on every PR, so there is not much value in running also running them nightly. I moved them to a new weekly workflow because it's still worth running them regularly. Finally, this updates the workflows to the latest versions used in our template repo. --------- Co-authored-by: Pavol Juhas <[email protected]>
1 parent fb7bc39 commit 61493eb

File tree

6 files changed

+146
-152
lines changed

6 files changed

+146
-152
lines changed

.github/workflows/codeql.yaml

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

.github/workflows/nightly-pytest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474

7575
steps:
7676
- name: Check out a copy of the OpenFermion git repository
77-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4
77+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
7878

7979
- name: Set up Python ${{matrix.python-version}}
8080
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5

.github/workflows/nightly.yaml

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
# limitations under the License.
1414

1515
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16-
# Nightly tests and scans workflow.
17-
#
1816
# This workflow runs nightly to run tests & scans on the OpenFermion codebase.
1917
# It can also be invoked manually via the "Run workflow" button at
2018
# https://github.com/quantumlib/OpenFermion/actions/workflows/nightly.yaml
2119
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2220

23-
name: 'Nightly tests & scans'
21+
name: 'Nightly tests'
2422
run-name: Run nightly tests and code scans
2523

2624
on:
@@ -47,25 +45,3 @@ jobs:
4745
with:
4846
args: '--pre'
4947
reason: '(nightly)'
50-
51-
codeql:
52-
name: Nightly CodeQL code scan
53-
uses: ./.github/workflows/codeql.yaml
54-
permissions: write-all
55-
with:
56-
reason: '(nightly)'
57-
58-
osv:
59-
name: Nightly OSV code scan
60-
uses: ./.github/workflows/osv-scanner.yaml
61-
permissions: write-all
62-
with:
63-
reason: '(nightly)'
64-
65-
scorecard:
66-
name: Nightly Scorecard analysis
67-
uses: ./.github/workflows/scorecard.yaml
68-
permissions: write-all
69-
secrets: inherit
70-
with:
71-
reason: '(nightly)'

.github/workflows/osv-scanner.yaml

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
# JavaScript, and others. The findings are reported in the repo's code-scanning
2121
# results page, https://github.com/quantumlib/REPO/security/code-scanning/.
2222
#
23-
# The OSV project provides a GA workflow that you can reference as a step with
23+
# Note: the OSV project provides a workflow you can reference as a step with
2424
# uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml.
2525
# Unfortunately, that workflow hardcodes some behaviors (such as uploading the
26-
# SARIF file to the workflow Actions tab, which we rarely need). The workflow
27-
# below is basically a heavily modified version of theirs.
26+
# SARIF file to the workflow Actions tab, which we have never needed). The
27+
# workflow in this file is basically a heavily modified version of theirs.
2828
#
2929
# For more OSV scanner examples and options, including how to ignore specific
3030
# vulnerabilities, see https://google.github.io/osv-scanner/github-action/.
3131
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3232

33-
name: OSV code scan
34-
run-name: Run OSV vulnerability scanner ${{inputs.reason}}
33+
name: OSV known vulnerabilities scanner
34+
run-name: Run OSV (open-source vulnerabilities) scanner ${{inputs.reason}}
3535

3636
on:
3737
pull_request:
@@ -45,20 +45,36 @@ on:
4545
types:
4646
- checks_requested
4747

48-
# Allow manual invocation.
49-
workflow_dispatch:
50-
51-
# Allow calling from nightly.yaml.
48+
# Allow calling from other workflows.
5249
workflow_call:
5350
inputs:
5451
reason:
52+
description: 'Append text to workflow run name:'
5553
type: string
54+
debug:
55+
description: 'Run with debugging options'
56+
type: boolean
57+
default: false
58+
59+
# Allow manual invocation.
60+
workflow_dispatch:
61+
inputs:
62+
debug:
63+
description: 'Run with debugging options'
64+
type: boolean
65+
default: true
5666

57-
# Declare default permissions as read only.
67+
# Declare default workflow permissions as read only.
5868
permissions: read-all
5969

70+
concurrency:
71+
# Cancel any previously-started but still active runs on the same branch.
72+
cancel-in-progress: true
73+
group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}}
74+
6075
jobs:
6176
osv-scan:
77+
if: github.repository_owner == 'quantumlib'
6278
name: Run OSV scanner
6379
runs-on: ubuntu-24.04
6480
timeout-minutes: 15
@@ -69,9 +85,12 @@ jobs:
6985
security-events: write
7086
# Needed to upload SARIF file to CodeQL.
7187
contents: read
88+
env:
89+
# Setting Bash SHELLOPTS here takes effect for all shell commands below.
90+
SHELLOPTS: ${{inputs.debug && 'xtrace' || '' }}
7291
steps:
7392
- name: Check out a copy of the git repository
74-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
93+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
7594
with:
7695
fetch-depth: 0
7796

@@ -82,10 +101,11 @@ jobs:
82101
83102
- name: Run OSV scanner on existing code
84103
# yamllint disable rule:line-length
85-
uses: google/osv-scanner-action/osv-scanner-action@456ceb78310755116e0a3738121351006286b797 # v2.2.1
104+
uses: google/osv-scanner-action/osv-scanner-action@b00f71e051ddddc6e46a193c31c8c0bf283bf9e6 # v2.1.0
86105
continue-on-error: true
87106
with:
88107
scan-args: |-
108+
--include-git-root
89109
--format=json
90110
--output=old-results.json
91111
--recursive
@@ -99,18 +119,19 @@ jobs:
99119
100120
- name: Run OSV scanner on new code
101121
# yamllint disable rule:line-length
102-
uses: google/osv-scanner-action/osv-scanner-action@456ceb78310755116e0a3738121351006286b797 # v2.2.1
122+
uses: google/osv-scanner-action/osv-scanner-action@b00f71e051ddddc6e46a193c31c8c0bf283bf9e6 # v2.1.0
103123
continue-on-error: true
104124
with:
105125
scan-args: |-
126+
--include-git-root
106127
--format=json
107128
--output=new-results.json
108129
--recursive
109130
./
110131
111132
- name: Run the OSV scanner reporter
112133
# yamllint disable rule:line-length
113-
uses: google/osv-scanner-action/osv-reporter-action@456ceb78310755116e0a3738121351006286b797 # v2.2.1
134+
uses: google/osv-scanner-action/osv-reporter-action@b00f71e051ddddc6e46a193c31c8c0bf283bf9e6 # v2.1.0
114135
with:
115136
scan-args: |-
116137
--output=osv-results.sarif
@@ -122,10 +143,18 @@ jobs:
122143
- name: Upload results to the repository's code-scanning results dashboard
123144
id: upload_artifact
124145
# yamllint disable rule:line-length
125-
uses: github/codeql-action/upload-sarif@96f518a34f7a870018057716cc4d7a5c014bd61c # v3.29.10
146+
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
126147
with:
127148
sarif_file: osv-results.sarif
128149

150+
- if: github.event.inputs.debug == true
151+
name: Upload results as artifacts to the workflow Summary page
152+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
153+
with:
154+
name: SARIF file
155+
path: results.sarif
156+
retention-days: 5
157+
129158
- name: Error troubleshooter
130159
if: ${{always() && steps.upload_artifact.outcome == 'failure'}}
131160
run: echo '::error::Artifact upload failed. Check the workflow logs.'

.github/workflows/scorecard.yaml renamed to .github/workflows/scorecard-scanner.yaml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,41 @@ on:
3636
types:
3737
- checks_requested
3838

39-
# Allow manual invocation.
40-
workflow_dispatch:
41-
4239
# Allow calling from nightly.yaml.
4340
workflow_call:
4441
inputs:
4542
reason:
43+
description: 'Append text to workflow run name:'
4644
type: string
45+
debug:
46+
description: 'Run with debugging options'
47+
type: boolean
48+
default: false
4749

48-
# Declare default permissions as read only.
50+
# Allow manual invocation.
51+
workflow_dispatch:
52+
inputs:
53+
debug:
54+
description: 'Run with debugging options'
55+
type: boolean
56+
default: true
57+
58+
# Declare default workflow permissions as read only.
4959
permissions: read-all
5060

5161
jobs:
5262
scorecard:
63+
if: github.repository_owner == 'quantumlib'
5364
name: Run Scorecard analyzer
5465
runs-on: ubuntu-24.04
55-
permissions: write-all
66+
permissions:
67+
actions: read
68+
contents: read
69+
security-events: write
5670
timeout-minutes: 15
5771
steps:
5872
- name: Check out a copy of the git repository
59-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
73+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
6074
with:
6175
persist-credentials: false
6276

@@ -72,6 +86,14 @@ jobs:
7286
publish_results: true
7387

7488
- name: Upload results to code-scanning dashboard
75-
uses: github/codeql-action/upload-sarif@96f518a34f7a870018057716cc4d7a5c014bd61c # v3
89+
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
7690
with:
7791
sarif_file: scorecard-results.sarif
92+
93+
- if: github.event.inputs.debug == true
94+
name: Upload results as artifacts to the workflow Summary page
95+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
96+
with:
97+
name: SARIF file
98+
path: results.sarif
99+
retention-days: 5

0 commit comments

Comments
 (0)