Skip to content

Commit

Permalink
Merge pull request #1120 from mikepenz/feature/refactor_testresult_pa…
Browse files Browse the repository at this point in the history
…rsing

Allow configuration of `bread_crumb_delimiter`
  • Loading branch information
mikepenz committed Jun 21, 2024
2 parents 46d12dc + 90d8c4d commit 5f36538
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 41 deletions.
55 changes: 28 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,34 @@ jobs:
### Inputs
| **Input** | **Description** |
|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `report_paths` | Optional. [Glob](https://github.com/actions/toolkit/tree/master/packages/glob) expression to junit report paths. Defaults to: `**/junit-reports/TEST-*.xml`. |
| `token` | Optional. GitHub token for creating a check run. Set to `${{ github.token }}` by default. |
| `test_files_prefix` | Optional. Prepends the provided prefix to test file paths within the report when annotating on GitHub. |
| `exclude_sources` | Optional. Provide `,` seperated array of folders to ignore for source lookup. Defaults to: `/build/,/__pycache__/` |
| `check_name` | Optional. Check name to use when creating a check run. The default is `JUnit Test Report`. |
| `suite_regex` | REMOVED (as of v5). Instead use `check_title_template` and configure: `{{BREAD_CRUMB}}{{SUITE_NAME}}/{{TEST_NAME}}` |
| `commit` | Optional. The commit SHA to update the status. This is useful when you run it with `workflow_run`. |
| `fail_on_failure` | Optional. Fail the build in case of a test failure. |
| `require_tests` | Optional. Fail if no test are found. |
| `require_passed_tests` | Optional. Fail if no passed test are found. (This is stricter than `require_tests`, which accepts skipped tests). |
| `include_passed` | Optional. By default the action will skip passed items for the annotations. Enable this flag to include them. |
| `check_retries` | Optional. If a testcase is retried, ignore the original failure. |
| `check_title_template` | Optional. Template to configure the title format. Placeholders: {{FILE_NAME}}, {{SUITE_NAME}}, {{TEST_NAME}}, {{CLASS_NAME}}, {{BREAD_CRUMB}}. |
| `summary` | Optional. Additional text to summary output |
| `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). |
| `update_check` | Optional. Uses an alternative API to update checks, use for cases with more than 50 annotations. Default: `false`. |
| `annotate_only` | Optional. Will only annotate the results on the files, won't create a check run. Defaults to `false`. |
| `transformers` | Optional. Array of `Transformer`s offering the ability to adjust the fileName. Defaults to: `[{"searchValue":"::","replaceValue":"/"}]` |
| `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) |
| `detailed_summary` | Optional. Include table with all test results in the summary. Defaults to `false`. |
| `flaky_summary` | Optional. Include table with all falky results in the summary. Defaults to `false`. |
| `annotate_notice` | Optional. Annotate passed test results along with warning/failed ones. Defaults to `false`. (Changed in v3.5.0) |
| `follow_symlink` | Optional. Enables to follow symlinks when searching test files via the globber. Defaults to `false`. |
| `job_name` | Optional. Specify the name of a check to update |
| `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`. |
| **Input** | **Description** |
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `report_paths` | Optional. [Glob](https://github.com/actions/toolkit/tree/master/packages/glob) expression to junit report paths. Defaults to: `**/junit-reports/TEST-*.xml`. |
| `token` | Optional. GitHub token for creating a check run. Set to `${{ github.token }}` by default. |
| `test_files_prefix` | Optional. Prepends the provided prefix to test file paths within the report when annotating on GitHub. |
| `exclude_sources` | Optional. Provide `,` seperated array of folders to ignore for source lookup. Defaults to: `/build/,/__pycache__/` |
| `check_name` | Optional. Check name to use when creating a check run. The default is `JUnit Test Report`. |
| `suite_regex` | REMOVED (as of v5). Instead use `check_title_template` and configure: `{{BREAD_CRUMB}}{{SUITE_NAME}}/{{TEST_NAME}}` |
| `commit` | Optional. The commit SHA to update the status. This is useful when you run it with `workflow_run`. |
| `fail_on_failure` | Optional. Fail the build in case of a test failure. |
| `require_tests` | Optional. Fail if no test are found. |
| `require_passed_tests` | Optional. Fail if no passed test are found. (This is stricter than `require_tests`, which accepts skipped tests). |
| `include_passed` | Optional. By default the action will skip passed items for the annotations. Enable this flag to include them. |
| `check_retries` | Optional. If a testcase is retried, ignore the original failure. |
| `check_title_template` | Optional. Template to configure the title format. Placeholders: {{FILE_NAME}}, {{SUITE_NAME}}, {{TEST_NAME}}, {{CLASS_NAME}}, {{BREAD_CRUMB}}. |
| `bread_crumb_delimiter` | Optional. Defines the delimiter characters between the breadcrumb elements. Defaults to: `/`. |
| `summary` | Optional. Additional text to summary output |
| `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). |
| `update_check` | Optional. Uses an alternative API to update checks, use for cases with more than 50 annotations. Default: `false`. |
| `annotate_only` | Optional. Will only annotate the results on the files, won't create a check run. Defaults to `false`. |
| `transformers` | Optional. Array of `Transformer`s offering the ability to adjust the fileName. Defaults to: `[{"searchValue":"::","replaceValue":"/"}]` |
| `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) |
| `detailed_summary` | Optional. Include table with all test results in the summary. Defaults to `false`. |
| `flaky_summary` | Optional. Include table with all falky results in the summary. Defaults to `false`. |
| `annotate_notice` | Optional. Annotate passed test results along with warning/failed ones. Defaults to `false`. (Changed in v3.5.0) |
| `follow_symlink` | Optional. Enables to follow symlinks when searching test files via the globber. Defaults to `false`. |
| `job_name` | Optional. Specify the name of a check to update |
| `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`. |

<details><summary><b>Common report_paths</b></summary>
<p>
Expand Down
14 changes: 10 additions & 4 deletions __tests__/testParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ describe('parseFile', () => {
undefined,
undefined,
undefined,
'/',
undefined,
undefined,
undefined,
Expand Down Expand Up @@ -261,7 +262,8 @@ describe('parseFile', () => {
false,
false,
['/build/', '/__pycache__/'],
undefined,
'{{BREAD_CRUMB}}{{SUITE_NAME}}/{{TEST_NAME}}',
'/',
'subproject/'
)
const filtered = annotations.filter(annotation => annotation.annotation_level !== 'notice')
Expand All @@ -278,7 +280,7 @@ describe('parseFile', () => {
retries: 0,
annotation_level: 'failure',
status: 'failure',
title: 'test_sample.test_which_fails',
title: 'pytest/test_which_fails',
message: "AssertionError: assert 'test' == 'xyz'\n - xyz\n + test",
raw_details:
"def test_which_fails():\n event = { 'attr': 'test'}\n> assert event['attr'] == 'xyz'\nE AssertionError: assert 'test' == 'xyz'\nE - xyz\nE + test\n\npython/test_sample.py:10: AssertionError"
Expand All @@ -292,7 +294,7 @@ describe('parseFile', () => {
retries: 0,
annotation_level: 'failure',
status: 'failure',
title: 'test_sample.test_with_error',
title: 'pytest/test_with_error',
message: "AttributeError: 'dict' object has no attribute 'attr'",
raw_details:
"def test_with_error():\n event = { 'attr': 'test'}\n> assert event.attr == 'test'\nE AttributeError: 'dict' object has no attribute 'attr'\n\npython/test_sample.py:14: AttributeError"
Expand Down Expand Up @@ -847,6 +849,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
false,
['/build/', '/__pycache__/'],
'{{TEST_NAME}}',
'',
'subproject'
)

Expand Down Expand Up @@ -1085,6 +1088,7 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
undefined,
undefined,
undefined,
'/',
undefined,
transformer
)
Expand Down Expand Up @@ -1200,7 +1204,8 @@ describe('parseTestReports', () => {
true,
true,
[],
'{{SUITE_NAME}}/{{TEST_NAME}}'
'{{SUITE_NAME}}/{{TEST_NAME}}',
'/'
)

expect(checkName).toBe('checkName')
Expand Down Expand Up @@ -1236,6 +1241,7 @@ describe('parseTestReports', () => {
false,
[],
'',
'/',
'',
undefined,
false,
Expand Down
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ inputs:
default: 'false'
check_title_template:
description: |-
Template to configure the title format. Placeholders: {{FILE_NAME}}, {{SUITE_NAME}}, {{TEST_NAME}}, {{CLASS_NAME}}.
Template to configure the title format. Placeholders: {{FILE_NAME}}, {{SUITE_NAME}}, {{TEST_NAME}}, {{CLASS_NAME}}, {{BREAD_CRUMB}}.
required: false
bread_crumb_delimiter:
description: |-
Defines the delimiter characters between the breadcrumb elements. Defaults to: `/`.
required: false
default: '/'
summary:
description: 'Additional text to summary output'
required: false
Expand Down
Loading

0 comments on commit 5f36538

Please sign in to comment.