From df71e0ee5aa0dcb78c7a24ddf187ebbf2c2b2c46 Mon Sep 17 00:00:00 2001 From: maxkahan Date: Thu, 1 Feb 2024 02:21:43 +0000 Subject: [PATCH] delete caches if they get too large after a run --- .github/workflows/build.yml | 13 ++++++++++--- delete_cache_if_too_big.sh | 9 +++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 delete_cache_if_too_big.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 46b4707b..04d76887 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,6 @@ permissions: env: PANTS_CONFIG_FILES: "pants.ci.toml" - jobs: test: name: Test @@ -48,5 +47,13 @@ jobs: - name: Run tests run: | pants test --use-coverage :: - - name: Run codecov - uses: codecov/codecov-action@v3 + delete-cache-if-too-big: + name: delete-cache + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Delete cache if too big + run: | + delete_cache_if_too_big ~/.cache/nce 512 + delete_cache_if_too_big ~/.cache/pants/named_caches 1024 diff --git a/delete_cache_if_too_big.sh b/delete_cache_if_too_big.sh new file mode 100644 index 00000000..ffc5c611 --- /dev/null +++ b/delete_cache_if_too_big.sh @@ -0,0 +1,9 @@ +function delete_cache_if_too_big() { + path=$1 + limit_mb=$2 + size_mb=$(du -m -d0 "${path}" | cut -f 1) + if (( size_mb > limit_mb )); then + echo "${path} is too large (${size_mb}mb), nuking it." + rm -rf "${path}" + fi + } \ No newline at end of file