Introduce free-disk-space action to prevent CI build failures#5029
Conversation
Test Results for Commit cdbab0fPull Request 5029: Results Test Case Results
Last updated: 2026-02-13 02:06:23 UTC |
There was a problem hiding this comment.
Pull request overview
This PR introduces a custom GitHub composite action to free disk space on GitHub-hosted Ubuntu runners to prevent CI build failures due to insufficient disk space. The action removes unnecessary pre-installed tools (dotnet, android SDK, GHC, CodeQL), cleans Docker system resources, and clears apt cache.
Changes:
- Added new composite action
.github/actions/free-disk-space/action.ymlthat performs disk cleanup operations - Integrated the action into the
docker_testjob inunit_tests.ymlworkflow - Integrated the action into the
linux_docker_jobinbuild_deploy.ymlworkflow
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
.github/actions/free-disk-space/action.yml |
New composite action that removes preinstalled tools, prunes Docker system, and cleans apt cache |
.github/workflows/unit_tests.yml |
Added free-disk-space action before Docker test image build |
.github/workflows/build_deploy.yml |
Added free-disk-space action before Docker build in deployment workflow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| shell: bash | ||
| run: | | ||
| echo "Cleaning Docker system..." | ||
| docker system prune -af --volumes |
There was a problem hiding this comment.
The docker system prune -af --volumes command removes all Docker build cache, which may slow down subsequent Docker builds by preventing layer reuse. This action runs before Docker build steps in both workflows, so cached layers from previous builds that could speed up the current build will be deleted.
Consider either:
- Removing the
--volumesflag to preserve named volumes - Using a more selective prune command like
docker builder prune -af --filter "until=24h"to keep recent cache - Moving this step to run after Docker builds complete, or making it conditional
- Adding error handling with
|| trueto make this step best-effort rather than failing the job
| docker system prune -af --volumes | |
| docker system prune -af || true |
| sudo rm -rf /usr/share/dotnet | ||
| sudo rm -rf /usr/local/lib/android | ||
| sudo rm -rf /opt/ghc | ||
| sudo rm -rf /opt/hostedtoolcache/CodeQL | ||
| echo "Done removing preinstalled tools" | ||
|
|
||
| - name: Clean Docker system | ||
| shell: bash | ||
| run: | | ||
| echo "Cleaning Docker system..." | ||
| docker system prune -af --volumes | ||
| echo "Done cleaning Docker" | ||
|
|
||
| - name: Clean apt cache | ||
| shell: bash | ||
| run: | | ||
| echo "Cleaning apt cache..." | ||
| sudo apt-get clean | ||
| sudo rm -rf /var/lib/apt/lists/* |
There was a problem hiding this comment.
The cleanup steps in this action have no error handling. If any command fails (e.g., a directory doesn't exist or Docker is not available), the entire job will fail. Since freeing disk space is typically a best-effort operation to prevent failures rather than being critical itself, consider adding || true to each command or using set +e to make failures non-fatal.
For example:
sudo rm -rf /usr/share/dotnet || true
sudo rm -rf /usr/local/lib/android || trueThis ensures that if one cleanup operation fails, the others can still proceed and the main job continues.
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL | |
| echo "Done removing preinstalled tools" | |
| - name: Clean Docker system | |
| shell: bash | |
| run: | | |
| echo "Cleaning Docker system..." | |
| docker system prune -af --volumes | |
| echo "Done cleaning Docker" | |
| - name: Clean apt cache | |
| shell: bash | |
| run: | | |
| echo "Cleaning apt cache..." | |
| sudo apt-get clean | |
| sudo rm -rf /var/lib/apt/lists/* | |
| sudo rm -rf /usr/share/dotnet || true | |
| sudo rm -rf /usr/local/lib/android || true | |
| sudo rm -rf /opt/ghc || true | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL || true | |
| echo "Done removing preinstalled tools" | |
| - name: Clean Docker system | |
| shell: bash | |
| run: | | |
| echo "Cleaning Docker system..." | |
| docker system prune -af --volumes || true | |
| echo "Done cleaning Docker" | |
| - name: Clean apt cache | |
| shell: bash | |
| run: | | |
| echo "Cleaning apt cache..." | |
| sudo apt-get clean || true | |
| sudo rm -rf /var/lib/apt/lists/* || true |
No description provided.