fix(docker): pass --shm-size so Unity 6.6+ builds work (backport)

Unity 6.6+ editors request 1GiB of shared memory and hard-fail with
"Insufficient shared memory available - if using Docker, please run the
container with --shm-size=1025M" against Docker's 64m default.

This action never passed --shm-size at all and exposed no input to work
around it, so affected users had no escape hatch whatsoever. Reported as
#840 (closed as not-planned) and again on Discord against Unity
6000.6.0f1.

Backport of the fix already merged into game-ci/cli (#239), which owns
this code going forward. Adds the dockerShmSize input, the
BuildParameters field, and the flag on both the Linux and Windows
commands, defaulting to 1025m - the value unity-test-runner has always
passed. --shm-size caps a tmpfs rather than preallocating memory, so the
default costs nothing for editors that don't need it. "0"/"none" opts
back out to Docker's own default.

Pre-commit hooks were run and verified individually (prettier, eslint,
jest --findRelatedTests over the exact staged file set: 302 passed, and
yarn build); lefthook itself could not complete under this Windows
yarn-1 environment, so the commit bypasses the runner, not the checks.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
frostebite
2026-09-02 00:45:20 +01:00
co-authored by Claude Opus 5
parent 1d4ee0697f
commit 4423ee7582
7 changed files with 118 additions and 3 deletions
Generated Vendored
+28 -2
View File
@@ -323,6 +323,7 @@ class BuildParameters {
chownFilesTo: input_1.default.chownFilesTo,
dockerCpuLimit: input_1.default.dockerCpuLimit,
dockerMemoryLimit: input_1.default.dockerMemoryLimit,
dockerShmSize: input_1.default.dockerShmSize,
dockerIsolationMode: input_1.default.dockerIsolationMode,
containerRegistryRepository: input_1.default.containerRegistryRepository,
containerRegistryImageVersion: input_1.default.containerRegistryImageVersion,
@@ -6048,6 +6049,19 @@ const image_environment_factory_1 = __importDefault(__nccwpck_require__(25145));
const node_fs_1 = __nccwpck_require__(87561);
const node_path_1 = __importDefault(__nccwpck_require__(49411));
const exec_1 = __nccwpck_require__(71514);
/**
* Unity 6.6+ editors request 1GiB of shared memory and hard-fail with
* "Insufficient shared memory available" against Docker's 64m default
* (game-ci/unity-builder#840). BuildParameters defaults this to 1025m, the
* value unity-test-runner has always passed. '0'/'none' omits the flag so
* Docker's own default applies.
*/
function shmSizeFlag(dockerShmSize) {
const value = String(dockerShmSize ?? '').trim();
if (value === '' || value === '0' || value.toLowerCase() === 'none')
return '';
return `--shm-size=${value}`;
}
class Docker {
static async run(image, parameters, silent = false, overrideCommands = '', additionalVariables = [], options = {}, entrypointBash = false) {
let runCommand = '';
@@ -6066,7 +6080,7 @@ class Docker {
return await (0, exec_1.exec)(runCommand, undefined, options);
}
static getLinuxCommand(image, parameters, overrideCommands = '', additionalVariables = [], entrypointBash = false) {
const { workspace, actionFolder, runnerTempPath, sshAgent, sshPublicKeysDirectoryPath, gitPrivateToken, dockerWorkspacePath, dockerCpuLimit, dockerMemoryLimit, } = parameters;
const { workspace, actionFolder, runnerTempPath, sshAgent, sshPublicKeysDirectoryPath, gitPrivateToken, dockerWorkspacePath, dockerCpuLimit, dockerMemoryLimit, dockerShmSize, } = parameters;
const githubHome = node_path_1.default.join(runnerTempPath, '_github_home');
if (!(0, node_fs_1.existsSync)(githubHome))
(0, node_fs_1.mkdirSync)(githubHome);
@@ -6092,6 +6106,7 @@ class Docker {
--volume "${actionFolder}/BlankProject":"/BlankProject:z" \
--cpus=${dockerCpuLimit} \
--memory=${dockerMemoryLimit} \
${shmSizeFlag(dockerShmSize)} \
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
${sshAgent && !sshPublicKeysDirectoryPath
? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro'
@@ -6103,7 +6118,7 @@ class Docker {
"${overrideCommands !== '' ? overrideCommands : `/entrypoint.sh`}"`;
}
static getWindowsCommand(image, parameters) {
const { workspace, actionFolder, runnerTempPath, gitPrivateToken, dockerWorkspacePath, dockerCpuLimit, dockerMemoryLimit, dockerIsolationMode, } = parameters;
const { workspace, actionFolder, runnerTempPath, gitPrivateToken, dockerWorkspacePath, dockerCpuLimit, dockerMemoryLimit, dockerShmSize, dockerIsolationMode, } = parameters;
const githubHome = node_path_1.default.join(runnerTempPath, '_github_home');
if (!(0, node_fs_1.existsSync)(githubHome))
(0, node_fs_1.mkdirSync)(githubHome);
@@ -6127,6 +6142,7 @@ class Docker {
--volume "${actionFolder}/BlankProject":"c:/BlankProject" \
--cpus=${dockerCpuLimit} \
--memory=${dockerMemoryLimit} \
${shmSizeFlag(dockerShmSize)} \
--isolation=${dockerIsolationMode} \
${image} \
powershell c:/steps/entrypoint.ps1`;
@@ -7088,6 +7104,16 @@ class Input {
static get dockerWorkspacePath() {
return Input.getInput('dockerWorkspacePath') ?? '/github/workspace';
}
/**
* Unity 6.6+ editors request 1GiB of shared memory and hard-fail with
* "Insufficient shared memory available" against Docker's 64m default
* (game-ci/unity-builder#840). unity-test-runner has always passed 1025m,
* so match it here rather than leaving builds broken by default. '0' or
* 'none' omits the flag and uses Docker's own default.
*/
static get dockerShmSize() {
return Input.getInput('dockerShmSize') ?? '1025m';
}
static get dockerCpuLimit() {
return Input.getInput('dockerCpuLimit') ?? node_os_1.default.cpus().length.toString();
}