Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ features = ["now"]

[workspace.dependencies.clap]
version = "4.3"
features = ["derive"]
features = ["derive", "cargo"]

[workspace.dependencies.rivet-term]
git = "https://github.com/rivet-dev/rivet-term"
Expand Down
2 changes: 0 additions & 2 deletions engine/packages/api-public/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ utoipa.workspace = true
[build-dependencies]
anyhow.workspace = true
fs_extra.workspace = true
vergen.workspace = true
vergen-gitcl.workspace = true
8 changes: 0 additions & 8 deletions engine/packages/api-public/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ use std::fs;
use std::path::Path;

fn main() -> Result<()> {
// Configure vergen to emit build metadata
vergen::Emitter::default()
.add_instructions(&vergen::BuildBuilder::all_build()?)?
.add_instructions(&vergen::CargoBuilder::all_cargo()?)?
.add_instructions(&vergen::RustcBuilder::all_rustc()?)?
.add_instructions(&vergen_gitcl::GitclBuilder::all_git()?)?
.emit()?;

let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let out_dir = env::var("OUT_DIR").unwrap();
let ui_dir = Path::new(&out_dir).join("ui");
Expand Down
17 changes: 9 additions & 8 deletions engine/packages/api-public/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use axum::Json;
use axum::response::IntoResponse;
use rivet_api_builder::extract::Extension;
use rivet_util::build_meta;
use serde_json::json;

use crate::ctx::ApiCtx;
Expand All @@ -11,13 +12,13 @@ pub async fn get_metadata(Extension(ctx): Extension<ApiCtx>) -> impl IntoRespons
ctx.skip_auth();

Json(json!({
"runtime": "engine",
"version": env!("CARGO_PKG_VERSION"),
"git_sha": env!("VERGEN_GIT_SHA"),
"build_timestamp": env!("VERGEN_BUILD_TIMESTAMP"),
"rustc_version": env!("VERGEN_RUSTC_SEMVER"),
"rustc_host": env!("VERGEN_RUSTC_HOST_TRIPLE"),
"cargo_target": env!("VERGEN_CARGO_TARGET_TRIPLE"),
"cargo_profile": if env!("VERGEN_CARGO_DEBUG") == "true" { "debug" } else { "release" }
"runtime": build_meta::RUNTIME,
"version": build_meta::VERSION,
"git_sha": build_meta::GIT_SHA,
"build_timestamp": build_meta::BUILD_TIMESTAMP,
"rustc_version": build_meta::RUSTC_VERSION,
"rustc_host": build_meta::RUSTC_HOST,
"cargo_target": build_meta::CARGO_TARGET,
"cargo_profile": build_meta::cargo_profile()
}))
}
1 change: 1 addition & 0 deletions engine/packages/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ hex.workspace = true
include_dir.workspace = true
indoc.workspace = true
lz4_flex.workspace = true
once_cell.workspace = true
pegboard-runner.workspace = true
pegboard-serverless.workspace = true
reqwest.workspace = true
Expand Down
17 changes: 16 additions & 1 deletion engine/packages/engine/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@ use std::{path::PathBuf, sync::Arc};

use anyhow::*;
use clap::Parser;
use once_cell::sync::Lazy;
use rivet_engine::{SubCommand, run_config};
use rivet_util::build_meta;

static LONG_VERSION: Lazy<String> = Lazy::new(|| {
format!(
"{}\nGit SHA: {}\nBuild Timestamp: {}\nRustc Version: {}\nRustc Host: {}\nCargo Target: {}\nCargo Profile: {}",
build_meta::VERSION,
build_meta::GIT_SHA,
build_meta::BUILD_TIMESTAMP,
build_meta::RUSTC_VERSION,
build_meta::RUSTC_HOST,
build_meta::CARGO_TARGET,
build_meta::cargo_profile()
)
});

#[derive(Parser)]
#[command(name = "Rivet", version, about)]
#[command(name = "Rivet", version, long_version = LONG_VERSION.as_str(), about)]
struct Cli {
#[command(subcommand)]
command: SubCommand,
Expand Down
5 changes: 5 additions & 0 deletions engine/packages/util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ tracing.workspace = true
url.workspace = true
uuid.workspace = true
utoipa.workspace = true

[build-dependencies]
anyhow.workspace = true
vergen.workspace = true
vergen-gitcl.workspace = true
13 changes: 13 additions & 0 deletions engine/packages/util/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use anyhow::Result;

fn main() -> Result<()> {
// Configure vergen to emit build metadata
vergen::Emitter::default()
.add_instructions(&vergen::BuildBuilder::all_build()?)?
.add_instructions(&vergen::CargoBuilder::all_cargo()?)?
.add_instructions(&vergen::RustcBuilder::all_rustc()?)?
.add_instructions(&vergen_gitcl::GitclBuilder::all_git()?)?
.emit()?;

Ok(())
}
33 changes: 33 additions & 0 deletions engine/packages/util/src/build_meta.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/// Runtime identifier for the engine
pub const RUNTIME: &str = "engine";

/// Package version from Cargo.toml
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

/// Git commit SHA
pub const GIT_SHA: &str = env!("VERGEN_GIT_SHA");

/// Build timestamp
pub const BUILD_TIMESTAMP: &str = env!("VERGEN_BUILD_TIMESTAMP");

/// Rustc version used to compile
pub const RUSTC_VERSION: &str = env!("VERGEN_RUSTC_SEMVER");

/// Rustc host triple
pub const RUSTC_HOST: &str = env!("VERGEN_RUSTC_HOST_TRIPLE");

/// Cargo target triple
pub const CARGO_TARGET: &str = env!("VERGEN_CARGO_TARGET_TRIPLE");

/// Cargo debug flag as string
const CARGO_DEBUG: &str = env!("VERGEN_CARGO_DEBUG");

/// Cargo profile (debug or release)
/// Returns "debug" if VERGEN_CARGO_DEBUG is "true", otherwise "release"
pub fn cargo_profile() -> &'static str {
if CARGO_DEBUG == "true" {
"debug"
} else {
"release"
}
}
1 change: 1 addition & 0 deletions engine/packages/util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub use rivet_util_id as id;

pub mod backoff;
pub mod billing;
pub mod build_meta;
pub mod check;
pub mod duration;
pub mod faker;
Expand Down
Loading