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 91a9ec71..b5efe37e 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/index.js.map b/dist/index.js.map index 6ab92cc7..5d4b1726 100644 Binary files a/dist/index.js.map and b/dist/index.js.map differ 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) {