From d47dc754af3158fdf4ab4ee9ec997a4b5d388894 Mon Sep 17 00:00:00 2001 From: Andrew Kahr <22359829+AndrewKahr@users.noreply.github.com> Date: Fri, 27 Oct 2023 16:52:55 -0700 Subject: [PATCH] Provide a default for linux to allow providing a custom limit on linux containers --- action.yml | 7 ++++--- dist/index.js | Bin 22171735 -> 22172212 bytes dist/index.js.map | Bin 14641121 -> 14641708 bytes src/model/docker.ts | 4 ++++ src/model/input.ts | 19 +++++++++++++++++-- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 47864bb2..c9099e77 100644 --- a/action.yml +++ b/action.yml @@ -109,13 +109,14 @@ inputs: dockerCpuLimit: required: false default: '' - description: 'Number of CPU cores to assign the Windows docker container. Defaults to all available cores.' + description: 'Number of CPU cores to assign the docker container. Defaults to all available cores on all platforms.' dockerMemoryLimit: required: false default: '' description: - 'Amount of memory to assign the Windows docker container. Defaults to 75% of total system memory rounded down to - the nearest gigabyte.' + 'Amount of memory to assign the docker container. Defaults to 95% of total system memory rounded down to the + nearest megabyte on Linux and 80% on Windows. On unrecognized platforms, defaults to 75% of total system memory. + To manually specify a value, use the format , where unit is either m or g. ie: 512m = 512 megabytes' allowDirtyBuild: required: false default: '' diff --git a/dist/index.js b/dist/index.js index 91a9ec71e4eed5211a4e9a26c65e5130fc4a68ad..b5efe37eb0a3f720eaf05e84bfbf8afea527d509 100644 GIT binary patch delta 1722 zcmZwHX;hSD7>DsQ@`5-DII_FIi;51QBd7?7C@SEJOJ!D;h%zWOJ8X4CzRB^p{ifIL^;Oms zR(t$q<(@KkWwu>6I#tWc{EL>D&ZWK*cag8ED9u&kE-hxzRqiSFm-;HbPRp^YI^1du zH4N)?h!GS0-(_Zwnd-_)w<>B6q*x2`f?}f1I+3Y?L~D0Pd+ga)Wc;%t!8*9P-C=WD zhgys%%id}f#Q*!IBs2McFG;HPHl(#gTBj-k%!ZJoC#|;QM)b=1HUohOLRSQ%8|>(g z9tc4w!q5{A^g=iy5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`I!e`4}z F)?W&C#AyHk diff --git a/dist/index.js.map b/dist/index.js.map index 6ab92cc7a3a894564c3cbd58fcd680be2f951489..5d4b17260be596dcf5ac0a3db2392f34893e711f 100644 GIT binary patch delta 1249 zcmZwBX;92@9LMol$5J^;yM=%G{|TK^NRm==6De0jMgMBqwX4=q&I&nG!p|+Y=u%im z<-YIxW}4}-@c_@7@yfuMY0F+WX{)MCMKSipg&KQd);Rh#4>dnb z=}sczgG*F#KwKN44{;1?UKbm?l?%%2)nv}die6&08Z1VGnh`3V$16H% zkvT<8G-oCT`lqO=$z1&{#$;=%Im6^7B7aIckrb|IMPs5Yx&GUrged|3AwiSW2K#l(>2fUl^GP~2Ls2>x5)De6nybs8^m-C0SHqt&$Jd0AG~Tk-ktbMI9q;nXNe z;zw-{50NxfvJ;1XOW#FIy5yRltyjR0u`x9LplstfQ2x^ghepJg2l){CahS3rC5gL$U-(&U?o;z zHP&D)a*&HWtiyV2Kt48N6E*Z4jvKg%Teyuo wxQlzZj|X^&M|g}Uc#3Cuju&`|S9py#c#C&4_-f16e@lz~1HSU>X#fBK delta 1041 zcmWm3`CH3z0KoBQWsB0aW@D@Nbt}o1CRc9e2$h>0rOd`i<_Iy0<&N-i#oQtq;hX!+ zO^y(`di(?V#cw^2w;x_Vyq|YPU9+mOwpr!#IZI0vfg;+ej;m^N=7s++g+nyf>n!3| zky;k+3|&y6*X{AT74U;UT0jXE0?-nz5QreOMleDUiZFyjjRS`=U%*29er*oZ-DZ2XGLFa2Q8WhNCzJFOK5`PT~|!;|$K?9LjMX7f^wVxP(gha2Z!ng{!!R z>yS~68@P#ExQ#owi+i|_2Y84_c#Il6!BafLbG*Pyyuxd|K`q|m9p2*u>hKYt@EP^^ Sg0E=6H+;trxkmTXmi`akfYhY` diff --git a/src/model/docker.ts b/src/model/docker.ts index de0a9354..ee21c753 100644 --- a/src/model/docker.ts +++ b/src/model/docker.ts @@ -48,6 +48,8 @@ class Docker { sshPublicKeysDirectoryPath, gitPrivateToken, dockerWorkspacePath, + dockerCpuLimit, + dockerMemoryLimit, } = parameters; const githubHome = path.join(runnerTempPath, '_github_home'); @@ -72,6 +74,8 @@ class Docker { --volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \ --volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \ --volume "${actionFolder}/unity-config:/usr/share/unity3d/config/:z" \ + --cpus=${dockerCpuLimit} \ + --memory=${dockerMemoryLimit} \ ${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \ ${ sshAgent && !sshPublicKeysDirectoryPath diff --git a/src/model/input.ts b/src/model/input.ts index fc9f447d..43667e18 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -232,9 +232,24 @@ class Input { } static get dockerMemoryLimit(): string { - const bytesInGigabyte = 1024 * 1024 * 1024; + const bytesInMegabyte = 1024 * 1024; - return Input.getInput('dockerMemoryLimit') || `${Math.floor((os.totalmem() / bytesInGigabyte) * 0.75)}G`; + let memoryMultiplier; + switch (os.platform()) { + case 'linux': + memoryMultiplier = 0.95; + break; + case 'win32': + memoryMultiplier = 0.8; + break; + default: + memoryMultiplier = 0.75; + break; + } + + return ( + Input.getInput('dockerMemoryLimit') || `${Math.floor((os.totalmem() / bytesInMegabyte) * memoryMultiplier)}m` + ); } public static ToEnvVarFormat(input: string) {