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 <luofucong@greptime.com>
This commit is contained in:
LFC
2022-09-14 15:10:10 +08:00
committed by GitHub
parent 2dbaad9770
commit 7dee7199dc
3 changed files with 17 additions and 6 deletions

View File

@@ -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

View File

@@ -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

View File

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