mirror of
https://github.com/game-ci/unity-test-runner.git
synced 2026-02-04 19:29:06 +08:00
Update windows images and add docker parameters (#244)
* Update windows images and add docker parameters * Run yarn-audit-fix
This commit is contained in:
9
src/jest.setup.ts
Normal file
9
src/jest.setup.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import failOnConsole from 'jest-fail-on-console';
|
||||
|
||||
// Fail when console logs something inside a test - use spyOn instead
|
||||
failOnConsole({
|
||||
shouldFailOnWarn: true,
|
||||
shouldFailOnError: true,
|
||||
shouldFailOnLog: true,
|
||||
shouldFailOnAssert: true,
|
||||
});
|
||||
@@ -23,6 +23,9 @@ export async function run() {
|
||||
packageMode,
|
||||
packageName,
|
||||
chownFilesTo,
|
||||
dockerCpuLimit,
|
||||
dockerMemoryLimit,
|
||||
dockerIsolationMode,
|
||||
unityLicensingServer,
|
||||
} = Input.getFromUser();
|
||||
const baseImage = new ImageTag({ editorVersion, customImage });
|
||||
@@ -46,6 +49,9 @@ export async function run() {
|
||||
gitPrivateToken,
|
||||
githubToken,
|
||||
chownFilesTo,
|
||||
dockerCpuLimit,
|
||||
dockerMemoryLimit,
|
||||
dockerIsolationMode,
|
||||
unityLicensingServer,
|
||||
...runnerContext,
|
||||
});
|
||||
|
||||
@@ -69,6 +69,8 @@ const Docker = {
|
||||
githubToken,
|
||||
runnerTemporaryPath,
|
||||
chownFilesTo,
|
||||
dockerCpuLimit,
|
||||
dockerMemoryLimit,
|
||||
unityLicensingServer,
|
||||
} = parameters;
|
||||
|
||||
@@ -126,6 +128,8 @@ const Docker = {
|
||||
--volume "${actionFolder}/steps:/steps:z" \
|
||||
--volume "${actionFolder}/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
|
||||
@@ -161,6 +165,9 @@ const Docker = {
|
||||
githubToken,
|
||||
runnerTemporaryPath,
|
||||
chownFilesTo,
|
||||
dockerCpuLimit,
|
||||
dockerMemoryLimit,
|
||||
dockerIsolationMode,
|
||||
unityLicensingServer,
|
||||
} = parameters;
|
||||
|
||||
@@ -222,6 +229,9 @@ const Docker = {
|
||||
? `--volume c:/Users/Administrator/.ssh/known_hosts:c:/root/.ssh/known_hosts`
|
||||
: ''
|
||||
} \
|
||||
--cpus=${dockerCpuLimit} \
|
||||
--memory=${dockerMemoryLimit} \
|
||||
--isolation=${dockerIsolationMode} \
|
||||
${useHostNetwork ? '--net=host' : ''} \
|
||||
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
|
||||
${image} \
|
||||
|
||||
@@ -50,7 +50,7 @@ describe('ImageTag', () => {
|
||||
targetPlatform: some.targetPlatform,
|
||||
});
|
||||
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111-2`);
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111-3`);
|
||||
});
|
||||
it('returns customImage if given', () => {
|
||||
const image = new ImageTag({
|
||||
@@ -65,13 +65,13 @@ describe('ImageTag', () => {
|
||||
it('returns the specific build platform', () => {
|
||||
const image = new ImageTag({ editorVersion: '2022.3.7f1', targetPlatform: 'WebGL' });
|
||||
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2022.3.7f1-webgl-2`);
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2022.3.7f1-webgl-3`);
|
||||
});
|
||||
|
||||
it('returns no specific build platform for generic targetPlatforms', () => {
|
||||
const image = new ImageTag({ targetPlatform: 'NoTarget' });
|
||||
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2022.3.7f1-2`);
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2022.3.7f1-3`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ class ImageTag {
|
||||
this.targetPlatform = targetPlatform;
|
||||
this.targetPlatformSuffix = ImageTag.getTargetPlatformSuffix(targetPlatform, editorVersion);
|
||||
this.imagePlatformPrefix = ImageTag.getImagePlatformPrefix(process.platform);
|
||||
this.imageRollingVersion = 2;
|
||||
this.imageRollingVersion = 3;
|
||||
}
|
||||
|
||||
static get versionPattern() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import UnityVersionParser from './unity-version-parser';
|
||||
import fs from 'fs';
|
||||
import { getInput } from '@actions/core';
|
||||
import os from 'os';
|
||||
|
||||
const Input = {
|
||||
get testModes() {
|
||||
@@ -85,6 +86,24 @@ const Input = {
|
||||
const rawPackageMode = getInput('packageMode') || 'false';
|
||||
let packageName = '';
|
||||
const chownFilesTo = getInput('chownFilesTo') || '';
|
||||
const dockerCpuLimit = getInput('dockerCpuLimit') || os.cpus().length.toString();
|
||||
const bytesInMegabyte = 1024 * 1024;
|
||||
let memoryMultiplier;
|
||||
switch (os.platform()) {
|
||||
case 'linux':
|
||||
memoryMultiplier = 0.95;
|
||||
break;
|
||||
case 'win32':
|
||||
memoryMultiplier = 0.8;
|
||||
break;
|
||||
default:
|
||||
memoryMultiplier = 0.75;
|
||||
break;
|
||||
}
|
||||
const dockerMemoryLimit =
|
||||
getInput('dockerMemoryLimit') ||
|
||||
`${Math.floor((os.totalmem() / bytesInMegabyte) * memoryMultiplier)}m`;
|
||||
const dockerIsolationMode = getInput('dockerIsolationMode') || 'default';
|
||||
|
||||
// Validate input
|
||||
if (!this.testModes.includes(testMode)) {
|
||||
@@ -159,6 +178,9 @@ const Input = {
|
||||
packageMode,
|
||||
packageName,
|
||||
chownFilesTo,
|
||||
dockerCpuLimit,
|
||||
dockerMemoryLimit,
|
||||
dockerIsolationMode,
|
||||
unityLicensingServer,
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user