Repository navigation
test(package): guard compile-time-embedded assets ship in packaged builds - #3130
Merged
Merged
Conversation
…ed builds #3123 was one instance of a general class: something read at compile time that exists in the dev checkout but may be absent in a packaged build. A plain `cargo build`/`cargo test` always sees the files (they're in the working tree), so it can never catch a packaging drop — the gap only surfaces in `cargo install` (crates.io archive) or the Nix build, both outer-loop. This scans `src/` for every `include_str!`/`include_bytes!` literal path and every askama `#[template(path = …)]`, resolves each, and asserts it is (a) present in `cargo package --list` (ships to crates.io) and (b) covered by the `flake.nix` source filter. A new embed whose directory isn't packaged now fails on the PR instead of after publish. Fast (no build), runs every PR. Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Follow-up to #3124, requested in this thread: turn the "build/package environment differs from the dev checkout" class inner-loop.
#3123 (
env!("VERGEN_GIT_DESCRIBE")failing on the crates.io archive) was one instance of a general pattern — something read at compile time that exists in our git checkout but may be absent in a packaged build. There are three mechanisms in the crate that do this, and a missing file in any of them is a hard compile error, exactly the #3123 failure mode:include_str!/include_bytes!dev/*.example.toml,dev/opencode-plugin.ts,gemini-extension.json#[template(path = …)](reads files at compile time via proc-macro)templates/{bash.sh,zsh.zsh,fish.fish,fish_wrapper.fish,nushell.nu,powershell.ps1}The detection gap: a plain
cargo build/cargo testalways sees these files (they're in the working tree), so it can never catch a packaging drop. Today that's only caught by the nightly Nix build (slow) or by crates.io itself after publish (the worst loop). The realistic future regression is someone adding a newinclude_str!("../../assets/foo")or#[template]outside the currently-packaged dirs — it passes every PR check, then breaks Nix that night andcargo installat the next release.This adds a fast guard (
embedded_assets_ship_in_package, no build, runs on every PR) that scanssrc/for every embedded path and asserts each is:cargo package --list— so it ships in the crates.io archive (thecargo install worktrunkfails from crates.io:VERGEN_GIT_DESCRIBEnot defined #3123 surface), andflake.nixsource filter — so it survives the Nix build.Both currently pass. I verified the test isn't vacuous: pointing an
include_str!at a tracked-but-unpackaged file (tests/helpers/wt-perf/src/lib.rs) fails it with both violations reported, distinct from the compiler's own "file not found" for a path that doesn't exist at all.This sits alongside the existing
version_build.rsguards (the fastenv!-vs-option_env!mechanism check on every PR, and the#[ignore]d full-archive build in nightly), extending the same philosophy to the file-presence half of the class.