From 3550110e577c25f7194090618265cec118ff3610 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 11 May 2023 09:43:13 -0700 Subject: [PATCH] ci: clear the target dir if it gets too big --- .github/workflows/ci.yml | 6 ++++++ script/clear-target-dir-if-larger-than | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 script/clear-target-dir-if-larger-than diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b7cb97efa..27af9e1164 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,6 +62,9 @@ jobs: clean: false submodules: 'recursive' + - name: Limit target directory size + run: script/clear-target-dir-if-larger-than 70 + - name: Run check run: cargo check --workspace @@ -110,6 +113,9 @@ jobs: clean: false submodules: 'recursive' + - name: Limit target directory size + run: script/clear-target-dir-if-larger-than 70 + - name: Determine version and release channel if: ${{ startsWith(github.ref, 'refs/tags/v') }} run: | diff --git a/script/clear-target-dir-if-larger-than b/script/clear-target-dir-if-larger-than new file mode 100755 index 0000000000..59c07f77f7 --- /dev/null +++ b/script/clear-target-dir-if-larger-than @@ -0,0 +1,20 @@ +#!/bin/bash + +set -eu + +if [[ $# < 1 ]]; then + echo "usage: $0 " + exit 1 +fi + +max_size_gb=$1 + +current_size=$(du -s target | cut -f1) +current_size_gb=$(expr ${current_size} / 1024 / 1024) + +echo "target directory size: ${current_size_gb}gb. max size: ${max_size_gb}gb" + +if [[ ${current_size_gb} -gt ${max_size_gb} ]]; then + echo "clearing target directory" + rm -rf target +fi