From 11faf75073c9ffbc31bc863c0488a34f0482e0bb Mon Sep 17 00:00:00 2001 From: Eric Harris-Braun Date: Wed, 13 Feb 2019 22:26:29 -0500 Subject: [PATCH] added HC_SCAFFOLD_VERSION env var --- cli/src/cli/scaffold/rust.rs | 10 ++++++++-- cli/src/cli/test.rs | 6 ++---- common/src/env_vars.rs | 5 +++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cli/src/cli/scaffold/rust.rs b/cli/src/cli/scaffold/rust.rs index b54bbcb077..73148d5cb0 100644 --- a/cli/src/cli/scaffold/rust.rs +++ b/cli/src/cli/scaffold/rust.rs @@ -4,6 +4,7 @@ use crate::{ error::DefaultResult, util, }; +use holochain_common::env_vars::EnvVar; use holochain_wasm_utils::wasm_target_dir; use std::{ fs::{self, OpenOptions}, @@ -27,8 +28,13 @@ fn generate_cargo_toml(name: &str, contents: &str) -> DefaultResult { let authors_default = Value::from("[\"TODO\"]"); let edition_default = Value::from("\"TODO\""); - // does this need changing? maybe a tag instead? - let version_default = String::from("branch = \"develop\""); + + let maybe_version = EnvVar::ScaffoldVersion.value().ok(); + let version_default = if maybe_version.is_some() { + maybe_version.unwrap() + } else { + String::from("tag = \"v0.0.4-alpha\"") + }; let maybe_package = config.get("package"); let name = Value::from(name); diff --git a/cli/src/cli/test.rs b/cli/src/cli/test.rs index 176598a08f..86adb0f0e0 100644 --- a/cli/src/cli/test.rs +++ b/cli/src/cli/test.rs @@ -71,10 +71,8 @@ pub mod tests { #[test] // flagged as broken for: // 1. taking 60+ seconds - // 2. because `generate_cargo_toml` in cli/src/scaffold/rust.rs sets the - // branch to a fixed value rather than develop and currently there's no way to - // adjust that on the fly. - // 3. because holochain-nodejs version doesn't exist yet + // NOTE, before re-enabling make sure to add an environment variable + // HC_SCAFFOLD_VERSION='branch="develop"' when you run the test. #[cfg(feature = "broken-tests")] fn test_command_basic_test() { let temp_dir = gen_dir(); diff --git a/common/src/env_vars.rs b/common/src/env_vars.rs index 617a4a6c84..0fafdf329f 100644 --- a/common/src/env_vars.rs +++ b/common/src/env_vars.rs @@ -19,6 +19,9 @@ //! - **NETWORKING_CONFIG_FILE** *string* Path to a JSON file containing configuration for the n3h networking module. More on this soon. Recommended to //! not use this as this time. //! +//! ### `hc generate` +//! - HC_SCAFFOLD_VERSION allows you to set a string value to be used in the generated Cargo.toml. We use this override the default which points to the current version tag, which a pointer to the develop branch for our CI tests, so for example in CI we can run our tests with: `HC_SCAFFOLD_VERSION='branch="develop"'` and that overrides the default. +//! //! ### Other //! - **HC_SIMPLE_LOGGER_MUTE** *int* Setting this value to 1 will silence the log output of a SimpleLogger. Use with any Conductor. @@ -36,6 +39,7 @@ pub enum EnvVar { N3hBootstrapNode, NetworkingConfigFile, SimpleLoggerMute, + ScaffoldVersion, } impl EnvVar { @@ -49,6 +53,7 @@ impl EnvVar { EnvVar::N3hBootstrapNode => "HC_N3H_BOOTSTRAP_NODE", EnvVar::NetworkingConfigFile => "NETWORKING_CONFIG_FILE", EnvVar::SimpleLoggerMute => "HC_SIMPLE_LOGGER_MUTE", + EnvVar::ScaffoldVersion => "HC_SCAFFOLD_VERSION", } }