Skip to content

Commit 320adde

Browse files
committed
ci: free space before using docker
1 parent 58b02e1 commit 320adde

File tree

8 files changed

+83
-106
lines changed

8 files changed

+83
-106
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) 2025 ETH Zurich and University of Bologna.
2+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# Author: Philippe Sauter <phsauter@iis.ee.ethz.ch>
6+
7+
name: 'Free Disk Space on Runner'
8+
description: 'Frees disk space on GitHub-hosted runners to make room for eg large Docker images'
9+
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- name: Show disk usage before cleanup
14+
shell: bash
15+
run: |
16+
echo "Disk usage before cleanup:"
17+
df -h
18+
19+
- name: Prune Docker data
20+
shell: bash
21+
run: |
22+
# Remove stopped containers, unused networks, dangling images, and build cache
23+
docker system prune -af || true
24+
25+
- name: Remove large preinstalled SDKs and toolchains
26+
shell: bash
27+
run: |
28+
# These paths are known big space hogs on ubuntu-latest runners
29+
sudo rm -rf /usr/local/lib/android || true
30+
sudo rm -rf /usr/share/dotnet || true
31+
sudo rm -rf /opt/ghc || true
32+
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
33+
sudo rm -rf /opt/hostedtoolcache/go || true
34+
35+
- name: Clean APT caches
36+
shell: bash
37+
run: |
38+
sudo apt-get clean || true
39+
sudo rm -rf /var/lib/apt/lists/* || true
40+
41+
- name: Show disk usage after cleanup
42+
shell: bash
43+
run: |
44+
echo "Disk usage after cleanup:"
45+
df -h

.github/actions/oseda-caching/action.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/actions/oseda-cmd/action.yml

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ inputs:
1111
cmd:
1212
description: 'Command to run in the OSEDA container'
1313
required: true
14-
image_file_name:
15-
description: 'Name of the artifact to download (default: oseda-image)'
16-
required: false
17-
default: 'oseda-image'
1814
service_name:
1915
description: 'Name of the Docker service (default: from ./docker-compose.yml)'
2016
required: false
@@ -26,50 +22,40 @@ runs:
2622
- name: Set up Docker environment
2723
shell: bash
2824
run: |
29-
echo "UID=$(id -u)" >> $GITHUB_ENV
30-
echo "GID=$(id -g)" >> $GITHUB_ENV
25+
echo "UID=$(id -u)" >> "$GITHUB_ENV"
26+
echo "GID=$(id -g)" >> "$GITHUB_ENV"
3127
3228
- name: Get image name from docker-compose
3329
id: get-image
3430
shell: bash
3531
run: |
3632
IMAGE=$(docker compose config | awk '/image:/{print $2}' | head -n 1)
3733
if [ -z "$IMAGE" ]; then
38-
echo "ERROR: No image found in docker-compose.yml"
34+
echo "[ERROR] No image found in docker-compose.yml"
3935
exit 1
4036
fi
41-
echo "IMAGE_NAME=$IMAGE" >> $GITHUB_ENV
42-
43-
- name: Download Docker image from cache
44-
continue-on-error: true
45-
uses: actions/cache/restore@v4
46-
with:
47-
key: oseda-${{ env.IMAGE_NAME }}
48-
path: /tmp/oseda.tar.gz
37+
echo "IMAGE_NAME=$IMAGE" >> "$GITHUB_ENV"
4938
50-
- name: Load or pull Docker image
39+
- name: Pull Docker image
5140
shell: bash
5241
run: |
53-
if [ -f "/tmp/oseda.tar.gz" ]; then
54-
docker import /tmp/oseda.tar.gz
55-
echo "Loaded image $IMAGE_NAME from artifacts/cache"
56-
else
57-
docker compose pull
58-
fi
42+
docker compose pull
5943
6044
- name: Determine service name if not provided
6145
shell: bash
6246
run: |
6347
if [ -z "${{ inputs.service_name }}" ]; then
6448
SERVICE_NAME=$(docker compose config --services | head -n 1)
65-
echo "service_name=$SERVICE_NAME" >> $GITHUB_ENV
49+
echo "service_name=$SERVICE_NAME" >> "$GITHUB_ENV"
6650
else
67-
echo "service_name=${{ inputs.service_name }}" >> $GITHUB_ENV
51+
echo "service_name=${{ inputs.service_name }}" >> "$GITHUB_ENV"
6852
fi
6953
7054
- name: Run commands in OSEDA container
7155
shell: bash
7256
run: |
73-
docker compose up -d
74-
docker compose exec ${{ env.service_name }} bash -c "source ~/.bashrc; ${{ inputs.cmd }}" | tee result.log
75-
echo "result_log=$(pwd)/result.log" >> $GITHUB_ENV
57+
# Avoid extra pulls now that we've already pulled
58+
docker compose up -d --pull=never
59+
docker compose exec -T "${{ env.service_name }}" \
60+
bash -lc "source ~/.bashrc; ${{ inputs.cmd }}" | tee result.log
61+
echo "result_log=$(pwd)/result.log" >> "$GITHUB_ENV"

.github/workflows/artistic.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
uses: actions/checkout@v4
3030
with:
3131
submodules: true
32+
- name: Free disk space
33+
uses: ./.github/actions/free-space
3234
- name: Get run ID of "Full Flow" workflow
3335
id: get-run-id
3436
run: |

.github/workflows/full-flow.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,19 @@ jobs:
2626
uses: actions/checkout@v4
2727
with:
2828
submodules: true
29-
29+
- name: Free disk space
30+
uses: ./.github/actions/free-space
3031
- name: Run Yosys, OpenROAD and KLayout
3132
uses: ./.github/actions/oseda-cmd
3233
with:
3334
cmd: "make yosys && make openroad && make klayout"
34-
- name: Upload openroad output
35+
- name: Upload openroad outputs
3536
uses: actions/upload-artifact@v4
3637
with:
3738
name: croc-openroad-out
38-
path: openroad/out
39-
continue-on-error: true
40-
- name: Upload openroad reports
41-
uses: actions/upload-artifact@v4
42-
with:
43-
name: croc-openroad-reports
44-
path: openroad/reports
39+
path: |
40+
openroad/out
41+
openroad/reports
4542
continue-on-error: true
4643
- name: Upload gds
4744
uses: actions/upload-artifact@v4

.github/workflows/short-flow.yml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ jobs:
2020
uses: actions/checkout@v4
2121
with:
2222
submodules: true
23-
23+
- name: Free disk space
24+
uses: ./.github/actions/free-space
2425
- name: Run simulation commands in OSEDA
2526
uses: ./.github/actions/oseda-cmd
2627
with:
@@ -31,21 +32,17 @@ jobs:
3132
name: croc-sw
3233
path: sw/bin
3334
continue-on-error: true
34-
- name: Upload waveform
35-
uses: actions/upload-artifact@v4
36-
with:
37-
name: croc-waveform
38-
path: croc.fst
39-
continue-on-error: true
40-
4135
- name: Upload simulation output
4236
uses: actions/upload-artifact@v4
4337
with:
4438
name: simulation-output
45-
path: ${{ env.result_log }}
39+
path: |
40+
verilator/croc.fst
41+
verilator/croc.log
42+
continue-on-error: true
4643
- name: Check simulation output
4744
shell: bash
48-
run: ./.github/scripts/check_sim.sh ${{ env.result_log }}
45+
run: ./.github/scripts/check_sim.sh ./verilator/croc.log
4946

5047
synthesis:
5148
runs-on: ubuntu-latest
@@ -55,20 +52,18 @@ jobs:
5552
uses: actions/checkout@v4
5653
with:
5754
submodules: true
58-
55+
- name: Free disk space
56+
uses: ./.github/actions/free-space
5957
- name: Setup OSEDA container
6058
uses: ./.github/actions/oseda-cmd
6159
with:
6260
cmd: "make yosys && tail -n 40 yosys/reports/*area.rpt"
63-
- name: Upload synthesis reports
61+
- name: Upload synthesis outputs
6462
uses: actions/upload-artifact@v4
6563
with:
6664
name: croc-synth-reports
67-
path: yosys/reports
68-
continue-on-error: true
69-
- name: Upload netlist
70-
uses: actions/upload-artifact@v4
71-
with:
72-
name: croc-netlist
73-
path: yosys/out
65+
path: |
66+
yosys/reports
67+
yosys/out
7468
continue-on-error: true
69+

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ verilator/obj_dir/Vtb_croc_soc: verilator/croc.f $(SW_HEX)
106106

107107
## Simulate RTL using Verilator
108108
verilator: verilator/obj_dir/Vtb_croc_soc
109-
cd verilator; obj_dir/Vtb_croc_soc +binary="$(realpath $(SW_HEX))"
109+
cd verilator; obj_dir/Vtb_croc_soc +binary="$(realpath $(SW_HEX))" | tee croc.log
110110

111111
.PHONY: verilator vsim vsim-yosys
112112

verilator/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
obj_dir
22
croc*.f
33
*.vcd
4+
*.fst
5+
*.log

0 commit comments

Comments
 (0)