mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
The gate's build job writes one nextest archive per shard (craft-common-actions gate.yml shard-archives), so each shard downloads only the test binaries it runs instead of the whole 2.4-2.6 GB archive. `cargo xtask ci archive` builds and lists the tests once, then plans the shards (xtask/src/shards.rs): whole binaries go to the lightest shard, heaviest first, by the times in .config/ci-test-times.tsv; a binary heavier than half a shard's share is split by test filter along its module tree, and its executable goes into each archive that runs part of it. On Linux shard 1 takes every binary with gpu-group tests. The build checks that every test runs on exactly one shard, writes the plan into the target directory, which every archive carries, and archives each shard with `cargo nextest archive -E`. A shard runs `xtask ci tests --shard <k>` with its part of the plan; the slice partition is gone. scripts/ci-test-times.py refreshes the times file from a CI run's shard logs; a missing or stale row only costs balance.
41 lines
1.9 KiB
Bash
Executable File
41 lines
1.9 KiB
Bash
Executable File
#!/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 one nextest archive per shard with `cargo xtask ci archive` (`shard-archives`), each
|
|
# holding only the test binaries that shard runs, the xtask binary and the shard plan
|
|
# (.config/nextest.toml). The shard extracts its archive and runs the test steps with
|
|
# `xtask ci tests --shard <k>` without building anything. The gate sets NEXTEST_ARCHIVE_FILE,
|
|
# GATE_SHARD and GATE_SHARDS.
|
|
#
|
|
# The build job balances the shards by recorded test times (.config/ci-test-times.tsv,
|
|
# xtask/src/shards.rs); a binary too heavy for one shard is split across shards by test filter.
|
|
#
|
|
# ci-test-shard.sh the shard runs its binaries
|
|
# ci-test-shard.sh --gpu-shard shard 1 runs nextest's `gpu` group alone on lavapipe, checked by
|
|
# scripts/ci-gpu-lavapipe.py (the build job ran
|
|
# `ci archive --gpu-shard`); the other shards run 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" --shard "$GATE_SHARD")
|
|
case "$(uname -s)" in MINGW* | MSYS* | CYGWIN*) xtask=("$archive/target/debug/xtask.exe" ci tests --from "$archive" --shard "$GATE_SHARD") ;; esac
|
|
|
|
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
|
|
exec "${xtask[@]}" --no-gpu
|
|
;;
|
|
*)
|
|
echo "usage: $0 [--gpu-shard]" >&2
|
|
exit 2
|
|
;;
|
|
esac
|