Skip to content

Commit

Permalink
delete caches if they get too large after a run
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkahan committed Feb 1, 2024
1 parent ae737d1 commit df71e0e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ permissions:
env:
PANTS_CONFIG_FILES: "pants.ci.toml"


jobs:
test:
name: Test
Expand Down Expand Up @@ -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
9 changes: 9 additions & 0 deletions delete_cache_if_too_big.sh
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit df71e0e

Please sign in to comment.