From 0dcd103827162e9a7aa27eb70ec17e5c76da10d7 Mon Sep 17 00:00:00 2001 From: Sivanantham Chinnaiyan Date: Mon, 5 Feb 2024 13:17:43 +0530 Subject: [PATCH] Free up storage in CI Signed-off-by: Sivanantham Chinnaiyan --- .github/actions/free-up-disk-space/action.yml | 41 +++++++++++++++++++ .github/workflows/e2e-test.yml | 4 +- .github/workflows/freeup-space.yml | 22 ++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/freeup-space.yml diff --git a/.github/actions/free-up-disk-space/action.yml b/.github/actions/free-up-disk-space/action.yml index f8a0d42bd8a..7d2ec855528 100644 --- a/.github/actions/free-up-disk-space/action.yml +++ b/.github/actions/free-up-disk-space/action.yml @@ -32,3 +32,44 @@ runs: docker image prune -a -f docker system df df -h + +# - name: Free space using action easimon/maximize-build-space@master +# uses: easimon/maximize-build-space@master +# with: +# root-reserve-mb: 4096 +# remove-dotnet: 'true' +# remove-android: 'true' +# remove-haskell: 'true' +# remove-codeql: 'true' +# remove-docker-images: 'true' + + - name: Free space + shell: bash + run: | + df -Th + + - name: Change docker data directory + shell: bash + run: | + DOCKER_ROOT_DIR=/mnt/docker + sudo mkdir -p "$DOCKER_ROOT_DIR" + # Check if the file exists and contains JSON data + if [ -f /etc/docker/daemon.json ]; then + # Check if the file is empty + if [ -s /etc/docker/daemon.json ]; then + # Append the new configuration to existing JSON data + jq --arg docker_root_dir "$DOCKER_ROOT_DIR" '. + {"data-root": $docker_root_dir}' /etc/docker/daemon.json | sudo tee /etc/docker/daemon.json > /dev/null + else + # If the file is empty, just write the new configuration + echo "{\"data-root\": \"$DOCKER_ROOT_DIR\"}" | sudo tee /etc/docker/daemon.json > /dev/null + fi + else + # If the file doesn't exist, create it and write the new configuration + echo "{\"data-root\": \"$DOCKER_ROOT_DIR\"}" | sudo tee /etc/docker/daemon.json > /dev/null + fi + echo "Modified docker configuration:" + cat /etc/docker/daemon.json + echo "Restarting docker" + sudo systemctl restart docker + echo "Docker root dir" + docker info -f '{{ .DockerRootDir}}' diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index b2e36ef8d90..ef3c0fb0e87 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -5,7 +5,7 @@ on: branches: [master, release*] paths: - "**" - - "!.github/**" +# - "!.github/**" - "!docs/**" - "!**.md" - ".github/workflows/e2e-test.yml" @@ -457,6 +457,8 @@ jobs: needs: [kserve-image-build, predictor-runtime-build, explainer-runtime-build] steps: + - name: Free-up disk space + uses: ./.github/actions/free-up-disk-space - uses: actions/checkout@v3 - uses: actions/setup-go@v4 with: diff --git a/.github/workflows/freeup-space.yml b/.github/workflows/freeup-space.yml new file mode 100644 index 00000000000..8ac7fefe31a --- /dev/null +++ b/.github/workflows/freeup-space.yml @@ -0,0 +1,22 @@ +name: Free up storage space + +on: + pull_request: + +jobs: + freeup-storage: + runs-on: ubuntu-latest + steps: + - name: Before cleanup + run: | + df -Th + + - name: checkout + uses: actions/checkout@v4 + + - name: free up storage + uses: ./github/actions/free-up-disk-space + + - name: After cleanup + run: | + sf -Th