-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: auto-set GitHub runner make job count
Dynamically determine an appropriate number of make jobs for the GitHub runner container, based upon the number of available CPU cores and RAM, using the rule that each job requires a dedicated core and 2.25GiB of RAM.
- Loading branch information
iamamyth
committed
Jan 16, 2025
1 parent
1179269
commit 1ce5d3a
Showing
3 changed files
with
36 additions
and
9 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,22 @@ | ||
name: 'set-make-job-count' | ||
description: 'Set the MAKE_JOB_COUNT environment variable to a value suitable for the host runner' | ||
runs: | ||
using: "composite" | ||
steps: | ||
# Each job runner requires 2.25 GiB (i.e. 1024 * 9/4 MiB) memory and | ||
# a dedicated logical CPU core | ||
- name: set-jobs-macOS | ||
if: runner.os == 'macOS' | ||
run: | | ||
echo MAKE_JOB_COUNT=$(expr $(printf '%s\n%s' $(( $(sysctl -n hw.memsize) * 4 / (1073741824 * 9) )) $(sysctl -n hw.logicalcpu) | sort -n | head -n1) '|' 1) >> $GITHUB_ENV | ||
shell: bash | ||
- name: set-jobs-windows | ||
if: runner.os == 'Windows' | ||
run: | | ||
echo MAKE_JOB_COUNT=$(expr $(printf '%s\n%s' $(( $(grep MemTotal: /proc/meminfo | cut -d: -f2 | cut -dk -f1) * 4 / (1048576 * 9) )) $(nproc) | sort -n | head -n1) '|' 1) >> $GITHUB_ENV | ||
shell: msys2 {0} | ||
- name: set-jobs-linux | ||
if: runner.os == 'Linux' | ||
run: | | ||
echo MAKE_JOB_COUNT=$(expr $(printf '%s\n%s' $(( $(grep MemTotal: /proc/meminfo | cut -d: -f2 | cut -dk -f1) * 4 / (1048576 * 9) )) $(nproc) | sort -n | head -n1) '|' 1) >> $GITHUB_ENV | ||
shell: bash |
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