From 7dee7199dcffc44d6b97ac5766f7c53e2c5a1e7c Mon Sep 17 00:00:00 2001 From: LFC Date: Wed, 14 Sep 2022 15:10:10 +0800 Subject: [PATCH] fix: set unittests dir to /tmp can explode grcov's disk (#253) * fix: set unittests dir to /tmp can explode grcov's disk Co-authored-by: luofucong --- .github/workflows/coverage.yml | 5 +++++ .github/workflows/develop.yml | 1 + src/common/telemetry/src/logging.rs | 17 +++++++++++------ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index c907c83f64..801943be5f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -24,6 +24,10 @@ jobs: toolchain: ${{ env.RUST_TOOLCHAIN }} override: true profile: minimal + - name: Cleanup disk + uses: curoky/cleanup-disk-action@v2.0 + with: + retain: 'rust' - name: Execute tests uses: actions-rs/cargo@v1 with: @@ -36,6 +40,7 @@ jobs: GT_S3_BUCKET: ${{ secrets.S3_BUCKET }} GT_S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }} GT_S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} + UNITTEST_LOG_DIR: "__unittest_logs" - name: Gather coverage data id: coverage uses: actions-rs/grcov@v0.1 diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index 4df7451404..0afdda9a41 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -46,6 +46,7 @@ jobs: GT_S3_BUCKET: ${{ secrets.S3_BUCKET }} GT_S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }} GT_S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} + UNITTEST_LOG_DIR: "__unittest_logs" fmt: name: Rustfmt diff --git a/src/common/telemetry/src/logging.rs b/src/common/telemetry/src/logging.rs index 8d128319d5..a9cd69d81e 100644 --- a/src/common/telemetry/src/logging.rs +++ b/src/common/telemetry/src/logging.rs @@ -29,12 +29,17 @@ pub fn init_default_ut_logging() { START.call_once(|| { let mut g = GLOBAL_UT_LOG_GUARD.as_ref().lock().unwrap(); - *g = Some(init_global_logging( - "unittest", - "/tmp/__unittest_logs", - "DEBUG", - false, - )); + + // When running in Github's actions, env "UNITTEST_LOG_DIR" is set to a directory other + // than "/tmp". + // This is to fix the problem that the "/tmp" disk space of action runner's is small, + // if we write testing logs in it, actions would fail due to disk out of space error. + let dir = + env::var("UNITTEST_LOG_DIR").unwrap_or_else(|_| "/tmp/__unittest_logs".to_string()); + + *g = Some(init_global_logging("unittest", &dir, "DEBUG", false)); + + info!("logs dir = {}", dir); }); }