Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/command-options/build-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ export class BuildOptions implements IOptions {
demandOption: false,
default: defaultDockerMemoryLimit(),
})
.option('dockerShmSize', {
description: String.dedent`Size of /dev/shm to assign the docker container, using the format <number><unit>
(m or g). Unity 6.6 beta / 6.7 alpha editors have been reported to fail with "Insufficient shared memory
available" against Docker's 64m default (see game-ci/unity-test-runner#307); leave unset to use Docker's
own default on older/stable editors that don't need it.`,
type: 'string',
demandOption: false,
default: '',
})
.option('dockerIsolationMode', {
description: String.dedent`Windows only. Isolation mode to use for the docker container. Can be one of
process, hyperv, or default. Default will pick the default mode as described by Microsoft where server
Expand Down
19 changes: 19 additions & 0 deletions src/model/docker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,31 @@ describe('Docker', () => {
engine: 'unity',
dockerCpuLimit: '4',
dockerMemoryLimit: '8192m',
dockerShmSize: '1024m',
useHostNetwork: true,
});

expect(command).toContain('--cpus=4');
expect(command).toContain('--memory=8192m');
expect(command).toContain('--shm-size=1024m');
expect(command).toContain('--net=host');
});

it('omits --shm-size when dockerShmSize is not set (game-ci/unity-test-runner#307)', () => {
const command = (Docker as any).getLinuxCommand('game-ci/unity-editor-stub:latest', {
hostOS: 'linux',
currentWorkDir: '/home/runner/work/cli/cli',
homeDir: '/home/runner',
cliDistPath: '/home/runner/work/cli/cli/dist',
sshAgent: '',
gitPrivateToken: '',
dockerWorkspacePath: '/github/workspace',
engine: 'unity',
});

expect(command).not.toContain('--shm-size');
});

it('mounts a custom SSH public keys directory instead of the known_hosts fallback', () => {
const command = (Docker as any).getLinuxCommand('game-ci/unity-editor-stub:latest', {
hostOS: 'linux',
Expand Down Expand Up @@ -134,11 +151,13 @@ describe('Docker', () => {
engine: 'unity',
dockerCpuLimit: '4',
dockerMemoryLimit: '8192m',
dockerShmSize: '1024m',
dockerIsolationMode: 'process',
});

expect(command).toContain('--cpus=4');
expect(command).toContain('--memory=8192m');
expect(command).toContain('--shm-size=1024m');
expect(command).toContain('--isolation=process');
});

Expand Down
4 changes: 4 additions & 0 deletions src/model/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Docker {
useHostNetwork,
dockerCpuLimit,
dockerMemoryLimit,
dockerShmSize,
} = options as Options & { commands?: string };

const home = homeDir;
Expand All @@ -98,6 +99,7 @@ class Docker {
sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : '',
dockerCpuLimit ? `--cpus=${dockerCpuLimit}` : '',
dockerMemoryLimit ? `--memory=${dockerMemoryLimit}` : '',
dockerShmSize ? `--shm-size=${dockerShmSize}` : '',
useHostNetwork ? '--net=host' : '',
`--volume "${home}":"/root:z"`,
`--volume "${currentWorkDir}":"${dockerWorkspacePath}:z"`,
Expand Down Expand Up @@ -128,6 +130,7 @@ class Docker {
engine,
dockerCpuLimit,
dockerMemoryLimit,
dockerShmSize,
dockerIsolationMode,
} = options as Options & { commands?: string };

Expand All @@ -150,6 +153,7 @@ class Docker {
` --env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \``,
dockerCpuLimit ? ` --cpus=${dockerCpuLimit} \`` : '',
dockerMemoryLimit ? ` --memory=${dockerMemoryLimit} \`` : '',
dockerShmSize ? ` --shm-size=${dockerShmSize} \`` : '',
dockerIsolationMode ? ` --isolation=${dockerIsolationMode} \`` : '',
` --volume="${currentWorkDir}":"c:${dockerWorkspacePath}" \``,
isUnityDefaultFlow ? ` --volume="${cliStoragePath}/registry-keys":"c:/registry-keys" \`` : '',
Expand Down
Loading