Provide a default for linux to allow providing a custom limit on linux containers
parent
9e22e88260
commit
d47dc754af
|
@ -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 <number><unit>, where unit is either m or g. ie: 512m = 512 megabytes'
|
||||
allowDirtyBuild:
|
||||
required: false
|
||||
default: ''
|
||||
|
|
|
@ -5888,7 +5888,7 @@ class Docker {
|
|||
}
|
||||
}
|
||||
static getLinuxCommand(image, parameters, overrideCommands = '', additionalVariables = [], entrypointBash = false) {
|
||||
const { workspace, actionFolder, runnerTempPath, sshAgent, sshPublicKeysDirectoryPath, gitPrivateToken, dockerWorkspacePath, } = parameters;
|
||||
const { workspace, actionFolder, runnerTempPath, sshAgent, sshPublicKeysDirectoryPath, gitPrivateToken, dockerWorkspacePath, dockerCpuLimit, dockerMemoryLimit, } = parameters;
|
||||
const githubHome = node_path_1.default.join(runnerTempPath, '_github_home');
|
||||
if (!(0, node_fs_1.existsSync)(githubHome))
|
||||
(0, node_fs_1.mkdirSync)(githubHome);
|
||||
|
@ -5912,6 +5912,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
|
||||
? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro'
|
||||
|
@ -6917,8 +6919,20 @@ class Input {
|
|||
return Input.getInput('dockerCpuLimit') || node_os_1.default.cpus().length.toString();
|
||||
}
|
||||
static get dockerMemoryLimit() {
|
||||
const bytesInGigabyte = 1024 * 1024 * 1024;
|
||||
return Input.getInput('dockerMemoryLimit') || `${Math.floor((node_os_1.default.totalmem() / bytesInGigabyte) * 0.75)}G`;
|
||||
const bytesInMegabyte = 1024 * 1024;
|
||||
let memoryMultiplier;
|
||||
switch (node_os_1.default.platform()) {
|
||||
case 'linux':
|
||||
memoryMultiplier = 0.95;
|
||||
break;
|
||||
case 'win32':
|
||||
memoryMultiplier = 0.8;
|
||||
break;
|
||||
default:
|
||||
memoryMultiplier = 0.75;
|
||||
break;
|
||||
}
|
||||
return (Input.getInput('dockerMemoryLimit') || `${Math.floor((node_os_1.default.totalmem() / bytesInMegabyte) * memoryMultiplier)}m`);
|
||||
}
|
||||
static ToEnvVarFormat(input) {
|
||||
if (input.toUpperCase() === input) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue