Files
foxhunt/crates/common/src/build_info.rs
jgrusewski 6ddcb52825 perf(ci): fix full workspace rebuild — move version from compile-time to runtime
Root cause: `option_env!("FOXHUNT_BUILD_VERSION")` in common/build_info.rs
was a compile-time macro tracked by cargo fingerprints (Rust 1.80+). Every
pipeline run with a new tag invalidated `common` → cascading rebuild of all
38 dependent workspace crates, even when zero source files changed.

Fix: replace `option_env!()` with `std::env::var()` (runtime LazyLock). Cargo
no longer tracks the version env var, so `common` only recompiles when its
source actually changes.

Also: skip git checkout when HEAD already matches target SHA (zero mtime
changes), and drop `-x` from git clean to preserve gitignored files.

Expected: ~3.7min → <1min for unchanged-crate rebuilds on warm PVC.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 02:10:20 +01:00

26 lines
859 B
Rust

//! Build version information.
//!
//! CI sets `FOXHUNT_BUILD_VERSION` env var at runtime (e.g. `2026.03.408`).
//! Local dev falls back to `CARGO_PKG_VERSION`.
//!
//! NOTE: Version is read at runtime (not compile time) so that changing the
//! version tag doesn't invalidate cargo fingerprints for `common` and cascade
//! a full workspace rebuild of all 38+ dependent crates.
use std::sync::LazyLock;
/// Compile-time fallback from Cargo.toml `version` field.
const CARGO_VERSION: &str = env!("CARGO_PKG_VERSION");
static VERSION: LazyLock<String> = LazyLock::new(|| {
std::env::var("FOXHUNT_BUILD_VERSION").unwrap_or_else(|_| CARGO_VERSION.to_owned())
});
/// Build version string.
///
/// CI: reads `FOXHUNT_BUILD_VERSION` env var at runtime.
/// Local: falls back to Cargo.toml `version` field.
pub fn version() -> &'static str {
&VERSION
}