mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-24 10:08:00 -06:00
CI: nextest, line tables only, one wasm check (#4269)
* CI speed: line tables for workspace crates, no debug info for dependencies * CI speed: xtask ci runs nextest and doctests, one wasm check, the CLI without default features
This commit is contained in:
+24
-11
@@ -78,20 +78,32 @@ pub fn wasm(_: &[String]) -> anyhow::Result<()> {
|
||||
.filter(|c| matches!(layers::classify(&c.name), Some(layers::Class::Layer(_) | layers::Class::Standalone(_))))
|
||||
.map(|c| c.name)
|
||||
.collect();
|
||||
let mut failed = Vec::new();
|
||||
// One call over every crate: they share one dependency build, and `--keep-going` reports
|
||||
// each failing crate instead of stopping at the first.
|
||||
let mut c = cargo();
|
||||
c.args(["check", "--target", "wasm32-unknown-unknown", "--keep-going"]);
|
||||
for pkg in &set {
|
||||
let mut c = cargo();
|
||||
c.args(["check", "--target", "wasm32-unknown-unknown", "-p", pkg]);
|
||||
if run(c, &format!("cargo check --target wasm32-unknown-unknown -p {pkg}")).is_err() {
|
||||
failed.push(pkg.clone());
|
||||
}
|
||||
c.args(["-p", pkg]);
|
||||
}
|
||||
if failed.is_empty() {
|
||||
println!("wasm32: {} crates ok", set.len());
|
||||
Ok(())
|
||||
run(c, &format!("cargo check --target wasm32-unknown-unknown --keep-going ({} crates)", set.len()))?;
|
||||
println!("wasm32: {} crates ok", set.len());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The workspace tests. Unit and integration tests run under cargo-nextest when it is installed
|
||||
/// (one process per test, so the run is not held up by its slowest binary), else under
|
||||
/// `cargo test`; doctests run separately because nextest does not run them. Examples are left
|
||||
/// out of the test build: clippy `--all-targets` already checks that they compile.
|
||||
pub fn test(_: &[String]) -> anyhow::Result<()> {
|
||||
let targets = ["--workspace", "--lib", "--bins", "--tests"];
|
||||
let nextest = cargo().args(["nextest", "--version"]).output().is_ok_and(|o| o.status.success());
|
||||
if nextest {
|
||||
run_args(&[&["nextest", "run", "--no-fail-fast"][..], &targets].concat())?;
|
||||
} else {
|
||||
bail!("wasm32 check failed for: {}", failed.join(", "))
|
||||
eprintln!("test: cargo-nextest is not installed, using cargo test (cargo install cargo-nextest --locked)");
|
||||
run_args(&[&["test", "--no-fail-fast"][..], &targets].concat())?;
|
||||
}
|
||||
run_args(&["test", "--workspace", "--doc"])
|
||||
}
|
||||
|
||||
pub fn ci(_: &[String]) -> anyhow::Result<()> {
|
||||
@@ -99,7 +111,8 @@ pub fn ci(_: &[String]) -> anyhow::Result<()> {
|
||||
let steps: Vec<Step> = vec![
|
||||
("fmt", Box::new(|| run_args(&["fmt", "--all", "--", "--check"]))),
|
||||
("clippy", Box::new(|| run_args(&["clippy", "--workspace", "--all-targets", "--", "-D", "warnings"]))),
|
||||
("test", Box::new(|| run_args(&["test", "--workspace"]))),
|
||||
("cli-no-default-features", Box::new(|| run_args(&["check", "-p", "pdfcraft-cli", "--no-default-features"]))),
|
||||
("test", Box::new(|| test(&[]))),
|
||||
("layers", Box::new(|| layers(&[]))),
|
||||
("wasm", Box::new(|| wasm(&[]))),
|
||||
("assets", Box::new(|| crate::assets::run(&[]))),
|
||||
|
||||
+7
-2
@@ -19,9 +19,14 @@ type Command = fn(&[String]) -> anyhow::Result<()>;
|
||||
const COMMANDS: &[(&str, &str, Command)] = &[
|
||||
("version", "Print the workspace version, or `version set X.Y.Z[-pre]` to change it and refresh Cargo.lock", version_cmd),
|
||||
("layers", "Enforce the crate dependency layering (plan/architecture.md §3)", gates::layers),
|
||||
("wasm", "cargo check --target wasm32-unknown-unknown for every crate below L8", gates::wasm),
|
||||
("wasm", "cargo check --target wasm32-unknown-unknown for every crate below L8, in one call", gates::wasm),
|
||||
("deny", "Dependency licences, bans, sources and advisories (deny.toml; needs cargo-deny)", gates::deny),
|
||||
("ci", "fmt --check, clippy -D warnings, test, layers, wasm, assets, deny, parity (stops at first failure)", gates::ci),
|
||||
(
|
||||
"ci",
|
||||
"fmt --check, clippy -D warnings, the CLI without default features, test, layers, wasm, assets, deny, parity (stops at first failure)",
|
||||
gates::ci,
|
||||
),
|
||||
("test", "Workspace tests: cargo nextest (cargo test when it is missing), then doctests", gates::test),
|
||||
("assets", "Enforce the asset policy (AGENTS.md §1) against ATTRIBUTION.toml; --write regenerates ATTRIBUTION.md", assets::run),
|
||||
("corpus", "Fetch the pinned pdf.js test corpus into corpus/ (git-ignored) and verify it; --update-pin re-records the pin", gates::corpus),
|
||||
("check", "Robustness sweep over corpus/ with pdfcraft-cli; fails on crashes or regressions vs xtask/baselines", gates::check),
|
||||
|
||||
Reference in New Issue
Block a user