CI: shard the Linux and Windows tests, lint leg, xtask environment fix, rust-cache v2.9.3

- xtask starts every cargo without the variables `cargo run` sets for xtask
  (CARGO_MANIFEST_DIR, CARGO_PKG_*, ...), so a build script that declares
  `rerun-if-env-changed` for them (ring) no longer reruns, with the whole
  craft facade above it, between builds inside and outside xtask.
- `cargo xtask ci` splits into the gate's parts without a second step list:
  `lint` (fmt, egui-fork, clippy, layers, panel-commands, scorecard, wasm,
  i18n report), `archive` (test build into the nextest archive, doctests),
  `tests --from <dir>` (test and panic_hunt from the extracted archive, on
  $NEXTEST_PARTITION; --gpu / --no-gpu select by the gpu test group) and
  `build` (cache warm-up). Plain `cargo xtask ci` still runs every step.
  PHOTOCRAFT_CI_EXCLUDE leaves packages out of the test build and doctests.
- The `ci` nextest profile's archive carries the xtask binary, so a shard
  builds nothing (scripts/ci-test-shard.sh).
- Linux gate: lint leg, one build, four shards. Shard 1 runs the gpu group
  alone on lavapipe and checks its output (scripts/ci-gpu-lavapipe.py now
  wraps that run); the second GPU run and its rebuild are gone.
- Windows unit, integration, clippy and warm legs move onto the shared gate
  (Windows runner, lint leg for Clippy, four shards), keeping the PR
  selection from the platforms job, rust-lld, /OPT:NOICF, /DEBUG:NONE and
  the D:\t target dir.
- The slowest-tests-first priorities apply on Linux too.
- Swatinem/rust-cache v2.9.3 by commit for this repository's own cache
  steps, with fresh keys; cache-version v2 for the gate and docs entries.
  `test (without heif)` restores the gate's entry through the shared action.
  Dispatch-only jobs no longer save caches no pull request reads; the quick
  perf suite restores perf-nightly's entry.
- windows_delay_loads reads the app from NEXTEST_BIN_EXE_photocraft, as the
  other app tests do, since archives relocate binaries.
This commit is contained in:
aiongg
2026-11-18 19:04:43 +00:00
parent a858d42a50
commit 0e3523cdcd
11 changed files with 646 additions and 322 deletions
+84 -211
View File
@@ -1,8 +1,8 @@
name: CI
# Quality gates for every push to main and every pull request. The Linux gate runs through the
# suite's shared gate workflow in craft-common-actions (`cargo xtask ci`); the Windows legs, the
# test variant and the corpus, web and fuzz jobs are PhotoCraft's own.
# Quality gates for every push to main and every pull request. The Linux and Windows tests run
# through the suite's shared gate workflow in craft-common-actions (`cargo xtask ci`, split over the
# gate's jobs); the test variant and the corpus, web and fuzz jobs are PhotoCraft's own.
on:
push:
branches: [main]
@@ -135,10 +135,22 @@ jobs:
fi
gpu=$(python3 scripts/ci-windows-gpu-tests.py "$BASE")
echo "windows_gpu=$gpu" >> "$GITHUB_OUTPUT"
if [ "$gpu" = false ]; then
echo "::notice::photocraft-gpu's tests are skipped on Windows: this pull request changes nothing they are built from (the Linux gate still runs them)."
fi
skip=$(python3 scripts/ci-windows-gpu-tests.py --skip-neutral "$BASE")
echo "windows_skip=$skip" >> "$GITHUB_OUTPUT"
if [ -n "$skip" ]; then
echo "::notice::Tests of platform-neutral packages the pull request does not reach are skipped on Windows (the Linux gate still runs them): $skip"
fi
# The Linux gate. Its rust-cache entry is the one `test (without heif)` restores.
# The Linux gate (craft-common-actions gate.yml). Its `lint` leg runs the checks that need no test
# build; its build job builds the tests once into a nextest archive and runs the doctests; four
# test shards run the tests from that archive. Shard 1 runs nextest's `gpu` group alone, on
# lavapipe, and fails on a skipped GPU comparison (scripts/ci-gpu-lavapipe.py); shards 2-4 split
# the other tests. With the five slowest UI tests (three of them in the `gpu` group) the GPU shard
# takes ~12 min of tests and the others ~8. Its rust-cache entry is the one `test (without heif)`
# restores.
gate:
if: github.event.action != 'labeled' || github.event.label.name == 'full-ci'
# Tracks @main so suite-wide CI fixes reach every app without a PR in each repository.
@@ -153,199 +165,71 @@ jobs:
craft-fonts-ref: cc9269cd8d8258785dac603fba3122e5d2556795
# Cargo.toml's dev profile already keeps line tables only.
dev-debug: ""
cache-version: v2
env: |
PHOTOCRAFT_FULL_SWEEP=${{ inputs.full_sweep && '1' || '0' }}
PHOTOCRAFT_NO_PRINT=1
LPDEST=photocraft-no-such-printer
timeout-minutes: 100
# On main, a `cache warm` leg builds the tests and saves the dependency cache as soon as the
# build succeeds; the gate legs then only restore, so a failing test cannot keep the entry
# from being saved (craft-common-actions#270). The same targets as the gate's test step (TEST_TARGETS in xtask/src/main.rs).
warm-command: cargo test --workspace --no-run --locked --features heif --lib --bins --tests
# fmt, clippy, layers, panel-commands, scorecard, tests, panic_hunt, doctests and the wasm32 check, with
# `--locked --features heif`, then the missing-translations report (xtask/src/main.rs).
command: python3 scripts/test-ci-gpu-lavapipe.py && python3 scripts/test-ci-windows-gpu-tests.py && cargo xtask ci && python3 scripts/ci-gpu-lavapipe.py
# On main, a `cache warm` leg builds xtask and the tests and saves the dependency cache as
# soon as the build succeeds; the build job then only restores, so a failing test cannot keep
# the entry from being saved (craft-common-actions#270). The lint leg keeps its own entry.
warm-command: cargo xtask ci build
# fmt, egui-fork, clippy, layers, panel-commands, scorecard, the wasm32 check and the
# missing-translations report (`cargo xtask ci lint`, xtask/src/main.rs), and the CI scripts'
# own tests.
lint-command: python3 scripts/test-ci-gpu-lavapipe.py && python3 scripts/test-ci-windows-gpu-tests.py && cargo xtask ci lint
test-shards: 4
# The test build with `--locked --features heif` (TEST_TARGETS in xtask/src/main.rs) into
# $NEXTEST_ARCHIVE_FILE, then the doctests.
archive-command: cargo xtask ci archive
# The tests and panic_hunt, from the archive.
shard-command: bash scripts/ci-test-shard.sh --gpu-shard
# Windows tests run as two legs in parallel: the unit tests and the integration tests. As one job
# they took ~28 min on the Windows runner; the legs take ~13 and ~15. Splitting the integration
# tests over a third runner (nextest --partition) saved ~2 min of wall time but cost ~7
# runner-minutes and one more Windows slot per PR. Moving these legs into the shared gate is
# tracked by storytold/craft-common-actions#212.
# The Windows tests and Clippy on the same gate, when `platforms` says the run needs them: a
# `lint` leg runs Clippy, the build job builds the tests into a nextest archive and runs the
# doctests, and four shards split the tests (Windows runs them ~1.75x slower than Linux, ~50 min
# of tests on one runner). The browser apps are wasm targets, so their native tests are left out;
# pull requests also leave out photocraft-gpu and the platform-neutral packages nothing they change
# reaches (`windows_gpu`, `windows_skip`). The `cache warm` leg (main only) builds what main's
# build job builds.
windows:
needs: platforms
if: needs.platforms.outputs.windows == 'true'
timeout-minutes: 100
name: test (windows-latest, ${{ matrix.part }})
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
# `warm` builds everything the other legs build and saves the dependency cache. Only main
# runs it; the other legs only restore.
part: ${{ fromJSON(github.ref == 'refs/heads/main' && '["unit","integration","clippy","warm"]' || '["unit","integration","clippy"]') }}
env:
# Released sccache expands Cargo's response files and exceeds Windows' rustc spawn limit
# (#13543). Let Cargo handle long commands until a release includes mozilla/sccache#3026.
# The dependency rust-cache below stays enabled; only compiler caching is disabled.
RUSTC_WRAPPER: ""
# Tracks @main so suite-wide CI fixes reach every app without a PR in each repository.
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
with:
os: '["windows-latest"]'
# The all-language UI tests shape real Japanese, Chinese, Korean and Devanagari labels with
# kittest's strict `MissingGlyphPolicy::Panic`, and a hosted Windows image has no guaranteed
# Japanese or Simplified Chinese system font. Same pinned central fonts as Linux and release.
craft-fonts-ref: cc9269cd8d8258785dac603fba3122e5d2556795
# No wasm32 check on Windows: the Linux lint leg runs it.
targets: ""
# No debuginfo on Windows: writing PDBs for ~200 test binaries cost 2.2 of ~21 build minutes.
# A panic still names its file and line; only backtrace frames lose theirs (Linux keeps
# line-tables-only, so a backtrace with lines is one OS away).
CARGO_PROFILE_DEV_DEBUG: "0"
# The Windows compiler command line carries one -L path per built dependency; keep each
# target path short enough for CreateProcess when the graph is large.
CARGO_TARGET_DIR: 'D:\t'
# rust-lld (shipped with the toolchain) links the test binaries instead of link.exe, and the
# test links skip identical-code folding and PDBs. The link arguments in build.rs
# (/DELAYLOAD, delayimp.lib) are lld-link options too.
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: rust-lld
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS: -Clink-arg=/OPT:NOICF -Clink-arg=/DEBUG:NONE
# The all-language UI tests shape real Japanese, Chinese, Korean and Devanagari labels
# with kittest's strict `MissingGlyphPolicy::Panic`. A hosted Windows image has no
# guaranteed Japanese or Simplified Chinese system font, and egui 0.37 panics on a
# missing glyph; the app's lazy system fallback runs after layout, too late for the
# first headless frame. Use the same pinned central fonts as Linux and release, so every
# language is drawn by a real embedded face rather than skipping. Same commit as the gate
# above and release.yml.
CRAFT_FONTS_DIR: ${{ github.workspace }}/craft-fonts
CRAFT_FONTS_REQUIRED: "1"
steps:
- name: Harden runner
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check out craft-fonts
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: storytold/craft-fonts
ref: cc9269cd8d8258785dac603fba3122e5d2556795
path: craft-fonts
persist-credentials: false
# The translations at the commit in craft-i18n.rev, as the gate and release.yml embed them
# (sets CRAFT_I18N_DIR and CRAFT_I18N_REQUIRED=1).
- name: Check out craft-i18n
uses: storytold/craft-common-actions/actions/checkout-craft-i18n@main
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
components: clippy
# rust-cache only looks at `<workspace>/<target>` (it joins the two), so the short
# CARGO_TARGET_DIR above must be passed as a path relative to the checkout. Without it the
# cache found nothing to restore or save and every run built all dependencies from scratch.
- name: Target directory for the dependency cache
id: cache-target
# An empty path would make rust-cache treat the checkout itself as the target directory,
# which its cleanup then prunes, so stop rather than write one.
run: |
relative=$(realpath -m --relative-to="$(cygpath -u "$GITHUB_WORKSPACE")" "$(cygpath -u "$CARGO_TARGET_DIR")")
if [ -z "$relative" ] || [ "$relative" = . ]; then
echo "::error::no target directory for rust-cache from CARGO_TARGET_DIR='$CARGO_TARGET_DIR'"
exit 1
fi
echo "relative=$relative" >> "$GITHUB_OUTPUT"
shell: bash
# Only main saves caches; PRs restore main's, so the repo's 10 GB cache budget keeps main's.
# All legs share one key (same dependencies). Only the `warm` leg saves it, as soon as the
# build is done and before any test runs, so a failing test never keeps the entry from being
# saved. It also runs Clippy, so the entry holds Clippy's dependency metadata for the `clippy`
# leg. A failed warm run saves nothing: an entry saved from a half-finished build would lack
# dependencies, and rust-cache never replaces an entry with the same key, so every later run
# would restore that half-filled entry until Cargo.lock changes.
# v2.9.1 on purpose: v2.9.2 is an ES-module bundle in which minimatch's `require('path')` fails,
# so it assumes "/" as the path separator and, on Windows, its glob never matches a backslash
# path. The save step then finds no cache paths ("Path Validation Error") and never saves.
# v2.9.1 is the last release with the CommonJS bundle. Move back once a release fixes this.
- uses: step-security/rust-cache@851174d9a2fdc03e0896e02844dcc61d81dd7851 # v2.9.1
with:
workspaces: . -> ${{ steps.cache-target.outputs.relative }}
save-if: ${{ github.ref == 'refs/heads/main' && matrix.part == 'warm' }}
cache-on-failure: false
# Clippy has its own parallel leg: after the test build it ran in the integration leg's
# critical path (#15446).
- name: Clippy
if: matrix.part == 'clippy'
run: cargo clippy --workspace --all-targets --locked --features heif -- -D warnings
- uses: step-security/taiki-e-install-action@76747d22a7567cc4438546a84f11bdf18e670ab8 # v2.87.32
if: matrix.part != 'clippy' && matrix.part != 'warm'
with:
tool: cargo-nextest@0.9.150
# The unit leg runs `--lib --bins` and the integration leg `--test '*'` (every
# integration-test target); the feature selection stays the same, so both legs share the
# dependency cache. photocraft-gpu's tests run when the `platforms` job says they can be
# affected (`windows_gpu`); excluding the package also skips building its test binaries.
- name: Test
if: matrix.part != 'clippy'
env:
PART: ${{ matrix.part }}
GPU: ${{ needs.platforms.outputs.windows_gpu }}
SKIP_NEUTRAL: ${{ needs.platforms.outputs.windows_skip }}
run: |
case "$PART" in
unit) targets=(--lib --bins) ;;
warm) targets=(--lib --bins --test '*') ;;
*) targets=(--test '*') ;;
esac
# The two browser apps are wasm targets; their native test builds check nothing the web job
# (and the Linux gate's wasm32 check) does not. Excluding them changes no other crate's
# features (`cargo tree -e features --workspace` is identical for every other package).
skip=(--exclude photocraft-web --exclude photocraft-web-boot)
# Only an explicit `false` skips them: a missing output runs everything.
if [ "$GPU" = false ]; then
skip+=(--exclude photocraft-gpu)
echo "::notice::photocraft-gpu's tests are skipped on Windows: this pull request changes nothing they are built from (the Linux gate still runs them)."
fi
# nextest reuses this build. The separate step writes cargo's --timings report for it.
# Pull requests without `full-ci` also skip the packages with no platform-specific code
# that nothing in the pull request reaches (scripts/ci-windows-gpu-tests.py); the Linux
# gate runs them. Main and `full-ci` run everything.
if [ -n "$SKIP_NEUTRAL" ]; then
for package in $SKIP_NEUTRAL; do skip+=(--exclude "$package"); done
echo "::notice::Tests of platform-neutral packages the pull request does not reach are skipped on Windows (the Linux gate still runs them): $SKIP_NEUTRAL"
fi
cargo test --no-run --timings --workspace "${skip[@]}" --locked --features heif "${targets[@]}"
if [ "$PART" != warm ]; then
cargo nextest run --profile ci --workspace "${skip[@]}" --locked --features heif "${targets[@]}"
fi
shell: bash
# Fills the cache entry's Clippy metadata (the `clippy` leg only restores it). A Clippy
# failure is the `clippy` leg's to report, not a reason to skip saving the cache.
- name: Clippy dependency metadata
if: matrix.part == 'warm'
continue-on-error: true
run: cargo clippy --workspace --all-targets --locked --features heif -- -D warnings
# Per-crate compile and link times of this leg's build (open the HTML in a browser).
- name: Upload cargo build timings
if: always() && matrix.part != 'clippy'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: cargo-timings-windows-${{ matrix.part }}
# CARGO_TARGET_DIR above; the glob needs forward slashes.
path: D:/t/cargo-timings/*.html
if-no-files-found: ignore
retention-days: 14
- name: Doctests
if: matrix.part == 'unit'
env:
SKIP_NEUTRAL: ${{ needs.platforms.outputs.windows_skip }}
run: |
skip=(--exclude photocraft-web --exclude photocraft-web-boot)
for package in $SKIP_NEUTRAL; do skip+=(--exclude "$package"); done
cargo test --workspace "${skip[@]}" --locked --features heif --doc
shell: bash
dev-debug: "0"
cache-version: v2
# CARGO_TARGET_DIR: the Windows compiler command line carries one -L path per built
# dependency; a short target path keeps it within CreateProcess's limit. rust-lld (shipped
# with the toolchain) links the test binaries instead of link.exe, and the test links skip
# identical-code folding and PDBs; the link arguments in build.rs (/DELAYLOAD, delayimp.lib)
# are lld-link options too.
env: |
PHOTOCRAFT_FULL_SWEEP=${{ inputs.full_sweep && '1' || '0' }}
PHOTOCRAFT_NO_PRINT=1
LPDEST=photocraft-no-such-printer
CARGO_TARGET_DIR=D:\t
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER=rust-lld
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS=-Clink-arg=/OPT:NOICF -Clink-arg=/DEBUG:NONE
PHOTOCRAFT_CI_EXCLUDE=photocraft-web photocraft-web-boot ${{ needs.platforms.outputs.windows_gpu == 'false' && 'photocraft-gpu' || '' }} ${{ needs.platforms.outputs.windows_skip }}
timeout-minutes: 100
warm-command: cargo xtask ci build
lint-command: cargo xtask ci clippy
test-shards: 4
archive-command: cargo xtask ci archive
shard-command: bash scripts/ci-test-shard.sh
# The same codecs without the optional decoder: HEIC must stay a clear "not in this build" error
# for distributors who leave it out. Runs beside the gate and restores the gate's dependency
@@ -386,12 +270,14 @@ jobs:
with:
toolchain: stable
# gate.yml keys its cache `<cache-version>-rust-<hash of Cargo.toml>-gate`.
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
# The gate's own key (the shared action computes it), restore only. The toolchain action
# exports CARGO_HOME, which the gate's legs do not have; align-environment leaves it out of
# the key.
- uses: storytold/craft-common-actions/actions/rust-cache@main
with:
prefix-key: v1-rust
shared-key: ${{ hashFiles('Cargo.toml') }}-gate
save-if: false
cache-version: v2
job: gate
align-environment: "true"
- uses: step-security/taiki-e-install-action@76747d22a7567cc4438546a84f11bdf18e670ab8 # v2.87.32
with:
@@ -427,8 +313,9 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
prefix-key: v1-rust
key: corpus
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-on-failure: true
@@ -470,8 +357,9 @@ jobs:
with:
toolchain: stable
targets: wasm32-unknown-unknown
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
prefix-key: v1-rust
key: ci-web
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-on-failure: true
@@ -546,9 +434,6 @@ jobs:
with:
toolchain: nightly
- run: rustc -Vv
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
with:
workspaces: crates/${{ matrix.target.crate }}/fuzz
- name: Install cargo-fuzz
run: cargo install cargo-fuzz --locked
- name: Fuzz
@@ -586,9 +471,6 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
with:
key: color-range-perf
- name: Compare exact outputs and release timings on 24 MP
run: |
set -o pipefail
@@ -622,9 +504,6 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
with:
key: selection-morphology-perf
- name: Compare exact outputs and release timings on 36 MP
run: |
set -o pipefail
@@ -657,9 +536,12 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
# perf-nightly.yml's entry (same key and runner); only that job saves it.
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
prefix-key: v1-rust
key: perf-release
save-if: false
- name: Quick performance suite
run: cargo xtask perf --quick
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
@@ -687,9 +569,6 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
with:
key: selection-combining-perf
- name: Compare exact outputs and release timings on 36 MP
run: |
set -o pipefail
@@ -723,12 +602,6 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
with:
workspaces: |
before -> target
after -> target
key: brush-tip-release
- name: Build the same benchmark against both versions
run: |
cp after/crates/paint/examples/big_dab_bench.rs before/crates/paint/examples/big_dab_bench.rs
+1 -1
View File
@@ -38,5 +38,5 @@ jobs:
free-disk-space: false
# Prebuilt mdBook, the version cargo install built before.
tools: mdbook@0.4.52
cache-version: v1-docs
cache-version: v2-docs
command: mdbook build book
+2 -1
View File
@@ -55,8 +55,9 @@ jobs:
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
prefix-key: v1-rust
key: perf-release
- name: Run benchmarks