unity-test-runner/src/index.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-01-29 21:22:26 +00:00
import * as core from '@actions/core';
import { Action, Docker, Input, ImageTag, Output, ResultsCheck } from './model';
2020-01-29 21:22:26 +00:00
async function action() {
Action.checkCompatibility();
const { dockerfile, workspace, actionFolder } = Action;
2020-01-30 23:57:08 +00:00
const {
unityVersion,
2020-11-26 08:17:42 +00:00
customImage,
2020-01-30 23:57:08 +00:00
projectPath,
testMode,
artifactsPath,
2020-04-01 20:24:13 +00:00
useHostNetwork,
createCheck,
githubToken,
2020-01-30 23:57:08 +00:00
customParameters,
} = Input.getFromUser();
2020-11-26 08:17:42 +00:00
const baseImage = ImageTag.createForBase({ version: unityVersion, customImage });
2020-01-29 21:22:26 +00:00
try {
// Build docker image
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
2020-01-29 21:22:26 +00:00
// Run docker image
await Docker.run(actionImage, {
workspace,
unityVersion,
projectPath,
testMode,
artifactsPath,
useHostNetwork,
customParameters,
});
if (createCheck) {
await ResultsCheck.publishResults(artifactsPath, githubToken);
}
} finally {
// Set output
await Output.setArtifactsPath(artifactsPath);
}
2020-01-29 21:22:26 +00:00
}
action().catch(error => {
core.setFailed(error.message);
});