Skip to content

Commit

Permalink
cargo-ci -> Remove lazy_static in favor of LazyLock.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbfm committed Jan 8, 2025
1 parent 11f413a commit e209fcd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 28 deletions.
1 change: 0 additions & 1 deletion .ci/cargo-ci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ clap = { workspace = true, features = ["derive", "string"] }
flate2 = { workspace = true }
fs-err = { workspace = true }
fs_extra = { workspace = true }
lazy_static = { workspace = true }
predicates = { workspace = true }
reqwest = { workspace = true, features = ["blocking"] }
shadow-rs = { workspace = true }
Expand Down
29 changes: 14 additions & 15 deletions .ci/cargo-ci/src/core/constants.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
use std::path::{PathBuf, Path};
use std::path::{Path, PathBuf};
use std::sync::LazyLock;

use lazy_static::lazy_static;
static WORKSPACE_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
let output = std::process::Command::new(env!("CARGO"))
.arg("locate-project")
.arg("--workspace")
.arg("--message-format=plain")
.output()
.unwrap()
.stdout;

lazy_static! {
static ref WORKSPACE_DIR: PathBuf = {
let output = std::process::Command::new(env!("CARGO"))
.arg("locate-project")
.arg("--workspace")
.arg("--message-format=plain")
.output()
.unwrap()
.stdout;
let cargo_path = Path::new(std::str::from_utf8(&output).unwrap().trim());
cargo_path.parent().unwrap().to_path_buf()
};
}
let cargo_path = Path::new(std::str::from_utf8(&output).unwrap().trim());

cargo_path.parent().unwrap().to_path_buf()
});

/// The root of the Cargo Workspace. Should be the repository root.
pub fn workspace_dir() -> PathBuf {
Expand Down
16 changes: 7 additions & 9 deletions .ci/cargo-ci/src/core/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use std::sync::LazyLock;
use cargo_metadata::Package;
use lazy_static::lazy_static;

lazy_static! {
static ref CARGO_METADATA: cargo_metadata::Metadata = {
cargo_metadata::MetadataCommand::new()
.manifest_path(crate::constants::workspace_dir().join("Cargo.toml"))
.exec()
.expect("Failed to gather Cargo metadata.")
};
}
static CARGO_METADATA: LazyLock<cargo_metadata::Metadata> = LazyLock::new(||
cargo_metadata::MetadataCommand::new()
.manifest_path(crate::constants::workspace_dir().join("Cargo.toml"))
.exec()
.expect("Failed to gather Cargo metadata.")
);

pub fn cargo() -> cargo_metadata::Metadata {
CARGO_METADATA.to_owned()
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resolver = "2"
[workspace.package]
version = "0.5.0-alpha"
edition = "2021"
rust-version = "1.78"
rust-version = "1.80"
license = "Apache-2.0"
repository = "https://github.com/eclipse-opendut/opendut"

Expand Down Expand Up @@ -89,7 +89,6 @@ hyper-util = "0.1.6"
indicatif = "0.17.7"
indoc = "2.0.4"
jsonwebtoken = "9.2.0"
lazy_static = "1.4.0"
leptos = { version = "0.6.15" }
leptos_oidc = { version = "0.4.0" }
leptos_router = { version = "0.6.15" }
Expand Down

0 comments on commit e209fcd

Please sign in to comment.