mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-25 20:14:31 +01:00
- scripts/ci-workspace-tests.sh holds every Workspace test step. When the selection reaches a replay-audit crate, the Linux leg builds once in gate.yml's build job, writes three nextest archives (every selected test, the audit's UI crates, the default-feature crates), runs the doctests, and three shard legs run the archives in parallel. Any other selection, and every macOS and Windows leg, builds and runs in one leg as before. - .config/cargo-dev.toml is the dev-profile tuning tools/cl passes locally (dependencies at opt-level 2, craft-theme/behavior/proof at 1, lto off); every CI test build passes it too, with .config/cargo-ci.toml adding the numeric crates at opt-level 1. The Workspace legs' cache entries are named after a hash of both files. Cargo.toml's profiles are unchanged. - nightly.yml builds through the same script and also starts the full tests on next.
101 lines
5.0 KiB
Bash
Executable File
101 lines
5.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# The Workspace gate's test steps (.github/workflows/workspace.yml), one per argument:
|
|
#
|
|
# run one leg builds and runs every test: each macOS and Windows leg, and the Linux leg when
|
|
# the selection reaches no replay-audit crate
|
|
# archive the Linux build job (gate.yml `archive-command`) builds once and writes one nextest
|
|
# archive per shard: 1 every selected test, 2 the replay audit's UI crates, 3 the
|
|
# default-feature crates
|
|
# shard a Linux shard leg runs its archive ($GATE_SHARD)
|
|
# doctest the doctests, in the build job after the archives (`after-archive-command`)
|
|
# audit prints whether the selection reaches a replay-audit crate (`true` or `false`)
|
|
# full the nightly run: every test, at the full sweep and proptest counts nightly.yml leaves set
|
|
#
|
|
# CRAFT_TESTS (all, some, none) and CRAFT_TEST_FILTER are the platforms job's selection;
|
|
# CRAFT_TEST_SKIP is its list of members whose tests do not run.
|
|
set -euo pipefail
|
|
|
|
# Every build passes the same profile overrides, so the steps of one leg share their build and
|
|
# match local `tools/cl` builds (.config/cargo-dev.toml); .config/cargo-ci.toml adds the gate's own.
|
|
config=(--config .config/cargo-dev.toml --config .config/cargo-ci.toml)
|
|
# Every test once, with every feature. Examples are not built, except the two whose tests run;
|
|
# clippy in the lint leg covers the rest. Every build is the whole workspace's: the filter narrows
|
|
# only what runs.
|
|
all_features=(--workspace --all-features --locked --profile ci "${config[@]}")
|
|
targets=(--lib --bins --tests)
|
|
examples=(-p craft-aep -p craft-video --example stubicc --example h264_h264enc_bench)
|
|
# The crates whose tests check behaviour with a feature off, which an all-features build cannot reach.
|
|
default_features=(-p craft-image-codecs -p craft-text --locked --profile ci "${config[@]}")
|
|
# The replay audit (craft-libs#2336): these crates' tests again, with every memoized view that would
|
|
# replay also run for real and compared with its replay.
|
|
audit_packages=(craft-ui-contract craft-ui-widgets craft-ui-panels craft-ui-patterns craft-ui-shell craft-ui-gallery craft-menu)
|
|
audit_filter=$(printf ' | package(%s)' "${audit_packages[@]}")
|
|
audit_filter="(${CRAFT_TEST_FILTER:-all()}) & (${audit_filter:3})"
|
|
filter=${CRAFT_TEST_FILTER:-all()}
|
|
|
|
doctests() {
|
|
# Whole-workspace: `cargo test -p <selected>` would resolve features over the selected crates
|
|
# only and rebuild the dependencies whose features differ.
|
|
cargo test --workspace --doc --all-features --locked "${config[@]}"
|
|
}
|
|
|
|
case "${1:-}" in
|
|
run)
|
|
if [ "${CRAFT_TESTS:-all}" = none ]; then
|
|
echo "No crate changed: no tests to run."
|
|
exit 0
|
|
fi
|
|
if [ "${RUNNER_OS:-}" = Windows ]; then
|
|
# shellcheck disable=SC2016 # $ErrorActionPreference is PowerShell's
|
|
powershell.exe -NoProfile -Command '$ErrorActionPreference = "Stop"; Start-Service Spooler; Add-PrinterDriver -Name "Generic / Text Only"'
|
|
fi
|
|
cargo nextest run "${all_features[@]}" -E "$filter" --no-tests=warn "${targets[@]}"
|
|
cargo nextest run "${examples[@]}" --all-features --locked --profile ci "${config[@]}" -E "$filter" --no-tests=warn
|
|
doctests
|
|
cargo nextest run "${default_features[@]}" -E "$filter" --no-tests=warn "${targets[@]}"
|
|
;;
|
|
archive)
|
|
for shard in 1 2 3; do mkdir -p "$NEXTEST_ARCHIVE_DIR/$shard"; done
|
|
# The examples' two packages join the one build here, so their tests are in shard 1's archive.
|
|
cargo nextest archive "${all_features[@]}" "${targets[@]}" --example stubicc --example h264_h264enc_bench \
|
|
-E "$filter" --archive-file "$NEXTEST_ARCHIVE_DIR/1/$NEXTEST_ARCHIVE_NAME"
|
|
# The same build, so nothing compiles again; only the audit crates' binaries.
|
|
cargo nextest archive "${all_features[@]}" "${targets[@]}" --example stubicc --example h264_h264enc_bench \
|
|
-E "$audit_filter" --archive-file "$NEXTEST_ARCHIVE_DIR/2/$NEXTEST_ARCHIVE_NAME"
|
|
cargo nextest archive "${default_features[@]}" "${targets[@]}" \
|
|
-E "$filter" --archive-file "$NEXTEST_ARCHIVE_DIR/3/$NEXTEST_ARCHIVE_NAME"
|
|
;;
|
|
shard)
|
|
run=(cargo nextest run --archive-file "$NEXTEST_ARCHIVE_FILE" --workspace-remap . --profile ci --no-tests=warn)
|
|
case "${GATE_SHARD:-}" in
|
|
1 | 3) "${run[@]}" ;;
|
|
2) CRAFT_UI_AUDIT_REPLAY=1 "${run[@]}" ;;
|
|
*) echo "unknown shard: '${GATE_SHARD:-}'" >&2; exit 2 ;;
|
|
esac
|
|
;;
|
|
doctest)
|
|
doctests
|
|
;;
|
|
audit)
|
|
case "${CRAFT_TESTS:-all}" in
|
|
none) echo false ;;
|
|
all) echo true ;;
|
|
*)
|
|
reached=false
|
|
for package in "${audit_packages[@]}"; do
|
|
if [[ " ${CRAFT_TEST_SKIP:-} " != *" $package "* ]]; then reached=true; fi
|
|
done
|
|
echo "$reached"
|
|
;;
|
|
esac
|
|
;;
|
|
full)
|
|
cargo nextest run "${all_features[@]}" --no-tests=warn "${targets[@]}"
|
|
cargo nextest run "${examples[@]}" --all-features --locked --profile ci "${config[@]}" --no-tests=warn
|
|
;;
|
|
*)
|
|
echo "usage: $0 run|archive|shard|doctest|audit|full" >&2
|
|
exit 2
|
|
;;
|
|
esac
|