Check GitHub token (#99)
* Reeplace createCheck option with check for githubToken * Fix index.jspull/100/head v2.0-alpha-3
parent
43d90c252f
commit
215f660c06
14
action.yml
14
action.yml
|
@ -28,18 +28,14 @@ inputs:
|
||||||
customParameters:
|
customParameters:
|
||||||
required: false
|
required: false
|
||||||
description: 'Extra parameters to configure the Unity editor run.'
|
description: 'Extra parameters to configure the Unity editor run.'
|
||||||
createCheck:
|
|
||||||
required: false
|
|
||||||
default: 'false'
|
|
||||||
description: 'Creates a check with the Test Results'
|
|
||||||
checkName:
|
|
||||||
required: false
|
|
||||||
default: 'Test Results'
|
|
||||||
description: 'Name for the check created when createCheck is true.'
|
|
||||||
githubToken:
|
githubToken:
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
description: 'Token to authorize access to the GitHub REST API. Required if and only if createCheck is true.'
|
description: 'Token to authorize access to the GitHub REST API. If provided, a check run will be created with the test results.'
|
||||||
|
checkName:
|
||||||
|
required: false
|
||||||
|
default: 'Test Results'
|
||||||
|
description: 'Name for the check run that is created when a github token is provided.'
|
||||||
outputs:
|
outputs:
|
||||||
artifactsPath:
|
artifactsPath:
|
||||||
description: 'Path where the artifacts are stored'
|
description: 'Path where the artifacts are stored'
|
||||||
|
|
File diff suppressed because one or more lines are too long
11
src/index.js
11
src/index.js
|
@ -12,10 +12,9 @@ async function action() {
|
||||||
testMode,
|
testMode,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
createCheck,
|
|
||||||
checkName,
|
|
||||||
githubToken,
|
|
||||||
customParameters,
|
customParameters,
|
||||||
|
githubToken,
|
||||||
|
checkName,
|
||||||
} = Input.getFromUser();
|
} = Input.getFromUser();
|
||||||
const baseImage = ImageTag.createForBase({ version: unityVersion, customImage });
|
const baseImage = ImageTag.createForBase({ version: unityVersion, customImage });
|
||||||
|
|
||||||
|
@ -31,16 +30,16 @@ async function action() {
|
||||||
testMode,
|
testMode,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
createCheck,
|
|
||||||
customParameters,
|
customParameters,
|
||||||
|
githubToken,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
// Set output
|
// Set output
|
||||||
await Output.setArtifactsPath(artifactsPath);
|
await Output.setArtifactsPath(artifactsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createCheck) {
|
if (githubToken) {
|
||||||
const failedTestCount = await ResultsCheck.createCheck(artifactsPath, checkName, githubToken);
|
const failedTestCount = await ResultsCheck.createCheck(artifactsPath, githubToken, checkName);
|
||||||
if (failedTestCount >= 1) {
|
if (failedTestCount >= 1) {
|
||||||
core.setFailed(`Test(s) Failed! Check '${checkName}' for details.`);
|
core.setFailed(`Test(s) Failed! Check '${checkName}' for details.`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ class Docker {
|
||||||
testMode,
|
testMode,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
createCheck,
|
|
||||||
customParameters,
|
customParameters,
|
||||||
|
githubToken,
|
||||||
} = parameters;
|
} = parameters;
|
||||||
|
|
||||||
const command = `docker run \
|
const command = `docker run \
|
||||||
|
@ -63,7 +63,7 @@ class Docker {
|
||||||
--volume "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
|
--volume "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
|
||||||
--volume "${workspace}":"/github/workspace" \
|
--volume "${workspace}":"/github/workspace" \
|
||||||
${useHostNetwork ? '--net=host' : ''} \
|
${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}`;
|
${image}`;
|
||||||
|
|
||||||
await exec(command, undefined, { silent });
|
await exec(command, undefined, { silent });
|
||||||
|
|
|
@ -21,10 +21,9 @@ class Input {
|
||||||
const rawProjectPath = getInput('projectPath') || '.';
|
const rawProjectPath = getInput('projectPath') || '.';
|
||||||
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
|
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
|
||||||
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
|
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 customParameters = getInput('customParameters') || '';
|
||||||
|
const githubToken = getInput('githubToken') || '';
|
||||||
|
const checkName = getInput('checkName') || 'Test Results';
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!includes(this.testModes, testMode)) {
|
if (!includes(this.testModes, testMode)) {
|
||||||
|
@ -47,7 +46,6 @@ class Input {
|
||||||
const projectPath = rawProjectPath.replace(/\/$/, '');
|
const projectPath = rawProjectPath.replace(/\/$/, '');
|
||||||
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
|
||||||
const useHostNetwork = rawUseHostNetwork === 'true';
|
const useHostNetwork = rawUseHostNetwork === 'true';
|
||||||
const createCheck = rawCreateCheck === 'true';
|
|
||||||
const unityVersion =
|
const unityVersion =
|
||||||
rawUnityVersion === 'auto' ? UnityVersionParser.read(projectPath) : rawUnityVersion;
|
rawUnityVersion === 'auto' ? UnityVersionParser.read(projectPath) : rawUnityVersion;
|
||||||
|
|
||||||
|
@ -59,10 +57,9 @@ class Input {
|
||||||
testMode,
|
testMode,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
createCheck,
|
|
||||||
checkName,
|
|
||||||
githubToken,
|
|
||||||
customParameters,
|
customParameters,
|
||||||
|
githubToken,
|
||||||
|
checkName,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,11 @@ import ResultsParser from './results-parser';
|
||||||
import { RunMeta } from './ts/results-meta.ts';
|
import { RunMeta } from './ts/results-meta.ts';
|
||||||
|
|
||||||
class ResultsCheck {
|
class ResultsCheck {
|
||||||
static async createCheck(artifactsPath, checkName, githubToken) {
|
static async createCheck(artifactsPath, githubToken, checkName) {
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!artifactsPath || !checkName || !githubToken) {
|
if (!artifactsPath || !checkName || !githubToken) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Missing input! {"artifactsPath": "${artifactsPath}", "checkName": "${checkName}", "githubToken": "${githubToken}`,
|
`Missing input! {"artifactsPath": "${artifactsPath}", "githubToken": "${githubToken}, "checkName": "${checkName}"`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue