Files
photocraft/.github/workflows/perf-nightly.yml
Dylan M. Taylor 5de01767dd ci: lock workflow actions through an actions.lock lockfile
Mutable action tags are a supply-chain risk: a moved tag runs different code
without a diff. Every workflow action is now pinned through
.github/workflows/actions.lock, and CI verifies the lockfile so an out-of-sync
or tampered one fails instead of running.
2026-11-12 07:18:11 -05:00

102 lines
3.3 KiB
YAML

name: Perf (nightly)
# The performance scorecard (#221): `cargo xtask perf` on a fixed macOS runner (Apple silicon,
# Metal), every night and on demand. It never runs on pull requests, so it can't block one.
# It fails when an enforced budget in perf/budgets.toml breaks or a scenario's p50 regresses
# more than 15 % against perf/baseline.json from the same machine class (other classes are
# never compared; a baseline built from several runs is judged against its highest p50). The
# table goes to the job summary; results.json is uploaded as the `perf-results` artifact.
#
# To give this runner class its own baseline: download the `perf-results` artifact of the last
# five or more nightly runs (`gh run download <run id> -n perf-results -D runs/<run id>`), run
# `cargo xtask perf --update-baseline --from runs/<id>/results.json ... --allow-contended` (this
# runner is never idle) and commit perf/baseline.json and docs/scorecard.md in a PR.
on:
schedule:
- cron: "23 3 * * *"
workflow_dispatch:
inputs:
quick:
description: "Quick subset (small documents, no budgets)"
type: boolean
default: false
update_baseline:
description: "Also write perf/baseline.json from this run (uploaded as an artifact, not committed)"
type: boolean
default: false
permissions:
contents: read
concurrency:
group: perf-nightly
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
jobs:
perf:
name: perf (macOS, Apple GPU)
# Pinned image, not -latest: the machine class must stay fixed for comparisons.
runs-on: macos-15
timeout-minutes: 120
steps:
- name: Harden runner
uses: step-security/[email protected]
with:
egress-policy: audit
- uses: actions/[email protected]
with:
persist-credentials: false
- uses: step-security/[email protected]
with:
toolchain: stable
- uses: step-security/[email protected]
with:
key: perf-release
- name: Run benchmarks
id: perf
env:
QUICK: ${{ inputs.quick }}
UPDATE: ${{ inputs.update_baseline }}
run: |
args=()
if [ "$QUICK" = "true" ]; then args+=(--quick); fi
# This runner is never idle: a baseline from it is recorded labelled as contended.
if [ "$UPDATE" = "true" ]; then args+=(--update-baseline --allow-contended); fi
cargo xtask perf "${args[@]}"
- name: Job summary
if: always()
run: |
if [ -f target/perf/summary.md ]; then
cat target/perf/summary.md >> "$GITHUB_STEP_SUMMARY"
else
echo "No perf summary: the run failed before writing one (see the log)." >> "$GITHUB_STEP_SUMMARY"
fi
- name: Upload results
if: always()
uses: actions/[email protected]
with:
name: perf-results
path: |
target/perf/*.json
target/perf/summary.md
if-no-files-found: warn
retention-days: 30
- name: Upload baseline
if: always() && inputs.update_baseline
uses: actions/[email protected]
with:
name: perf-baseline
path: perf/baseline.json
if-no-files-found: warn
retention-days: 30