GitHub Action
The action installs tx0, fails the job on findings a pull request introduced, keeps the cache of tx0 between runs, and uploads the findings to GitHub code scanning.
The action is read from the tx0 repository, which is not public yet. Until it is, the workflow on CI runs the same check with tx0 installed from PyPI.
The workflow
name: tx0
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
security-events: write
jobs:
tx0:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: tx0io/tx0@mainOn a pull request, only findings that are new since the base count for the gate. On a push to main, the whole tree is checked. To pin the version and pass more arguments to tx0 check:
- uses: tx0io/tx0@main
with:
version: 0.1.0-alpha.3
args: --tier recommendedWhat it does
- Picks the build for the runner: Linux, macOS or Windows, x86_64 or arm64. With
version: latestit asks GitHub for the newest release. - Restores the binary and the result store of tx0 from the Actions cache. Results are keyed by content, so an older entry is always safe to reuse.
- On a pull request, finds the base from the merge commit GitHub prepared and fetches it if the checkout does not have it. The default shallow checkout is enough.
- Writes SARIF for the whole tree, then runs
tx0 check --since BASE, so the exit code counts only what the pull request introduced. Code scanning compares whole result sets, which is why the upload gets every finding. - Saves the cache and uploads the SARIF file. Pull requests from forks get a read-only token and skip the upload.
The gate is the [gate] table of tx0.toml; without it, any new finding fails the job.
Inputs
- version
- the tx0 version to install, such as 0.1.0; default
latest - working-directory
- where to run tx0, relative to the workspace; default
. - args
- more arguments for tx0 check, such as --tier recommended or paths; default empty
- base
- the revision whose findings count as known; on pull requests, the base the pull request is merged into; on other events the whole tree is reported; default empty
- cache
- keep the binary and the cache of tx0 between runs with the Actions cache; default
true - upload-sarif
- upload the findings of the whole tree to code scanning; needs security-events: write; default
true - sarif-file
- where to write the SARIF file; default
tx0.sarif - token
- the token for the GitHub API, used to find the newest release when only pre-releases exist; default
github.token
Outputs
- version
- the installed tx0 version
- exit-code
- the exit code of the check: 0 passed, 1 the gate failed, 2 or 3 tx0 could not run
For other CI systems, CI has the commands to run.