forked from jsoref/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Public runners have ~10G of ram available. XL runners have >50G of ram available. It's nice to be able to run tests on public runners. Introduce an action that: * (Linux) frees some memory * (Linux) adds some swap * (Linux and macOS) calculates available memory * (Windows) suggests 10G of available memory
- Loading branch information
Showing
5 changed files
with
115 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Make more memory available | ||
description: Stops services and adds swap | ||
|
||
inputs: | ||
max: | ||
description: Maximum memory to suggest using | ||
default: 50000 | ||
|
||
outputs: | ||
available: | ||
description: Available memory | ||
value: ${{ steps.memory.outputs.available }} | ||
suggested: | ||
description: Memory suggested for use (constrained by max and available) | ||
value: ${{ steps.memory.outputs.suggested }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Stop services | ||
if: env.RUNNER_OS == 'Linux' | ||
shell: bash | ||
run: | | ||
sudo systemctl disable php8.1-fpm mono-xsp4 walinuxagent multipathd walinuxagent chrony cron getty@tty1 networkd-dispatcher rsyslog serial-getty@ttyS0 snapd multipathd.socket snapd.socket | ||
sudo systemctl stop php8.1-fpm mono-xsp4 walinuxagent multipathd walinuxagent chrony cron getty@tty1 networkd-dispatcher rsyslog serial-getty@ttyS0 snapd | ||
sudo killall mono | ||
- name: enable swap | ||
if: env.RUNNER_OS == 'Linux' | ||
shell: bash | ||
run: | | ||
sudo fallocate -l 10G /mnt/big-swapfile | ||
sudo chmod 600 /mnt/big-swapfile | ||
sudo mkswap /mnt/big-swapfile | ||
sudo swapon /mnt/big-swapfile | ||
- name: Report Available Memory (Linux) | ||
id: memory-linux | ||
if: runner.os == 'Linux' | ||
shell: bash | ||
run: | | ||
free | | ||
perl -ne ' | ||
next unless /Mem:.*\s(\d+)$/; | ||
my $m = int($1 / 102400)*100; | ||
print "available=$m\n"; | ||
' >> "$GITHUB_OUTPUT" | ||
- name: Report Available Memory (macOS) | ||
id: memory-mac | ||
if: runner.os == 'macOS' | ||
shell: bash | ||
run: | | ||
sysctl -a | | ||
perl -e ' | ||
my $m; | ||
while (<>) { | ||
next unless /.*memsize.*:\s*(\d+)/; | ||
my $m0 = int($1 >> 20); | ||
$m = $m0 unless ($m && $m > $m0); | ||
} | ||
print "available=$m\n"; | ||
' >> "$GITHUB_OUTPUT" | ||
- name: Report Available Memory (Windows) | ||
id: memory-windows | ||
if: runner.os == 'Windows' | ||
shell: bash | ||
run: | | ||
echo "available=10737418240" >> "$GITHUB_OUTPUT" | ||
- name: Report Memory | ||
id: memory | ||
shell: bash | ||
env: | ||
max: ${{ inputs.max }} | ||
available: ${{ steps.memory-linux.outputs.available || steps.memory-mac.outputs.available || steps.memory-windows.outputs.available }} | ||
run: | | ||
perl -e ' | ||
my $available = $ENV{available}; | ||
my $max = $ENV{max} || $available; | ||
my $s = ($m < $max ? $available : $max); | ||
print "suggested=$s\n"."available=$available\n"; | ||
' >> "$GITHUB_OUTPUT" |
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
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
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 |
---|---|---|
|
@@ -32,6 +32,7 @@ on: | |
- main | ||
- rc/* | ||
- codeql-cli-* | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
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