Skip to content

Commit 4f3f929

Browse files
committed
disk and docker clean up in between jobs
1 parent c12e69f commit 4f3f929

6 files changed

Lines changed: 178 additions & 14 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: cleanup-runner-disk
2+
description: "Free disk on GitHub-hosted runners (docker + caches)"
3+
inputs:
4+
aggressive:
5+
description: "Remove large hostedtoolcache components (dotnet/codeql/etc)"
6+
required: false
7+
default: "false"
8+
show-df:
9+
description: "Show disk usage before/after"
10+
required: false
11+
default: "true"
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Cleanup disk
16+
shell: bash
17+
env:
18+
AGGRESSIVE: ${{ inputs.aggressive }}
19+
SHOW_DF: ${{ inputs.show-df }}
20+
run: |
21+
set -euxo pipefail
22+
23+
if [[ "${SHOW_DF}" == "true" ]]; then
24+
echo "=== Disk usage BEFORE ==="
25+
df -h /
26+
docker system df || true
27+
fi
28+
29+
# Docker / build caches
30+
docker ps -a || true
31+
docker system prune -af --volumes || true
32+
docker builder prune -af || true
33+
docker image prune -af || true
34+
docker volume prune -f || true
35+
36+
# Package managers / language caches
37+
sudo apt-get clean || true
38+
sudo rm -rf /var/lib/apt/lists/* /var/cache/apt/archives || true
39+
rm -rf ~/.cache/pip ~/.npm ~/.cache/pip-tools ~/.cache/yarn ~/.cache/uv || true
40+
41+
# Hosted tool caches (optionally purge heavy directories ~20-30GB)
42+
if [[ "${AGGRESSIVE}" == "true" ]]; then
43+
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android /opt/hostedtoolcache/CodeQL || true
44+
fi
45+
46+
if [[ "${SHOW_DF}" == "true" ]]; then
47+
echo "=== Disk usage AFTER ==="
48+
df -h /
49+
docker system df || true
50+
fi

.github/workflows/build-citus-community-nightlies.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
strategy:
2929
fail-fast: false
30+
max-parallel: 3 # limit concurrent docker builds to reduce overlay pressure
3031
matrix:
3132
platform:
3233
- el/8
@@ -54,12 +55,23 @@ jobs:
5455
run: git clone -b "${MAIN_BRANCH}" --depth=1 https://github.com/citusdata/packaging.git packaging
5556

5657
- name: Install package dependencies
57-
run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev python3-testresources
58+
run: |
59+
sudo apt-get update
60+
sudo apt-get install --no-install-recommends -y libcurl4-openssl-dev libssl-dev python3-testresources
61+
sudo apt-get clean
62+
sudo rm -rf /var/lib/apt/lists/*
63+
64+
- name: Disk usage before build
65+
run: |
66+
df -h /
67+
docker system df || true
5868
5969
- name: Install python requirements
6070
run: python -m pip install -r tools/packaging_automation/requirements.txt
6171

6272
- name: Build packages
73+
env:
74+
DOCKER_BUILDKIT: 1
6375
run: |
6476
python -m tools.packaging_automation.citus_package \
6577
--gh_token "${GH_TOKEN}" \
@@ -80,3 +92,14 @@ jobs:
8092
--output_file_path "$(pwd)/packages" \
8193
--current_branch "${GITHUB_REF##*/}" \
8294
--main_branch "develop"
95+
96+
- name: Remove build artifacts
97+
if: always()
98+
run: |
99+
rm -rf tools packaging packages dist build .pytest_cache || true
100+
101+
- name: Cleanup docker cache and free disk
102+
if: always()
103+
uses: ./.github/actions/cleanup-runner-disk
104+
with:
105+
aggressive: true

.github/workflows/build-package-test.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
runs-on: ubuntu-latest
3939
strategy:
4040
fail-fast: false
41+
max-parallel: 3 # limit concurrent docker builds to reduce overlay pressure
4142
matrix:
4243
TARGET_PLATFORM:
4344
- oraclelinux,8
@@ -61,19 +62,29 @@ jobs:
6162
uses: actions/checkout@v2
6263

6364
- name: Install package dependencies
64-
run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev python3-testresources
65+
run: |
66+
sudo apt-get update
67+
sudo apt-get install --no-install-recommends -y libcurl4-openssl-dev libssl-dev python3-testresources
68+
sudo apt-get clean
69+
sudo rm -rf /var/lib/apt/lists/*
70+
71+
- name: Disk usage before build
72+
run: |
73+
df -h /
74+
docker system df || true
6575
6676
- name: Install wheel for el/8
6777
if: matrix.TARGET_PLATFORM == 'centos,8'
6878
run: python -m pip install wheel
6979

7080
- name: Build image for the target platform
71-
run: |
72-
git checkout -- dockerfiles
73-
./update_image
7481
env:
7582
TARGET_PLATFORM: ${{ matrix.TARGET_PLATFORM }}
7683
POSTGRES_VERSION: ${{ matrix.POSTGRES_VERSION }}
84+
DOCKER_BUILDKIT: 1
85+
run: |
86+
git checkout -- dockerfiles
87+
./update_image
7788
7889
- name: Clone tools repo for test
7990
run: git clone -b v0.8.35 --depth=1 https://github.com/citusdata/tools.git tools
@@ -92,3 +103,15 @@ jobs:
92103
env:
93104
TARGET_PLATFORM: ${{ matrix.TARGET_PLATFORM }}
94105
POSTGRES_VERSION: ${{ matrix.POSTGRES_VERSION }}
106+
107+
- name: Remove build artifacts
108+
if: always()
109+
run: |
110+
rm -rf tools packages dist build .pytest_cache || true
111+
112+
- name: Cleanup docker cache and free disk
113+
if: always()
114+
uses: ./.github/actions/cleanup-runner-disk
115+
with:
116+
aggressive: true
117+

.github/workflows/build-package.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
runs-on: ubuntu-latest
3939
strategy:
4040
fail-fast: false
41+
max-parallel: 3 # limit concurrent docker builds to reduce overlay pressure
4142
matrix:
4243
TARGET_PLATFORM:
4344
- oraclelinux,8
@@ -61,19 +62,29 @@ jobs:
6162
uses: actions/checkout@v2
6263

6364
- name: Install package dependencies
64-
run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev python3-testresources
65+
run: |
66+
sudo apt-get update
67+
sudo apt-get install --no-install-recommends -y libcurl4-openssl-dev libssl-dev python3-testresources
68+
sudo apt-get clean
69+
sudo rm -rf /var/lib/apt/lists/*
70+
71+
- name: Disk usage before build
72+
run: |
73+
df -h /
74+
docker system df || true
6575
6676
- name: Install wheel for el/8
6777
if: matrix.TARGET_PLATFORM == 'centos,8'
6878
run: python -m pip install wheel
6979

7080
- name: Build image for the target platform
71-
run: |
72-
git checkout -- dockerfiles
73-
./update_image
7481
env:
7582
TARGET_PLATFORM: ${{ matrix.TARGET_PLATFORM }}
7683
POSTGRES_VERSION: ${{ matrix.POSTGRES_VERSION }}
84+
DOCKER_BUILDKIT: 1
85+
run: |
86+
git checkout -- dockerfiles
87+
./update_image
7788
7889
- name: Clone tools repo for test
7990
run: git clone -b v0.8.35 --depth=1 https://github.com/citusdata/tools.git tools
@@ -92,3 +103,15 @@ jobs:
92103
env:
93104
TARGET_PLATFORM: ${{ matrix.TARGET_PLATFORM }}
94105
POSTGRES_VERSION: ${{ matrix.POSTGRES_VERSION }}
106+
107+
- name: Remove build artifacts
108+
if: always()
109+
run: |
110+
rm -rf tools packages dist build .pytest_cache || true
111+
112+
- name: Cleanup docker cache and free disk
113+
if: always()
114+
uses: ./.github/actions/cleanup-runner-disk
115+
with:
116+
aggressive: true
117+

.github/workflows/build-pgazure-nightlies.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
runs-on: ubuntu-latest
2525
strategy:
2626
fail-fast: false
27+
max-parallel: 3 # limit concurrent docker builds to reduce overlay pressure
2728
matrix:
2829
platform:
2930
- el/7
@@ -55,12 +56,23 @@ jobs:
5556
run: git clone -b "${MAIN_BRANCH}" --depth=1 https://github.com/citusdata/packaging.git packaging
5657

5758
- name: Install package dependencies
58-
run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev python3-testresources
59+
run: |
60+
sudo apt-get update
61+
sudo apt-get install --no-install-recommends -y libcurl4-openssl-dev libssl-dev python3-testresources
62+
sudo apt-get clean
63+
sudo rm -rf /var/lib/apt/lists/*
64+
65+
- name: Disk usage before build
66+
run: |
67+
df -h /
68+
docker system df || true
5969
6070
- name: Install python requirements
6171
run: python -m pip install -r tools/packaging_automation/requirements.txt
6272

6373
- name: Build packages
74+
env:
75+
DOCKER_BUILDKIT: 1
6476
run: |
6577
python -m tools.packaging_automation.citus_package \
6678
--gh_token "${GH_TOKEN}" \
@@ -80,3 +92,14 @@ jobs:
8092
--output_file_path "$(pwd)/packages" \
8193
--current_branch "${GITHUB_REF##*/}" \
8294
--main_branch "develop"
95+
96+
- name: Remove build artifacts
97+
if: always()
98+
run: |
99+
rm -rf tools packaging packages dist build .pytest_cache || true
100+
101+
- name: Cleanup docker cache and free disk
102+
if: always()
103+
uses: ./.github/actions/cleanup-runner-disk
104+
with:
105+
aggressive: true

.github/workflows/image-health-check.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
runs-on: ubuntu-latest
4141
strategy:
4242
fail-fast: false
43+
max-parallel: 3 # limit concurrent docker builds to reduce overlay pressure
4344
matrix:
4445
TARGET_PLATFORM:
4546
- oraclelinux,8
@@ -63,19 +64,29 @@ jobs:
6364
uses: actions/checkout@v2
6465

6566
- name: Install package dependencies
66-
run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev python3-testresources
67+
run: |
68+
sudo apt-get update
69+
sudo apt-get install --no-install-recommends -y libcurl4-openssl-dev libssl-dev python3-testresources
70+
sudo apt-get clean
71+
sudo rm -rf /var/lib/apt/lists/*
72+
73+
- name: Disk usage before build
74+
run: |
75+
df -h /
76+
docker system df || true
6777
6878
- name: Install wheel for el/8
6979
if: matrix.TARGET_PLATFORM == 'centos,8'
7080
run: python -m pip install wheel
7181

7282
- name: Build image for the target platform
73-
run: |
74-
git checkout -- dockerfiles
75-
./update_image
7683
env:
7784
TARGET_PLATFORM: ${{ matrix.TARGET_PLATFORM }}
7885
POSTGRES_VERSION: ${{ matrix.POSTGRES_VERSION }}
86+
DOCKER_BUILDKIT: 1
87+
run: |
88+
git checkout -- dockerfiles
89+
./update_image
7990
8091
- name: Clone tools repo for test
8192
run: git clone -b v0.8.35 --depth=1 https://github.com/citusdata/tools.git tools
@@ -87,3 +98,14 @@ jobs:
8798
env:
8899
PACKAGING_IMAGE_PLATFORM: "${{matrix.TARGET_PLATFORM}}"
89100

101+
- name: Remove build artifacts
102+
if: always()
103+
run: |
104+
rm -rf tools packages dist build .pytest_cache || true
105+
106+
- name: Cleanup docker cache and free disk
107+
if: always()
108+
uses: ./.github/actions/cleanup-runner-disk
109+
with:
110+
aggressive: true
111+

0 commit comments

Comments
 (0)