Skip to content

Commit d9d781e

Browse files
authored
chore(api-public): return build metadata (#3278)
1 parent 8fda8a4 commit d9d781e

File tree

5 files changed

+105
-7
lines changed

5 files changed

+105
-7
lines changed

Cargo.lock

Lines changed: 81 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ tracing = "0.1.40"
8282
tracing-core = "0.1"
8383
tracing-opentelemetry = "0.29"
8484
tracing-slog = "0.2"
85-
vergen = "9.0.4"
85+
vergen = { version = "9.0.4", features = ["build", "cargo", "rustc"] }
86+
vergen-gitcl = "1.0.0"
8687
reqwest-eventsource = "0.6.0"
8788

8889
[workspace.dependencies.sentry]

engine/packages/api-public/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@ tracing.workspace = true
3333
utoipa.workspace = true
3434

3535
[build-dependencies]
36+
anyhow.workspace = true
3637
fs_extra.workspace = true
38+
vergen.workspace = true
39+
vergen-gitcl.workspace = true

engine/packages/api-public/build.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
use anyhow::Result;
12
use fs_extra::dir;
23
use std::env;
34
use std::fs;
45
use std::path::Path;
56

6-
fn main() {
7+
fn main() -> Result<()> {
8+
// Configure vergen to emit build metadata
9+
vergen::Emitter::default()
10+
.add_instructions(&vergen::BuildBuilder::all_build()?)?
11+
.add_instructions(&vergen::CargoBuilder::all_cargo()?)?
12+
.add_instructions(&vergen::RustcBuilder::all_rustc()?)?
13+
.add_instructions(&vergen_gitcl::GitclBuilder::all_git()?)?
14+
.emit()?;
15+
716
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
817
let out_dir = env::var("OUT_DIR").unwrap();
918
let ui_dir = Path::new(&out_dir).join("ui");
@@ -39,4 +48,6 @@ fn main() {
3948

4049
fs::write(index_html_path, index_html_content).expect("Failed to write index.html");
4150
}
51+
52+
Ok(())
4253
}

engine/packages/api-public/src/metadata.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ pub async fn get_metadata(Extension(ctx): Extension<ApiCtx>) -> impl IntoRespons
1212

1313
Json(json!({
1414
"runtime": "engine",
15-
"version": env!("CARGO_PKG_VERSION")
15+
"version": env!("CARGO_PKG_VERSION"),
16+
"git_sha": env!("VERGEN_GIT_SHA"),
17+
"build_timestamp": env!("VERGEN_BUILD_TIMESTAMP"),
18+
"rustc_version": env!("VERGEN_RUSTC_SEMVER"),
19+
"rustc_host": env!("VERGEN_RUSTC_HOST_TRIPLE"),
20+
"cargo_target": env!("VERGEN_CARGO_TARGET_TRIPLE"),
21+
"cargo_profile": if env!("VERGEN_CARGO_DEBUG") == "true" { "debug" } else { "release" }
1622
}))
1723
}

0 commit comments

Comments
 (0)