From e4fa9e8b86a1bb6642964d66d48ede4bf0619776 Mon Sep 17 00:00:00 2001 From: "A.J. Kaptijn" Date: Tue, 20 Feb 2024 22:18:08 +0100 Subject: [PATCH] fail the check-run without results --- dist/index.js | 7 ++++++- src/main.ts | 14 +++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9457ea1..2e7f80a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -296,7 +296,6 @@ class TestReporter { return __awaiter(this, void 0, void 0, function* () { if (files.length === 0) { core.warning(`No file matches path ${this.path}`); - return null; } core.info(`Processing test results for check run ${name}`); const results = []; @@ -327,6 +326,12 @@ class TestReporter { summary: '' } }, github.context.repo)); } + if (files.length === 0) { + yield this.octokit.rest.checks.update(Object.assign({ check_run_id: check.data.id, status: 'completed', output: { + title: name, + summary: 'No test result files found' + }, conclusion: 'failure' }, github.context.repo)); + } core.info('Creating report summary'); const { listSuites, listTests, onlySummary } = this; const baseUrl = check.data.html_url || ''; diff --git a/src/main.ts b/src/main.ts index e1ca308..8a745eb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -197,7 +197,6 @@ class TestReporter { async createReport(parser: TestParser, name: string, files: FileContent[]): Promise { if (files.length === 0) { core.warning(`No file matches path ${this.path}`) - return null } core.info(`Processing test results for check run ${name}`) @@ -254,6 +253,19 @@ class TestReporter { }) } + if (files.length === 0) { + await this.octokit.rest.checks.update({ + check_run_id: check.data.id, + status: 'completed', + output: { + title: name, + summary: 'No test result files found' + }, + conclusion: 'failure', + ...github.context.repo + }) + } + core.info('Creating report summary') const {listSuites, listTests, onlySummary} = this const baseUrl = check.data.html_url || ''