mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
remove output-to parameter
This commit is contained in:
parent
bd65e34c96
commit
4a79aca441
3 changed files with 58 additions and 158 deletions
|
|
@ -70,13 +70,6 @@ inputs:
|
||||||
Detailed listing of test suites and test cases will be skipped.
|
Detailed listing of test suites and test cases will be skipped.
|
||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
output-to:
|
|
||||||
description: |
|
|
||||||
The location to write the report to. Supported options:
|
|
||||||
- checks
|
|
||||||
- step-summary
|
|
||||||
default: 'step-summary'
|
|
||||||
required: false
|
|
||||||
token:
|
token:
|
||||||
description: GitHub Access Token
|
description: GitHub Access Token
|
||||||
required: false
|
required: false
|
||||||
|
|
|
||||||
45
dist/index.js
generated
vendored
45
dist/index.js
generated
vendored
|
|
@ -302,7 +302,6 @@ class TestReporter {
|
||||||
this.workDirInput = core.getInput('working-directory', { required: false });
|
this.workDirInput = core.getInput('working-directory', { required: false });
|
||||||
this.buildDirInput = core.getInput('build-directory', { required: false });
|
this.buildDirInput = core.getInput('build-directory', { required: false });
|
||||||
this.onlySummary = core.getInput('only-summary', { required: false }) === 'true';
|
this.onlySummary = core.getInput('only-summary', { required: false }) === 'true';
|
||||||
this.outputTo = core.getInput('output-to', { required: false });
|
|
||||||
this.token = core.getInput('token', { required: true });
|
this.token = core.getInput('token', { required: true });
|
||||||
this.slugPrefix = '';
|
this.slugPrefix = '';
|
||||||
this.context = (0, github_utils_1.getCheckRunContext)();
|
this.context = (0, github_utils_1.getCheckRunContext)();
|
||||||
|
|
@ -319,14 +318,8 @@ class TestReporter {
|
||||||
core.setFailed(`Input parameter 'max-annotations' has invalid value`);
|
core.setFailed(`Input parameter 'max-annotations' has invalid value`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.outputTo !== 'checks' && this.outputTo !== 'step-summary') {
|
|
||||||
core.setFailed(`Input parameter 'output-to' has invalid value`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.outputTo === 'step-summary') {
|
|
||||||
this.slugPrefix = createSlugPrefix();
|
this.slugPrefix = createSlugPrefix();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
run() {
|
run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (this.workDirInput) {
|
if (this.workDirInput) {
|
||||||
|
|
@ -391,7 +384,7 @@ class TestReporter {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
createReport(parser, name, files) {
|
createReport(parser, name, files) {
|
||||||
var _a, _b;
|
var _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (files.length === 0) {
|
if (files.length === 0) {
|
||||||
core.warning(`No file matches path ${this.path}`);
|
core.warning(`No file matches path ${this.path}`);
|
||||||
|
|
@ -409,26 +402,9 @@ class TestReporter {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let createResp = null;
|
|
||||||
let baseUrl = '';
|
let baseUrl = '';
|
||||||
let check_run_id = 0;
|
const run_attempt = (_a = process.env['GITHUB_RUN_ATTEMPT']) !== null && _a !== void 0 ? _a : 1;
|
||||||
switch (this.outputTo) {
|
|
||||||
case 'checks': {
|
|
||||||
core.info(`Creating check run ${name}`);
|
|
||||||
createResp = yield this.octokit.rest.checks.create(Object.assign({ head_sha: this.context.sha, name, status: 'in_progress', output: {
|
|
||||||
title: name,
|
|
||||||
summary: ''
|
|
||||||
} }, github.context.repo));
|
|
||||||
baseUrl = (_a = createResp.data.html_url) !== null && _a !== void 0 ? _a : '';
|
|
||||||
check_run_id = createResp.data.id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'step-summary': {
|
|
||||||
const run_attempt = (_b = process.env['GITHUB_RUN_ATTEMPT']) !== null && _b !== void 0 ? _b : 1;
|
|
||||||
baseUrl = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${github.context.runId}/attempts/${run_attempt}`;
|
baseUrl = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${github.context.runId}/attempts/${run_attempt}`;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
core.info('Creating report summary');
|
core.info('Creating report summary');
|
||||||
const { listSuites, listTests, onlySummary, slugPrefix } = this;
|
const { listSuites, listTests, onlySummary, slugPrefix } = this;
|
||||||
const summary = (0, get_report_1.getReport)(results, { listSuites, listTests, baseUrl, slugPrefix, onlySummary });
|
const summary = (0, get_report_1.getReport)(results, { listSuites, listTests, baseUrl, slugPrefix, onlySummary });
|
||||||
|
|
@ -441,20 +417,6 @@ class TestReporter {
|
||||||
const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0);
|
const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0);
|
||||||
const shortSummary = `${passed} passed, ${failed} failed and ${skipped} skipped `;
|
const shortSummary = `${passed} passed, ${failed} failed and ${skipped} skipped `;
|
||||||
core.info(`Updating check run conclusion (${conclusion}) and output`);
|
core.info(`Updating check run conclusion (${conclusion}) and output`);
|
||||||
switch (this.outputTo) {
|
|
||||||
case 'checks': {
|
|
||||||
const resp = yield this.octokit.rest.checks.update(Object.assign({ check_run_id,
|
|
||||||
conclusion, status: 'completed', output: {
|
|
||||||
title: shortSummary,
|
|
||||||
summary,
|
|
||||||
annotations
|
|
||||||
} }, github.context.repo));
|
|
||||||
core.info(`Check run create response: ${resp.status}`);
|
|
||||||
core.info(`Check run URL: ${resp.data.url}`);
|
|
||||||
core.info(`Check run HTML: ${resp.data.html_url}`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'step-summary': {
|
|
||||||
core.summary.addRaw(`# ${shortSummary}`);
|
core.summary.addRaw(`# ${shortSummary}`);
|
||||||
core.summary.addRaw(summary);
|
core.summary.addRaw(summary);
|
||||||
yield core.summary.write();
|
yield core.summary.write();
|
||||||
|
|
@ -482,9 +444,6 @@ class TestReporter {
|
||||||
endColumn: annotation.end_column
|
endColumn: annotation.end_column
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
return results;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
54
src/main.ts
54
src/main.ts
|
|
@ -53,7 +53,6 @@ class TestReporter {
|
||||||
readonly workDirInput = core.getInput('working-directory', {required: false})
|
readonly workDirInput = core.getInput('working-directory', {required: false})
|
||||||
readonly buildDirInput = core.getInput('build-directory', {required: false})
|
readonly buildDirInput = core.getInput('build-directory', {required: false})
|
||||||
readonly onlySummary = core.getInput('only-summary', {required: false}) === 'true'
|
readonly onlySummary = core.getInput('only-summary', {required: false}) === 'true'
|
||||||
readonly outputTo = core.getInput('output-to', {required: false})
|
|
||||||
readonly token = core.getInput('token', {required: true})
|
readonly token = core.getInput('token', {required: true})
|
||||||
readonly slugPrefix: string = ''
|
readonly slugPrefix: string = ''
|
||||||
readonly octokit: InstanceType<typeof GitHub>
|
readonly octokit: InstanceType<typeof GitHub>
|
||||||
|
|
@ -77,15 +76,8 @@ class TestReporter {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.outputTo !== 'checks' && this.outputTo !== 'step-summary') {
|
|
||||||
core.setFailed(`Input parameter 'output-to' has invalid value`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.outputTo === 'step-summary') {
|
|
||||||
this.slugPrefix = createSlugPrefix()
|
this.slugPrefix = createSlugPrefix()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async run(): Promise<void> {
|
async run(): Promise<void> {
|
||||||
if (this.workDirInput) {
|
if (this.workDirInput) {
|
||||||
|
|
@ -185,33 +177,10 @@ class TestReporter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let createResp = null
|
|
||||||
let baseUrl = ''
|
let baseUrl = ''
|
||||||
let check_run_id = 0
|
|
||||||
|
|
||||||
switch (this.outputTo) {
|
|
||||||
case 'checks': {
|
|
||||||
core.info(`Creating check run ${name}`)
|
|
||||||
createResp = await this.octokit.rest.checks.create({
|
|
||||||
head_sha: this.context.sha,
|
|
||||||
name,
|
|
||||||
status: 'in_progress',
|
|
||||||
output: {
|
|
||||||
title: name,
|
|
||||||
summary: ''
|
|
||||||
},
|
|
||||||
...github.context.repo
|
|
||||||
})
|
|
||||||
baseUrl = createResp.data.html_url ?? ''
|
|
||||||
check_run_id = createResp.data.id
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'step-summary': {
|
|
||||||
const run_attempt = process.env['GITHUB_RUN_ATTEMPT'] ?? 1
|
const run_attempt = process.env['GITHUB_RUN_ATTEMPT'] ?? 1
|
||||||
baseUrl = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${github.context.runId}/attempts/${run_attempt}`
|
baseUrl = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${github.context.runId}/attempts/${run_attempt}`
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
core.info('Creating report summary')
|
core.info('Creating report summary')
|
||||||
const {listSuites, listTests, onlySummary, slugPrefix} = this
|
const {listSuites, listTests, onlySummary, slugPrefix} = this
|
||||||
|
|
@ -229,28 +198,10 @@ class TestReporter {
|
||||||
const shortSummary = `${passed} passed, ${failed} failed and ${skipped} skipped `
|
const shortSummary = `${passed} passed, ${failed} failed and ${skipped} skipped `
|
||||||
|
|
||||||
core.info(`Updating check run conclusion (${conclusion}) and output`)
|
core.info(`Updating check run conclusion (${conclusion}) and output`)
|
||||||
switch (this.outputTo) {
|
|
||||||
case 'checks': {
|
|
||||||
const resp = await this.octokit.rest.checks.update({
|
|
||||||
check_run_id,
|
|
||||||
conclusion,
|
|
||||||
status: 'completed',
|
|
||||||
output: {
|
|
||||||
title: shortSummary,
|
|
||||||
summary,
|
|
||||||
annotations
|
|
||||||
},
|
|
||||||
...github.context.repo
|
|
||||||
})
|
|
||||||
core.info(`Check run create response: ${resp.status}`)
|
|
||||||
core.info(`Check run URL: ${resp.data.url}`)
|
|
||||||
core.info(`Check run HTML: ${resp.data.html_url}`)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'step-summary': {
|
|
||||||
core.summary.addRaw(`# ${shortSummary}`)
|
core.summary.addRaw(`# ${shortSummary}`)
|
||||||
core.summary.addRaw(summary)
|
core.summary.addRaw(summary)
|
||||||
await core.summary.write()
|
await core.summary.write()
|
||||||
|
|
||||||
for (const annotation of annotations) {
|
for (const annotation of annotations) {
|
||||||
let fn
|
let fn
|
||||||
switch (annotation.annotation_level) {
|
switch (annotation.annotation_level) {
|
||||||
|
|
@ -276,9 +227,6 @@ class TestReporter {
|
||||||
endColumn: annotation.end_column
|
endColumn: annotation.end_column
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue