mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-26 17:57:07 +00:00
ci: the Linux gate builds the real-file corpus tests in and its shards fetch the corpora
Part of #15711
This commit is contained in:
@@ -196,6 +196,7 @@ jobs:
|
||||
LPDEST=photocraft-no-such-printer
|
||||
CARGO_PROFILE_TEST_STRIP=symbols
|
||||
PHOTOCRAFT_CI_EXCLUDE=${{ needs.platforms.outputs.linux_skip }}
|
||||
PHOTOCRAFT_CORPUS_TESTS=1
|
||||
timeout-minutes: 100
|
||||
cache-workspace-crates: true
|
||||
lint-cache: false
|
||||
|
||||
@@ -21,6 +21,12 @@ cargo nextest run --archive-file "$NEXTEST_ARCHIVE_FILE" --workspace-remap . --e
|
||||
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
|
||||
|
||||
# The gate builds the real-file corpus tests in (PHOTOCRAFT_CORPUS_TESTS=1, xtask's CORPUS_FEATURES):
|
||||
# they fail when the corpus is missing, so a shard fetches it first (pinned commits, sha256-verified).
|
||||
if [ "${PHOTOCRAFT_CORPUS_TESTS:-}" = 1 ]; then
|
||||
"${xtask[0]}" corpus --all
|
||||
fi
|
||||
|
||||
case "${1:-}" in
|
||||
"") exec "${xtask[@]}" ;;
|
||||
--gpu-shard)
|
||||
|
||||
@@ -381,7 +381,25 @@ fn gate_args(exclude: &[String]) -> Vec<String> {
|
||||
|
||||
/// The test build every test step shares: the gate's packages and features, TEST_TARGETS.
|
||||
fn test_build_args(exclude: &[String]) -> Vec<String> {
|
||||
test_build_args_with(exclude, std::env::var_os("PHOTOCRAFT_CORPUS_TESTS").is_some_and(|v| v == "1"))
|
||||
}
|
||||
|
||||
/// Packages whose real-file corpus tests (`feature = "corpus"`) the gate builds in with
|
||||
/// PHOTOCRAFT_CORPUS_TESTS=1. Those tests fail when the corpus is missing, so the gate's shards
|
||||
/// fetch it first (scripts/ci-test-shard.sh); a local `ci tests` leaves them out.
|
||||
const CORPUS_FEATURES: [&str; 2] = ["photocraft-io/corpus", "photocraft-engine/corpus"];
|
||||
|
||||
fn test_build_args_with(exclude: &[String], corpus: bool) -> Vec<String> {
|
||||
let mut args = gate_args(exclude);
|
||||
if corpus {
|
||||
// `--features pkg/feature` names a package `--exclude` removed from the build: leave it out.
|
||||
let extra: Vec<&str> = CORPUS_FEATURES.iter().copied().filter(|f| !exclude.iter().any(|e| f.split('/').next() == Some(e.as_str()))).collect();
|
||||
if let Some(i) = args.iter().position(|a| a == "--features")
|
||||
&& !extra.is_empty()
|
||||
{
|
||||
args[i + 1] = format!("{},{}", args[i + 1], extra.join(","));
|
||||
}
|
||||
}
|
||||
args.extend(TEST_TARGETS[1..].iter().map(|a| a.to_string()));
|
||||
args
|
||||
}
|
||||
@@ -797,6 +815,14 @@ mod ci_tests {
|
||||
let here = CiOptions { partition: None, selection: Selection::All, ..options };
|
||||
assert!(!nextest_args(&here, true, None, None).join(" ").contains("--no-tests"));
|
||||
assert_eq!(test_build_args(&here.exclude).join(" "), build);
|
||||
assert_eq!(test_build_args_with(&here.exclude, false).join(" "), build);
|
||||
assert_eq!(
|
||||
test_build_args_with(&here.exclude, true).join(" "),
|
||||
"--workspace --locked --features heif,photocraft-io/corpus,photocraft-engine/corpus --exclude photocraft-web --lib --bins --tests"
|
||||
);
|
||||
// A package the build leaves out cannot get a feature.
|
||||
let args = test_build_args_with(&["photocraft-io".to_string()], true).join(" ");
|
||||
assert!(args.contains("--features heif,photocraft-engine/corpus ") && !args.contains("photocraft-io/corpus"), "{args}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user