Skip to content

ci: check pushes only on main, cache audit - #20

Merged
npmccallum merged 2 commits into
mainfrom
bot/devmap/ci-push-main-audit-cache
Oct 31, 2026
Merged

npmccallum merged 2 commits into
mainfrom
bot/devmap/ci-push-main-audit-cache

Conversation

@npmccallum

Copy link
Copy Markdown
Contributor

Summary

A workflow is a set of automatic steps GitHub runs for this project. The workspace and security workflows run for a push, which sends new commits to GitHub, only when it goes to the main branch. Other branches are checked through their pull request, so each pull request update is checked once. When a pull request gets another update, any run that is checking an earlier update of that pull request is cancelled.

The audit is the security check that compares our dependencies, the outside libraries this project uses, with a public list of known security problems. Its cargo-audit program uses a cache: a saved copy kept between runs so the program is not rebuilt each time. The audit downloads the latest public list on every run.

Closes #17
Closes #18

Approach

  • Both workflows use a concurrency group, the name GitHub uses to decide which runs may cancel each other. For a pull request, the name combines the workflow name with the pull request number. Every other run uses its run ID, a number GitHub gives to each run, so a push to main, a scheduled run or a manual run cannot cancel another run or wait for it.
  • The security workflow runs for a push to main or a pull request update only when the change touches a file in its path filters, the file list that decides whether a check runs. It also runs every Monday and when started by hand.
  • Only the program folder, ~/.cache/cargo-audit-0.22.2, is saved. The ~/.cargo/bin folder also holds Rust tools, so it is left out.
  • The name that finds the saved copy includes the program version, the system and processor type, and a fingerprint of the exact Rust compiler, the program that builds Rust source code. The fingerprint is a short code that changes whenever the compiler changes. The version 0.22.2 is written once, in the security workflow's settings.
  • After the Rust tools are set up, the security check restores the saved copy and checks that the program reports version 0.22.2. If the folder is empty or the program reports a different version, the check builds the program and saves it.

Verification

  • All local tests were run and passed for every commit in this series independently
  • For each commit, the format check and clippy, the Rust code checker, passed with warnings treated as errors. Features are the optional parts of a Rust library that can be turned on or off. Clippy ran with all optional features, with the default features and with no default features. Hawkeye 6.5.0, the license header checker, passed. Cargo deny, which checks dependency and license rules, and the audit passed.
  • For each commit, the tests passed with all optional features and with no default features. The examples in the documentation passed as tests in both settings. Separate feature combinations for the disk verification library passed. The commands that the macOS and Windows runs use passed on Linux. Building every test and running the documentation examples passed with Rust 1.87.0, the oldest supported Rust version.
  • For each commit, the sample checks for the script that prepares the disk tests that need admin rights passed, as did the rules about which project libraries may depend on each other. The documentation built with warnings treated as errors and with the docs workflow's command. Building and checking the packages, the files published to crates.io (the Rust package site), passed with an empty build folder, as GitHub runs it.
  • For each commit, gitlint, the commit message checker, passed. Git's whitespace check passed for the whole series and for each commit. The working folder had no uncommitted changes before or after the checks.
  • For each commit, actionlint, the workflow file checker, passed on all three workflow files together with shellcheck, the shell script checker.
  • The step that installs cargo-audit, copied exactly from security.yml, passed three times in a local test: with an empty program folder, with a filled folder, and with a program that reports a different version. With the empty folder and the wrong version, the step installed version 0.22.2 into its own folder, ready for the cache step to save. With the filled folder, the step used the saved program without building it. The audit then passed with that program.
  • The tests that need admin (root) rights were not run; they use device-mapper, the Linux feature that stacks virtual disks, and loop devices, which make a file act like a disk; both need admin rights that the work machine blocks. The macOS and Windows runs were not done because this pull request changes only the workflow files and no Rust code, so those tests do not cover anything it changes.

A push sends new commits to GitHub. The workspace and security checks
run for a push only when it goes to the main branch. Other branches
are checked through their pull request, so each update to a pull
request is checked once.

Each run belongs to a group: the name GitHub uses to decide which runs
may cancel each other. When a pull request gets another update, any
run that is checking an earlier update of the same pull request is
cancelled, so only the latest update is checked. Runs on main,
scheduled runs and manual runs each get their own group, so they are
never cancelled.

The security check runs for a push to main or a pull request update
only when the change touches a file in its path filters, the file list
that decides whether a check runs. It also runs every Monday and when
started by hand.
The security check uses cargo-audit 0.22.2, a program that compares
our dependencies, the outside libraries this project uses, with a
public list of known security problems.

The program has its own cache: a saved copy kept between runs so the
program is not rebuilt each time. The cache name covers the program
version, the system and processor type, and the exact Rust compiler.

After the Rust compiler and tools are set up, the check restores the
cache and makes sure the program reports version 0.22.2. If the cache
is empty or the program does not match, the check builds cargo-audit
and saves it to the cache.

On every run, cargo-audit downloads the latest list of known security
problems.
@npmccallum
npmccallum merged commit 68ccd76 into main Oct 31, 2026
12 checks passed
@npmccallum
npmccallum deleted the bot/devmap/ci-push-main-audit-cache branch October 31, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: cache the pinned cargo-audit executable in security checks ci: avoid duplicate push/PR runs and cancel superseded PR revisions

1 participant