Skip to content

Commit b0349e9

Browse files
brynaryclaude
andcommitted
feat(cli): surface debug build profile in version output
Non-release builds now append the profile to `fabro --version` (`x.y (sha date debug)`), `fabro version`, and `fabro system info`, so users can tell a local build apart from a shipped release. The API's `SystemInfoResponse` gains a `profile` field so the client can render the server's build profile too. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 65baf12 commit b0349e9

10 files changed

Lines changed: 53 additions & 1 deletion

File tree

docs/api-reference/fabro-api.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4028,6 +4028,9 @@ components:
40284028
build_date:
40294029
type: ["string", "null"]
40304030
description: Build date when available.
4031+
profile:
4032+
type: ["string", "null"]
4033+
description: Cargo build profile (e.g. `release`, `debug`) when available.
40314034
os:
40324035
type: string
40334036
description: Target operating system.

lib/crates/fabro-cli/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,13 @@ fn main() {
2424

2525
let build_date = chrono::Utc::now().format("%Y-%m-%d").to_string();
2626
println!("cargo:rustc-env=FABRO_BUILD_DATE={build_date}");
27+
28+
let profile = std::env::var("PROFILE").unwrap_or_default();
29+
let profile_suffix = if profile == "release" {
30+
String::new()
31+
} else {
32+
format!(" {profile}")
33+
};
34+
println!("cargo:rustc-env=FABRO_BUILD_PROFILE={profile}");
35+
println!("cargo:rustc-env=FABRO_BUILD_PROFILE_SUFFIX={profile_suffix}");
2736
}

lib/crates/fabro-cli/src/args.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub(crate) const LONG_VERSION: &str = concat!(
1414
env!("FABRO_GIT_SHA"),
1515
" ",
1616
env!("FABRO_BUILD_DATE"),
17+
env!("FABRO_BUILD_PROFILE_SUFFIX"),
1718
")"
1819
);
1920

lib/crates/fabro-cli/src/commands/system/info.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ pub(super) async fn info_command(
4343
response.git_sha.as_deref().unwrap_or("unknown"),
4444
response.build_date.as_deref().unwrap_or("unknown")
4545
);
46+
if let Some(profile) = response
47+
.profile
48+
.as_deref()
49+
.filter(|p| !p.is_empty() && *p != "release")
50+
{
51+
println!("Profile: {profile}");
52+
}
4653
println!(
4754
"Platform: {}/{}",
4855
response.os.as_deref().unwrap_or("unknown"),

lib/crates/fabro-cli/src/commands/version.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub(crate) async fn version_command(
3737
version: response.version,
3838
git_sha: response.git_sha,
3939
build_date: response.build_date,
40+
profile: response.profile,
4041
os: response.os,
4142
arch: response.arch,
4243
uptime_secs: response.uptime_secs,
@@ -98,6 +99,7 @@ struct ClientVersionInfo {
9899
version: &'static str,
99100
git_sha: &'static str,
100101
build_date: &'static str,
102+
profile: &'static str,
101103
os: &'static str,
102104
arch: &'static str,
103105
}
@@ -108,6 +110,7 @@ enum ServerVersionInfo {
108110
version: Option<String>,
109111
git_sha: Option<String>,
110112
build_date: Option<String>,
113+
profile: Option<String>,
111114
os: Option<String>,
112115
arch: Option<String>,
113116
uptime_secs: Option<i64>,
@@ -123,11 +126,16 @@ fn client_info() -> ClientVersionInfo {
123126
version: env!("CARGO_PKG_VERSION"),
124127
git_sha: env!("FABRO_GIT_SHA"),
125128
build_date: env!("FABRO_BUILD_DATE"),
129+
profile: env!("FABRO_BUILD_PROFILE"),
126130
os: std::env::consts::OS,
127131
arch: std::env::consts::ARCH,
128132
}
129133
}
130134

135+
fn is_non_release_profile(profile: &str) -> bool {
136+
!profile.is_empty() && profile != "release"
137+
}
138+
131139
fn format_server_target(target: &ServerTarget) -> String {
132140
match target {
133141
ServerTarget::HttpUrl { api_url, .. } => api_url.clone(),
@@ -140,6 +148,7 @@ fn json_output(client: &ClientVersionInfo, server: &ServerVersionInfo) -> Value
140148
"version": client.version,
141149
"git_sha": client.git_sha,
142150
"build_date": client.build_date,
151+
"profile": client.profile,
143152
"os": client.os,
144153
"arch": client.arch,
145154
});
@@ -151,6 +160,7 @@ fn json_output(client: &ClientVersionInfo, server: &ServerVersionInfo) -> Value
151160
version,
152161
git_sha,
153162
build_date,
163+
profile,
154164
os,
155165
arch,
156166
uptime_secs,
@@ -165,6 +175,9 @@ fn json_output(client: &ClientVersionInfo, server: &ServerVersionInfo) -> Value
165175
if let Some(build_date) = build_date {
166176
server_map.insert("build_date".to_string(), Value::String(build_date.clone()));
167177
}
178+
if let Some(profile) = profile {
179+
server_map.insert("profile".to_string(), Value::String(profile.clone()));
180+
}
168181
if let Some(os) = os {
169182
server_map.insert("os".to_string(), Value::String(os.clone()));
170183
}
@@ -193,6 +206,9 @@ fn print_text_output(client: &ClientVersionInfo, server: &ServerVersionInfo) {
193206
println!(" Version: {}", client.version);
194207
println!(" Git SHA: {}", client.git_sha);
195208
println!(" Build Date: {}", client.build_date);
209+
if is_non_release_profile(client.profile) {
210+
println!(" Profile: {}", client.profile);
211+
}
196212
println!(" OS/Arch: {}/{}", client.os, client.arch);
197213
println!();
198214

@@ -202,6 +218,7 @@ fn print_text_output(client: &ClientVersionInfo, server: &ServerVersionInfo) {
202218
version,
203219
git_sha,
204220
build_date,
221+
profile,
205222
os,
206223
arch,
207224
uptime_secs,
@@ -213,6 +230,9 @@ fn print_text_output(client: &ClientVersionInfo, server: &ServerVersionInfo) {
213230
" Build Date: {}",
214231
build_date.as_deref().unwrap_or("unknown")
215232
);
233+
if let Some(profile) = profile.as_deref().filter(|p| is_non_release_profile(p)) {
234+
println!(" Profile: {profile}");
235+
}
216236
println!(
217237
" OS/Arch: {}/{}",
218238
os.as_deref().unwrap_or("unknown"),
@@ -256,6 +276,7 @@ mod tests {
256276
version: Some("1.0.0".into()),
257277
git_sha: None,
258278
build_date: None,
279+
profile: None,
259280
os: None,
260281
arch: None,
261282
uptime_secs: None,
@@ -267,6 +288,7 @@ mod tests {
267288
version: Some("1.2.0".into()),
268289
git_sha: None,
269290
build_date: None,
291+
profile: None,
270292
os: None,
271293
arch: None,
272294
uptime_secs: None,
@@ -281,6 +303,7 @@ mod tests {
281303
version: None,
282304
git_sha: None,
283305
build_date: None,
306+
profile: None,
284307
os: None,
285308
arch: None,
286309
uptime_secs: None,

lib/crates/fabro-server/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ fn main() {
2424

2525
let build_date = chrono::Utc::now().format("%Y-%m-%d").to_string();
2626
println!("cargo:rustc-env=FABRO_BUILD_DATE={build_date}");
27+
28+
let profile = std::env::var("PROFILE").unwrap_or_default();
29+
println!("cargo:rustc-env=FABRO_BUILD_PROFILE={profile}");
2730
}

lib/crates/fabro-server/src/demo/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ pub(crate) async fn get_system_info(
568568
"version": env!("CARGO_PKG_VERSION"),
569569
"git_sha": option_env!("FABRO_GIT_SHA"),
570570
"build_date": option_env!("FABRO_BUILD_DATE"),
571+
"profile": option_env!("FABRO_BUILD_PROFILE"),
571572
"os": std::env::consts::OS,
572573
"arch": std::env::consts::ARCH,
573574
"storage_engine": "slatedb",

lib/crates/fabro-server/src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,7 @@ async fn get_system_info(
12261226
version: Some(FABRO_VERSION.to_string()),
12271227
git_sha: option_env!("FABRO_GIT_SHA").map(str::to_string),
12281228
build_date: option_env!("FABRO_BUILD_DATE").map(str::to_string),
1229+
profile: option_env!("FABRO_BUILD_PROFILE").map(str::to_string),
12291230
os: Some(std::env::consts::OS.to_string()),
12301231
arch: Some(std::env::consts::ARCH.to_string()),
12311232
storage_engine: Some("slatedb".to_string()),

lib/crates/fabro-test/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn find_test_fixtures_dir(start: &Path) -> Option<PathBuf> {
2929
/// Static filters applied to every snapshot.
3030
static INSTA_FILTERS: &[(&str, &str)] = &[
3131
(r"fabro \d+\.\d+\.\d+(?:-[\w.]+)?", "fabro [VERSION]"),
32-
(r"\([0-9a-f]{7} \d{4}-\d{2}-\d{2}\)", "([BUILD])"),
32+
(r"\([0-9a-f]{7} \d{4}-\d{2}-\d{2}(?: \w+)?\)", "([BUILD])"),
3333
(r"\b[0-9A-HJKMNP-TV-Z]{26}\b", "[ULID]"),
3434
(r"in \d+(\.\d+)?(ms|s)", "in [TIME]"),
3535
(

lib/packages/fabro-api-client/src/models/system-info-response.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export interface SystemInfoResponse {
3636
* Build date when available.
3737
*/
3838
'build_date'?: string | null;
39+
/**
40+
* Cargo build profile (e.g. `release`, `debug`) when available.
41+
*/
42+
'profile'?: string | null;
3943
/**
4044
* Target operating system.
4145
*/

0 commit comments

Comments
 (0)