-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5a3619
commit ad9a371
Showing
2 changed files
with
284 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,166 @@ | ||
# Extends disk space on github hosted runners | ||
|
||
|
||
name: "Extend space" | ||
name: "Extend space macOS" | ||
description: "Teases out as much free space as possible" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Create mountpoint for extended space | ||
shell: "bash" | ||
run: sudo mkdir /mnt/extended | ||
|
||
- name: Maximize build space | ||
uses: easimon/maximize-build-space@v6 | ||
# uses: AdityaGarg8/remove-unwanted-software@v1 | ||
with: | ||
remove-dotnet: true | ||
remove-android: true | ||
remove-haskell: true | ||
build-mount-path: /mnt/extended | ||
root-reserve-mb: 512 | ||
swap-size-mb: 1024 | ||
|
||
# after we've got the extended space mounted, we can use overlayfs and bind | ||
# mounts as appropriate to make this space available to all paths that are | ||
# expected to be written to. | ||
# | ||
# for new directories (such as /nix), a bind mount is enough for existing | ||
# directories (such as $HOME and /tmp), we use an overlay to preserve access | ||
# to the existing files, while redirecting changes to the extended space. | ||
- name: Use extended space for /nix, /tmp, /var/tmp, and $HOME | ||
- name: Extend space macos | ||
shell: "bash" | ||
run: | | ||
export EXTENDED_PATH=/mnt/extended | ||
sudo mkdir $EXTENDED_PATH/{tmp,nix,home} | ||
sudo mkdir $EXTENDED_PATH/tmp/{upper,work} | ||
sudo mv /tmp{,_lower} | ||
sudo mkdir /tmp | ||
sudo mount -t overlay overlay \ | ||
-o lowerdir=/tmp_lower,upperdir=$EXTENDED_PATH/tmp/upper,workdir=$EXTENDED_PATH/tmp/work \ | ||
/tmp | ||
sudo chown $(id -u):$(id -g) /tmp | ||
sudo mkdir -p $EXTENDED_PATH/var/tmp/{upper,work} | ||
sudo mv /var/tmp{,_lower} | ||
sudo mkdir -p /var/tmp | ||
sudo mount -t overlay overlay \ | ||
-o lowerdir=/var/tmp_lower,upperdir=$EXTENDED_PATH/var/tmp/upper,workdir=$EXTENDED_PATH/var/tmp/work \ | ||
/var/tmp | ||
sudo chown $(id -u):$(id -g) /var/tmp | ||
sudo mkdir /nix | ||
sudo mount -o bind $EXTENDED_PATH/nix /nix | ||
sudo mkdir $EXTENDED_PATH/home/{upper,work} | ||
sudo mv ${HOME} ${HOME}_lower | ||
sudo mkdir ${HOME} | ||
sudo chown $(id -u):$(id -g) $HOME | ||
sudo mount -t overlay overlay \ | ||
-o lowerdir=${HOME}_lower,upperdir=$EXTENDED_PATH/home/upper,workdir=$EXTENDED_PATH/home/work \ | ||
$HOME | ||
sudo chown $(id -u):$(id -g) $HOME | ||
df -h | ||
set -e | ||
set -u | ||
set -o pipefail | ||
# Uninstall Gems. | ||
for gem in $(gem list --no-versions | grep -v \ | ||
-e 'bigdecimal' \ | ||
-e 'CFPropertyList' \ | ||
-e 'cmath' \ | ||
-e 'csv' \ | ||
-e 'date' \ | ||
-e 'dbm' \ | ||
-e 'did_you_mean' \ | ||
-e 'e2mmap' \ | ||
-e 'etc' \ | ||
-e 'fcntl' \ | ||
-e 'fiddle' \ | ||
-e 'fileutils' \ | ||
-e 'forwardable' \ | ||
-e 'io-console' \ | ||
-e 'ipaddr' \ | ||
-e 'irb' \ | ||
-e 'json' \ | ||
-e 'libxml-ruby' \ | ||
-e 'logger' \ | ||
-e 'matrix' \ | ||
-e 'minitest' \ | ||
-e 'mutex_m' \ | ||
-e 'net-telnet' \ | ||
-e 'nokogiri' \ | ||
-e 'openssl' \ | ||
-e 'ostruct' \ | ||
-e 'power_assert' \ | ||
-e 'prime' \ | ||
-e 'psych' \ | ||
-e 'rake' \ | ||
-e 'rexml' \ | ||
-e 'rdoc' \ | ||
-e 'rbs' \ | ||
-e 'rss' \ | ||
-e 'scanf' \ | ||
-e 'shell' \ | ||
-e 'sqlite3' \ | ||
-e 'stringio' \ | ||
-e 'strscan' \ | ||
-e 'sync' \ | ||
-e 'test-unit' \ | ||
-e 'thwait' \ | ||
-e 'tracer' \ | ||
-e 'typeprof' \ | ||
-e 'webrick' \ | ||
-e 'xmlrpc' \ | ||
-e 'zlib' \ | ||
); do | ||
sudo gem uninstall --force --all --ignore-dependencies --executables "$gem" | ||
done | ||
# Uninstall Homebrew. | ||
brew update | ||
sudo rm -rf /usr/local/miniconda & | ||
rm -rf /usr/local/lib/node_modules & | ||
rm -f /usr/local/bin/terminal-notifier | ||
rm -f /usr/local/bin/change_hostname.sh | ||
rm -f /usr/local/bin/azcopy | ||
if which brew &>/dev/null; then | ||
eval "$(brew list --formula | xargs -I% echo 'brew uninstall --formula --force --ignore-dependencies "%" &')" | ||
eval "$(brew list --cask | xargs -I% echo '{ brew uninstall --cask --force "%"; brew uninstall --cask --zap --force "%"; } &')" | ||
brew uninstall --cask --zap --force dotnet & | ||
brew uninstall --cask --zap --force adoptopenjdk/openjdk/adoptopenjdk8 & | ||
brew uninstall --cask --zap --force mono-mdk & | ||
brew uninstall --cask --zap --force xamarin-android & | ||
brew uninstall --cask --zap --force xamarin-ios & | ||
brew uninstall --cask --zap --force xamarin-mac & | ||
wait | ||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" -- --force | ||
fi | ||
# # Uninstall Xcode and Command Line Tools | ||
# mkdir -p /tmp/trash | ||
# for trash in /Applications/Xcode*.app /Library/Developer/CommandLineTools; do | ||
# sudo mv "$trash" /tmp/trash/ | ||
# done | ||
# sudo pkgutil --forget com.apple.pkg.CLTools_Executables | ||
# sudo xcode-select --reset | ||
# Clean environment. | ||
for trash in ~/.DS_Store \ | ||
~/.Trash/* \ | ||
~/.aliyun \ | ||
~/.android \ | ||
~/.azcopy \ | ||
~/.azure \ | ||
~/.bash_history \ | ||
~/.bash_profile \ | ||
~/.bash_sessions \ | ||
~/.bashrc \ | ||
~/.cabal \ | ||
~/.cache \ | ||
~/.cargo \ | ||
~/.cocoapods \ | ||
~/.composer \ | ||
~/.conda \ | ||
~/.config \ | ||
~/.dotnet \ | ||
~/.fastlane \ | ||
~/.gem \ | ||
~/.ghcup \ | ||
~/.gitconfig \ | ||
~/.gradle \ | ||
~/.local \ | ||
~/.m2 \ | ||
~/.mono \ | ||
~/.npm \ | ||
~/.npmrc \ | ||
~/.nvm \ | ||
~/.oracle_jre_usage \ | ||
~/.packer.d \ | ||
~/.rustup \ | ||
~/.sh_history \ | ||
~/.ssh \ | ||
~/.subversion \ | ||
~/.sqlite_history \ | ||
~/.vcpkg \ | ||
~/.viminfo \ | ||
~/.wget-hsts \ | ||
~/.yarn \ | ||
~/Library/Caches/Homebrew \ | ||
~/Microsoft \ | ||
~/hostedtoolcache \ | ||
~/*.txt; do | ||
if [[ -e "$trash" ]]; then | ||
mv "$trash" /tmp/trash/ | ||
fi | ||
done | ||
# Delete broken symlinks. | ||
for exe in /usr/local/bin/*; do | ||
if [[ -L "$exe" ]] && ! [[ -e "$exe" ]]; then | ||
rm "$exe" | ||
fi | ||
done | ||
mkdir -p /tmp/trash | ||
for pkg in /var/db/receipts/*.plist; do | ||
pkg_id="$(basename "${pkg}" .plist)" | ||
volume="$(pkgutil --pkg-info "${pkg_id}" | sed -n -e 's/^volume: //p')" | ||
location="$(pkgutil --pkg-info "${pkg_id}" | sed -n -e 's/^location: //p')" | ||
pkgutil --only-files --files "${pkg_id}" | xargs -I% sudo mv -f "${volume}${location}/%" /tmp/trash/ || true | ||
pkgutil --only-dirs --files "${pkg_id}" | xargs -I% sudo rmdir -p "${volume}${location}/%" || true | ||
pkgutil --forget "${pkg_id}" | ||
done | ||
Oops, something went wrong.