Check GitHub token (#99)

* Reeplace createCheck option with check for githubToken

* Fix index.js
This commit is contained in:
David Finol
2021-02-28 00:44:56 -06:00
committed by GitHub
parent 43d90c252f
commit 215f660c06
6 changed files with 19 additions and 27 deletions

View File

@@ -12,10 +12,9 @@ async function action() {
testMode,
artifactsPath,
useHostNetwork,
createCheck,
checkName,
githubToken,
customParameters,
githubToken,
checkName,
} = Input.getFromUser();
const baseImage = ImageTag.createForBase({ version: unityVersion, customImage });
@@ -31,16 +30,16 @@ async function action() {
testMode,
artifactsPath,
useHostNetwork,
createCheck,
customParameters,
githubToken,
});
} finally {
// Set output
await Output.setArtifactsPath(artifactsPath);
}
if (createCheck) {
const failedTestCount = await ResultsCheck.createCheck(artifactsPath, checkName, githubToken);
if (githubToken) {
const failedTestCount = await ResultsCheck.createCheck(artifactsPath, githubToken, checkName);
if (failedTestCount >= 1) {
core.setFailed(`Test(s) Failed! Check '${checkName}' for details.`);
}

View File

@@ -25,8 +25,8 @@ class Docker {
testMode,
artifactsPath,
useHostNetwork,
createCheck,
customParameters,
githubToken,
} = parameters;
const command = `docker run \
@@ -63,7 +63,7 @@ class Docker {
--volume "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
--volume "${workspace}":"/github/workspace" \
${useHostNetwork ? '--net=host' : ''} \
${createCheck ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
${image}`;
await exec(command, undefined, { silent });

View File

@@ -21,10 +21,9 @@ class Input {
const rawProjectPath = getInput('projectPath') || '.';
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
const rawCreateCheck = getInput('createCheck') || 'false';
const checkName = getInput('checkName') || 'Test Results';
const githubToken = getInput('githubToken') || '';
const customParameters = getInput('customParameters') || '';
const githubToken = getInput('githubToken') || '';
const checkName = getInput('checkName') || 'Test Results';
// Validate input
if (!includes(this.testModes, testMode)) {
@@ -47,7 +46,6 @@ class Input {
const projectPath = rawProjectPath.replace(/\/$/, '');
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
const useHostNetwork = rawUseHostNetwork === 'true';
const createCheck = rawCreateCheck === 'true';
const unityVersion =
rawUnityVersion === 'auto' ? UnityVersionParser.read(projectPath) : rawUnityVersion;
@@ -59,10 +57,9 @@ class Input {
testMode,
artifactsPath,
useHostNetwork,
createCheck,
checkName,
githubToken,
customParameters,
githubToken,
checkName,
};
}
}

View File

@@ -7,11 +7,11 @@ import ResultsParser from './results-parser';
import { RunMeta } from './ts/results-meta.ts';
class ResultsCheck {
static async createCheck(artifactsPath, checkName, githubToken) {
static async createCheck(artifactsPath, githubToken, checkName) {
// Validate input
if (!artifactsPath || !checkName || !githubToken) {
throw new Error(
`Missing input! {"artifactsPath": "${artifactsPath}", "checkName": "${checkName}", "githubToken": "${githubToken}`,
`Missing input! {"artifactsPath": "${artifactsPath}", "githubToken": "${githubToken}, "checkName": "${checkName}"`,
);
}