File tree Expand file tree Collapse file tree
actions/host-cleanup-linux Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Host Cleanup (Linux)
2+ description : Reclaims disk space on Linux CI agents by removing unused pre-installed software
3+
4+ runs :
5+ using : ' composite'
6+ steps :
7+ - name : Cleanup unused host dependencies
8+ if : runner.os == 'Linux'
9+ shell : bash
10+ run : bash "$GITHUB_WORKSPACE/build/workflow/scripts/host-cleanup-linux.sh"
Original file line number Diff line number Diff line change 2626 fetch-depth : 0 # Required for gitversion
2727 submodules : true
2828
29+ - name : Free disk space (Linux)
30+ uses : ./.github/actions/host-cleanup-linux
31+
2932 - name : Setup dotnet 9.0.101
30333134 with :
Original file line number Diff line number Diff line change 1616 fetchDepth : 0
1717 persistCredentials : true
1818
19- - bash : |
20- # This list is based on what the base image contains and
21- # may need to be adjusted as new software gets installed.
22- # Use the `du` command below to determine what can be
23- # uninstalled.
24-
25- rm -fR ~/.cargo
26- rm -fR ~/.rustup
27- rm -fR ~/.dotnet
28- sudo rm -fR /usr/share/swift
29- sudo rm -fR /opt/microsoft/msedge
30- sudo rm -fR /usr/local/.ghcup
31- sudo rm -fR /usr/lib/mono
32- sudo snap remove lxd
33- sudo snap remove core20
34- sudo apt remove snapd
19+ - template : templates/host-cleanup-linux.yml
3520
36- df -h
37- # du -h -d 3 /
38- displayName: 'Cleanup unused image dependencies (Linux)'
39- condition: eq(variables['Agent.OS'], 'Linux')
4021 - task : UseDotNet@2
4122 retryCountOnTaskFailure : 3
4223 inputs :
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # Reclaims disk space on Linux CI agents by removing pre-installed
3+ # software that is not needed for the build.
4+ #
5+ # This list is based on what the base image contains and
6+ # may need to be adjusted as new software gets installed.
7+ # Use the `du` command to determine what can be uninstalled.
8+
9+ # Use sudo only when available and non-interactive (no password prompt)
10+ if command -v sudo > /dev/null 2>&1 && sudo -n true > /dev/null 2>&1 ; then
11+ SUDO=" sudo -n"
12+ else
13+ SUDO=" "
14+ fi
15+
16+ echo " Disk space before cleanup:"
17+ df -h /
18+
19+ rm -rf ~ /.cargo ~ /.rustup ~ /.dotnet || true
20+
21+ $SUDO rm -rf /usr/share/swift || true
22+ $SUDO rm -rf /opt/microsoft/msedge || true
23+ $SUDO rm -rf /usr/local/.ghcup || true
24+ $SUDO rm -rf /usr/lib/mono || true
25+ $SUDO rm -rf /usr/local/lib/android || true
26+ $SUDO rm -rf /opt/ghc || true
27+ $SUDO rm -rf /opt/hostedtoolcache/CodeQL || true
28+
29+ if command -v snap > /dev/null 2>&1 ; then
30+ timeout 60s $SUDO snap remove lxd || true
31+ timeout 60s $SUDO snap remove core20 || true
32+ fi
33+
34+ if command -v apt-get > /dev/null 2>&1 ; then
35+ DEBIAN_FRONTEND=noninteractive timeout 120s $SUDO apt-get purge -y snapd || true
36+ fi
37+
38+ echo " Disk space after cleanup:"
39+ df -h /
Original file line number Diff line number Diff line change 77 vmImage : ubuntu-latest
88
99 steps :
10+ - template : templates/host-cleanup-linux.yml
11+
1012 - task : NodeTool@0
1113 inputs :
1214 versionSource : ' spec'
Original file line number Diff line number Diff line change 1+ # Reusable AzDO template: Cleanup unused dependencies on Linux CI agents.
2+ # Calls the shared host-cleanup-linux.sh script to avoid duplication with GitHub Actions.
3+ steps :
4+ - bash : |
5+ bash "$(Build.SourcesDirectory)/build/workflow/scripts/host-cleanup-linux.sh"
6+ displayName: Cleanup unused host dependencies
7+ condition: eq(variables['Agent.OS'], 'Linux')
You can’t perform that action at this time.
0 commit comments