-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmisc_setup
More file actions
executable file
·65 lines (60 loc) · 2.2 KB
/
misc_setup
File metadata and controls
executable file
·65 lines (60 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
# This script sets the miscellanies environment variables and installs miscellaneous libraries
# for GitHub Actions.
#
# Usage: bash misc_setup
# The directory where this scrip resides
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
bash "$SCRIPT_DIR"/misc_env
bash "$SCRIPT_DIR"/misc_lib
# Clean up disk space by removing unnecessary directories on GitHub-hosted Linux runners.
if [[ "$RUNNER_OS" == "Linux" ]]; then
for dir in \
/usr/share/swift \
/usr/lib/jvm \
/usr/local/share/powershell \
/usr/local/julia* \
/usr/local/share/chromium \
/opt/microsoft \
/opt/az \
/usr/share/dotnet \
/usr/local/.ghcup \
/usr/local/lib/android \
/opt/google ;
do
du -hs "$dir" || true
sudo rm -rf "$dir"
done
docker system prune -af || true
docker builder prune -af || true
fi
# The following line resizes the swap of GitHub-hosted Linux runners.
# As of 20250727, this is needed by profiling PRIMA on MATLAB R2025a, or the GitHub-hosted runners
# may shut down due to memory starvation. This did not happen with earlier versions of MATLAB.
# For GITHUB_ACTIONS, RUNNER_ENVIRONMENT, and RUNNER_OS variables, see:
# https://docs.github.com/en/actions/reference/workflows-and-actions/variables
if [[ -z ${SWAP_SIZE+x} ]] ; then
SWAP_SIZE=16 # Default swap size in GB
fi
if [[ "$GITHUB_ACTIONS" == "true" && "$RUNNER_ENVIRONMENT" == "github-hosted" && "$RUNNER_OS" == "Linux" ]]; then
bash "$SCRIPT_DIR"/resize_swap "$SWAP_SIZE"
fi
echo -e "\n*********************************************************************************************\n"
echo "System Information:"
if [[ "$RUNNER_OS" == "Linux" ]]; then
uname -a
lscpu
lsmem
df -h
elif [[ "$RUNNER_OS" == "macOS" ]]; then
sysctl -a | grep machdep.cpu
echo Total Memory: "$(( $(sysctl -n hw.memsize) / 1024 / 1024 / 1024 ))" GB
df -h
elif [[ "$RUNNER_OS" == "Windows" ]]; then
systeminfo
wmic logicaldisk get DeviceID,Size,FreeSpace
else
echo "Unknown OS: $RUNNER_OS"
exit 1
fi
echo -e "\n*********************************************************************************************\n"