Add createCheck to display test results in GitHub UI
parent
b3bcba9d25
commit
6a619e780c
|
@ -32,6 +32,10 @@ inputs:
|
|||
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:
|
||||
required: false
|
||||
default: ''
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -13,6 +13,7 @@ async function action() {
|
|||
artifactsPath,
|
||||
useHostNetwork,
|
||||
createCheck,
|
||||
checkName,
|
||||
githubToken,
|
||||
customParameters,
|
||||
} = Input.getFromUser();
|
||||
|
@ -39,9 +40,9 @@ async function action() {
|
|||
}
|
||||
|
||||
if (createCheck) {
|
||||
const fail = await ResultsCheck.publishResults(artifactsPath, githubToken);
|
||||
const fail = await ResultsCheck.publishResults(artifactsPath, checkName, githubToken);
|
||||
if (fail > 0) {
|
||||
core.setFailed('Tests Failed! See Test Results for details.');
|
||||
core.setFailed(`Tests Failed! Check ${checkName} for details.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ class Input {
|
|||
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') || ''; // Validate input
|
||||
if (!includes(this.testModes, testMode)) {
|
||||
|
@ -57,6 +58,7 @@ class Input {
|
|||
artifactsPath,
|
||||
useHostNetwork,
|
||||
createCheck,
|
||||
checkName,
|
||||
githubToken,
|
||||
customParameters,
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ import ReportConverter from './report-converter';
|
|||
import { RunMeta } from './ts/meta.ts';
|
||||
|
||||
class ResultsCheck {
|
||||
static async publishResults(artifactsPath, githubToken) {
|
||||
static async publishResults(artifactsPath, checkName, githubToken) {
|
||||
// Parse all reports
|
||||
const runs = [];
|
||||
const files = fs.readdirSync(artifactsPath);
|
||||
|
@ -41,7 +41,13 @@ class ResultsCheck {
|
|||
core.info(runSummary.summary);
|
||||
|
||||
// Create check
|
||||
await ResultsCheck.createCheck(githubToken, runs, runSummary, runSummary.extractAnnotations());
|
||||
await ResultsCheck.createCheck(
|
||||
checkName,
|
||||
githubToken,
|
||||
runs,
|
||||
runSummary,
|
||||
runSummary.extractAnnotations(),
|
||||
);
|
||||
return runSummary.failed;
|
||||
}
|
||||
|
||||
|
@ -54,7 +60,7 @@ class ResultsCheck {
|
|||
return ReportConverter.convertReport(path.basename(filepath), report);
|
||||
}
|
||||
|
||||
static async createCheck(githubToken, runs, runSummary, annotations) {
|
||||
static async createCheck(checkName, githubToken, runs, runSummary, annotations) {
|
||||
const pullRequest = github.context.payload.pull_request;
|
||||
const headSha = (pullRequest && pullRequest.head.sha) || github.context.sha;
|
||||
|
||||
|
@ -65,7 +71,7 @@ class ResultsCheck {
|
|||
core.info(`Posting results for ${headSha}`);
|
||||
const createCheckRequest = {
|
||||
...github.context.repo,
|
||||
name: 'Test Results',
|
||||
name: checkName,
|
||||
head_sha: headSha,
|
||||
status: 'completed',
|
||||
conclusion: 'neutral',
|
||||
|
|
|
@ -78,7 +78,7 @@ export class RunMeta extends Meta {
|
|||
|
||||
get mark(): string {
|
||||
if (this.failed > 0) return '❌️';
|
||||
else if (this.skipped === 0) return '✔️';
|
||||
else if (this.skipped === 0) return '✅';
|
||||
return '⚠️';
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ export class TestMeta extends Meta {
|
|||
get mark(): string {
|
||||
if (this.isFailed()) return '❌️';
|
||||
else if (this.isSkipped()) return '⚠️';
|
||||
return '✔️';
|
||||
return '✅';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue