From ca360e063ca2740f07de4225c983b5443810646f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20F=2E=20=C5=A0?= Date: Sat, 9 Dec 2023 14:36:49 +0100 Subject: [PATCH] Introduce better app meta (#36) * Introduce better app meta * Minor fixes --- server/Cargo.lock | 152 +++++++++++++++++++++++++++++++++++++- server/Cargo.toml | 3 - server/build.rs | 29 -------- server/src/routes/root.rs | 19 +---- shared/Cargo.lock | 152 +++++++++++++++++++++++++++++++++++++- shared/Cargo.toml | 4 + shared/build.rs | 3 + shared/src/lib.rs | 3 +- shared/src/meta.rs | 36 +++++++++ worker/Cargo.lock | 152 +++++++++++++++++++++++++++++++++++++- worker/src/lib.rs | 19 +---- 11 files changed, 501 insertions(+), 71 deletions(-) delete mode 100644 server/build.rs create mode 100644 shared/build.rs create mode 100644 shared/src/meta.rs diff --git a/server/Cargo.lock b/server/Cargo.lock index d5a77ba..ce0ba6e 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -258,6 +258,15 @@ version = "0.10.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -325,6 +334,69 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "build-info" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "155eb070980e96aeb4ef3b8620b0febb2ae5e17451dc1b329681bdd4eb0a94e1" +dependencies = [ + "build-info-common", + "build-info-proc", +] + +[[package]] +name = "build-info-build" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b69d6331ec579144d39e1c128f343d23e9b837617df1bed4ed032e141f83f06a" +dependencies = [ + "anyhow", + "base64 0.21.4", + "bincode", + "build-info-common", + "cargo_metadata", + "chrono", + "git2", + "glob", + "pretty_assertions", + "rustc_version", + "serde_json", + "zstd 0.12.4", +] + +[[package]] +name = "build-info-common" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8209c0c2b13da7e5f7202e591b6d41b46c8f0e78d031dedf5cff71cc8c6ec773" +dependencies = [ + "chrono", + "derive_more", + "semver", + "serde", +] + +[[package]] +name = "build-info-proc" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc1874cb1995691fb01f9bb56e75f9660d2614e74607fa71c08a8b3bd7e30e4" +dependencies = [ + "anyhow", + "base64 0.21.4", + "bincode", + "build-info-common", + "chrono", + "num-bigint", + "num-traits", + "proc-macro-error", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.38", + "zstd 0.12.4", +] + [[package]] name = "bumpalo" version = "3.14.0" @@ -563,6 +635,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "core-foundation" version = "0.9.3" @@ -740,8 +818,10 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ + "convert_case", "proc-macro2", "quote", + "rustc_version", "syn 1.0.109", ] @@ -967,6 +1047,8 @@ dependencies = [ "bech32 0.10.0-beta", "blake2", "bs58", + "build-info", + "build-info-build", "chrono", "ciborium", "crc16", @@ -1609,6 +1691,19 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "git2" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" +dependencies = [ + "bitflags 2.4.1", + "libc", + "libgit2-sys", + "log", + "url", +] + [[package]] name = "glob" version = "0.3.1" @@ -2076,6 +2171,30 @@ version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +[[package]] +name = "libgit2-sys" +version = "0.16.1+1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + +[[package]] +name = "libz-sys" +version = "1.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.4.10" @@ -2605,6 +2724,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +[[package]] +name = "pretty_assertions" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +dependencies = [ + "diff", + "yansi", +] + [[package]] name = "prettyplease" version = "0.2.15" @@ -4398,7 +4527,7 @@ dependencies = [ "pbkdf2 0.11.0", "sha1", "time", - "zstd", + "zstd 0.11.2+zstd.1.5.2", ] [[package]] @@ -4407,7 +4536,16 @@ version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "zstd-safe", + "zstd-safe 5.0.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +dependencies = [ + "zstd-safe 6.0.6", ] [[package]] @@ -4420,6 +4558,16 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "zstd-safe" +version = "6.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +dependencies = [ + "libc", + "zstd-sys", +] + [[package]] name = "zstd-sys" version = "2.0.9+zstd.1.5.5" diff --git a/server/Cargo.toml b/server/Cargo.toml index 4b42f16..b9ad4d6 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -53,6 +53,3 @@ serde_with = "3.3.0" bech32 = "0.10.0-alpha" crc32fast = "1.3.2" ciborium = "0.2.1" - -[build-dependencies] -chrono = "0.4.24" diff --git a/server/build.rs b/server/build.rs deleted file mode 100644 index 7e41343..0000000 --- a/server/build.rs +++ /dev/null @@ -1,29 +0,0 @@ -use chrono::prelude::{DateTime, Utc}; -use std::process::Command; - -fn get_git_rev() -> Option { - let output = Command::new("git") - .args(["rev-parse", "--short", "HEAD"]) - .output() - .ok()?; - - if output.status.success() { - String::from_utf8(output.stdout).ok() - } else { - None - } -} - -fn get_compile_date() -> String { - let system_time = std::time::SystemTime::now(); - let date_time: DateTime = system_time.into(); - format!("{}", date_time.format("%+")) -} - -fn main() { - println!("cargo:rustc-env=STATIC_BUILD_DATE={}", get_compile_date()); - - if let Some(rev) = get_git_rev() { - println!("cargo:rustc-env=GIT_REV={}", rev); - } -} diff --git a/server/src/routes/root.rs b/server/src/routes/root.rs index 5d2bf5a..87c62f6 100644 --- a/server/src/routes/root.rs +++ b/server/src/routes/root.rs @@ -1,20 +1,7 @@ use axum::Json; -use std::env; - -#[derive(Debug, serde::Serialize)] -pub struct AppVersion { - rev: String, - name: String, - semver: String, - compile_time: String, -} +use enstate_shared::meta::{AppMeta, APP_META}; #[allow(clippy::unused_async)] -pub async fn get() -> Json { - Json(AppVersion { - rev: env!("GIT_REV").to_string(), - name: env!("CARGO_PKG_NAME").to_string(), - semver: env!("CARGO_PKG_VERSION").to_string(), - compile_time: env!("STATIC_BUILD_DATE").to_string(), - }) +pub async fn get() -> Json { + Json(APP_META.clone()) } diff --git a/shared/Cargo.lock b/shared/Cargo.lock index a60201c..f741cd4 100644 --- a/shared/Cargo.lock +++ b/shared/Cargo.lock @@ -191,6 +191,15 @@ version = "0.10.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -258,6 +267,69 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "build-info" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "155eb070980e96aeb4ef3b8620b0febb2ae5e17451dc1b329681bdd4eb0a94e1" +dependencies = [ + "build-info-common", + "build-info-proc", +] + +[[package]] +name = "build-info-build" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b69d6331ec579144d39e1c128f343d23e9b837617df1bed4ed032e141f83f06a" +dependencies = [ + "anyhow", + "base64 0.21.4", + "bincode", + "build-info-common", + "cargo_metadata", + "chrono", + "git2", + "glob", + "pretty_assertions", + "rustc_version", + "serde_json", + "zstd 0.12.4", +] + +[[package]] +name = "build-info-common" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8209c0c2b13da7e5f7202e591b6d41b46c8f0e78d031dedf5cff71cc8c6ec773" +dependencies = [ + "chrono", + "derive_more", + "semver", + "serde", +] + +[[package]] +name = "build-info-proc" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc1874cb1995691fb01f9bb56e75f9660d2614e74607fa71c08a8b3bd7e30e4" +dependencies = [ + "anyhow", + "base64 0.21.4", + "bincode", + "build-info-common", + "chrono", + "num-bigint", + "num-traits", + "proc-macro-error", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.38", + "zstd 0.12.4", +] + [[package]] name = "bumpalo" version = "3.14.0" @@ -482,6 +554,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "core-foundation" version = "0.9.3" @@ -659,8 +737,10 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ + "convert_case", "proc-macro2", "quote", + "rustc_version", "syn 1.0.109", ] @@ -815,6 +895,8 @@ dependencies = [ "bech32 0.10.0-beta", "blake2", "bs58", + "build-info", + "build-info-build", "chrono", "ciborium", "crc16", @@ -1443,6 +1525,19 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "git2" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" +dependencies = [ + "bitflags 2.4.1", + "libc", + "libgit2-sys", + "log", + "url", +] + [[package]] name = "glob" version = "0.3.1" @@ -1904,6 +1999,30 @@ version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +[[package]] +name = "libgit2-sys" +version = "0.16.1+1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + +[[package]] +name = "libz-sys" +version = "1.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.4.10" @@ -2392,6 +2511,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +[[package]] +name = "pretty_assertions" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +dependencies = [ + "diff", + "yansi", +] + [[package]] name = "prettyplease" version = "0.2.15" @@ -3922,7 +4051,7 @@ dependencies = [ "pbkdf2 0.11.0", "sha1", "time", - "zstd", + "zstd 0.11.2+zstd.1.5.2", ] [[package]] @@ -3931,7 +4060,16 @@ version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "zstd-safe", + "zstd-safe 5.0.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +dependencies = [ + "zstd-safe 6.0.6", ] [[package]] @@ -3944,6 +4082,16 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "zstd-safe" +version = "6.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +dependencies = [ + "libc", + "zstd-sys", +] + [[package]] name = "zstd-sys" version = "2.0.9+zstd.1.5.5" diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 261528b..816daed 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -34,6 +34,7 @@ crc32fast = "1.3.2" hex = "0.4.3" reqwest = "0.11.22" ethers-ccip-read = { git = "https://github.com/ensdomains/ethers-ccip-read" } +build-info = "0.0.34" # needed to enable the "js" feature for compatibility with wasm, # see https://docs.rs/getrandom/#webassembly-support @@ -45,6 +46,9 @@ web-sys = { version = "0.3.63", features = ["console"] } [dev-dependencies] tokio = { version = "1", features = ["full"] } +[build-dependencies] +build-info-build = "0.0.34" + [profile.release] lto = true strip = true diff --git a/shared/build.rs b/shared/build.rs new file mode 100644 index 0000000..d36778f --- /dev/null +++ b/shared/build.rs @@ -0,0 +1,3 @@ +fn main() { + build_info_build::build_script(); +} diff --git a/shared/src/lib.rs b/shared/src/lib.rs index 817f3ab..499e08e 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -1,3 +1,4 @@ +pub mod cache; +pub mod meta; pub mod models; pub mod utils; -pub mod cache; diff --git a/shared/src/meta.rs b/shared/src/meta.rs new file mode 100644 index 0000000..cb818f7 --- /dev/null +++ b/shared/src/meta.rs @@ -0,0 +1,36 @@ +use lazy_static::lazy_static; + +#[derive(Debug, Clone, serde::Serialize)] +pub struct AppMeta { + pub rev: String, + pub name: String, + pub version: String, + pub compile_time: String, +} + +build_info::build_info!(fn build_info); + +lazy_static! { + pub static ref APP_META: AppMeta = gen_app_meta(); +} + +pub fn gen_app_meta() -> AppMeta { + let build_info = build_info(); + let vc_info = build_info.version_control.as_ref().unwrap(); + let info = vc_info.git().unwrap(); + + let commit_id: String = info.commit_id.chars().take(8).collect(); + + let tag = info + .tags + .get(0) + .map(|val| val.to_string()) + .unwrap_or_else(|| format!("git:{}", &commit_id)); + + AppMeta { + rev: commit_id.to_string(), + version: tag, + compile_time: build_info.timestamp.to_string(), + name: "enstate".to_string(), + } +} diff --git a/worker/Cargo.lock b/worker/Cargo.lock index 8bbade8..38289ec 100644 --- a/worker/Cargo.lock +++ b/worker/Cargo.lock @@ -191,6 +191,15 @@ version = "0.10.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -258,6 +267,69 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "build-info" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "155eb070980e96aeb4ef3b8620b0febb2ae5e17451dc1b329681bdd4eb0a94e1" +dependencies = [ + "build-info-common", + "build-info-proc", +] + +[[package]] +name = "build-info-build" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b69d6331ec579144d39e1c128f343d23e9b837617df1bed4ed032e141f83f06a" +dependencies = [ + "anyhow", + "base64 0.21.4", + "bincode", + "build-info-common", + "cargo_metadata", + "chrono", + "git2", + "glob", + "pretty_assertions", + "rustc_version", + "serde_json", + "zstd 0.12.4", +] + +[[package]] +name = "build-info-common" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8209c0c2b13da7e5f7202e591b6d41b46c8f0e78d031dedf5cff71cc8c6ec773" +dependencies = [ + "chrono", + "derive_more", + "semver", + "serde", +] + +[[package]] +name = "build-info-proc" +version = "0.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc1874cb1995691fb01f9bb56e75f9660d2614e74607fa71c08a8b3bd7e30e4" +dependencies = [ + "anyhow", + "base64 0.21.4", + "bincode", + "build-info-common", + "chrono", + "num-bigint", + "num-traits", + "proc-macro-error", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.38", + "zstd 0.12.4", +] + [[package]] name = "bumpalo" version = "3.14.0" @@ -504,6 +576,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "core-foundation" version = "0.9.3" @@ -681,8 +759,10 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ + "convert_case", "proc-macro2", "quote", + "rustc_version", "syn 1.0.109", ] @@ -863,6 +943,8 @@ dependencies = [ "bech32 0.10.0-beta", "blake2", "bs58", + "build-info", + "build-info-build", "chrono", "ciborium", "crc16", @@ -1490,6 +1572,19 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "git2" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" +dependencies = [ + "bitflags 2.4.1", + "libc", + "libgit2-sys", + "log", + "url", +] + [[package]] name = "glob" version = "0.3.1" @@ -1962,6 +2057,30 @@ version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +[[package]] +name = "libgit2-sys" +version = "0.16.1+1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + +[[package]] +name = "libz-sys" +version = "1.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.4.10" @@ -2475,6 +2594,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +[[package]] +name = "pretty_assertions" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +dependencies = [ + "diff", + "yansi", +] + [[package]] name = "prettyplease" version = "0.2.15" @@ -4095,7 +4224,7 @@ dependencies = [ "pbkdf2 0.11.0", "sha1", "time", - "zstd", + "zstd 0.11.2+zstd.1.5.2", ] [[package]] @@ -4104,7 +4233,16 @@ version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "zstd-safe", + "zstd-safe 5.0.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +dependencies = [ + "zstd-safe 6.0.6", ] [[package]] @@ -4117,6 +4255,16 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "zstd-safe" +version = "6.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +dependencies = [ + "libc", + "zstd-sys", +] + [[package]] name = "zstd-sys" version = "2.0.9+zstd.1.5.5" diff --git a/worker/src/lib.rs b/worker/src/lib.rs index 046e4aa..4a51344 100644 --- a/worker/src/lib.rs +++ b/worker/src/lib.rs @@ -1,6 +1,7 @@ -use lazy_static::lazy_static; use std::sync::Arc; +use enstate_shared::meta::gen_app_meta; +use lazy_static::lazy_static; use worker::{event, Context, Cors, Env, Method, Request, Response}; use crate::lookup::LookupType; @@ -15,14 +16,6 @@ lazy_static! { .with_methods(Method::all()); } -#[derive(Debug, serde::Serialize)] -struct AppVersion { - rev: String, - name: String, - semver: String, - compile_time: String, -} - #[event(fetch, respond_with_errors)] async fn main(req: Request, env: Env, _ctx: Context) -> worker::Result { if req.path() == "/" { @@ -45,11 +38,5 @@ async fn main(req: Request, env: Env, _ctx: Context) -> worker::Result } fn root_handler() -> Response { - Response::from_json(&AppVersion { - rev: env!("GIT_REV").to_string(), - name: env!("CARGO_PKG_NAME").to_string(), - semver: env!("CARGO_PKG_VERSION").to_string(), - compile_time: env!("STATIC_BUILD_DATE").to_string(), - }) - .expect("from_json should've succeeded") + Response::from_json(&gen_app_meta()).expect("from_json should've succeeded") }