feat: --version flag with git hash + test script kill fix
Some checks failed
Build Release Binaries / build-amd64 (push) Failing after 2m9s
Mirror to GitHub / mirror (push) Failing after 32s

wzp-relay --version prints "wzp-relay <short-git-hash>".
Build hash also logged on startup: version=abc1234.
Enables verifying deployed relay matches expected build.

Also fixed federation-test.sh: use kill -INT (not SIGTERM) so
clients save recordings before exit. Added save delay.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-04-08 12:36:33 +04:00
parent c8a3aaacb6
commit 8dbda3e052
3 changed files with 32 additions and 6 deletions

18
crates/wzp-relay/build.rs Normal file
View File

@@ -0,0 +1,18 @@
use std::process::Command;
fn main() {
// Get git hash at build time
let output = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output();
let hash = match output {
Ok(o) if o.status.success() => {
String::from_utf8_lossy(&o.stdout).trim().to_string()
}
_ => "unknown".to_string(),
};
println!("cargo:rustc-env=WZP_BUILD_HASH={hash}");
println!("cargo:rerun-if-changed=.git/HEAD");
}

View File

@@ -135,6 +135,10 @@ fn parse_args() -> CliResult {
args.get(i).expect("--debug-tap requires a room name (or '*' for all)").to_string(),
);
}
"--version" | "-V" => {
println!("wzp-relay {}", env!("WZP_BUILD_HASH"));
std::process::exit(0);
}
"--mesh-status" => {
// Print mesh table from a fresh registry and exit.
// In practice this is useful after the relay has been running;
@@ -257,10 +261,14 @@ fn detect_public_ip() -> Option<String> {
None
}
/// Build-time git hash, set by build.rs or env.
const BUILD_GIT_HASH: &str = env!("WZP_BUILD_HASH");
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let CliResult { mut config, identity_path, config_file, config_needs_create } = parse_args();
tracing_subscriber::fmt().init();
info!(version = BUILD_GIT_HASH, "wzp-relay build");
rustls::crypto::ring::default_provider()
.install_default()
.expect("failed to install rustls crypto provider");

View File

@@ -112,7 +112,7 @@ PIDS+=($!); sleep 2
RUST_LOG=error $CLIENT --room $ROOM --seed $SEED_A --send-tone $DURATION "$RELAY1" &
PIDS+=($!); sleep $((DURATION + 3))
kill ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null; wait ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null || true
kill -INT ${PIDS[-2]} 2>/dev/null; sleep 3; kill -INT ${PIDS[-1]} 2>/dev/null; wait ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null || true
PIDS=("${PIDS[@]:0:${#PIDS[@]}-2}")
analyze "$RESULTS/t1_b.raw" "Relay1→Relay2 audio"
@@ -129,7 +129,7 @@ PIDS+=($!); sleep 2
RUST_LOG=error $CLIENT --room $ROOM --seed $SEED_B --send-tone $DURATION "$RELAY2" &
PIDS+=($!); sleep $((DURATION + 3))
kill ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null; wait ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null || true
kill -INT ${PIDS[-2]} 2>/dev/null; sleep 3; kill -INT ${PIDS[-1]} 2>/dev/null; wait ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null || true
PIDS=("${PIDS[@]:0:${#PIDS[@]}-2}")
analyze "$RESULTS/t2_a.raw" "Relay2→Relay1 audio"
@@ -146,7 +146,7 @@ PIDS+=($!); sleep 2
RUST_LOG=error $CLIENT --room $ROOM --seed $SEED_A --send-tone $DURATION "$RELAY1" &
PIDS+=($!); sleep $((DURATION + 3))
kill ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null; wait ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null || true
kill -INT ${PIDS[-2]} 2>/dev/null; sleep 3; kill -INT ${PIDS[-1]} 2>/dev/null; wait ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null || true
PIDS=("${PIDS[@]:0:${#PIDS[@]}-2}")
analyze "$RESULTS/t3_c.raw" "Relay1→Relay3 (via Relay2) audio"
@@ -163,7 +163,7 @@ PIDS+=($!); sleep 2
RUST_LOG=error $CLIENT --room $ROOM --seed $SEED_A --send-file "$AUDIO" "$RELAY1" &
PIDS+=($!); sleep 20 # file is 60s but we only wait 20
kill ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null; wait ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null || true
kill -INT ${PIDS[-2]} 2>/dev/null; sleep 3; kill -INT ${PIDS[-1]} 2>/dev/null; wait ${PIDS[-1]} ${PIDS[-2]} 2>/dev/null || true
PIDS=("${PIDS[@]:0:${#PIDS[@]}-2}")
analyze "$RESULTS/t4_b.raw" "File playback Relay1→Relay2"
@@ -193,7 +193,7 @@ RUST_LOG=error $CLIENT --room $ROOM --seed $SEED_B --record "$RESULTS/t5_b_rejoi
B_PID=$!; PIDS+=($B_PID)
sleep 8
kill -INT $B_PID 2>/dev/null; wait $B_PID 2>/dev/null || true
kill $A_PID 2>/dev/null; wait $A_PID 2>/dev/null || true
kill -INT $A_PID 2>/dev/null; wait $A_PID 2>/dev/null || true
analyze "$RESULTS/t5_b_first.raw" "B first join (before disconnect)"
analyze "$RESULTS/t5_b_rejoin.raw" "B rejoin (after disconnect)"
@@ -213,7 +213,7 @@ PIDS+=($!); sleep $((DURATION + 3))
# Kill all 3
for i in 1 2 3; do
kill ${PIDS[-$i]} 2>/dev/null || true
kill -INT ${PIDS[-$i]} 2>/dev/null || true
done
wait 2>/dev/null || true
PIDS=()