Update windows images and add docker parameters (#244)
* Update windows images and add docker parameters * Run yarn-audit-fixpull/254/head
parent
7b6d529621
commit
8bb2cdbd2c
18
action.yml
18
action.yml
|
@ -60,6 +60,24 @@ inputs:
|
|||
required: false
|
||||
default: ''
|
||||
description: 'User and optionally group (user or user:group or uid:gid) to give ownership of the resulting build artifacts'
|
||||
dockerCpuLimit:
|
||||
required: false
|
||||
default: ''
|
||||
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 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'
|
||||
dockerIsolationMode:
|
||||
required: false
|
||||
default: 'default'
|
||||
description:
|
||||
'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 versions use process and desktop versions use hyperv. Only
|
||||
applicable on Windows'
|
||||
unityLicensingServer:
|
||||
required: false
|
||||
default: ''
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -8,4 +8,6 @@ module.exports = {
|
|||
'^.+\\.ts$': 'ts-jest',
|
||||
},
|
||||
verbose: true,
|
||||
modulePathIgnorePatterns: ['<rootDir>/lib/', '<rootDir>/dist/'],
|
||||
setupFilesAfterEnv: ['<rootDir>/src/jest.setup.ts'],
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "unity-test-runner",
|
||||
"version": "2.0.0",
|
||||
"version": "3.0.0",
|
||||
"description": "Run tests for any Unity project.",
|
||||
"main": "dist/index.js",
|
||||
"repository": "git@github.com:game-ci/unity-test-runner.git",
|
||||
|
@ -24,7 +24,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^14.14.9",
|
||||
"@types/node": "^20.8.10",
|
||||
"@types/semver": "^7.3.5",
|
||||
"@typescript-eslint/parser": "^5.9.0",
|
||||
"@vercel/ncc": "^0.33.1",
|
||||
|
@ -37,11 +37,14 @@
|
|||
"husky": "^7.0.4",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^26.6.3",
|
||||
"jest-fail-on-console": "^3.0.2",
|
||||
"js-yaml": "^3.14.0",
|
||||
"lint-staged": "^12.1.2",
|
||||
"prettier": "^2.2.1",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "^4.1.5"
|
||||
"ts-node": "10.4.0",
|
||||
"typescript": "^4.1.5",
|
||||
"yarn-audit-fix": "^9.3.8"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,jsx,ts,tsx}": [
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue