fix: propagate build version through local deploy

This commit is contained in:
fawney19
2026-05-23 00:26:07 +08:00
parent b5e942ca9d
commit c7641dad0a
4 changed files with 81 additions and 3 deletions

View File

@@ -20,6 +20,12 @@ pub(crate) fn mount_core_routes(router: Router<AppState>) -> Router<AppState> {
.route("/_gateway/health", get(health))
}
fn current_gateway_version() -> &'static str {
option_env!("AETHER_BUILD_VERSION")
.filter(|version| !version.is_empty())
.unwrap_or(env!("CARGO_PKG_VERSION"))
}
pub(crate) async fn health(State(state): State<AppState>) -> impl IntoResponse {
let request_concurrency = state.request_concurrency_snapshot().map(|snapshot| {
json!({
@@ -78,7 +84,7 @@ pub(crate) async fn frontdoor_manifest(State(state): State<AppState>) -> impl In
Json(json!({
"component": "aether-gateway",
"manifest_version": FRONTDOOR_MANIFEST_VERSION,
"version": env!("CARGO_PKG_VERSION"),
"version": current_gateway_version(),
"mode": "compatibility_frontdoor",
"entrypoints": {
"public_manifest": FRONTDOOR_MANIFEST_PATH,

View File

@@ -24,6 +24,42 @@ fn admin_system_build_version_contract_uses_explicit_local_build_arg() {
"Dockerfile.app.local should pass explicit build version pattern {pattern}"
);
}
let deploy = read_workspace_file("deploy.sh");
for pattern in [
"detect_build_version()",
"git describe --tags --always --dirty",
"AETHER_BUILD_VERSION=\"${AETHER_BUILD_VERSION:-$(detect_build_version)}\"",
"--build-arg \"AETHER_BUILD_VERSION=$AETHER_BUILD_VERSION\"",
">>> AETHER_BUILD_VERSION",
] {
assert!(
deploy.contains(pattern),
"deploy.sh should pass deterministic local build version pattern {pattern}"
);
}
let vite_config = read_workspace_file("frontend/vite.config.ts");
for pattern in [
"process.env.AETHER_BUILD_VERSION",
"process.env.AETHER_VERSION",
] {
assert!(
vite_config.contains(pattern),
"frontend/vite.config.ts should consume local build version pattern {pattern}"
);
}
let core_api = read_workspace_file("apps/aether-gateway/src/api/core.rs");
for pattern in [
"option_env!(\"AETHER_BUILD_VERSION\")",
"\"version\": current_gateway_version()",
] {
assert!(
core_api.contains(pattern),
"api/core.rs should expose build version pattern {pattern}"
);
}
}
#[test]