Skip to content

Commit

Permalink
Disable color log on CI (#2002)
Browse files Browse the repository at this point in the history
  • Loading branch information
soareschen authored Mar 23, 2022
1 parent 20e5fe6 commit 06cff57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -- \
Expand Down Expand Up @@ -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 -- \
Expand Down Expand Up @@ -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 \
Expand Down
17 changes: 12 additions & 5 deletions tools/test-framework/src/bootstrap/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ static INIT: Once = Once::new();
read the environment variables and return a [`TestConfig`].
*/
pub fn init_test() -> Result<TestConfig, Error> {
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());
Expand Down Expand Up @@ -59,7 +64,7 @@ pub fn init_test() -> Result<TestConfig, Error> {
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"));

Expand All @@ -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();
}

0 comments on commit 06cff57

Please sign in to comment.