Skip to content

test(package): guard compile-time-embedded assets ship in packaged builds - #3130

Merged
max-sixty merged 1 commit into
mainfrom
fix/embedded-asset-package-guard-27801364624
Jun 19, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/embedded-asset-package-guard-27801364624

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

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:

Mechanism Embeds
include_str! / include_bytes! dev/*.example.toml, dev/opencode-plugin.ts, gemini-extension.json
askama #[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 test always 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 new include_str!("../../assets/foo") or #[template] outside the currently-packaged dirs — it passes every PR check, then breaks Nix that night and cargo install at the next release.

This adds a fast guard (embedded_assets_ship_in_package, no build, runs on every PR) that scans src/ for every embedded path and asserts each is:

  1. present in cargo package --list — so it ships in the crates.io archive (the cargo install worktrunk fails from crates.io: VERGEN_GIT_DESCRIBE not defined #3123 surface), and
  2. covered by the flake.nix source 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.rs guards (the fast env!-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.

…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]>
@worktrunk-bot worktrunk-bot added the automated-fix Automated CI fix label Jun 19, 2026
@max-sixty
max-sixty merged commit d67e6ab into main Jun 19, 2026
34 of 43 checks passed
@max-sixty
max-sixty deleted the fix/embedded-asset-package-guard-27801364624 branch June 19, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants