mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-27 04:37:14 +00:00
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:
+11
-6
@@ -11,7 +11,8 @@ nextest-version = "0.9.150"
|
||||
#
|
||||
# GPU tests: each test is its own process here, so the in-process `gpu_lock()` mutexes no longer
|
||||
# serialize them. Too many concurrent wgpu devices time out (`PollError: ... Wait timed out`), so
|
||||
# this group caps them at 4. scripts/ci-gpu-lavapipe.py reads this group's filters directly.
|
||||
# this group caps them at 4. `cargo xtask ci tests --gpu` reads this group's filters directly: the
|
||||
# Linux gate runs the group in a shard of its own on lavapipe (scripts/ci-gpu-lavapipe.py).
|
||||
[test-groups]
|
||||
gpu = { max-threads = 4 }
|
||||
|
||||
@@ -26,6 +27,12 @@ test-group = 'gpu'
|
||||
fail-fast = false
|
||||
slow-timeout = { period = "60s", terminate-after = 10 }
|
||||
failure-output = "immediate-final"
|
||||
# The gate's shards run the tests from a nextest archive (`cargo xtask ci archive`) and start them
|
||||
# with the xtask binary the archive carries, so a shard builds nothing. Only one of the two exists.
|
||||
archive.include = [
|
||||
{ path = "debug/xtask", relative-to = "target", depth = 0, on-missing = "ignore" },
|
||||
{ path = "debug/xtask.exe", relative-to = "target", depth = 0, on-missing = "ignore" },
|
||||
]
|
||||
|
||||
# Keep phase timings for the remaining expensive Windows GPU regressions visible. This does
|
||||
# not relax their timeout, isolate failures differently or remove any test cases.
|
||||
@@ -48,11 +55,10 @@ threads-required = 2
|
||||
|
||||
# Slowest tests start first. nextest starts higher-priority tests first, so a long test no longer
|
||||
# begins at the end of the run and extends the job. Every test that took over 60 s on the Windows
|
||||
# runner in the cold run of #15474 (unit and integration legs); the list names the test, so a test
|
||||
# that gets faster stays harmless and a new slow one is added here. Priority only orders the
|
||||
# start; it changes no timeout, group or result.
|
||||
# runner in the cold run of #15474 (unit and integration legs); the same tests are the slowest on
|
||||
# Linux. The list names the test, so a test that gets faster stays harmless and a new slow one is
|
||||
# added here. Priority only orders the start; it changes no timeout, group or result.
|
||||
[[profile.ci.overrides]]
|
||||
platform = 'cfg(target_os = "windows")'
|
||||
# over 200 s
|
||||
filter = '''
|
||||
(package(photocraft-ui-egui) & test(=input::shortcut_dispatch::tests::every_displayed_shortcut_dispatches_from_where_focus_usually_is)) |
|
||||
@@ -64,7 +70,6 @@ filter = '''
|
||||
priority = 100
|
||||
|
||||
[[profile.ci.overrides]]
|
||||
platform = 'cfg(target_os = "windows")'
|
||||
# 60 to 200 s
|
||||
filter = '''
|
||||
(package(photocraft-gpu) & test(=camera_raw::clarity_texture_and_dehaze_with_shadows_highlights_and_per_pixel_stages)) |
|
||||
|
||||
+84
-211
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -10,7 +10,8 @@ const PRINT_ONLY: [&str; 2] = ["windows.data.pdf.dll", "prntvpt.dll"];
|
||||
/// The built exe names each print-only DLL in its delay-load table, never its import table.
|
||||
#[test]
|
||||
fn print_only_system_dlls_are_delay_loaded() {
|
||||
let exe = std::fs::read(env!("CARGO_BIN_EXE_photocraft")).unwrap();
|
||||
// Nextest archives relocate binaries; plain Cargo keeps the compile-time path valid.
|
||||
let exe = std::fs::read(std::env::var_os("NEXTEST_BIN_EXE_photocraft").unwrap_or_else(|| env!("CARGO_BIN_EXE_photocraft").into())).unwrap();
|
||||
let pe = Pe::parse(&exe);
|
||||
let imports = pe.dll_names(1, 20, 12);
|
||||
let delayed = pe.dll_names(13, 32, 4);
|
||||
|
||||
+2
-1
@@ -45,6 +45,7 @@ cargo run --release -p photocraft -- --control 7878 --control-token-file .privat
|
||||
cargo test --workspace # everything
|
||||
cargo xtask test # tests (nextest when installed) + doctests
|
||||
cargo xtask ci # the CI gate: fmt, clippy, layers, scorecard, tests, panic_hunt, doctests, wasm, i18n report
|
||||
cargo xtask ci lint # only the gate's steps that need no test build (its lint leg)
|
||||
cargo xtask stats # tests and lines per crate
|
||||
cargo xtask parity # Photoshop menu coverage -> docs/parity-checklist.md
|
||||
```
|
||||
@@ -113,7 +114,7 @@ the opted-in test; an unset variable leaves the ordinary behavior tests availabl
|
||||
After review, remove only the two generated PNGs and their owned temporary directory. The same
|
||||
Rust test and variable work on Windows with the native shell's environment-variable syntax.
|
||||
|
||||
**GPU tests without a GPU.** Linux CI uses the shared `craft-common-actions` gate with Mesa's Vulkan driver installed. After the regular gate, `python3 scripts/ci-gpu-lavapipe.py` reruns the configured `gpu` group with `WGPU_BACKEND=vulkan` and the lavapipe ICD explicitly selected. It requires Vulkan parity evidence and rejects authored skips, except the documented software-adapter timing exceptions. It reads the filter from `.config/nextest.toml`, so no second filter needs maintaining. To run locally on Linux, install `mesa-vulkan-drivers libvulkan1` and run the same script. Windows uses WARP; this check does not certify Windows skip coverage.
|
||||
**GPU tests without a GPU.** Linux CI uses the shared `craft-common-actions` gate with Mesa's Vulkan driver installed. The gate builds the tests once into a nextest archive (`cargo xtask ci archive`) and runs them in shards from it (`cargo xtask ci tests`). One shard runs the configured `gpu` group alone, through `python3 scripts/ci-gpu-lavapipe.py`, with `WGPU_BACKEND=vulkan` and the lavapipe ICD explicitly selected; the other shards split the remaining tests. The script requires Vulkan parity evidence in that shard's output and rejects authored skips, except the documented software-adapter timing exceptions. xtask reads the group's filter from `.config/nextest.toml`, so no second filter needs maintaining. To run locally on Linux, install `mesa-vulkan-drivers libvulkan1`, build an archive and run `python3 scripts/ci-gpu-lavapipe.py <extracted>/target/debug/xtask ci tests --from <extracted> --gpu` as the gate's shard command in `.github/workflows/ci.yml` does. Windows uses WARP; this check does not certify Windows skip coverage.
|
||||
|
||||
## Fonts (craft-fonts)
|
||||
|
||||
|
||||
+26
-25
@@ -1,21 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run the configured GPU group on lavapipe without silently losing comparisons."""
|
||||
"""Run a command with wgpu on lavapipe, and fail if a GPU comparison in its output was skipped.
|
||||
|
||||
The Linux gate runs nextest's `gpu` test group in a shard of its own through this script
|
||||
(`ci-gpu-lavapipe.py <xtask> ci tests --from <dir> --gpu`, .github/workflows/ci.yml): every wgpu
|
||||
device in the run is Vulkan on Mesa's CPU rasterizer, each test's output is shown, and the output
|
||||
is checked here for authored skips and for the parity tests' Vulkan backend line.
|
||||
|
||||
Usage: ci-gpu-lavapipe.py COMMAND [ARGS...]
|
||||
"""
|
||||
import glob
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import tomllib
|
||||
|
||||
|
||||
def gpu_filter(config):
|
||||
filters = [row['filter'] for row in config['profile']['default']['overrides']
|
||||
if row.get('test-group') == 'gpu']
|
||||
if not filters:
|
||||
raise ValueError('nextest GPU group has no filters')
|
||||
return ' | '.join(f'({value})' for value in filters)
|
||||
|
||||
|
||||
def validate_log(lines):
|
||||
@@ -37,23 +35,16 @@ def validate_log(lines):
|
||||
return rejected
|
||||
|
||||
|
||||
def main():
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
with (root / '.config/nextest.toml').open('rb') as source:
|
||||
selected = gpu_filter(tomllib.load(source))
|
||||
icds = sorted(glob.glob('/usr/share/vulkan/icd.d/lvp_icd*.json'))
|
||||
if not icds:
|
||||
raise RuntimeError('Install mesa-vulkan-drivers and libvulkan1 before this check')
|
||||
def run(command, icds, out=sys.stdout):
|
||||
"""Runs `command` on the Vulkan drivers in `icds`; returns its exit status, or 1 when it passed
|
||||
but its output shows a skipped comparison."""
|
||||
env = dict(os.environ, WGPU_BACKEND='vulkan', VK_ICD_FILENAMES=os.pathsep.join(icds))
|
||||
command = ['cargo', 'nextest', 'run', '--profile', 'ci', '--workspace', '--locked',
|
||||
'--features', 'heif', '--lib', '--bins', '--tests', '-E', selected,
|
||||
'--success-output', 'immediate', '--color', 'never']
|
||||
# Stream output and keep it on disk, rather than buffering every successful test in memory.
|
||||
with tempfile.TemporaryFile(mode='w+t') as log:
|
||||
with subprocess.Popen(command, cwd=root, env=env, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT, text=True) as process:
|
||||
with subprocess.Popen(command, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
text=True) as process:
|
||||
for line in process.stdout:
|
||||
sys.stdout.write(line)
|
||||
out.write(line)
|
||||
log.write(line)
|
||||
result = process.wait()
|
||||
log.seek(0)
|
||||
@@ -63,5 +54,15 @@ def main():
|
||||
return result if result else int(bool(errors))
|
||||
|
||||
|
||||
def main(argv):
|
||||
if not argv:
|
||||
print(__doc__, file=sys.stderr)
|
||||
return 2
|
||||
icds = sorted(glob.glob('/usr/share/vulkan/icd.d/lvp_icd*.json'))
|
||||
if not icds:
|
||||
raise RuntimeError('Install mesa-vulkan-drivers and libvulkan1 before this check')
|
||||
return run(argv, icds)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
# One shard of the gate's tests: the gate's `shard-command` (.github/workflows/ci.yml). The gate's
|
||||
# build job wrote a nextest archive of the tests with `cargo xtask ci archive`, and the archive
|
||||
# carries that xtask binary (.config/nextest.toml), so the shard extracts it and runs the test steps
|
||||
# with `xtask ci tests` without building anything. The gate sets NEXTEST_ARCHIVE_FILE, GATE_SHARD,
|
||||
# GATE_SHARDS and NEXTEST_PARTITION.
|
||||
#
|
||||
# ci-test-shard.sh the shard runs its hash partition of every test
|
||||
# ci-test-shard.sh --gpu-shard shard 1 runs nextest's `gpu` group alone on lavapipe, checked by
|
||||
# scripts/ci-gpu-lavapipe.py; the other shards split the other tests
|
||||
set -euo pipefail
|
||||
|
||||
archive=target/nextest-archive
|
||||
mkdir -p "$archive"
|
||||
cargo nextest run --archive-file "$NEXTEST_ARCHIVE_FILE" --workspace-remap . --extract-to "$archive" --extract-overwrite -E 'none()' --no-tests=pass
|
||||
xtask=("$archive/target/debug/xtask" ci tests --from "$archive")
|
||||
|
||||
case "${1:-}" in
|
||||
"") exec "${xtask[@]}" ;;
|
||||
--gpu-shard)
|
||||
if [ "$GATE_SHARDS" -lt 2 ]; then
|
||||
echo "::error::--gpu-shard needs at least two shards, got $GATE_SHARDS"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$GATE_SHARD" = 1 ]; then
|
||||
exec python3 scripts/ci-gpu-lavapipe.py "${xtask[@]}" --gpu
|
||||
fi
|
||||
NEXTEST_PARTITION="hash:$((GATE_SHARD - 1))/$((GATE_SHARDS - 1))" exec "${xtask[@]}" --no-gpu
|
||||
;;
|
||||
*)
|
||||
echo "usage: $0 [--gpu-shard]" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
@@ -1,5 +1,7 @@
|
||||
import importlib.util
|
||||
import io
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
spec = importlib.util.spec_from_file_location('gpu_check', Path(__file__).with_name('ci-gpu-lavapipe.py'))
|
||||
@@ -29,15 +31,29 @@ class LogChecks(unittest.TestCase):
|
||||
'SKIP the comparison: this GPU finishes a 6 MP composite in 1 ms against 2 ms of encoding',
|
||||
'SKIP the sum: this refresh still fit one command buffer']))
|
||||
|
||||
def test_selects_all_gpu_filters_from_config(self):
|
||||
config = {'profile': {'default': {'overrides': [
|
||||
{'filter': 'package(a)', 'test-group': 'gpu'},
|
||||
{'filter': 'package(b)', 'test-group': 'cpu'},
|
||||
{'filter': 'test(c)', 'test-group': 'gpu'}]}}}
|
||||
self.assertEqual(check.gpu_filter(config), '(package(a)) | (test(c))')
|
||||
config['profile']['default']['overrides'] = []
|
||||
with self.assertRaises(ValueError):
|
||||
check.gpu_filter(config)
|
||||
|
||||
class Wrapper(unittest.TestCase):
|
||||
"""The gate's GPU shard runs xtask through `run`: its output is shown and checked."""
|
||||
|
||||
def status(self, script, icds=('/icd/lvp_icd.x86_64.json',)):
|
||||
out = io.StringIO()
|
||||
return check.run([sys.executable, '-c', script], list(icds), out), out.getvalue()
|
||||
|
||||
def test_runs_on_the_given_vulkan_driver_and_shows_the_output(self):
|
||||
status, out = self.status(
|
||||
"import os; print('GPU parity backend: Vulkan', os.environ['WGPU_BACKEND'], os.environ['VK_ICD_FILENAMES'])")
|
||||
self.assertEqual(status, 0)
|
||||
self.assertIn('GPU parity backend: Vulkan vulkan /icd/lvp_icd.x86_64.json', out)
|
||||
|
||||
def test_a_passing_run_with_a_skip_fails(self):
|
||||
status, _ = self.status("print('GPU parity backend: Vulkan'); print('skipping GPU parity tests: no device')")
|
||||
self.assertEqual(status, 1)
|
||||
status, _ = self.status("print('no parity test ran')")
|
||||
self.assertEqual(status, 1)
|
||||
|
||||
def test_a_failing_run_keeps_its_status(self):
|
||||
status, _ = self.status("print('GPU parity backend: Vulkan'); raise SystemExit(100)")
|
||||
self.assertEqual(status, 100)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
//! The environment of the cargo processes xtask starts.
|
||||
//!
|
||||
//! `cargo xtask` is `cargo run -p xtask`, so xtask runs with the variables Cargo sets for the
|
||||
//! binary it runs: `CARGO_MANIFEST_DIR`, `CARGO_PKG_NAME`, `CARGO_PKG_VERSION_*` and the rest, all
|
||||
//! describing xtask. A cargo started from xtask passes them on to every build script it runs. Cargo
|
||||
//! compares a build script's `rerun-if-env-changed` variables with its own environment, so a script
|
||||
//! that declares one of them (ring declares `CARGO_PKG_NAME` and the version parts) reruns, and
|
||||
//! everything that depends on it rebuilds, each time one build starts inside xtask and the next
|
||||
//! outside it (a CI script, the cache warm-up, a developer's own `cargo test`).
|
||||
|
||||
use std::ffi::OsStr;
|
||||
use std::process::Command;
|
||||
|
||||
/// Whether `name` is a variable Cargo sets for the binary `cargo run` starts (rather than one it
|
||||
/// reads from the environment of whoever started it). `CARGO` stays: it names the cargo that ran
|
||||
/// xtask, which is the one xtask starts.
|
||||
pub fn set_by_cargo_run(name: &OsStr) -> bool {
|
||||
let Some(name) = name.to_str() else { return false };
|
||||
matches!(name, "CARGO_MANIFEST_DIR" | "CARGO_MANIFEST_PATH" | "CARGO_CRATE_NAME" | "CARGO_BIN_NAME" | "CARGO_PRIMARY_PACKAGE" | "OUT_DIR")
|
||||
|| name.starts_with("CARGO_PKG_")
|
||||
|| name.starts_with("CARGO_BIN_EXE_")
|
||||
}
|
||||
|
||||
/// Removes from `cmd` every variable of the current environment that Cargo set for this binary,
|
||||
/// so the cargo it starts sees the environment xtask itself was started with.
|
||||
pub fn without_cargo_run_vars(cmd: &mut Command) -> &mut Command {
|
||||
for (name, _) in std::env::vars_os() {
|
||||
if set_by_cargo_run(&name) {
|
||||
cmd.env_remove(name);
|
||||
}
|
||||
}
|
||||
cmd
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn removes_only_the_variables_cargo_run_sets() {
|
||||
for name in [
|
||||
"CARGO_MANIFEST_DIR",
|
||||
"CARGO_MANIFEST_PATH",
|
||||
"CARGO_PKG_NAME",
|
||||
"CARGO_PKG_VERSION_PRE",
|
||||
"CARGO_CRATE_NAME",
|
||||
"CARGO_BIN_NAME",
|
||||
"CARGO_PRIMARY_PACKAGE",
|
||||
"CARGO_BIN_EXE_photocraft",
|
||||
"OUT_DIR",
|
||||
] {
|
||||
assert!(set_by_cargo_run(OsStr::new(name)), "{name}");
|
||||
}
|
||||
// What the developer or CI set: build settings, the target dir, the cargo to run.
|
||||
for name in ["CARGO", "CARGO_HOME", "CARGO_TARGET_DIR", "CARGO_INCREMENTAL", "CARGO_PROFILE_DEV_DEBUG", "RUSTFLAGS", "PATH", "PKG_CONFIG_PATH"] {
|
||||
assert!(!set_by_cargo_run(OsStr::new(name)), "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
// A test process runs with the variables Cargo sets for test binaries, CARGO_PKG_NAME among them.
|
||||
#[test]
|
||||
fn a_child_cargo_does_not_inherit_them() {
|
||||
assert!(std::env::var_os("CARGO_PKG_NAME").is_some(), "cargo sets CARGO_PKG_NAME for tests");
|
||||
let mut cmd = Command::new("true");
|
||||
without_cargo_run_vars(&mut cmd);
|
||||
let removed: Vec<_> = cmd.get_envs().filter(|(_, value)| value.is_none()).map(|(name, _)| name.to_owned()).collect();
|
||||
assert!(removed.iter().any(|name| name == "CARGO_PKG_NAME"), "{removed:?}");
|
||||
assert!(removed.iter().all(|name| set_by_cargo_run(name)), "{removed:?}");
|
||||
}
|
||||
}
|
||||
+389
-67
@@ -3,6 +3,7 @@
|
||||
//! Pure Rust (std + serde_json). External tools (`cargo`, `curl`, `tar`) are
|
||||
//! invoked through `std::process::Command`.
|
||||
|
||||
mod cargo_env;
|
||||
mod corpus;
|
||||
mod corpus_pins;
|
||||
mod i18n_report;
|
||||
@@ -31,9 +32,16 @@ commands:
|
||||
wasm cargo check --target wasm32-unknown-unknown for the wasm-safe crates (one call, plus
|
||||
one per optional web feature)
|
||||
test workspace tests (cargo nextest when installed, else cargo test), then doctests
|
||||
ci the CI gate: fmt --check, egui-fork, clippy -D warnings, layers, panel-commands, scorecard --check, tests
|
||||
(nextest --profile ci), panic_hunt, doctests and wasm, with --locked --features heif
|
||||
(stops at first failure), then the i18n-report
|
||||
ci [lint | archive | build | tests --from <dir> [--gpu | --no-gpu] | <step>]
|
||||
the CI gate: fmt --check, egui-fork, clippy -D warnings, layers, panel-commands, scorecard --check,
|
||||
tests (nextest --profile ci), panic_hunt, doctests, wasm and the i18n-report, with --locked
|
||||
--features heif (stops at first failure). The gate splits it over its jobs: `lint` runs the
|
||||
steps that need no test build; `archive` builds the tests into the nextest archive at
|
||||
$NEXTEST_ARCHIVE_FILE and runs the doctests; `tests --from <dir>` runs the tests from that
|
||||
archive extracted to <dir>, on the partition in $NEXTEST_PARTITION (`--gpu`: only nextest's
|
||||
gpu test group, each test's output shown; `--no-gpu`: every other test); `build` only builds
|
||||
the tests (the cache warm-up). $PHOTOCRAFT_CI_EXCLUDE (packages separated by spaces) leaves
|
||||
packages out of the test build and the doctests
|
||||
corpus [--all | --pngsuite | --psd | --psd-tools | --pixls | --atn | --photoshop | --gimp] [--local] [--update-manifest]
|
||||
show where test corpora live and their pins (xtask/src/corpus_pins.rs), or fetch
|
||||
them into corpus/ (pinned commits, sha256-verified; --all = every corpus but pixls,
|
||||
@@ -70,7 +78,7 @@ fn main() -> ExitCode {
|
||||
Some("panel-commands") => panel_commands::run(&root()),
|
||||
Some("wasm") => cmd_wasm(),
|
||||
Some("test") => cmd_test().and_then(|()| cmd_doctest()),
|
||||
Some("ci") => cmd_ci(),
|
||||
Some("ci") => ci_from_args(&rest, ci_exclude()).and_then(|(plan, options)| cmd_ci(&plan, &options)),
|
||||
Some("corpus") => corpus::cmd(&rest),
|
||||
Some("test-corpus") => corpus::test_cmd(&rest),
|
||||
Some("stats") => stats::run(&root(), rest.contains(&"--exact")),
|
||||
@@ -101,9 +109,11 @@ pub fn root() -> PathBuf {
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).parent().expect("xtask has a parent dir").to_path_buf()
|
||||
}
|
||||
|
||||
/// A cargo command in the workspace root, without the variables `cargo run` set for xtask.
|
||||
pub fn cargo() -> Command {
|
||||
let mut c = Command::new(std::env::var("CARGO").unwrap_or_else(|_| "cargo".into()));
|
||||
c.current_dir(root());
|
||||
cargo_env::without_cargo_run_vars(&mut c);
|
||||
c
|
||||
}
|
||||
|
||||
@@ -241,25 +251,223 @@ fn cmd_test() -> Result<(), String> {
|
||||
/// official builds open HEIC photos with.
|
||||
const GATE_ARGS: [&str; 4] = ["--workspace", "--locked", "--features", "heif"];
|
||||
|
||||
/// The gate's tests. nextest's `ci` profile stops at the first failure and terminates hung tests
|
||||
/// (.config/nextest.toml). `panic_hunt` runs only the engine's `#[ignore]`d panic hunt (AGENTS.md
|
||||
/// Rule 9) with the same packages, features and targets as the tests, so nothing rebuilds.
|
||||
fn cmd_gate_tests(panic_hunt: bool) -> Result<(), String> {
|
||||
/// Where a `ci` step runs when the gate splits the work over its jobs. `cargo xtask ci` alone runs
|
||||
/// every step, in the order of [`CI_STEPS`].
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
enum Part {
|
||||
/// Checks that need no test build: the gate's lint leg.
|
||||
Lint,
|
||||
/// Steps that need the test build, in the job that builds it.
|
||||
Build,
|
||||
/// The tests, which the gate builds once and runs from the archive in several shards.
|
||||
Test,
|
||||
}
|
||||
|
||||
/// How `ci` gets the test binaries.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
enum TestSource {
|
||||
/// Builds and runs them here.
|
||||
InPlace,
|
||||
/// Builds them only (the cache warm-up).
|
||||
BuildOnly,
|
||||
/// Builds them into a nextest archive at this path instead of running them.
|
||||
Archive(PathBuf),
|
||||
/// Runs them from a nextest archive extracted to this directory (`--extract-to`), on the
|
||||
/// partition given, if any.
|
||||
Extracted { dir: PathBuf, partition: Option<String> },
|
||||
}
|
||||
|
||||
/// Which tests a run from the archive takes, by nextest's `gpu` test group.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
enum Selection {
|
||||
All,
|
||||
/// Only the group, with each test's output shown: the Linux gate runs it on lavapipe, and
|
||||
/// scripts/ci-gpu-lavapipe.py checks that output for skipped GPU comparisons.
|
||||
Gpu,
|
||||
/// Every test outside the group.
|
||||
NoGpu,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct CiOptions {
|
||||
tests: TestSource,
|
||||
selection: Selection,
|
||||
/// Workspace packages left out of the test build and the doctests ($PHOTOCRAFT_CI_EXCLUDE).
|
||||
exclude: Vec<String>,
|
||||
}
|
||||
|
||||
type StepFn = fn(&CiOptions) -> Result<(), String>;
|
||||
|
||||
/// The CI gate's steps, in the order `cargo xtask ci` runs them.
|
||||
const CI_STEPS: [(&str, Part, StepFn); 11] = [
|
||||
("fmt", Part::Lint, step_fmt),
|
||||
("egui-fork", Part::Lint, |_| cmd_egui_fork()),
|
||||
("clippy", Part::Lint, step_clippy),
|
||||
("layers", Part::Lint, |_| cmd_layers()),
|
||||
("panel-commands", Part::Lint, |_| panel_commands::run(&root())),
|
||||
("scorecard", Part::Lint, |_| scorecard::run(&root(), &["--check"])),
|
||||
("test", Part::Test, |o| step_tests(o, false)),
|
||||
("panic_hunt", Part::Test, |o| step_tests(o, true)),
|
||||
("doctest", Part::Build, step_doctest),
|
||||
("wasm", Part::Lint, |_| cmd_wasm()),
|
||||
("i18n", Part::Lint, step_i18n),
|
||||
];
|
||||
|
||||
fn step_fmt(_: &CiOptions) -> Result<(), String> {
|
||||
let mut c = cargo();
|
||||
if nextest_available() {
|
||||
c.args(["nextest", "run", "--profile", "ci"]).args(GATE_ARGS).args(&TEST_TARGETS[1..]);
|
||||
if panic_hunt {
|
||||
c.args(["--run-ignored", "only", "-E", "binary_id(photocraft-engine::panic_hunt)"]);
|
||||
}
|
||||
} else if panic_hunt {
|
||||
// `-- --ignored` across the workspace would run every ignored test, not only the hunt. The
|
||||
// engine has no `heif` feature of its own; it reaches the decoder through photocraft-io.
|
||||
c.args(["test", "-p", "photocraft-engine", "--locked", "--features", "photocraft-io/heif", "--test", "panic_hunt", "--", "--ignored"]);
|
||||
} else {
|
||||
eprintln!("note: cargo-nextest is not installed, running cargo test (cargo install cargo-nextest --locked)");
|
||||
c.arg("test").args(GATE_ARGS).args(&TEST_TARGETS[1..]);
|
||||
c.args(["fmt", "--all", "--", "--check"]);
|
||||
run(c, "cargo fmt --all -- --check")
|
||||
}
|
||||
|
||||
fn step_clippy(_: &CiOptions) -> Result<(), String> {
|
||||
let mut c = cargo();
|
||||
c.arg("clippy").args(GATE_ARGS).args(["--all-targets", "--keep-going", "--", "-D", "warnings"]);
|
||||
run(c, "cargo clippy --workspace --locked --features heif --all-targets --keep-going -- -D warnings")
|
||||
}
|
||||
|
||||
fn step_doctest(o: &CiOptions) -> Result<(), String> {
|
||||
let mut c = cargo();
|
||||
c.arg("test").args(gate_args(&o.exclude)).arg("--doc");
|
||||
let what = shown(&c);
|
||||
run(c, &what)
|
||||
}
|
||||
|
||||
fn step_i18n(_: &CiOptions) -> Result<(), String> {
|
||||
// Lists missing translations for the log; a missing string shows in English, so it never fails CI.
|
||||
if let Err(e) = i18n_report::run(&root()) {
|
||||
eprintln!("warning: i18n report failed: {e}");
|
||||
}
|
||||
let what = format!("cargo {}", c.get_args().map(|a| a.to_string_lossy()).collect::<Vec<_>>().join(" "));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// GATE_ARGS without the excluded packages.
|
||||
fn gate_args(exclude: &[String]) -> Vec<String> {
|
||||
let mut args: Vec<String> = GATE_ARGS.iter().map(|a| a.to_string()).collect();
|
||||
for package in exclude {
|
||||
args.extend(["--exclude".to_string(), package.clone()]);
|
||||
}
|
||||
args
|
||||
}
|
||||
|
||||
/// The test build every test step shares: the gate's packages and features, TEST_TARGETS.
|
||||
fn test_build_args(exclude: &[String]) -> Vec<String> {
|
||||
let mut args = gate_args(exclude);
|
||||
args.extend(TEST_TARGETS[1..].iter().map(|a| a.to_string()));
|
||||
args
|
||||
}
|
||||
|
||||
/// The filter of nextest's `gpu` test group: the default profile's overrides that put tests in it.
|
||||
fn gpu_filter(config: &toml::Table) -> Result<String, String> {
|
||||
let filters: Vec<String> = config
|
||||
.get("profile")
|
||||
.and_then(|p| p.get("default"))
|
||||
.and_then(|d| d.get("overrides"))
|
||||
.and_then(toml::Value::as_array)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter(|row| row.get("test-group").and_then(toml::Value::as_str) == Some("gpu"))
|
||||
.filter_map(|row| row.get("filter").and_then(toml::Value::as_str))
|
||||
.map(|filter| format!("({})", filter.trim()))
|
||||
.collect();
|
||||
if filters.is_empty() {
|
||||
return Err("the nextest `gpu` test group has no filters (.config/nextest.toml)".into());
|
||||
}
|
||||
Ok(filters.join(" | "))
|
||||
}
|
||||
|
||||
fn read_gpu_filter() -> Result<String, String> {
|
||||
let path = root().join(".config/nextest.toml");
|
||||
let text = std::fs::read_to_string(&path).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||
gpu_filter(&toml::from_str(&text).map_err(|e| format!("{}: {e}", path.display()))?)
|
||||
}
|
||||
|
||||
/// The nextest command line of a test step. `panic_hunt` runs only the engine's `#[ignore]`d panic
|
||||
/// hunt (AGENTS.md Rule 9), from the same test build as the tests, so nothing rebuilds. `gpu` is
|
||||
/// the group's filter, read only when the selection needs it. nextest's `ci` profile terminates
|
||||
/// hung tests and repeats every failure at the end of the log (.config/nextest.toml).
|
||||
fn nextest_args(o: &CiOptions, panic_hunt: bool, gpu: Option<&str>) -> Vec<String> {
|
||||
let mut args: Vec<String> = ["nextest", "run", "--profile", "ci"].map(String::from).to_vec();
|
||||
let mut filters = Vec::new();
|
||||
if panic_hunt {
|
||||
args.extend(["--run-ignored", "only"].map(String::from));
|
||||
filters.push("binary_id(photocraft-engine::panic_hunt)".to_string());
|
||||
}
|
||||
match &o.tests {
|
||||
TestSource::Extracted { dir, partition } => {
|
||||
let target = dir.join("target");
|
||||
let path = |p: PathBuf| p.to_string_lossy().into_owned();
|
||||
args.extend([
|
||||
"--binaries-metadata".to_string(),
|
||||
path(target.join("nextest").join("binaries-metadata.json")),
|
||||
"--cargo-metadata".to_string(),
|
||||
path(target.join("nextest").join("cargo-metadata.json")),
|
||||
"--target-dir-remap".to_string(),
|
||||
path(target.clone()),
|
||||
"--workspace-remap".to_string(),
|
||||
path(root()),
|
||||
]);
|
||||
if let Some(partition) = partition {
|
||||
args.extend(["--partition".to_string(), partition.clone()]);
|
||||
}
|
||||
// A partition or a selection may hold no panic hunt; the shard that does runs it.
|
||||
if panic_hunt {
|
||||
args.extend(["--no-tests", "warn"].map(String::from));
|
||||
}
|
||||
}
|
||||
_ => args.extend(test_build_args(&o.exclude)),
|
||||
}
|
||||
match (o.selection, gpu) {
|
||||
(Selection::Gpu, Some(gpu)) => {
|
||||
filters.push(format!("({gpu})"));
|
||||
args.extend(["--success-output", "immediate"].map(String::from));
|
||||
}
|
||||
(Selection::NoGpu, Some(gpu)) => filters.push(format!("not ({gpu})")),
|
||||
_ => {}
|
||||
}
|
||||
if !filters.is_empty() {
|
||||
args.extend(["-E".to_string(), filters.join(" & ")]);
|
||||
}
|
||||
args
|
||||
}
|
||||
|
||||
fn shown(c: &Command) -> String {
|
||||
format!("cargo {}", c.get_args().map(|a| a.to_string_lossy()).collect::<Vec<_>>().join(" "))
|
||||
}
|
||||
|
||||
/// The `test` and `panic_hunt` steps.
|
||||
fn step_tests(o: &CiOptions, panic_hunt: bool) -> Result<(), String> {
|
||||
let mut c = cargo();
|
||||
if o.tests == TestSource::InPlace && !nextest_available() {
|
||||
if panic_hunt {
|
||||
// `-- --ignored` across the workspace would run every ignored test, not only the hunt. The
|
||||
// engine has no `heif` feature of its own; it reaches the decoder through photocraft-io.
|
||||
c.args(["test", "-p", "photocraft-engine", "--locked", "--features", "photocraft-io/heif", "--test", "panic_hunt", "--", "--ignored"]);
|
||||
} else {
|
||||
eprintln!("note: cargo-nextest is not installed, running cargo test (cargo install cargo-nextest --locked)");
|
||||
c.arg("test").args(test_build_args(&o.exclude));
|
||||
}
|
||||
} else {
|
||||
let gpu = if o.selection == Selection::All { None } else { Some(read_gpu_filter()?) };
|
||||
c.args(nextest_args(o, panic_hunt, gpu.as_deref()));
|
||||
}
|
||||
let what = shown(&c);
|
||||
run(c, &what)
|
||||
}
|
||||
|
||||
/// Builds the test steps' binaries without running them: into a nextest archive the shards run
|
||||
/// from, or only into the target directory (the cache warm-up). The `ci` profile's archive also
|
||||
/// carries this xtask binary, so a shard runs the test steps without building anything.
|
||||
fn build_tests(o: &CiOptions) -> Result<(), String> {
|
||||
let mut c = cargo();
|
||||
match &o.tests {
|
||||
TestSource::Archive(file) => {
|
||||
c.args(["nextest", "archive", "--profile", "ci"]).args(test_build_args(&o.exclude)).arg("--archive-file").arg(file);
|
||||
}
|
||||
_ => {
|
||||
c.args(["test", "--no-run"]).args(test_build_args(&o.exclude));
|
||||
}
|
||||
}
|
||||
let what = shown(&c);
|
||||
run(c, &what)
|
||||
}
|
||||
|
||||
@@ -276,55 +484,93 @@ fn cmd_parity() -> Result<(), String> {
|
||||
run(c, "cargo run -p photocraft-ui-egui --example parity")
|
||||
}
|
||||
|
||||
fn cmd_ci() -> Result<(), String> {
|
||||
type Step = (&'static str, Box<dyn Fn() -> Result<(), String>>);
|
||||
let steps: Vec<Step> = vec![
|
||||
(
|
||||
"fmt",
|
||||
Box::new(|| {
|
||||
let mut c = cargo();
|
||||
c.args(["fmt", "--all", "--", "--check"]);
|
||||
run(c, "cargo fmt --all -- --check")
|
||||
}),
|
||||
),
|
||||
("egui-fork", Box::new(cmd_egui_fork)),
|
||||
(
|
||||
"clippy",
|
||||
Box::new(|| {
|
||||
let mut c = cargo();
|
||||
c.arg("clippy").args(GATE_ARGS).args(["--all-targets", "--keep-going", "--", "-D", "warnings"]);
|
||||
run(c, "cargo clippy --workspace --locked --features heif --all-targets --keep-going -- -D warnings")
|
||||
}),
|
||||
),
|
||||
("layers", Box::new(cmd_layers)),
|
||||
("panel-commands", Box::new(|| panel_commands::run(&root()))),
|
||||
("scorecard", Box::new(|| scorecard::run(&root(), &["--check"]))),
|
||||
("test", Box::new(|| cmd_gate_tests(false))),
|
||||
("panic_hunt", Box::new(|| cmd_gate_tests(true))),
|
||||
(
|
||||
"doctest",
|
||||
Box::new(|| {
|
||||
let mut c = cargo();
|
||||
c.arg("test").args(GATE_ARGS).arg("--doc");
|
||||
run(c, "cargo test --workspace --locked --features heif --doc")
|
||||
}),
|
||||
),
|
||||
("wasm", Box::new(cmd_wasm)),
|
||||
(
|
||||
"i18n",
|
||||
Box::new(|| {
|
||||
// Lists missing translations for the log; a missing string shows in English, so it never fails CI.
|
||||
if let Err(e) = i18n_report::run(&root()) {
|
||||
eprintln!("warning: i18n report failed: {e}");
|
||||
/// The packages the gate leaves out of a test build: the Windows legs skip the browser apps, and
|
||||
/// on pull requests the packages nothing changed reaches (.github/workflows/ci.yml).
|
||||
fn ci_exclude() -> Vec<String> {
|
||||
std::env::var("PHOTOCRAFT_CI_EXCLUDE").unwrap_or_default().split_whitespace().map(String::from).collect()
|
||||
}
|
||||
|
||||
/// The steps `cargo xtask ci <args>` runs, and how: no argument runs every step; a part (`lint`,
|
||||
/// `archive`, `build`, `tests`) runs the steps of one gate job; a step's name runs that step.
|
||||
fn ci_from_args(args: &[&str], exclude: Vec<String>) -> Result<(Vec<(&'static str, StepFn)>, CiOptions), String> {
|
||||
let mut options = CiOptions { tests: TestSource::InPlace, selection: Selection::All, exclude };
|
||||
let mut what = None;
|
||||
let mut from = None;
|
||||
let mut it = args.iter();
|
||||
while let Some(&arg) = it.next() {
|
||||
match arg {
|
||||
"--from" => {
|
||||
let dir = it.next().ok_or("--from needs the directory the archive was extracted to")?;
|
||||
from = Some(std::path::absolute(dir).map_err(|e| format!("--from {dir}: {e}"))?);
|
||||
}
|
||||
"--gpu" => options.selection = Selection::Gpu,
|
||||
"--no-gpu" => options.selection = Selection::NoGpu,
|
||||
_ if what.is_none() && !arg.starts_with('-') => what = Some(arg),
|
||||
_ => return Err(format!("ci: unexpected argument `{arg}`")),
|
||||
}
|
||||
}
|
||||
let parts: &[Part] = match what {
|
||||
None => &[Part::Lint, Part::Test, Part::Build],
|
||||
Some("lint") => &[Part::Lint],
|
||||
Some("archive") => {
|
||||
let file = std::env::var_os("NEXTEST_ARCHIVE_FILE").ok_or("ci archive: set NEXTEST_ARCHIVE_FILE to the archive to write")?;
|
||||
options.tests = TestSource::Archive(file.into());
|
||||
&[Part::Test, Part::Build]
|
||||
}
|
||||
Some("build") => {
|
||||
options.tests = TestSource::BuildOnly;
|
||||
&[Part::Test]
|
||||
}
|
||||
Some("tests") => {
|
||||
let dir = from.take().ok_or("ci tests: --from <dir> names the directory the archive was extracted to")?;
|
||||
let partition = std::env::var("NEXTEST_PARTITION").ok().filter(|p| !p.is_empty());
|
||||
options.tests = TestSource::Extracted { dir, partition };
|
||||
&[Part::Test]
|
||||
}
|
||||
Some(step) => {
|
||||
let plan: Vec<_> = CI_STEPS.iter().filter(|s| s.0 == step).map(|&(name, _, f)| (name, f)).collect();
|
||||
if plan.is_empty() {
|
||||
return Err(format!("ci: no part or step `{step}`"));
|
||||
}
|
||||
return Ok((plan, options));
|
||||
}
|
||||
};
|
||||
if from.is_some() || (options.selection != Selection::All && !matches!(options.tests, TestSource::Extracted { .. })) {
|
||||
return Err("ci: --from, --gpu and --no-gpu go with `ci tests`".into());
|
||||
}
|
||||
Ok((ci_plan(parts, &options.tests), options))
|
||||
}
|
||||
|
||||
/// The steps of `parts`, in CI_STEPS order. When the tests are only built (into an archive or the
|
||||
/// target directory), the test steps become that one build.
|
||||
fn ci_plan(parts: &[Part], tests: &TestSource) -> Vec<(&'static str, StepFn)> {
|
||||
let build_only = match tests {
|
||||
TestSource::Archive(_) => Some("archive"),
|
||||
TestSource::BuildOnly => Some("build"),
|
||||
_ => None,
|
||||
};
|
||||
let mut plan: Vec<(&'static str, StepFn)> = Vec::new();
|
||||
for &(name, part, f) in &CI_STEPS {
|
||||
if !parts.contains(&part) {
|
||||
continue;
|
||||
}
|
||||
match (part, build_only) {
|
||||
(Part::Test, Some(build)) => {
|
||||
if !plan.iter().any(|s| s.0 == build) {
|
||||
plan.push((build, build_tests));
|
||||
}
|
||||
Ok(())
|
||||
}),
|
||||
),
|
||||
];
|
||||
}
|
||||
_ => plan.push((name, f)),
|
||||
}
|
||||
}
|
||||
plan
|
||||
}
|
||||
|
||||
fn cmd_ci(steps: &[(&'static str, StepFn)], options: &CiOptions) -> Result<(), String> {
|
||||
let mut done = Vec::new();
|
||||
for (name, f) in &steps {
|
||||
for (name, f) in steps {
|
||||
eprintln!("\n=== ci: {name} ===");
|
||||
if let Err(e) = f() {
|
||||
if let Err(e) = f(options) {
|
||||
println!("\nCI summary:");
|
||||
for d in &done {
|
||||
println!(" ok {d}");
|
||||
@@ -340,3 +586,79 @@ fn cmd_ci() -> Result<(), String> {
|
||||
println!("\nCI summary: all {} steps passed ({})", done.len(), done.join(", "));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod ci_tests {
|
||||
use super::*;
|
||||
|
||||
fn names(args: &[&str]) -> Vec<&'static str> {
|
||||
ci_from_args(args, Vec::new()).unwrap().0.into_iter().map(|s| s.0).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_gate_jobs_together_run_every_step_once() {
|
||||
let all = names(&[]);
|
||||
assert_eq!(all, CI_STEPS.map(|s| s.0));
|
||||
let lint = names(&["lint"]);
|
||||
let tests = names(&["tests", "--from", "x"]);
|
||||
assert_eq!(tests, ["test", "panic_hunt"]);
|
||||
let archive = ci_plan(&[Part::Test, Part::Build], &TestSource::Archive("a.tar.zst".into())).into_iter().map(|s| s.0).collect::<Vec<_>>();
|
||||
assert_eq!(archive, ["archive", "doctest"]);
|
||||
let mut split: Vec<_> = lint.iter().chain(&tests).chain(archive.iter().filter(|s| **s != "archive")).copied().collect();
|
||||
split.sort_unstable();
|
||||
let mut every = all.clone();
|
||||
every.sort_unstable();
|
||||
assert_eq!(split, every);
|
||||
assert_eq!(names(&["build"]), ["build"]);
|
||||
assert_eq!(names(&["clippy"]), ["clippy"]);
|
||||
assert!(ci_from_args(&["nope"], Vec::new()).is_err());
|
||||
assert!(ci_from_args(&["lint", "--gpu"], Vec::new()).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_shard_runs_its_partition_from_the_extracted_archive() {
|
||||
let options = CiOptions {
|
||||
tests: TestSource::Extracted { dir: "/x".into(), partition: Some("hash:2/3".into()) },
|
||||
selection: Selection::NoGpu,
|
||||
exclude: Vec::new(),
|
||||
};
|
||||
let args = nextest_args(&options, false, Some("package(g)")).join(" ");
|
||||
assert!(args.starts_with("nextest run --profile ci --binaries-metadata /x/target/nextest/binaries-metadata.json"), "{args}");
|
||||
assert!(args.contains("--target-dir-remap /x/target --workspace-remap ") && args.contains("--partition hash:2/3"), "{args}");
|
||||
assert!(args.ends_with("-E not (package(g))") && !args.contains("--workspace "), "{args}");
|
||||
let gpu = CiOptions { selection: Selection::Gpu, ..options.clone() };
|
||||
let hunt = nextest_args(&gpu, true, Some("package(g)")).join(" ");
|
||||
assert!(hunt.contains("--run-ignored only") && hunt.contains("--no-tests warn") && hunt.contains("--success-output immediate"), "{hunt}");
|
||||
assert!(hunt.ends_with("-E binary_id(photocraft-engine::panic_hunt) & (package(g))"), "{hunt}");
|
||||
// In place, a test step builds what the archive holds.
|
||||
let here = CiOptions { tests: TestSource::InPlace, selection: Selection::All, exclude: vec!["photocraft-web".into()] };
|
||||
assert_eq!(
|
||||
nextest_args(&here, false, None).join(" "),
|
||||
"nextest run --profile ci --workspace --locked --features heif --exclude photocraft-web --lib --bins --tests"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_gpu_group_takes_every_filter_that_selects_it() {
|
||||
let config: toml::Table = toml::from_str(
|
||||
r#"
|
||||
[[profile.default.overrides]]
|
||||
filter = 'package(a)'
|
||||
test-group = 'gpu'
|
||||
[[profile.default.overrides]]
|
||||
filter = 'package(b)'
|
||||
test-group = 'cpu'
|
||||
[[profile.default.overrides]]
|
||||
filter = '''
|
||||
test(c)
|
||||
'''
|
||||
test-group = 'gpu'
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(gpu_filter(&config).unwrap(), "(package(a)) | (test(c))");
|
||||
assert!(gpu_filter(&toml::from_str("[profile.default]").unwrap()).is_err());
|
||||
// The workspace's own group exists and parses.
|
||||
assert!(read_gpu_filter().unwrap().contains("package(photocraft-gpu)"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user