Repository navigation
Tooling: cargo xtask (ci, fmt, test, coverage, example) and CI through it - #7
Merged
Merged
Conversation
Repetitive work should have one implementation that CI and developers both run. The repo becomes a workspace with an xtask crate (clap + duct) providing ci, fmt, test, coverage and example. Every task is a list of Step values; ci_steps() is the single ordered list, leaving a place for the snapshot step. Children run in their own process groups, killed on drop and on SIGINT/SIGTERM (ctrlc), so nothing outlives xtask. A missing cargo-llvm-cov prints its install command. examples/hello.rs gives `example` something to list and run. The CI workflow now only calls `cargo xtask ci`, plus msrv and coverage jobs, and runs on pull requests and pushes to main with superseded runs cancelled. Behavior change: CI no longer runs on every branch push. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
The From<bool> impls on FmtMode, Profile and ReportFormat let a naked bool stand in for those enums anywhere in xtask, which CLAUDE.md rules out. The clap struct is the foreign boundary, so the flags stay bools there and are matched into the enums once, where they are parsed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Owner
Author
|
Review (main session): read the full diff; ran Known limits, accepted for now: line coverage only (branch coverage needs nightly); the non-unix path compiles but does not kill process groups; children are ended with SIGKILL, so a future child that needs graceful shutdown will need SIGTERM-then-KILL. |
15 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3, closes #4. Part of #6 (branch protection still pending).
Summary
xtaskmember,publish = false) with the aliascargo xtask. xtask dependencies stay out of thebullseyelibrary's dependency tree.--helpon each):ci,fmt [--check],test [-- ARGS],coverage [--lcov],example [NAME] [--release].Stepvalues (name, cargo args, env).ci_steps()is the single ordered list consumed byrun_all, so the snapshot step from Tooling: cargo xtask snapshots for reference screenshots #5 is one more entry appended there. Each step prints==> name: command; a failure names the step and exits non-zero.examplewith no name listsexamples/with the first//!line of each;examples/hello.rsis a trivial eframe window so there is something to list and run.coverageprints the install command (cargo install cargo-llvm-cov) and fails if the tool is missing, and prints the report path on success.xtask/src/process.rs): each child starts in its own process group (before_spawn+process_group(0)); a guard SIGKILLs the group on drop (normal exit), and the SIGINT/SIGTERM handler kills every registered group and exits 130. Non-unix compiles viacfg(no group kill; the console delivers Ctrl-C to children).pull_requestandpushtomain,concurrencycancelling superseded runs, jobsci(onlycargo xtask ci),msrv(1.96,cargo check --workspace --all-targets) andcoverage(cargo xtask coverage --lcov, uploadslcov.info). The required status check nameciis unchanged.Dependencies (xtask only)
clap(derive): the CLI, with generated help anddebug_assertself-check.duct: subprocesses, as specified in Tooling: adopt the cargo xtask pattern (clap + duct) #3;before_spawnis where the process group is set.anyhow: error context for the step failures.ctrlc(terminationfeature): handles SIGINT and SIGTERM (and SIGHUP) on one thread with a plain closure, and is portable (Windows console handler), whichsignal-hookwould need more code for. Chosen oversignal-hookfor being the smaller API.libc(unix only): the singlekill(-pgid, SIGKILL)call; already in the tree transitively viactrlc/nix.Verification
cargo xtask cipasses locally (fmt, clippy, 11 library tests plus 16 xtask tests, doctests, rustdoc).cargo xtask coverageandcoverage --lcovwork locally (cargo-llvm-cov).target/debug/xtask example helloin the background; thehellowindow process appeared in its own process group (pgid equal to its pid).kill -INT <xtask pid>ended both xtask andhello; noexamples/helloprocess remained. Repeated with SIGTERM: both gone within a second.Notes
cargo-llvm-cov --branchneeds nightly. Line coverage only for now.clippy --all-targetsneeds them for winit/eframe on ubuntu, an apt step goes in thecijob.llvm-tools-previewon the stable toolchain.🤖 Generated with Claude Code
https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up