Skip to content

Commit db64fd3

Browse files
authored
[ci] Allocate swap memory (#3655)
1 parent fa4ba4e commit db64fd3

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

.github/actions/disk/action.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,39 @@ runs:
5959
echo "TMP=D:\Temp" >> $env:GITHUB_ENV
6060
New-Item -ItemType Directory -Path "D:\Temp" -Force | Out-Null
6161
62+
- name: Configure swap (Linux)
63+
shell: bash
64+
if: runner.os == 'Linux'
65+
run: |
66+
sudo swapoff -a
67+
sudo fallocate -l 8G /swapfile
68+
sudo chmod 600 /swapfile
69+
sudo mkswap /swapfile
70+
sudo swapon /swapfile
71+
sudo swapon --show
72+
73+
# macOS manages swap dynamically via dynamic_pager; ensure it is running and report state.
74+
- name: Configure swap (macOS)
75+
shell: bash
76+
if: runner.os == 'macOS'
77+
run: |
78+
set -euxo pipefail
79+
sudo mkdir -p /private/var/vm
80+
if ! pgrep -x dynamic_pager >/dev/null; then
81+
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist || true
82+
fi
83+
sysctl vm.swapusage || true
84+
85+
# Windows manages the pagefile dynamically by default, and changing its size requires a
86+
# reboot to take effect (not practical within a single job). Log the current state only.
87+
- name: Log pagefile (Windows)
88+
shell: pwsh
89+
if: runner.os == 'Windows'
90+
run: |
91+
$ErrorActionPreference = 'Continue'
92+
Get-CimInstance -ClassName Win32_PageFileUsage | Format-List Name, AllocatedBaseSize, CurrentUsage, PeakUsage
93+
Get-CimInstance -ClassName Win32_PageFileSetting | Format-List Name, InitialSize, MaximumSize
94+
6295
- name: Show disk free (after)
6396
shell: bash
6497
run: df -h || true

0 commit comments

Comments
 (0)