From 06cff5763459dd8ebf054131cc146a1b9a441358 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Wed, 23 Mar 2022 13:48:31 +0100 Subject: [PATCH] Disable color log on CI (#2002) --- .github/workflows/integration.yaml | 3 +++ tools/test-framework/src/bootstrap/init.rs | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 7b03a6c061..98c3fab70f 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -69,6 +69,7 @@ jobs: - env: RUST_LOG: info RUST_BACKTRACE: 1 + NO_COLOR_LOG: 1 run: | nix shell github:informalsystems/cosmos.nix#${{ matrix.gaiad }} -c cargo \ test -p ibc-integration-test --no-fail-fast -- \ @@ -135,6 +136,7 @@ jobs: - env: RUST_LOG: info RUST_BACKTRACE: 1 + NO_COLOR_LOG: 1 run: | nix shell github:informalsystems/cosmos.nix#gaia6-ordered -c cargo \ test -p ibc-integration-test --features ordered --no-fail-fast -- \ @@ -165,6 +167,7 @@ jobs: - env: RUST_LOG: info RUST_BACKTRACE: 1 + NO_COLOR_LOG: 1 CHAIN_COMMAND_PATH: icad run: | nix shell github:informalsystems/cosmos.nix#ica -c cargo \ diff --git a/tools/test-framework/src/bootstrap/init.rs b/tools/test-framework/src/bootstrap/init.rs index cdbff03f07..0dfc120c62 100644 --- a/tools/test-framework/src/bootstrap/init.rs +++ b/tools/test-framework/src/bootstrap/init.rs @@ -25,11 +25,16 @@ static INIT: Once = Once::new(); read the environment variables and return a [`TestConfig`]. */ pub fn init_test() -> Result { + let no_color_log = env::var("NO_COLOR_LOG") + .ok() + .map(|val| val == "1") + .unwrap_or(false); + INIT.call_once(|| { - if enable_ansi() { + if enable_ansi() && !no_color_log { color_eyre::install().unwrap(); } - install_logger(); + install_logger(!no_color_log); }); let chain_command_path = env::var("CHAIN_COMMAND_PATH").unwrap_or_else(|_| "gaiad".to_string()); @@ -59,7 +64,7 @@ pub fn init_test() -> Result { Install the [`tracing_subscriber`] logger handlers so that logs will be displayed during test. */ -pub fn install_logger() { +pub fn install_logger(with_color: bool) { // Use log level INFO by default if RUST_LOG is not set. let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")); @@ -68,7 +73,9 @@ pub fn install_logger() { None => false, }); - let module_filter = ts::fmt::layer().with_filter(module_filter_fn); + let layer = ts::fmt::layer() + .with_ansi(with_color) + .with_filter(module_filter_fn); - ts::registry().with(env_filter).with(module_filter).init(); + ts::registry().with(env_filter).with(layer).init(); }