Complete milestone 09 world integration gate (#75)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use std::path::Path;
|
||||
|
||||
const KEYS: [&str; 3] = ["GRID_USER", "GRID_PASSWORD", "GRID_LOGIN_URL"];
|
||||
const LIVE_OPT_IN: &str = "RUN_LIVE_TESTS";
|
||||
|
||||
fn dotenv_has(path: &Path, key: &str) -> bool {
|
||||
std::fs::read_to_string(path).is_ok_and(|contents| {
|
||||
@@ -22,9 +23,19 @@ fn main() {
|
||||
for key in KEYS {
|
||||
println!("cargo:rerun-if-env-changed={key}");
|
||||
}
|
||||
if KEYS.iter().all(|key| {
|
||||
std::env::var(key).is_ok_and(|value| !value.trim().is_empty()) || dotenv_has(&dotenv, key)
|
||||
}) {
|
||||
println!("cargo:rerun-if-env-changed={LIVE_OPT_IN}");
|
||||
let opted_in = std::env::var(LIVE_OPT_IN).is_ok_and(|value| {
|
||||
matches!(
|
||||
value.trim().to_ascii_lowercase().as_str(),
|
||||
"1" | "true" | "yes"
|
||||
)
|
||||
});
|
||||
if opted_in
|
||||
&& KEYS.iter().all(|key| {
|
||||
std::env::var(key).is_ok_and(|value| !value.trim().is_empty())
|
||||
|| dotenv_has(&dotenv, key)
|
||||
})
|
||||
{
|
||||
println!("cargo:rustc-cfg=live_grid_credentials");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user