Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate error annotations when not publishing a check #8

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Optional. Defaults to true. Fail if there are none test results found.
### `show_skipped`

Optional. Defaults to false. Show skipped tests count.
t
### `skip_publishing`

Optional. Skip the test report publishing (check run creation). The default is `false`.

### `update_existing_check`

Expand Down
18 changes: 18 additions & 0 deletions action.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const action = async () => {
const updateExistingCheck = (core.getInput('update_existing_check') || "false") === "true";
const removeDuplicates = (core.getInput('remove_duplicates') || "true") === "true";

const skipPublishing = core.getInput('skip_publishing') === 'true';

core.info(`Running action with failIfEmpty: ${failIfEmpty}, showSkipped: ${showSkipped}, updateExistingCheck: ${updateExistingCheck}`)

let { total, passed, failed, ignored, skipped, annotations, durationMs, errors } = await parseTestReports(reportPaths, showSkipped);
Expand All @@ -54,6 +56,22 @@ const action = async () => {
errors.forEach(error => core.debug(`Could not fully parse ${error.file}: ${error.error}`));
}

if (skipPublishing) {
core.info('Not publishing test result due to skip_publishing=true');
for (const annotation of annotations) {
const properties = {
title: annotation.title,
file: annotation.path,
startLine: annotation.start_line,
endLine: annotation.end_line,
startColumn: annotation.start_column,
endColumn: annotation.end_column
};
core.error(annotation.message, properties);
}
return;
}

const octokit = github.getOctokit(core.getInput('github_token'));

let stats = [
Expand Down
11 changes: 10 additions & 1 deletion action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ describe('action should work', () => {
check_name: 'Test Report',
fail_if_empty: "true",
show_skipped: "false",
update_existing_check: "false"
update_existing_check: "false",
skip_publishing: 'false'
};
});

Expand Down Expand Up @@ -141,6 +142,14 @@ describe('action should work', () => {
expect(request).toMatchObject(masterSuccess);
});

it('should not send report on skip_publishing', async () => {
inputs.skip_publishing = 'true';

// nock error if the request is sent

await action();
});

it('should send reports with skipped', async () => {
inputs.report_paths = '**/ok/target/surefire-reports/testng-results.xml';
inputs.show_skipped = "true";
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ inputs:
commit:
description: 'commit sha to update the status'
required: false
skip_publishing:
description: 'skip test report publishing'
required: false
default: 'false'

runs:
using: 'node16'
main: 'dist/index.js'
18 changes: 18 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading