mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 22:07:09 +01:00
Add 'conclusion' output parameter
This commit is contained in:
parent
651a2e1bf1
commit
1ee2707b1a
5 changed files with 25 additions and 11 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
|
@ -26,5 +26,5 @@ jobs:
|
||||||
name: 'JEST Tests'
|
name: 'JEST Tests'
|
||||||
path: '__tests__/__results__/jest-junit.xml'
|
path: '__tests__/__results__/jest-junit.xml'
|
||||||
reporter: 'jest-junit'
|
reporter: 'jest-junit'
|
||||||
- name: 'Sanity check' # re-run tests in case this action failed to detected failing test
|
- name: 'Sanity check' # re-run tests in case this action failed to detect failing test
|
||||||
run: npm test
|
run: npm test
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,12 @@ inputs:
|
||||||
description: 'GitHub Access Token'
|
description: 'GitHub Access Token'
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
outputs:
|
||||||
|
conclusion:
|
||||||
|
description: |
|
||||||
|
Final conclusion of the created check run:
|
||||||
|
- 'success' if no failed tests was found
|
||||||
|
- 'failure' if any failed test was found
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
|
||||||
21
dist/index.js
generated
vendored
21
dist/index.js
generated
vendored
|
|
@ -50,21 +50,27 @@ async function main() {
|
||||||
const parser = getParser(reporter);
|
const parser = getParser(reporter);
|
||||||
const content = file_utils_1.getFileContent(path);
|
const content = file_utils_1.getFileContent(path);
|
||||||
const result = await parser(content);
|
const result = await parser(content);
|
||||||
|
const conclusion = result.success ? 'success' : 'failure';
|
||||||
await octokit.checks.create({
|
await octokit.checks.create({
|
||||||
head_sha: sha,
|
head_sha: sha,
|
||||||
name,
|
name,
|
||||||
|
conclusion,
|
||||||
status: 'completed',
|
status: 'completed',
|
||||||
conclusion: result.success ? 'success' : 'failure',
|
|
||||||
output: result.output,
|
output: result.output,
|
||||||
...github.context.repo,
|
...github.context.repo
|
||||||
});
|
});
|
||||||
|
core.setOutput('conclusion', conclusion);
|
||||||
}
|
}
|
||||||
function getParser(reporter) {
|
function getParser(reporter) {
|
||||||
switch (reporter) {
|
switch (reporter) {
|
||||||
case 'dotnet-trx': throw new Error('Not implemented yet!');
|
case 'dotnet-trx':
|
||||||
case 'flutter-machine': throw new Error('Not implemented yet!');
|
throw new Error('Not implemented yet!');
|
||||||
case 'jest-junit': return jest_junit_parser_1.parseJestJunit;
|
case 'flutter-machine':
|
||||||
default: throw new Error(`Input parameter 'reporter' is set to invalid value '${reporter}'`);
|
throw new Error('Not implemented yet!');
|
||||||
|
case 'jest-junit':
|
||||||
|
return jest_junit_parser_1.parseJestJunit;
|
||||||
|
default:
|
||||||
|
throw new Error(`Input parameter 'reporter' is set to invalid value '${reporter}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
|
@ -251,8 +257,7 @@ exports.getCheckRunSha = void 0;
|
||||||
const github = __importStar(__webpack_require__(5438));
|
const github = __importStar(__webpack_require__(5438));
|
||||||
function getCheckRunSha() {
|
function getCheckRunSha() {
|
||||||
if (github.context.payload.pull_request) {
|
if (github.context.payload.pull_request) {
|
||||||
const pr = github.context.payload
|
const pr = github.context.payload.pull_request;
|
||||||
.pull_request;
|
|
||||||
return pr.head.sha;
|
return pr.head.sha;
|
||||||
}
|
}
|
||||||
return github.context.sha;
|
return github.context.sha;
|
||||||
|
|
|
||||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
|
|
@ -25,15 +25,18 @@ async function main(): Promise<void> {
|
||||||
const parser = getParser(reporter)
|
const parser = getParser(reporter)
|
||||||
const content = getFileContent(path)
|
const content = getFileContent(path)
|
||||||
const result = await parser(content)
|
const result = await parser(content)
|
||||||
|
const conclusion = result.success ? 'success' : 'failure'
|
||||||
|
|
||||||
await octokit.checks.create({
|
await octokit.checks.create({
|
||||||
head_sha: sha,
|
head_sha: sha,
|
||||||
name,
|
name,
|
||||||
|
conclusion,
|
||||||
status: 'completed',
|
status: 'completed',
|
||||||
conclusion: result.success ? 'success' : 'failure',
|
|
||||||
output: result.output,
|
output: result.output,
|
||||||
...github.context.repo
|
...github.context.repo
|
||||||
})
|
})
|
||||||
|
|
||||||
|
core.setOutput('conclusion', conclusion)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getParser(reporter: string): ParseTestResult {
|
function getParser(reporter: string): ParseTestResult {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue