Skip to content

Commit 731f74e

Browse files
authored
Merge pull request #1259 from ptsd/feature/allow_ignore_classname_in_resolver
Feat: Allow ignoring the `classname` attribute when calling `resolveFileAndLine`
2 parents 73a1121 + 22da2ed commit 731f74e

File tree

8 files changed

+188
-55
lines changed

8 files changed

+188
-55
lines changed

README.md

+34-32
Original file line numberDiff line numberDiff line change
@@ -72,38 +72,40 @@ jobs:
7272
7373
### Inputs
7474
75-
| **Input** | **Description** |
76-
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
77-
| `report_paths` | Optional. [Glob](https://github.com/actions/toolkit/tree/master/packages/glob) expression to junit report paths. Defaults to: `**/junit-reports/TEST-*.xml`. |
78-
| `token` | Optional. GitHub token for creating a check run. Set to `${{ github.token }}` by default. |
79-
| `test_files_prefix` | Optional. Prepends the provided prefix to test file paths within the report when annotating on GitHub. |
80-
| `exclude_sources` | Optional. Provide `,` seperated array of folders to ignore for source lookup. Defaults to: `/build/,/__pycache__/` |
81-
| `check_name` | Optional. Check name to use when creating a check run. The default is `JUnit Test Report`. |
82-
| `suite_regex` | REMOVED (as of v5). Instead use `check_title_template` and configure: `{{BREAD_CRUMB}}{{SUITE_NAME}}/{{TEST_NAME}}` |
83-
| `commit` | Optional. The commit SHA to update the status. This is useful when you run it with `workflow_run`. |
84-
| `fail_on_failure` | Optional. Fail the build in case of a test failure. |
85-
| `require_tests` | Optional. Fail if no test are found. |
86-
| `require_passed_tests` | Optional. Fail if no passed test are found. (This is stricter than `require_tests`, which accepts skipped tests). |
87-
| `include_passed` | Optional. By default the action will skip passed items for the annotations. Enable this flag to include them. |
88-
| `check_retries` | Optional. If a testcase is retried, ignore the original failure. |
89-
| `check_title_template` | Optional. Template to configure the title format. Placeholders: {{FILE_NAME}}, {{SUITE_NAME}}, {{TEST_NAME}}, {{CLASS_NAME}}, {{BREAD_CRUMB}}. |
90-
| `bread_crumb_delimiter` | Optional. Defines the delimiter characters between the breadcrumb elements. Defaults to: `/`. |
91-
| `summary` | Optional. Additional text to summary output |
92-
| `check_annotations` | Optional. Defines if the checks will include annotations. If disabled skips all annotations for the check. (This does not affect `annotate_only`, which uses no checks). |
93-
| `update_check` | Optional. Uses an alternative API to update checks, use for cases with more than 50 annotations. Default: `false`. |
94-
| `annotate_only` | Optional. Will only annotate the results on the files, won't create a check run. Defaults to `false`. |
95-
| `transformers` | Optional. Array of `Transformer`s offering the ability to adjust the fileName. Defaults to: `[{"searchValue":"::","replaceValue":"/"}]` |
96-
| `job_summary` | Optional. Enables the publishing of the job summary for the results. Defaults to `true`. May be required to disable [Enterprise Server](https://github.com/mikepenz/action-junit-report/issues/637) |
97-
| `detailed_summary` | Optional. Include table with all test results in the summary. Defaults to `false`. |
98-
| `flaky_summary` | Optional. Include table with all falky results in the summary. Defaults to `false`. |
99-
| `group_suite` | Optional. If enabled, will group the testcases by test suite in the `detailed_summary`. Defaults to `false`. |
100-
| `comment` | Optional. Enables a comment being added to the PR with the summary tables (Respects the summary configuration flags). Defaults to `false`. |
101-
| `updateComment` | Optional. If a prior action run comment exists, it is updated. If disabled, new comments are creted for each run. Defaults to `true`. |
102-
| `annotate_notice` | Optional. Annotate passed test results along with warning/failed ones. Defaults to `false`. (Changed in v3.5.0) |
103-
| `follow_symlink` | Optional. Enables to follow symlinks when searching test files via the globber. Defaults to `false`. |
104-
| `job_name` | Optional. Specify the name of a check to update |
105-
| `annotations_limit` | Optional. Specify the limit for annotations. This will also interrupt parsing all test-suites if the limit is reached. Defaults to: `No Limit`. |
106-
| `skip_annotations` | Optional. Setting this flag will result in no annotations being added to the run. Defaults to `false`. |
75+
| **Input** | **Description** |
76+
|----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
77+
| `report_paths` | Optional. [Glob](https://github.com/actions/toolkit/tree/master/packages/glob) expression to junit report paths. Defaults to: `**/junit-reports/TEST-*.xml`. |
78+
| `token` | Optional. GitHub token for creating a check run. Set to `${{ github.token }}` by default. |
79+
| `test_files_prefix` | Optional. Prepends the provided prefix to test file paths within the report when annotating on GitHub. |
80+
| `exclude_sources` | Optional. Provide `,` seperated array of folders to ignore for source lookup. Defaults to: `/build/,/__pycache__/` |
81+
| `check_name` | Optional. Check name to use when creating a check run. The default is `JUnit Test Report`. |
82+
| `suite_regex` | REMOVED (as of v5). Instead use `check_title_template` and configure: `{{BREAD_CRUMB}}{{SUITE_NAME}}/{{TEST_NAME}}` |
83+
| `commit` | Optional. The commit SHA to update the status. This is useful when you run it with `workflow_run`. |
84+
| `fail_on_failure` | Optional. Fail the build in case of a test failure. |
85+
| `require_tests` | Optional. Fail if no test are found. |
86+
| `require_passed_tests` | Optional. Fail if no passed test are found. (This is stricter than `require_tests`, which accepts skipped tests). |
87+
| `include_passed` | Optional. By default the action will skip passed items for the annotations. Enable this flag to include them. |
88+
| `check_retries` | Optional. If a testcase is retried, ignore the original failure. |
89+
| `check_title_template` | Optional. Template to configure the title format. Placeholders: {{FILE_NAME}}, {{SUITE_NAME}}, {{TEST_NAME}}, {{CLASS_NAME}}, {{BREAD_CRUMB}}. |
90+
| `bread_crumb_delimiter` | Optional. Defines the delimiter characters between the breadcrumb elements. Defaults to: `/`. |
91+
| `summary` | Optional. Additional text to summary output |
92+
| `check_annotations` | Optional. Defines if the checks will include annotations. If disabled skips all annotations for the check. (This does not affect `annotate_only`, which uses no checks). |
93+
| `update_check` | Optional. Uses an alternative API to update checks, use for cases with more than 50 annotations. Default: `false`. |
94+
| `annotate_only` | Optional. Will only annotate the results on the files, won't create a check run. Defaults to `false`. |
95+
| `transformers` | Optional. Array of `Transformer`s offering the ability to adjust the fileName. Defaults to: `[{"searchValue":"::","replaceValue":"/"}]` |
96+
| `job_summary` | Optional. Enables the publishing of the job summary for the results. Defaults to `true`. May be required to disable [Enterprise Server](https://github.com/mikepenz/action-junit-report/issues/637) |
97+
| `detailed_summary` | Optional. Include table with all test results in the summary. Defaults to `false`. |
98+
| `flaky_summary` | Optional. Include table with all falky results in the summary. Defaults to `false`. |
99+
| `group_suite` | Optional. If enabled, will group the testcases by test suite in the `detailed_summary`. Defaults to `false`. |
100+
| `comment` | Optional. Enables a comment being added to the PR with the summary tables (Respects the summary configuration flags). Defaults to `false`. |
101+
| `updateComment` | Optional. If a prior action run comment exists, it is updated. If disabled, new comments are creted for each run. Defaults to `true`. |
102+
| `annotate_notice` | Optional. Annotate passed test results along with warning/failed ones. Defaults to `false`. (Changed in v3.5.0) |
103+
| `follow_symlink` | Optional. Enables to follow symlinks when searching test files via the globber. Defaults to `false`. |
104+
| `job_name` | Optional. Specify the name of a check to update |
105+
| `annotations_limit` | Optional. Specify the limit for annotations. This will also interrupt parsing all test-suites if the limit is reached. Defaults to: `No Limit`. |
106+
| `skip_annotations` | Optional. Setting this flag will result in no annotations being added to the run. Defaults to `false`. |
107+
| `truncate_stack_traces` | Optional. Truncate stack traces from test output to 2 lines in annotations. Defaults to `true`. |
108+
| `resolve_ignore_classname` | Optional. Force ignore test case classname from the xml report (This can help fix issues with some tools/languages). Defaults to `false`. |
107109

108110
### Common Configurations
109111

__tests__/testParser.test.ts

+46
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,52 @@ describe('parseFile', () => {
409409
])
410410
})
411411

412+
it('should ignore classname when requested', async () => {
413+
const testResult = await parseFile(
414+
'test_results/nextest/basic.xml',
415+
'',
416+
false,
417+
false,
418+
false,
419+
undefined,
420+
undefined,
421+
'/',
422+
'',
423+
undefined,
424+
false,
425+
-1,
426+
true,
427+
false,
428+
undefined,
429+
true)
430+
expect(testResult).toBeDefined()
431+
const {totalCount, skippedCount, globalAnnotations} = testResult!!
432+
const filtered = globalAnnotations.filter(annotation => annotation.annotation_level !== 'notice')
433+
434+
expect(totalCount).toBe(3)
435+
expect(skippedCount).toBe(0)
436+
expect(filtered).toStrictEqual([
437+
{
438+
annotation_level: 'failure',
439+
end_column: 0,
440+
end_line: 154,
441+
message: 'thread \'test_failure\' panicked at tests/parry3d.rs:154:5:\n' +
442+
' assertion `left == right` failed: 0 must equal 1',
443+
path: 'tests/parry3d.rs',
444+
raw_details: 'thread \'test_failure\' panicked at tests/parry3d.rs:154:5:\n' +
445+
' assertion `left == right` failed: 0 must equal 1\n' +
446+
' left: 0\n' +
447+
' right: 1\n' +
448+
' note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace',
449+
start_column: 0,
450+
start_line: 154,
451+
retries: 0,
452+
status: 'failure',
453+
title: 'oxidized_navigation::parry3d.test_failure'
454+
}
455+
])
456+
})
457+
412458
it('should parse correctly fileName and line for a Java file with invalid chars', async () => {
413459
const {fileName, line} = await resolveFileAndLine(
414460
null,

action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ inputs:
128128
description: 'Truncate stack traces from test output to 2 lines in annotations'
129129
required: false
130130
default: 'true'
131+
resolve_ignore_classname:
132+
description: 'Force ignore test case classname from the xml report (This can help fix issues with some tools/languages)'
133+
required: false
134+
default: 'false'
131135
outputs:
132136
total:
133137
description: 'The total count of all checks'

0 commit comments

Comments
 (0)