Merge remote-tracking branch 'upstream/main'
commit
793451abba
|
@ -62,7 +62,7 @@ jobs:
|
||||||
testMode: ${{ matrix.testMode }}
|
testMode: ${{ matrix.testMode }}
|
||||||
artifactsPath: ${{ matrix.testMode }}-artifacts
|
artifactsPath: ${{ matrix.testMode }}-artifacts
|
||||||
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue
|
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: Test results for ${{ matrix.testMode }}
|
name: Test results for ${{ matrix.testMode }}
|
||||||
path: ${{ steps.tests.outputs.artifactsPath }}
|
path: ${{ steps.tests.outputs.artifactsPath }}
|
||||||
|
@ -105,16 +105,25 @@ jobs:
|
||||||
projectPath: ${{ matrix.projectPath }}
|
projectPath: ${{ matrix.projectPath }}
|
||||||
unityVersion: ${{ matrix.unityVersion }}
|
unityVersion: ${{ matrix.unityVersion }}
|
||||||
testMode: all
|
testMode: all
|
||||||
|
coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+MyScripts'
|
||||||
# Test implicit artifactsPath, by not setting it
|
# Test implicit artifactsPath, by not setting it
|
||||||
|
|
||||||
# Upload artifacts
|
# Upload artifacts
|
||||||
- name: Upload test results
|
- name: Upload test results
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: Test results (all)
|
name: Test results (all)
|
||||||
path: ${{ steps.allTests.outputs.artifactsPath }}
|
path: ${{ steps.allTests.outputs.artifactsPath }}
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
|
# Upload coverage
|
||||||
|
- name: Upload coverage results
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: Coverage results (all)
|
||||||
|
path: ${{ steps.allTests.outputs.coveragePath }}
|
||||||
|
retention-days: 14
|
||||||
|
|
||||||
testRunnerInEditMode:
|
testRunnerInEditMode:
|
||||||
name: Test edit mode 📝
|
name: Test edit mode 📝
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -156,12 +165,20 @@ jobs:
|
||||||
|
|
||||||
# Upload artifacts
|
# Upload artifacts
|
||||||
- name: Upload test results
|
- name: Upload test results
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: Test results (edit mode)
|
name: Test results (edit mode)
|
||||||
path: ${{ steps.editMode.outputs.artifactsPath }}
|
path: ${{ steps.editMode.outputs.artifactsPath }}
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
|
# Upload coverage
|
||||||
|
- name: Upload coverage results
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: Coverage results (edit mode)
|
||||||
|
path: ${{ steps.editMode.outputs.coveragePath }}
|
||||||
|
retention-days: 14
|
||||||
|
|
||||||
testRunnerInPlayMode:
|
testRunnerInPlayMode:
|
||||||
name: Test play mode 📺
|
name: Test play mode 📺
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -203,12 +220,20 @@ jobs:
|
||||||
|
|
||||||
# Upload artifacts
|
# Upload artifacts
|
||||||
- name: Upload test results
|
- name: Upload test results
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: Test results (play mode)
|
name: Test results (play mode)
|
||||||
path: ${{ steps.playMode.outputs.artifactsPath }}
|
path: ${{ steps.playMode.outputs.artifactsPath }}
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
|
# Upload coverage
|
||||||
|
- name: Upload coverage results
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: Coverage results (play mode)
|
||||||
|
path: ${{ steps.playMode.outputs.coveragePath }}
|
||||||
|
retention-days: 14
|
||||||
|
|
||||||
testEachModeSequentially:
|
testEachModeSequentially:
|
||||||
name: Test each mode sequentially 👩👩👧👦 # don't try this at home (it's much slower)
|
name: Test each mode sequentially 👩👩👧👦 # don't try this at home (it's much slower)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -258,7 +283,7 @@ jobs:
|
||||||
|
|
||||||
# Upload combined artifacts
|
# Upload combined artifacts
|
||||||
- name: Upload combined test results
|
- name: Upload combined test results
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: Test results (combined)
|
name: Test results (combined)
|
||||||
path: artifacts/
|
path: artifacts/
|
||||||
|
|
|
@ -8,4 +8,6 @@ fi
|
||||||
yarn lint-staged
|
yarn lint-staged
|
||||||
yarn lint
|
yarn lint
|
||||||
yarn test
|
yarn test
|
||||||
|
|
||||||
yarn build
|
yarn build
|
||||||
|
git add dist
|
||||||
|
|
|
@ -20,6 +20,10 @@ inputs:
|
||||||
required: false
|
required: false
|
||||||
default: 'all'
|
default: 'all'
|
||||||
description: 'The type of tests to be run by the test runner.'
|
description: 'The type of tests to be run by the test runner.'
|
||||||
|
coverageOptions:
|
||||||
|
required: false
|
||||||
|
default: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport'
|
||||||
|
description: 'Optional coverage parameters for the -coverageOptions argument.'
|
||||||
artifactsPath:
|
artifactsPath:
|
||||||
required: false
|
required: false
|
||||||
default: 'artifacts'
|
default: 'artifacts'
|
||||||
|
@ -50,7 +54,9 @@ inputs:
|
||||||
description: 'Whether the tests are being run for a Unity package instead of a Unity project. If true, any custom docker image passed to this action must have `jq` installed. NOTE: packages with dependencies outside of the Unity package registry are currently not supported.'
|
description: 'Whether the tests are being run for a Unity package instead of a Unity project. If true, any custom docker image passed to this action must have `jq` installed. NOTE: packages with dependencies outside of the Unity package registry are currently not supported.'
|
||||||
outputs:
|
outputs:
|
||||||
artifactsPath:
|
artifactsPath:
|
||||||
description: 'Path where the artifacts are stored'
|
description: 'Path where the artifacts are stored.'
|
||||||
|
coveragePath:
|
||||||
|
description: 'Path where the code coverage results are stored.'
|
||||||
branding:
|
branding:
|
||||||
icon: 'box'
|
icon: 'box'
|
||||||
color: 'gray-dark'
|
color: 'gray-dark'
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
ARG IMAGE
|
|
||||||
FROM $IMAGE
|
|
||||||
|
|
||||||
LABEL "com.github.actions.name"="Unity - Test runner"
|
|
||||||
LABEL "com.github.actions.description"="Run tests for any Unity project."
|
|
||||||
LABEL "com.github.actions.icon"="box"
|
|
||||||
LABEL "com.github.actions.color"="gray-dark"
|
|
||||||
|
|
||||||
LABEL "repository"="http://github.com/webbertakken/unity-actions"
|
|
||||||
LABEL "homepage"="http://github.com/webbertakken/unity-actions"
|
|
||||||
LABEL "maintainer"="Webber Takken <webber@takken.io>"
|
|
||||||
|
|
||||||
ADD steps /steps
|
|
||||||
RUN chmod -R +x /steps
|
|
||||||
ADD entrypoint.sh /entrypoint.sh
|
|
||||||
RUN chmod +x /entrypoint.sh
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
@ -41,20 +41,19 @@ function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
model_1.Action.checkCompatibility();
|
model_1.Action.checkCompatibility();
|
||||||
const { dockerfile, workspace, actionFolder } = model_1.Action;
|
const { workspace, actionFolder } = model_1.Action;
|
||||||
const { unityVersion, customImage, projectPath, customParameters, testMode, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, checkName, packageMode, packageName, } = model_1.Input.getFromUser();
|
const { editorVersion, customImage, projectPath, customParameters, testMode, coverageOptions, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, checkName, packageMode, packageName, } = model_1.Input.getFromUser();
|
||||||
const baseImage = new model_1.ImageTag({ version: unityVersion, customImage });
|
const baseImage = new model_1.ImageTag({ editorVersion, customImage });
|
||||||
const runnerTemporaryPath = process.env.RUNNER_TEMP;
|
const runnerTemporaryPath = process.env.RUNNER_TEMP;
|
||||||
try {
|
try {
|
||||||
// Build docker image
|
yield model_1.Docker.run(baseImage, {
|
||||||
const actionImage = yield model_1.Docker.build({ path: actionFolder, dockerfile, baseImage });
|
actionFolder,
|
||||||
// Run docker image
|
editorVersion,
|
||||||
yield model_1.Docker.run(actionImage, {
|
|
||||||
unityVersion,
|
|
||||||
workspace,
|
workspace,
|
||||||
projectPath,
|
projectPath,
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
|
coverageOptions,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
@ -66,8 +65,8 @@ function run() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
// Set output
|
|
||||||
yield model_1.Output.setArtifactsPath(artifactsPath);
|
yield model_1.Output.setArtifactsPath(artifactsPath);
|
||||||
|
yield model_1.Output.setCoveragePath('CodeCoverage');
|
||||||
}
|
}
|
||||||
if (githubToken) {
|
if (githubToken) {
|
||||||
const failedTestCount = yield model_1.ResultsCheck.createCheck(artifactsPath, githubToken, checkName);
|
const failedTestCount = yield model_1.ResultsCheck.createCheck(artifactsPath, githubToken, checkName);
|
||||||
|
@ -118,9 +117,6 @@ const Action = {
|
||||||
get actionFolder() {
|
get actionFolder() {
|
||||||
return `${Action.rootFolder}/dist`;
|
return `${Action.rootFolder}/dist`;
|
||||||
},
|
},
|
||||||
get dockerfile() {
|
|
||||||
return `${Action.actionFolder}/Dockerfile`;
|
|
||||||
},
|
|
||||||
get workspace() {
|
get workspace() {
|
||||||
return process.env.GITHUB_WORKSPACE;
|
return process.env.GITHUB_WORKSPACE;
|
||||||
},
|
},
|
||||||
|
@ -155,32 +151,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const fs_1 = __nccwpck_require__(7147);
|
const fs_1 = __nccwpck_require__(7147);
|
||||||
const image_tag_1 = __importDefault(__nccwpck_require__(7648));
|
|
||||||
const exec_1 = __nccwpck_require__(1514);
|
const exec_1 = __nccwpck_require__(1514);
|
||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
const Docker = {
|
const Docker = {
|
||||||
build(buildParameters, silent = false) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const { path: buildPath, dockerfile, baseImage } = buildParameters;
|
|
||||||
const { version } = baseImage;
|
|
||||||
const tag = new image_tag_1.default({ version });
|
|
||||||
const command = `docker build ${buildPath} \
|
|
||||||
--file ${dockerfile} \
|
|
||||||
--build-arg IMAGE=${baseImage} \
|
|
||||||
--tag ${tag}`;
|
|
||||||
yield (0, exec_1.exec)(command, undefined, { silent });
|
|
||||||
return tag;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
run(image, parameters, silent = false) {
|
run(image, parameters, silent = false) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { unityVersion, workspace, projectPath, customParameters, testMode, artifactsPath, useHostNetwork, sshAgent, packageMode, packageName, gitPrivateToken, githubToken, runnerTemporaryPath, } = parameters;
|
const { actionFolder, editorVersion, workspace, projectPath, customParameters, testMode, coverageOptions, artifactsPath, useHostNetwork, sshAgent, packageMode, packageName, gitPrivateToken, githubToken, runnerTemporaryPath, } = parameters;
|
||||||
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
|
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
|
||||||
if (!(0, fs_1.existsSync)(githubHome))
|
if (!(0, fs_1.existsSync)(githubHome))
|
||||||
(0, fs_1.mkdirSync)(githubHome);
|
(0, fs_1.mkdirSync)(githubHome);
|
||||||
const githubWorkflow = path_1.default.join(runnerTemporaryPath, '_github_workflow');
|
const githubWorkflow = path_1.default.join(runnerTemporaryPath, '_github_workflow');
|
||||||
if (!(0, fs_1.existsSync)(githubWorkflow))
|
if (!(0, fs_1.existsSync)(githubWorkflow))
|
||||||
(0, fs_1.mkdirSync)(githubWorkflow);
|
(0, fs_1.mkdirSync)(githubWorkflow);
|
||||||
|
const testPlatforms = (testMode === 'all' ? ['playmode', 'editmode', 'COMBINE_RESULTS'] : [testMode]).join(';');
|
||||||
const command = `docker run \
|
const command = `docker run \
|
||||||
--workdir /github/workspace \
|
--workdir /github/workspace \
|
||||||
--rm \
|
--rm \
|
||||||
|
@ -189,10 +172,12 @@ const Docker = {
|
||||||
--env UNITY_EMAIL \
|
--env UNITY_EMAIL \
|
||||||
--env UNITY_PASSWORD \
|
--env UNITY_PASSWORD \
|
||||||
--env UNITY_SERIAL \
|
--env UNITY_SERIAL \
|
||||||
--env UNITY_VERSION="${unityVersion}" \
|
--env UNITY_VERSION="${editorVersion}" \
|
||||||
--env PROJECT_PATH="${projectPath}" \
|
--env PROJECT_PATH="${projectPath}" \
|
||||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||||
--env TEST_MODE="${testMode}" \
|
--env TEST_PLATFORMS="${testPlatforms}" \
|
||||||
|
--env COVERAGE_OPTIONS="${coverageOptions}" \
|
||||||
|
--env COVERAGE_RESULTS_PATH="CodeCoverage" \
|
||||||
--env ARTIFACTS_PATH="${artifactsPath}" \
|
--env ARTIFACTS_PATH="${artifactsPath}" \
|
||||||
--env PACKAGE_MODE="${packageMode}" \
|
--env PACKAGE_MODE="${packageMode}" \
|
||||||
--env PACKAGE_NAME="${packageName}" \
|
--env PACKAGE_NAME="${packageName}" \
|
||||||
|
@ -213,15 +198,17 @@ const Docker = {
|
||||||
--env RUNNER_WORKSPACE \
|
--env RUNNER_WORKSPACE \
|
||||||
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
||||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
||||||
--volume "/var/run/docker.sock":"/var/run/docker.sock" \
|
|
||||||
--volume "${githubHome}":"/root:z" \
|
--volume "${githubHome}":"/root:z" \
|
||||||
--volume "${githubWorkflow}":"/github/workflow:z" \
|
--volume "${githubWorkflow}":"/github/workflow:z" \
|
||||||
--volume "${workspace}":"/github/workspace:z" \
|
--volume "${workspace}":"/github/workspace:z" \
|
||||||
|
--volume "${actionFolder}/steps":"/steps:z" \
|
||||||
|
--volume "${actionFolder}/entrypoint.sh":"/entrypoint.sh:z" \
|
||||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
||||||
${useHostNetwork ? '--net=host' : ''} \
|
${useHostNetwork ? '--net=host' : ''} \
|
||||||
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
|
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
|
||||||
${image}`;
|
${image} \
|
||||||
|
/bin/bash /entrypoint.sh`;
|
||||||
yield (0, exec_1.exec)(command, undefined, { silent });
|
yield (0, exec_1.exec)(command, undefined, { silent });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -243,22 +230,25 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const platform_1 = __importDefault(__nccwpck_require__(9707));
|
const platform_1 = __importDefault(__nccwpck_require__(9707));
|
||||||
class ImageTag {
|
class ImageTag {
|
||||||
constructor(imageProperties) {
|
constructor(imageProperties) {
|
||||||
const { repository = 'unityci', name = 'editor', version = '2019.2.11f1', platform = platform_1.default.types.StandaloneLinux64, customImage, } = imageProperties;
|
const { editorVersion = '2019.2.11f1', targetPlatform = platform_1.default.types.StandaloneLinux64, customImage, } = imageProperties;
|
||||||
if (!ImageTag.versionPattern.test(version)) {
|
if (!ImageTag.versionPattern.test(editorVersion)) {
|
||||||
throw new Error(`Invalid version "${version}".`);
|
throw new Error(`Invalid version "${editorVersion}".`);
|
||||||
}
|
}
|
||||||
const builderPlatform = ImageTag.getTargetPlatformToImageSuffixMap(platform, version);
|
// Either
|
||||||
this.repository = repository;
|
|
||||||
this.name = name;
|
|
||||||
this.version = version;
|
|
||||||
this.platform = platform;
|
|
||||||
this.builderPlatform = builderPlatform;
|
|
||||||
this.customImage = customImage;
|
this.customImage = customImage;
|
||||||
|
// Or
|
||||||
|
this.repository = 'unityci';
|
||||||
|
this.name = 'editor';
|
||||||
|
this.editorVersion = editorVersion;
|
||||||
|
this.targetPlatform = targetPlatform;
|
||||||
|
this.targetPlatformSuffix = ImageTag.getTargetPlatformSuffix(targetPlatform, editorVersion);
|
||||||
|
this.imagePlatformPrefix = ImageTag.getImagePlatformPrefix(process.platform);
|
||||||
|
this.imageRollingVersion = 1;
|
||||||
}
|
}
|
||||||
static get versionPattern() {
|
static get versionPattern() {
|
||||||
return /^20\d{2}\.\d\.\w{3,4}|3$/;
|
return /^20\d{2}\.\d\.\w{3,4}|3$/;
|
||||||
}
|
}
|
||||||
static get imageSuffixes() {
|
static get targetPlatformSuffixes() {
|
||||||
return {
|
return {
|
||||||
generic: '',
|
generic: '',
|
||||||
webgl: 'webgl',
|
webgl: 'webgl',
|
||||||
|
@ -271,11 +261,19 @@ class ImageTag {
|
||||||
facebook: 'facebook',
|
facebook: 'facebook',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
static getTargetPlatformToImageSuffixMap(platform, version) {
|
static getImagePlatformPrefix(platform) {
|
||||||
const { generic, webgl, mac, windows, linux, linuxIl2cpp, android, ios, facebook } = ImageTag.imageSuffixes;
|
|
||||||
const [major, minor] = version.split('.').map(digit => Number(digit));
|
|
||||||
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
|
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
|
case 'linux':
|
||||||
|
return 'ubuntu';
|
||||||
|
default:
|
||||||
|
throw new Error('The Operating System of this runner is not yet supported.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static getTargetPlatformSuffix(targetPlatform, editorVersion) {
|
||||||
|
const { generic, webgl, mac, windows, linux, linuxIl2cpp, android, ios, facebook } = ImageTag.targetPlatformSuffixes;
|
||||||
|
const [major, minor] = editorVersion.split('.').map(digit => Number(digit));
|
||||||
|
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
|
||||||
|
switch (targetPlatform) {
|
||||||
case platform_1.default.types.StandaloneOSX:
|
case platform_1.default.types.StandaloneOSX:
|
||||||
return mac;
|
return mac;
|
||||||
case platform_1.default.types.StandaloneWindows:
|
case platform_1.default.types.StandaloneWindows:
|
||||||
|
@ -322,22 +320,21 @@ class ImageTag {
|
||||||
default:
|
default:
|
||||||
throw new Error(`
|
throw new Error(`
|
||||||
Platform must be one of the ones described in the documentation.
|
Platform must be one of the ones described in the documentation.
|
||||||
"${platform}" is currently not supported.`);
|
"${targetPlatform}" is currently not supported.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get tag() {
|
get tag() {
|
||||||
return `${this.version}-${this.builderPlatform}`.replace(/-+$/, '');
|
const versionAndTarget = `${this.editorVersion}-${this.targetPlatformSuffix}`.replace(/-+$/, '');
|
||||||
|
return `${this.imagePlatformPrefix}-${versionAndTarget}-${this.imageRollingVersion}`;
|
||||||
}
|
}
|
||||||
get image() {
|
get image() {
|
||||||
return `${this.repository}/${this.name}`.replace(/^\/+/, '');
|
return `${this.repository}/${this.name}`.replace(/^\/+/, '');
|
||||||
}
|
}
|
||||||
toString() {
|
toString() {
|
||||||
const { image, tag, customImage } = this;
|
const { image, tag, customImage } = this;
|
||||||
if (customImage && customImage !== '') {
|
if (customImage)
|
||||||
return customImage;
|
return customImage;
|
||||||
}
|
return `${image}:${tag}`;
|
||||||
const dockerRepoVersion = 0;
|
|
||||||
return `${image}:${tag}-${dockerRepoVersion}`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = ImageTag;
|
exports["default"] = ImageTag;
|
||||||
|
@ -428,11 +425,12 @@ const Input = {
|
||||||
},
|
},
|
||||||
getFromUser() {
|
getFromUser() {
|
||||||
// Input variables specified in workflow using "with" prop.
|
// Input variables specified in workflow using "with" prop.
|
||||||
const rawUnityVersion = (0, core_1.getInput)('unityVersion') || 'auto';
|
const unityVersion = (0, core_1.getInput)('unityVersion') || 'auto';
|
||||||
const customImage = (0, core_1.getInput)('customImage') || '';
|
const customImage = (0, core_1.getInput)('customImage') || '';
|
||||||
const rawProjectPath = (0, core_1.getInput)('projectPath') || '.';
|
const rawProjectPath = (0, core_1.getInput)('projectPath') || '.';
|
||||||
const customParameters = (0, core_1.getInput)('customParameters') || '';
|
const customParameters = (0, core_1.getInput)('customParameters') || '';
|
||||||
const testMode = ((0, core_1.getInput)('testMode') || 'all').toLowerCase();
|
const testMode = ((0, core_1.getInput)('testMode') || 'all').toLowerCase();
|
||||||
|
const coverageOptions = (0, core_1.getInput)('coverageOptions') || '';
|
||||||
const rawArtifactsPath = (0, core_1.getInput)('artifactsPath') || 'artifacts';
|
const rawArtifactsPath = (0, core_1.getInput)('artifactsPath') || 'artifacts';
|
||||||
const rawUseHostNetwork = (0, core_1.getInput)('useHostNetwork') || 'false';
|
const rawUseHostNetwork = (0, core_1.getInput)('useHostNetwork') || 'false';
|
||||||
const sshAgent = (0, core_1.getInput)('sshAgent') || '';
|
const sshAgent = (0, core_1.getInput)('sshAgent') || '';
|
||||||
|
@ -469,14 +467,15 @@ const Input = {
|
||||||
// Sanitise other input
|
// Sanitise other input
|
||||||
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
||||||
const useHostNetwork = rawUseHostNetwork === 'true';
|
const useHostNetwork = rawUseHostNetwork === 'true';
|
||||||
const unityVersion = rawUnityVersion === 'auto' ? unity_version_parser_1.default.read(projectPath) : rawUnityVersion;
|
const editorVersion = unityVersion === 'auto' ? unity_version_parser_1.default.read(projectPath) : unityVersion;
|
||||||
// Return sanitised input
|
// Return sanitised input
|
||||||
return {
|
return {
|
||||||
unityVersion,
|
editorVersion,
|
||||||
customImage,
|
customImage,
|
||||||
projectPath,
|
projectPath,
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
|
coverageOptions,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
@ -534,6 +533,11 @@ const Output = {
|
||||||
yield core.setOutput('artifactsPath', artifactsPath);
|
yield core.setOutput('artifactsPath', artifactsPath);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
setCoveragePath(coveragePath) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
yield core.setOutput('coveragePath', coveragePath);
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
exports["default"] = Output;
|
exports["default"] = Output;
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -77,27 +77,18 @@ fi
|
||||||
echo "Using artifacts path \"$ARTIFACTS_PATH\" to save test results."
|
echo "Using artifacts path \"$ARTIFACTS_PATH\" to save test results."
|
||||||
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
|
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set and display the coverage results path
|
||||||
|
#
|
||||||
|
|
||||||
|
echo "Using coverage results path \"$COVERAGE_RESULTS_PATH\" to save test coverage results."
|
||||||
|
FULL_COVERAGE_RESULTS_PATH=$GITHUB_WORKSPACE/$COVERAGE_RESULTS_PATH
|
||||||
|
|
||||||
#
|
#
|
||||||
# Display custom parameters
|
# Display custom parameters
|
||||||
#
|
#
|
||||||
echo "Using custom parameters $CUSTOM_PARAMETERS."
|
|
||||||
|
|
||||||
# Set the modes for testing
|
echo "Using custom parameters $CUSTOM_PARAMETERS."
|
||||||
case $TEST_MODE in
|
|
||||||
editmode)
|
|
||||||
echo "Edit mode selected for testing."
|
|
||||||
EDIT_MODE=true
|
|
||||||
;;
|
|
||||||
playmode)
|
|
||||||
echo "Play mode selected for testing."
|
|
||||||
PLAY_MODE=true
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "All modes selected for testing."
|
|
||||||
EDIT_MODE=true
|
|
||||||
PLAY_MODE=true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# The following tests are 2019 mode (requires Unity 2019.2.11f1 or later)
|
# The following tests are 2019 mode (requires Unity 2019.2.11f1 or later)
|
||||||
# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html
|
# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html
|
||||||
|
@ -128,118 +119,61 @@ echo ""
|
||||||
ls -alh $UNITY_PROJECT_PATH
|
ls -alh $UNITY_PROJECT_PATH
|
||||||
|
|
||||||
#
|
#
|
||||||
# Testing in EditMode
|
# Testing for each platform
|
||||||
#
|
#
|
||||||
EDIT_MODE_EXIT_CODE=0
|
for platform in ${TEST_PLATFORMS//;/ }; do
|
||||||
if [ "$EDIT_MODE" = "true" ]; then
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "###########################"
|
echo "###########################"
|
||||||
echo "# Testing in EditMode #"
|
echo "# Testing in $platform #"
|
||||||
echo "###########################"
|
echo "###########################"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
if [[ "$platform" != "COMBINE_RESULTS" ]]; then
|
||||||
|
runTests="-runTests -testPlatform $platform -testResults $FULL_ARTIFACTS_PATH/$platform-results.xml"
|
||||||
|
else
|
||||||
|
runTests="-quit"
|
||||||
|
fi
|
||||||
|
|
||||||
unity-editor \
|
unity-editor \
|
||||||
-batchmode \
|
-batchmode \
|
||||||
-logFile "$FULL_ARTIFACTS_PATH/editmode.log" \
|
-logFile "$FULL_ARTIFACTS_PATH/$platform.log" \
|
||||||
-projectPath "$UNITY_PROJECT_PATH" \
|
-projectPath "$UNITY_PROJECT_PATH" \
|
||||||
-runTests \
|
-coverageResultsPath "$FULL_COVERAGE_RESULTS_PATH" \
|
||||||
-testPlatform editmode \
|
$runTests \
|
||||||
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml" \
|
-enableCodeCoverage \
|
||||||
|
-debugCodeOptimization \
|
||||||
|
-coverageOptions "$COVERAGE_OPTIONS" \
|
||||||
$CUSTOM_PARAMETERS
|
$CUSTOM_PARAMETERS
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
EDIT_MODE_EXIT_CODE=$?
|
TEST_EXIT_CODE=$?
|
||||||
|
|
||||||
# Print unity log output
|
# Print unity log output
|
||||||
cat "$FULL_ARTIFACTS_PATH/editmode.log"
|
cat "$FULL_ARTIFACTS_PATH/$platform.log"
|
||||||
|
|
||||||
# Display results
|
# Display results
|
||||||
if [ $EDIT_MODE_EXIT_CODE -eq 0 ]; then
|
if [ $TEST_EXIT_CODE -eq 0 ]; then
|
||||||
echo "Run succeeded, no failures occurred";
|
echo "Run succeeded, no failures occurred";
|
||||||
elif [ $EDIT_MODE_EXIT_CODE -eq 2 ]; then
|
elif [ $TEST_EXIT_CODE -eq 2 ]; then
|
||||||
echo "Run succeeded, some tests failed";
|
echo "Run succeeded, some tests failed";
|
||||||
elif [ $EDIT_MODE_EXIT_CODE -eq 3 ]; then
|
elif [ $TEST_EXIT_CODE -eq 3 ]; then
|
||||||
echo "Run failure (other failure)";
|
echo "Run failure (other failure)";
|
||||||
else
|
else
|
||||||
echo "Unexpected exit code $EDIT_MODE_EXIT_CODE";
|
echo "Unexpected exit code $TEST_EXIT_CODE";
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
if [ $TEST_EXIT_CODE -ne 0 ]; then
|
||||||
# Testing in PlayMode
|
TEST_RUNNER_EXIT_CODE=$TEST_EXIT_CODE
|
||||||
#
|
|
||||||
PLAY_MODE_EXIT_CODE=0
|
|
||||||
if [ "$PLAY_MODE" = "true" ]; then
|
|
||||||
echo ""
|
|
||||||
echo "###########################"
|
|
||||||
echo "# Testing in PlayMode #"
|
|
||||||
echo "###########################"
|
|
||||||
echo ""
|
|
||||||
unity-editor \
|
|
||||||
-batchmode \
|
|
||||||
-logFile "$FULL_ARTIFACTS_PATH/playmode.log" \
|
|
||||||
-projectPath "$UNITY_PROJECT_PATH" \
|
|
||||||
-runTests \
|
|
||||||
-testPlatform playmode \
|
|
||||||
-testResults "$FULL_ARTIFACTS_PATH/playmode-results.xml" \
|
|
||||||
$CUSTOM_PARAMETERS
|
|
||||||
|
|
||||||
# Catch exit code
|
|
||||||
PLAY_MODE_EXIT_CODE=$?
|
|
||||||
|
|
||||||
# Print unity log output
|
|
||||||
cat "$FULL_ARTIFACTS_PATH/playmode.log"
|
|
||||||
|
|
||||||
# Display results
|
|
||||||
if [ $PLAY_MODE_EXIT_CODE -eq 0 ]; then
|
|
||||||
echo "Run succeeded, no failures occurred";
|
|
||||||
elif [ $PLAY_MODE_EXIT_CODE -eq 2 ]; then
|
|
||||||
echo "Run succeeded, some tests failed";
|
|
||||||
elif [ $PLAY_MODE_EXIT_CODE -eq 3 ]; then
|
|
||||||
echo "Run failure (other failure)";
|
|
||||||
else
|
|
||||||
echo "Unexpected exit code $PLAY_MODE_EXIT_CODE";
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Results
|
|
||||||
#
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "###########################"
|
|
||||||
echo "# Project directory #"
|
|
||||||
echo "###########################"
|
|
||||||
echo ""
|
|
||||||
ls -alh $UNITY_PROJECT_PATH
|
|
||||||
|
|
||||||
if [ "$EDIT_MODE" = "true" ]; then
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "###########################"
|
echo "###########################"
|
||||||
echo "# Edit Mode Results #"
|
echo "# $platform Results #"
|
||||||
echo "###########################"
|
echo "###########################"
|
||||||
echo ""
|
echo ""
|
||||||
cat "$FULL_ARTIFACTS_PATH/editmode-results.xml"
|
|
||||||
cat "$FULL_ARTIFACTS_PATH/editmode-results.xml" | grep test-run | grep Passed
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$PLAY_MODE" = "true" ]; then
|
if [[ "$platform" != "COMBINE_RESULTS" ]]; then
|
||||||
echo ""
|
cat "$FULL_ARTIFACTS_PATH/$platform-results.xml"
|
||||||
echo "###########################"
|
cat "$FULL_ARTIFACTS_PATH/$platform-results.xml" | grep test-run | grep Passed
|
||||||
echo "# Play Mode Results #"
|
fi
|
||||||
echo "###########################"
|
done
|
||||||
echo ""
|
|
||||||
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml"
|
|
||||||
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml" | grep test-run | grep Passed
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Exit
|
|
||||||
#
|
|
||||||
|
|
||||||
if [ $EDIT_MODE_EXIT_CODE -gt 0 ]; then
|
|
||||||
TEST_RUNNER_EXIT_CODE=$EDIT_MODE_EXIT_CODE
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $PLAY_MODE_EXIT_CODE -gt 0 ]; then
|
|
||||||
TEST_RUNNER_EXIT_CODE=$PLAY_MODE_EXIT_CODE
|
|
||||||
fi
|
|
||||||
|
|
19
src/index.ts
19
src/index.ts
|
@ -5,13 +5,14 @@ async function run() {
|
||||||
try {
|
try {
|
||||||
Action.checkCompatibility();
|
Action.checkCompatibility();
|
||||||
|
|
||||||
const { dockerfile, workspace, actionFolder } = Action;
|
const { workspace, actionFolder } = Action;
|
||||||
const {
|
const {
|
||||||
unityVersion,
|
editorVersion,
|
||||||
customImage,
|
customImage,
|
||||||
projectPath,
|
projectPath,
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
|
coverageOptions,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
@ -21,20 +22,18 @@ async function run() {
|
||||||
packageMode,
|
packageMode,
|
||||||
packageName,
|
packageName,
|
||||||
} = Input.getFromUser();
|
} = Input.getFromUser();
|
||||||
const baseImage = new ImageTag({ version: unityVersion, customImage });
|
const baseImage = new ImageTag({ editorVersion, customImage });
|
||||||
const runnerTemporaryPath = process.env.RUNNER_TEMP;
|
const runnerTemporaryPath = process.env.RUNNER_TEMP;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Build docker image
|
await Docker.run(baseImage, {
|
||||||
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
actionFolder,
|
||||||
|
editorVersion,
|
||||||
// Run docker image
|
|
||||||
await Docker.run(actionImage, {
|
|
||||||
unityVersion,
|
|
||||||
workspace,
|
workspace,
|
||||||
projectPath,
|
projectPath,
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
|
coverageOptions,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
@ -45,8 +44,8 @@ async function run() {
|
||||||
runnerTemporaryPath,
|
runnerTemporaryPath,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
// Set output
|
|
||||||
await Output.setArtifactsPath(artifactsPath);
|
await Output.setArtifactsPath(artifactsPath);
|
||||||
|
await Output.setCoveragePath('CodeCoverage');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (githubToken) {
|
if (githubToken) {
|
||||||
|
|
|
@ -26,11 +26,4 @@ describe('Action', () => {
|
||||||
expect(path.basename(actionFolder)).toStrictEqual('dist');
|
expect(path.basename(actionFolder)).toStrictEqual('dist');
|
||||||
expect(fs.existsSync(actionFolder)).toStrictEqual(true);
|
expect(fs.existsSync(actionFolder)).toStrictEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the docker file', () => {
|
|
||||||
const { dockerfile } = Action;
|
|
||||||
|
|
||||||
expect(path.basename(dockerfile)).toStrictEqual('Dockerfile');
|
|
||||||
expect(fs.existsSync(dockerfile)).toStrictEqual(true);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,10 +29,6 @@ const Action = {
|
||||||
return `${Action.rootFolder}/dist`;
|
return `${Action.rootFolder}/dist`;
|
||||||
},
|
},
|
||||||
|
|
||||||
get dockerfile() {
|
|
||||||
return `${Action.actionFolder}/Dockerfile`;
|
|
||||||
},
|
|
||||||
|
|
||||||
get workspace() {
|
get workspace() {
|
||||||
return process.env.GITHUB_WORKSPACE;
|
return process.env.GITHUB_WORKSPACE;
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,21 +1,7 @@
|
||||||
import Action from './action';
|
import Action from './action';
|
||||||
import Docker from './docker';
|
import Docker from './docker';
|
||||||
import ImageTag from './image-tag';
|
|
||||||
|
|
||||||
describe('Docker', () => {
|
describe('Docker', () => {
|
||||||
it.skip('builds', async () => {
|
|
||||||
const path = Action.actionFolder;
|
|
||||||
const dockerfile = `${path}/Dockerfile`;
|
|
||||||
const baseImage = new ImageTag({
|
|
||||||
repository: '',
|
|
||||||
name: 'alpine',
|
|
||||||
version: '3',
|
|
||||||
platform: 'Test',
|
|
||||||
});
|
|
||||||
const tag = await Docker.build({ path, dockerfile, baseImage }, true);
|
|
||||||
expect(tag).toBeInstanceOf(ImageTag);
|
|
||||||
expect(tag.toString()).toStrictEqual('unity-builder:3');
|
|
||||||
}, 240_000);
|
|
||||||
it.skip('runs', async () => {
|
it.skip('runs', async () => {
|
||||||
const image = 'unity-builder:2019.2.11f1-webgl';
|
const image = 'unity-builder:2019.2.11f1-webgl';
|
||||||
const parameters = {
|
const parameters = {
|
||||||
|
|
|
@ -1,31 +1,17 @@
|
||||||
import { existsSync, mkdirSync } from 'fs';
|
import { existsSync, mkdirSync } from 'fs';
|
||||||
import ImageTag from './image-tag';
|
|
||||||
import { exec } from '@actions/exec';
|
import { exec } from '@actions/exec';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
const Docker = {
|
const Docker = {
|
||||||
async build(buildParameters, silent = false) {
|
|
||||||
const { path: buildPath, dockerfile, baseImage } = buildParameters;
|
|
||||||
const { version } = baseImage;
|
|
||||||
|
|
||||||
const tag = new ImageTag({ version });
|
|
||||||
const command = `docker build ${buildPath} \
|
|
||||||
--file ${dockerfile} \
|
|
||||||
--build-arg IMAGE=${baseImage} \
|
|
||||||
--tag ${tag}`;
|
|
||||||
|
|
||||||
await exec(command, undefined, { silent });
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
},
|
|
||||||
|
|
||||||
async run(image, parameters, silent = false) {
|
async run(image, parameters, silent = false) {
|
||||||
const {
|
const {
|
||||||
unityVersion,
|
actionFolder,
|
||||||
|
editorVersion,
|
||||||
workspace,
|
workspace,
|
||||||
projectPath,
|
projectPath,
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
|
coverageOptions,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
@ -40,6 +26,9 @@ const Docker = {
|
||||||
if (!existsSync(githubHome)) mkdirSync(githubHome);
|
if (!existsSync(githubHome)) mkdirSync(githubHome);
|
||||||
const githubWorkflow = path.join(runnerTemporaryPath, '_github_workflow');
|
const githubWorkflow = path.join(runnerTemporaryPath, '_github_workflow');
|
||||||
if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow);
|
if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow);
|
||||||
|
const testPlatforms = (
|
||||||
|
testMode === 'all' ? ['playmode', 'editmode', 'COMBINE_RESULTS'] : [testMode]
|
||||||
|
).join(';');
|
||||||
|
|
||||||
const command = `docker run \
|
const command = `docker run \
|
||||||
--workdir /github/workspace \
|
--workdir /github/workspace \
|
||||||
|
@ -49,10 +38,12 @@ const Docker = {
|
||||||
--env UNITY_EMAIL \
|
--env UNITY_EMAIL \
|
||||||
--env UNITY_PASSWORD \
|
--env UNITY_PASSWORD \
|
||||||
--env UNITY_SERIAL \
|
--env UNITY_SERIAL \
|
||||||
--env UNITY_VERSION="${unityVersion}" \
|
--env UNITY_VERSION="${editorVersion}" \
|
||||||
--env PROJECT_PATH="${projectPath}" \
|
--env PROJECT_PATH="${projectPath}" \
|
||||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||||
--env TEST_MODE="${testMode}" \
|
--env TEST_PLATFORMS="${testPlatforms}" \
|
||||||
|
--env COVERAGE_OPTIONS="${coverageOptions}" \
|
||||||
|
--env COVERAGE_RESULTS_PATH="CodeCoverage" \
|
||||||
--env ARTIFACTS_PATH="${artifactsPath}" \
|
--env ARTIFACTS_PATH="${artifactsPath}" \
|
||||||
--env PACKAGE_MODE="${packageMode}" \
|
--env PACKAGE_MODE="${packageMode}" \
|
||||||
--env PACKAGE_NAME="${packageName}" \
|
--env PACKAGE_NAME="${packageName}" \
|
||||||
|
@ -73,15 +64,17 @@ const Docker = {
|
||||||
--env RUNNER_WORKSPACE \
|
--env RUNNER_WORKSPACE \
|
||||||
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
||||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
||||||
--volume "/var/run/docker.sock":"/var/run/docker.sock" \
|
|
||||||
--volume "${githubHome}":"/root:z" \
|
--volume "${githubHome}":"/root:z" \
|
||||||
--volume "${githubWorkflow}":"/github/workflow:z" \
|
--volume "${githubWorkflow}":"/github/workflow:z" \
|
||||||
--volume "${workspace}":"/github/workspace:z" \
|
--volume "${workspace}":"/github/workspace:z" \
|
||||||
|
--volume "${actionFolder}/steps":"/steps:z" \
|
||||||
|
--volume "${actionFolder}/entrypoint.sh":"/entrypoint.sh:z" \
|
||||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
||||||
${useHostNetwork ? '--net=host' : ''} \
|
${useHostNetwork ? '--net=host' : ''} \
|
||||||
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
|
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
|
||||||
${image}`;
|
${image} \
|
||||||
|
/bin/bash /entrypoint.sh`;
|
||||||
|
|
||||||
await exec(command, undefined, { silent });
|
await exec(command, undefined, { silent });
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import ImageTag from './image-tag';
|
import ImageTag from './image-tag';
|
||||||
|
|
||||||
|
jest.spyOn(ImageTag, 'getImagePlatformPrefix').mockReturnValue('ubuntu');
|
||||||
|
|
||||||
describe('ImageTag', () => {
|
describe('ImageTag', () => {
|
||||||
const some = {
|
const some = {
|
||||||
repository: 'test1',
|
editorVersion: '2099.9.f9f9',
|
||||||
name: 'test2',
|
targetPlatform: 'Test',
|
||||||
version: '2099.9.f9f9',
|
|
||||||
platform: 'Test',
|
|
||||||
builderPlatform: '',
|
builderPlatform: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,40 +17,45 @@ describe('ImageTag', () => {
|
||||||
|
|
||||||
describe('constructor', () => {
|
describe('constructor', () => {
|
||||||
it('can be called', () => {
|
it('can be called', () => {
|
||||||
const { platform } = some;
|
const { targetPlatform } = some;
|
||||||
expect(() => new ImageTag({ platform })).not.toThrow();
|
expect(() => new ImageTag({ platform: targetPlatform })).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts parameters and sets the right properties', () => {
|
it('accepts parameters and sets the right properties', () => {
|
||||||
const image = new ImageTag(some);
|
const image = new ImageTag(some);
|
||||||
|
|
||||||
expect(image.repository).toStrictEqual(some.repository);
|
expect(image.repository).toStrictEqual('unityci');
|
||||||
expect(image.name).toStrictEqual(some.name);
|
expect(image.name).toStrictEqual('editor');
|
||||||
expect(image.version).toStrictEqual(some.version);
|
expect(image.editorVersion).toStrictEqual(some.editorVersion);
|
||||||
expect(image.platform).toStrictEqual(some.platform);
|
expect(image.targetPlatform).toStrictEqual(some.targetPlatform);
|
||||||
expect(image.builderPlatform).toStrictEqual(some.builderPlatform);
|
expect(image.targetPlatformSuffix).toStrictEqual(some.builderPlatform);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', version => {
|
test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', editorVersion => {
|
||||||
expect(() => new ImageTag({ version, platform: some.platform })).not.toThrow();
|
expect(
|
||||||
|
() => new ImageTag({ editorVersion, targetPlatform: some.targetPlatform }),
|
||||||
|
).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each(['some version', '', 1])('throws for incorrect versions %p', version => {
|
test.each(['some version', '', 1])('throws for incorrect versions %p', editorVersion => {
|
||||||
const { platform } = some;
|
const { targetPlatform } = some;
|
||||||
expect(() => new ImageTag({ version, platform })).toThrow();
|
expect(() => new ImageTag({ editorVersion, targetPlatform })).toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('toString', () => {
|
describe('toString', () => {
|
||||||
it('returns the correct version', () => {
|
it('returns the correct version', () => {
|
||||||
const image = new ImageTag({ version: '2099.1.1111', platform: some.platform });
|
const image = new ImageTag({
|
||||||
|
editorVersion: '2099.1.1111',
|
||||||
|
targetPlatform: some.targetPlatform,
|
||||||
|
});
|
||||||
|
|
||||||
expect(image.toString()).toStrictEqual(`${defaults.image}:2099.1.1111-0`);
|
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111-1`);
|
||||||
});
|
});
|
||||||
it('returns customImage if given', () => {
|
it('returns customImage if given', () => {
|
||||||
const image = new ImageTag({
|
const image = new ImageTag({
|
||||||
version: '2099.1.1111',
|
editorVersion: '2099.1.1111',
|
||||||
platform: some.platform,
|
targetPlatform: some.targetPlatform,
|
||||||
customImage: `${defaults.image}:2099.1.1111@347598437689743986`,
|
customImage: `${defaults.image}:2099.1.1111@347598437689743986`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -58,15 +63,15 @@ describe('ImageTag', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the specific build platform', () => {
|
it('returns the specific build platform', () => {
|
||||||
const image = new ImageTag({ version: '2019.2.11f1', platform: 'WebGL' });
|
const image = new ImageTag({ editorVersion: '2019.2.11f1', targetPlatform: 'WebGL' });
|
||||||
|
|
||||||
expect(image.toString()).toStrictEqual(`${defaults.image}:2019.2.11f1-webgl-0`);
|
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2019.2.11f1-webgl-1`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns no specific build platform for generic targetPlatforms', () => {
|
it('returns no specific build platform for generic targetPlatforms', () => {
|
||||||
const image = new ImageTag({ platform: 'NoTarget' });
|
const image = new ImageTag({ targetPlatform: 'NoTarget' });
|
||||||
|
|
||||||
expect(image.toString()).toStrictEqual(`${defaults.image}:2019.2.11f1-0`);
|
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2019.2.11f1-1`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,41 +1,44 @@
|
||||||
import Platform from './platform';
|
import Platform from './platform';
|
||||||
|
|
||||||
class ImageTag {
|
class ImageTag {
|
||||||
|
public customImage?: string;
|
||||||
public repository: string;
|
public repository: string;
|
||||||
public name: string;
|
public name: string;
|
||||||
public version: string;
|
public editorVersion: string;
|
||||||
public platform: any;
|
public targetPlatform: string;
|
||||||
public builderPlatform: string;
|
public targetPlatformSuffix: string;
|
||||||
public customImage: any;
|
public imagePlatformPrefix: string;
|
||||||
|
public imageRollingVersion: number;
|
||||||
|
|
||||||
constructor(imageProperties) {
|
constructor(imageProperties) {
|
||||||
const {
|
const {
|
||||||
repository = 'unityci',
|
editorVersion = '2019.2.11f1',
|
||||||
name = 'editor',
|
targetPlatform = Platform.types.StandaloneLinux64,
|
||||||
version = '2019.2.11f1',
|
|
||||||
platform = Platform.types.StandaloneLinux64,
|
|
||||||
customImage,
|
customImage,
|
||||||
} = imageProperties;
|
} = imageProperties;
|
||||||
|
|
||||||
if (!ImageTag.versionPattern.test(version)) {
|
if (!ImageTag.versionPattern.test(editorVersion)) {
|
||||||
throw new Error(`Invalid version "${version}".`);
|
throw new Error(`Invalid version "${editorVersion}".`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const builderPlatform = ImageTag.getTargetPlatformToImageSuffixMap(platform, version);
|
// Either
|
||||||
|
|
||||||
this.repository = repository;
|
|
||||||
this.name = name;
|
|
||||||
this.version = version;
|
|
||||||
this.platform = platform;
|
|
||||||
this.builderPlatform = builderPlatform;
|
|
||||||
this.customImage = customImage;
|
this.customImage = customImage;
|
||||||
|
|
||||||
|
// Or
|
||||||
|
this.repository = 'unityci';
|
||||||
|
this.name = 'editor';
|
||||||
|
this.editorVersion = editorVersion;
|
||||||
|
this.targetPlatform = targetPlatform;
|
||||||
|
this.targetPlatformSuffix = ImageTag.getTargetPlatformSuffix(targetPlatform, editorVersion);
|
||||||
|
this.imagePlatformPrefix = ImageTag.getImagePlatformPrefix(process.platform);
|
||||||
|
this.imageRollingVersion = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get versionPattern() {
|
static get versionPattern() {
|
||||||
return /^20\d{2}\.\d\.\w{3,4}|3$/;
|
return /^20\d{2}\.\d\.\w{3,4}|3$/;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get imageSuffixes() {
|
static get targetPlatformSuffixes() {
|
||||||
return {
|
return {
|
||||||
generic: '',
|
generic: '',
|
||||||
webgl: 'webgl',
|
webgl: 'webgl',
|
||||||
|
@ -49,13 +52,22 @@ class ImageTag {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static getTargetPlatformToImageSuffixMap(platform, version) {
|
static getImagePlatformPrefix(platform) {
|
||||||
const { generic, webgl, mac, windows, linux, linuxIl2cpp, android, ios, facebook } =
|
|
||||||
ImageTag.imageSuffixes;
|
|
||||||
|
|
||||||
const [major, minor] = version.split('.').map(digit => Number(digit));
|
|
||||||
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
|
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
|
case 'linux':
|
||||||
|
return 'ubuntu';
|
||||||
|
default:
|
||||||
|
throw new Error('The Operating System of this runner is not yet supported.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static getTargetPlatformSuffix(targetPlatform, editorVersion) {
|
||||||
|
const { generic, webgl, mac, windows, linux, linuxIl2cpp, android, ios, facebook } =
|
||||||
|
ImageTag.targetPlatformSuffixes;
|
||||||
|
|
||||||
|
const [major, minor] = editorVersion.split('.').map(digit => Number(digit));
|
||||||
|
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
|
||||||
|
switch (targetPlatform) {
|
||||||
case Platform.types.StandaloneOSX:
|
case Platform.types.StandaloneOSX:
|
||||||
return mac;
|
return mac;
|
||||||
case Platform.types.StandaloneWindows:
|
case Platform.types.StandaloneWindows:
|
||||||
|
@ -103,12 +115,17 @@ class ImageTag {
|
||||||
default:
|
default:
|
||||||
throw new Error(`
|
throw new Error(`
|
||||||
Platform must be one of the ones described in the documentation.
|
Platform must be one of the ones described in the documentation.
|
||||||
"${platform}" is currently not supported.`);
|
"${targetPlatform}" is currently not supported.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get tag() {
|
get tag() {
|
||||||
return `${this.version}-${this.builderPlatform}`.replace(/-+$/, '');
|
const versionAndTarget = `${this.editorVersion}-${this.targetPlatformSuffix}`.replace(
|
||||||
|
/-+$/,
|
||||||
|
'',
|
||||||
|
);
|
||||||
|
|
||||||
|
return `${this.imagePlatformPrefix}-${versionAndTarget}-${this.imageRollingVersion}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
get image() {
|
get image() {
|
||||||
|
@ -118,12 +135,9 @@ class ImageTag {
|
||||||
toString() {
|
toString() {
|
||||||
const { image, tag, customImage } = this;
|
const { image, tag, customImage } = this;
|
||||||
|
|
||||||
if (customImage && customImage !== '') {
|
if (customImage) return customImage;
|
||||||
return customImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
const dockerRepoVersion = 0;
|
return `${image}:${tag}`;
|
||||||
return `${image}:${tag}-${dockerRepoVersion}`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,12 @@ const Input = {
|
||||||
|
|
||||||
getFromUser() {
|
getFromUser() {
|
||||||
// Input variables specified in workflow using "with" prop.
|
// Input variables specified in workflow using "with" prop.
|
||||||
const rawUnityVersion = getInput('unityVersion') || 'auto';
|
const unityVersion = getInput('unityVersion') || 'auto';
|
||||||
const customImage = getInput('customImage') || '';
|
const customImage = getInput('customImage') || '';
|
||||||
const rawProjectPath = getInput('projectPath') || '.';
|
const rawProjectPath = getInput('projectPath') || '.';
|
||||||
const customParameters = getInput('customParameters') || '';
|
const customParameters = getInput('customParameters') || '';
|
||||||
const testMode = (getInput('testMode') || 'all').toLowerCase();
|
const testMode = (getInput('testMode') || 'all').toLowerCase();
|
||||||
|
const coverageOptions = getInput('coverageOptions') || '';
|
||||||
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
|
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
|
||||||
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
|
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
|
||||||
const sshAgent = getInput('sshAgent') || '';
|
const sshAgent = getInput('sshAgent') || '';
|
||||||
|
@ -111,16 +112,17 @@ const Input = {
|
||||||
// Sanitise other input
|
// Sanitise other input
|
||||||
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
||||||
const useHostNetwork = rawUseHostNetwork === 'true';
|
const useHostNetwork = rawUseHostNetwork === 'true';
|
||||||
const unityVersion =
|
const editorVersion =
|
||||||
rawUnityVersion === 'auto' ? UnityVersionParser.read(projectPath) : rawUnityVersion;
|
unityVersion === 'auto' ? UnityVersionParser.read(projectPath) : unityVersion;
|
||||||
|
|
||||||
// Return sanitised input
|
// Return sanitised input
|
||||||
return {
|
return {
|
||||||
unityVersion,
|
editorVersion,
|
||||||
customImage,
|
customImage,
|
||||||
projectPath,
|
projectPath,
|
||||||
customParameters,
|
customParameters,
|
||||||
testMode,
|
testMode,
|
||||||
|
coverageOptions,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
sshAgent,
|
sshAgent,
|
||||||
|
|
|
@ -6,4 +6,19 @@ describe('Output', () => {
|
||||||
await expect(Output.setArtifactsPath('')).resolves.not.toThrow();
|
await expect(Output.setArtifactsPath('')).resolves.not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('setCoveragePath', () => {
|
||||||
|
it('does not throw', async () => {
|
||||||
|
await expect(Output.setCoveragePath('')).resolves.not.toThrow();
|
||||||
|
await expect(Output.setCoveragePath('artifacts')).resolves.not.toThrow();
|
||||||
|
await expect(Output.setCoveragePath('coverage')).resolves.not.toThrow();
|
||||||
|
await expect(Output.setCoveragePath('CodeCoverage')).resolves.not.toThrow();
|
||||||
|
await expect(Output.setCoveragePath('./artifacts')).resolves.not.toThrow();
|
||||||
|
await expect(Output.setCoveragePath('./coverage')).resolves.not.toThrow();
|
||||||
|
await expect(Output.setCoveragePath('./CodeCoverage')).resolves.not.toThrow();
|
||||||
|
await expect(Output.setCoveragePath('./artifacts/coverage')).resolves.not.toThrow();
|
||||||
|
await expect(Output.setCoveragePath('./coverage/')).resolves.not.toThrow();
|
||||||
|
await expect(Output.setCoveragePath('./CodeCoverage/')).resolves.not.toThrow();
|
||||||
|
await expect(Output.setCoveragePath('./artifacts/coverage/')).resolves.not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,9 @@ const Output = {
|
||||||
async setArtifactsPath(artifactsPath) {
|
async setArtifactsPath(artifactsPath) {
|
||||||
await core.setOutput('artifactsPath', artifactsPath);
|
await core.setOutput('artifactsPath', artifactsPath);
|
||||||
},
|
},
|
||||||
|
async setCoveragePath(coveragePath) {
|
||||||
|
await core.setOutput('coveragePath', coveragePath);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Output;
|
export default Output;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"com.unity.ide.vscode": "1.1.2",
|
"com.unity.ide.vscode": "1.1.2",
|
||||||
"com.unity.package-manager-ui": "2.2.0",
|
"com.unity.package-manager-ui": "2.2.0",
|
||||||
"com.unity.test-framework": "1.0.13",
|
"com.unity.test-framework": "1.0.13",
|
||||||
|
"com.unity.testtools.codecoverage": "1.1.1",
|
||||||
"com.unity.textmeshpro": "2.0.1",
|
"com.unity.textmeshpro": "2.0.1",
|
||||||
"com.unity.timeline": "1.1.0",
|
"com.unity.timeline": "1.1.0",
|
||||||
"com.unity.ugui": "1.0.0",
|
"com.unity.ugui": "1.0.0",
|
||||||
|
|
|
@ -3601,9 +3601,9 @@ minimatch@^3.0.4:
|
||||||
brace-expansion "^1.1.7"
|
brace-expansion "^1.1.7"
|
||||||
|
|
||||||
minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5:
|
minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5:
|
||||||
version "1.2.5"
|
version "1.2.6"
|
||||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
||||||
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
||||||
|
|
||||||
mixin-deep@^1.2.0:
|
mixin-deep@^1.2.0:
|
||||||
version "1.3.2"
|
version "1.3.2"
|
||||||
|
|
Loading…
Reference in New Issue