mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-07 20:35:33 -04:00
Provide a default for linux to allow providing a custom limit on linux containers
This commit is contained in:
parent
9e22e88260
commit
d47dc754af
@ -109,13 +109,14 @@ inputs:
|
|||||||
dockerCpuLimit:
|
dockerCpuLimit:
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
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:
|
dockerMemoryLimit:
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
description:
|
description:
|
||||||
'Amount of memory to assign the Windows docker container. Defaults to 75% of total system memory rounded down to
|
'Amount of memory to assign the docker container. Defaults to 95% of total system memory rounded down to the
|
||||||
the nearest gigabyte.'
|
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:
|
allowDirtyBuild:
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
@ -48,6 +48,8 @@ class Docker {
|
|||||||
sshPublicKeysDirectoryPath,
|
sshPublicKeysDirectoryPath,
|
||||||
gitPrivateToken,
|
gitPrivateToken,
|
||||||
dockerWorkspacePath,
|
dockerWorkspacePath,
|
||||||
|
dockerCpuLimit,
|
||||||
|
dockerMemoryLimit,
|
||||||
} = parameters;
|
} = parameters;
|
||||||
|
|
||||||
const githubHome = path.join(runnerTempPath, '_github_home');
|
const githubHome = path.join(runnerTempPath, '_github_home');
|
||||||
@ -72,6 +74,8 @@ class Docker {
|
|||||||
--volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \
|
--volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \
|
||||||
--volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \
|
--volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \
|
||||||
--volume "${actionFolder}/unity-config:/usr/share/unity3d/config/:z" \
|
--volume "${actionFolder}/unity-config:/usr/share/unity3d/config/:z" \
|
||||||
|
--cpus=${dockerCpuLimit} \
|
||||||
|
--memory=${dockerMemoryLimit} \
|
||||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||||
${
|
${
|
||||||
sshAgent && !sshPublicKeysDirectoryPath
|
sshAgent && !sshPublicKeysDirectoryPath
|
||||||
|
@ -232,9 +232,24 @@ class Input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static get dockerMemoryLimit(): string {
|
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) {
|
public static ToEnvVarFormat(input: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user