-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OSV code scanner and make minor adjustments to CI (#992)
* Run all nightly tests from a common top-level workflow This removes the individual cron schedule entries from the workflows that run at night, and instead invokes them from `nightly.yaml`. * Rename workflows to use .yaml extension consistently `.yaml` is actually the official file extension for YAML. * Add OSV scanner workflow * Adjust names and trigger conditions * Tell yamllint the long lines are okay * Rework organization some more * Set up another problem matcher * Add .editorconfig file (#990) This adds settings based on some common-sense values and the OpenFermion project's current conventions, such as line length and use of spaces instead of tabs. * Add shellcheck for shell script linting (#991) * Add .shellcheckrc This adds a config file for .shellcheckrc, and sets a few optional flags to try to make shellcheck slightly more thorough. * Add shellcheck problem matcher * Add a heading to help break up the text a little * Add shellcheck to CI checks * Edit CONTRIBUTING.md (#993) This adds a warning about the CLA implications for GenAI code, and tries to add some more info about the contribution process. * Add markdownlint config file (#995) This adds a `.markdownlintrc` configuration file for [markdownlint](https://github.com/igorshubovych/markdownlint-cli), a popular linter for Markdown files. The settings here try to be as close to the Google style as possible while still being compatible with GitHub-flavored Markdown. This same markdownlint file is used in Cirq and other Quantumlib projects. * Fix warnings reported by shellcheck (#997) There are no functional changes in this commit; all changes are to address lint reported by shellcheck. * CI checks need to be run if ci.yml changes (#998) The tests for changed files needs to consider changes to the workflow definitions too, because a change to the workflow definition could involve changing options or other aspects of the CI tests that might change the check results. * Add problem matchers for Mypy, Pytest, and Black (#1000) * Add problem matchers for mypy and pytest * Add problem matcher for Black * Pass input sha to format-incremental If the user supplied a sha in a manual workflow run, we need to pass that to `format-incremental` or else it won't compare files to the correct revision. * Prefer single quotes in YAML Due to how GitHub Actions syntax works, I'm finding it safer to use single quotes for YAML values and (usually) double quotes in shell scripts. * Tighten format of "run:" for one-liners It seems slightly reasier to read the code whenn single-line shell commands are put on the same line as the `run:`, instead of being put on a separate line. * More setup, editing, configuration, renaming, tweaking
- Loading branch information
Showing
7 changed files
with
183 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Summary: run nightly tests and scans. | ||
# | ||
# This workflow runs nightly to run tests & scans on the OpenFermion codebase. | ||
# It can also be invoked manually via the "Run workflow" button at | ||
# https://github.com/quantumlib/OpenFermion/actions/workflows/nightly.yaml | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
name: Nightly full tests | ||
run-name: Run nightly tests and code scans in ${{github.repository}} | ||
|
||
on: | ||
schedule: | ||
- cron: '15 2 * * *' | ||
|
||
# Allow manual invocation. | ||
workflow_dispatch: | ||
|
||
# Declare default permissions as read only. | ||
permissions: read-all | ||
|
||
jobs: | ||
cirq-stable: | ||
name: Pytest Cirq stable release | ||
uses: ./.github/workflows/nightly-pytest.yaml | ||
with: | ||
args: '' | ||
reason: nightly | ||
|
||
cirq-pre: | ||
name: Pytest Cirq pre-release | ||
uses: ./.github/workflows/nightly-pytest.yaml | ||
with: | ||
args: '--pre' | ||
reason: nightly | ||
|
||
codeql: | ||
name: CodeQL code scan | ||
uses: ./.github/workflows/codeql.yaml | ||
permissions: write-all | ||
with: | ||
reason: nightly | ||
|
||
scorecard: | ||
name: Scorecard code scan | ||
uses: ./.github/workflows/scorecard.yaml | ||
permissions: write-all | ||
with: | ||
reason: nightly | ||
|
||
osv: | ||
name: OSV code scan | ||
uses: ./.github/workflows/osv-scanner.yaml | ||
permissions: write-all | ||
with: | ||
reason: nightly |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Summary: run Open Source Vulnerabilities (OSV) code scan. | ||
# | ||
# For more examples and options, including how to ignore specific | ||
# vulnerabilities, see https://google.github.io/osv-scanner/github-action/. | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
name: OSV code scan | ||
run-name: Do ${{inputs.reason}} OSV code scan | ||
|
||
on: | ||
merge_group: | ||
types: | ||
- checks_requested | ||
|
||
# Allow calling from nightly.yaml. | ||
workflow_call: | ||
inputs: | ||
# Why is this workflow being called? | ||
reason: | ||
type: string | ||
required: false | ||
|
||
# Allow manual invocation. | ||
workflow_dispatch: | ||
|
||
# Declare default permissions as read only. | ||
permissions: read-all | ||
|
||
jobs: | ||
osv-scan: | ||
name: Run | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 15 | ||
permissions: | ||
# Needed to upload the results to code-scanning dashboard. | ||
security-events: write | ||
# Read commit contents | ||
contents: read | ||
actions: read | ||
steps: | ||
- name: Check out a copy of the git repository | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Run OSV analysis | ||
# yamllint disable rule:line-length | ||
uses: google/osv-scanner-action/osv-scanner-action@f8115f2f28022984d4e8070d2f0f85abcf6f3458 # v1.9.2 | ||
continue-on-error: true | ||
with: | ||
scan-args: |- | ||
--format=json | ||
--output=osv-results.json | ||
--recursive | ||
--skip-git | ||
./ | ||
- name: Run osv-scanner-reporter | ||
# yamllint disable rule:line-length | ||
uses: google/osv-scanner-action/osv-reporter-action@f8115f2f28022984d4e8070d2f0f85abcf6f3458 # v1.9.2 | ||
with: | ||
scan-args: |- | ||
--output=osv-results.sarif | ||
--new=osv-results.json | ||
--gh-annotations=true | ||
--fail-on-vuln=true | ||
- name: Upload to code-scanning dashboard | ||
uses: github/codeql-action/upload-sarif@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8 | ||
with: | ||
sarif_file: osv-results.sarif |
30 changes: 19 additions & 11 deletions
30
.github/workflows/ossf-scorecard.yaml → .github/workflows/scorecard.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters