Skip to content

Commit 335bc2e

Browse files
authored
chore(ci): more disk space cleanups (#3322)
1 parent af48705 commit 335bc2e

File tree

2 files changed

+72
-14
lines changed

2 files changed

+72
-14
lines changed

.github/workflows/ci.yml

Lines changed: 71 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ on:
88
branches:
99
- "main"
1010

11+
env:
12+
POETRY_CACHE_DIR: /tmp/pypoetry-cache
13+
POETRY_VENV_IN_PROJECT: false
14+
POETRY_INSTALLER_MODERN_INSTALLATION: false
15+
PIP_NO_CACHE_DIR: 1
16+
1117
jobs:
1218
lint-pr:
1319
name: Lint PR
@@ -28,11 +34,17 @@ jobs:
2834
steps:
2935
- name: Free up disk space
3036
run: |
37+
# Remove unnecessary software and cached packages
3138
sudo apt-get remove -y '^dotnet-.*' '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*' azure-cli google-cloud-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri || true
3239
sudo apt-get autoremove -y
3340
sudo apt-get clean
34-
# Remove Docker images
35-
docker rmi $(docker images -aq) || true
41+
# Remove Docker images and containers
42+
docker system prune -af || true
43+
# Remove additional system files
44+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL || true
45+
sudo rm -rf /imagegeneration || true
46+
# Clear APT cache completely
47+
sudo rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* || true
3648
# Show available space
3749
df -h
3850
- uses: actions/checkout@v4
@@ -46,13 +58,20 @@ jobs:
4658
python-version: 3.11
4759
- name: Install Poetry
4860
uses: snok/install-poetry@v1
61+
with:
62+
version: latest
63+
virtualenvs-create: true
64+
virtualenvs-in-project: false
65+
virtualenvs-path: ~/.cache/pypoetry/virtualenvs
4966

5067
- uses: actions/setup-node@v4
5168
with:
5269
node-version: 18
5370

5471
- uses: nrwl/nx-set-shas@v4
55-
- run: npm ci
72+
- run: npm ci --cache ~/.npm --prefer-offline
73+
- name: Clean npm cache
74+
run: npm cache clean --force || true
5675
- run: npx nx affected -t install --with dev
5776
- run: npx nx affected -t lint --parallel=3
5877

@@ -66,11 +85,17 @@ jobs:
6685
steps:
6786
- name: Free up disk space
6887
run: |
88+
# Remove unnecessary software and cached packages
6989
sudo apt-get remove -y '^dotnet-.*' '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*' azure-cli google-cloud-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri || true
7090
sudo apt-get autoremove -y
7191
sudo apt-get clean
72-
# Remove Docker images
73-
docker rmi $(docker images -aq) || true
92+
# Remove Docker images and containers
93+
docker system prune -af || true
94+
# Remove additional system files
95+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL || true
96+
sudo rm -rf /imagegeneration || true
97+
# Clear APT cache completely
98+
sudo rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* || true
7499
# Show available space
75100
df -h
76101
- uses: actions/checkout@v4
@@ -83,20 +108,33 @@ jobs:
83108
python-version: ${{ matrix.python-version }}
84109
- name: Install Poetry
85110
uses: snok/install-poetry@v1
111+
with:
112+
version: latest
113+
virtualenvs-create: true
114+
virtualenvs-in-project: false
115+
virtualenvs-path: ~/.cache/pypoetry/virtualenvs
86116

87117
- uses: actions/setup-node@v4
88118
with:
89119
node-version: 18
90120

91121
- uses: nrwl/nx-set-shas@v4
92122

93-
- run: npm ci
123+
- run: npm ci --cache ~/.npm --prefer-offline
124+
- name: Clean npm cache
125+
run: npm cache clean --force || true
94126

95127
- name: Install
96-
run: npx nx affected -t install --with dev --parallel=3
128+
run: npx nx affected -t install --with dev --parallel=2
129+
97130

98131
- name: Build
99-
run: npx nx affected -t build-release --parallel=3
132+
run: npx nx affected -t build-release --parallel=2
133+
134+
- name: Clean build artifacts to save space
135+
run: |
136+
find packages -name "dist" -type d -exec rm -rf {} + || true
137+
find packages -name "*.egg-info" -type d -exec rm -rf {} + || true
100138
101139
test-packages:
102140
name: Test Packages
@@ -111,11 +149,17 @@ jobs:
111149
steps:
112150
- name: Free up disk space
113151
run: |
152+
# Remove unnecessary software and cached packages
114153
sudo apt-get remove -y '^dotnet-.*' '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*' azure-cli google-cloud-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri || true
115154
sudo apt-get autoremove -y
116155
sudo apt-get clean
117-
# Remove Docker images
118-
docker rmi $(docker images -aq) || true
156+
# Remove Docker images and containers
157+
docker system prune -af || true
158+
# Remove additional system files
159+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL || true
160+
sudo rm -rf /imagegeneration || true
161+
# Clear APT cache completely
162+
sudo rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* || true
119163
# Show available space
120164
df -h
121165
- uses: actions/checkout@v4
@@ -130,19 +174,33 @@ jobs:
130174

131175
- name: Install Poetry
132176
uses: snok/install-poetry@v1
177+
with:
178+
version: latest
179+
virtualenvs-create: true
180+
virtualenvs-in-project: false
181+
virtualenvs-path: ~/.cache/pypoetry/virtualenvs
133182

134183
- uses: actions/setup-node@v4
135184
with:
136185
node-version: 18
137186

138187
- uses: nrwl/nx-set-shas@v4
139188

140-
- run: npm ci
189+
- run: npm ci --cache ~/.npm --prefer-offline
190+
- name: Clean npm cache
191+
run: npm cache clean --force || true
141192

142193
- name: Install
143-
run: npx nx affected -t install --exclude='sample-app' --with dev --parallel=3
194+
run: npx nx affected -t install --exclude='sample-app' --with dev --parallel=2
195+
144196

145197
- name: Test
146198
env:
147199
HAYSTACK_TELEMETRY_ENABLED: False
148-
run: npx nx affected -t test --exclude='sample-app' --exclude='opentelemetry-instrumentation-haystack' --parallel=3
200+
run: npx nx affected -t test --exclude='sample-app' --exclude='opentelemetry-instrumentation-haystack' --parallel=2
201+
202+
- name: Clean test artifacts to save space
203+
run: |
204+
find packages -name ".pytest_cache" -type d -exec rm -rf {} + || true
205+
find packages -name "__pycache__" -type d -exec rm -rf {} + || true
206+
find packages -name "*.pyc" -delete || true

packages/traceloop-sdk/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"options": {
3939
"silent": false,
4040
"args": "",
41-
"cacheDir": ".cache/pypoetry",
41+
"cacheDir": "/tmp/pypoetry-cache",
4242
"verbose": false,
4343
"debug": false
4444
}

0 commit comments

Comments
 (0)