Skip to content

Commit

Permalink
Change default value for check_name
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed Jun 6, 2022
1 parent 16647a7 commit 54910ea
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,32 @@ The `if: always()` clause guarantees that this action always runs, even if earli
fail on test failure. The published results however indicate failure if tests fail or errors occur.
This behaviour is configurable.*

## What is new in version 2

<details>
<summary>These changes have to be considered when moving from version 1 to version 2:</summary>

### Default value for `check_name` changed
Unless `check_name` is set in your config, the check name used to publish test results changes from `"Unit Test Results"` to `"Test Results"`.

**Impact:**
The check with the old name will not be updated once moved to version 2.

**Workaround to get version 1 behaviour:**
Add `check_name: "Unit Test Results"` to your config.

### Default value for `comment_title` changed
Unless `comment_title` or `check_name` are set in your config, the title used to comment on open pull requests changes from `"Unit Test Results"` to `"Test Results"`.

**Impact:**
Existing comments with the old title will not be updated once moved to version 2, but a new comment is created.

**Workaround to get version 1 behaviour:**
See workaround for `check_name`.

</details>


## Publishing test results

Test results are published on GitHub at various (configurable) places:
Expand Down Expand Up @@ -173,7 +199,7 @@ The list of most notable options:
|Option|Default Value|Description|
|:-----|:-----:|:----------|
|`junit_files`|`*.xml`|File patterns of JUnit XML test result files. Supports `*`, `**`, `?`, and `[]`. Use multiline string for multiple patterns. Patterns starting with `!` exclude the matching files. There have to be at least one pattern starting without a `!`.|
|`check_name`|`"Unit Test Results"`|An alternative name for the check result.|
|`check_name`|`"Test Results"`|An alternative name for the check result.|
|`comment_title`|same as `check_name`|An alternative name for the pull request comment.|

<details>
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ inputs:
required: false
check_name:
description: 'Name of the created check run'
default: 'Unit Test Results'
default: 'Test Results'
required: false
comment_title:
description: 'Title of PR comments, defaults to value of check_name input'
Expand Down
2 changes: 1 addition & 1 deletion composite/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ inputs:
required: false
check_name:
description: 'Name of the created check run'
default: 'Unit Test Results'
default: 'Test Results'
required: false
comment_title:
description: 'Title of PR comments, defaults to value of check_name input'
Expand Down
4 changes: 2 additions & 2 deletions python/publish/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def hide_orphaned_commit_comments(self, pull: PullRequest) -> None:

# hide all those comments
for node_id, comment_commit_sha in comment_ids:
logger.info(f'hiding unit test result comment for commit {comment_commit_sha}')
logger.info(f'hiding test result comment for commit {comment_commit_sha}')
self.hide_comment(node_id)

def hide_all_but_latest_comments(self, pull: PullRequest) -> None:
Expand All @@ -605,5 +605,5 @@ def hide_all_but_latest_comments(self, pull: PullRequest) -> None:

# hide all those comments
for node_id in comment_ids:
logger.info(f'hiding unit test result comment {node_id}')
logger.info(f'hiding test result comment {node_id}')
self.hide_comment(node_id)
4 changes: 2 additions & 2 deletions python/publish_unit_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def main(settings: Settings, gha: GithubAction) -> None:
logger.info(f'reading {settings.junit_files_glob}')
logger.debug(f'reading {list(files)}')

# get the unit test results
# get the test results
parsed = parse_junit_xml_files(files, settings.time_factor, settings.ignore_runs).with_commit(settings.commit)
[gha.error(message=f'Error processing result file: {error.message}', file=error.file, line=error.line, column=error.column)
for error in parsed.errors]
Expand Down Expand Up @@ -253,7 +253,7 @@ def get_settings(options: dict, gha: Optional[GithubAction] = None) -> Settings:
f'It is optional, but when given must be one of these values: '
f'{", ".join(time_factors.keys())}')

check_name = get_var('CHECK_NAME', options) or 'Unit Test Results'
check_name = get_var('CHECK_NAME', options) or 'Test Results'
comment_on_pr = get_bool_var('COMMENT_ON_PR', options, default=True, gha=gha)
annotations = get_annotations_config(options, event)

Expand Down
8 changes: 4 additions & 4 deletions python/test/test_action_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ def test_get_settings_test_changes_limit(self):

def test_get_settings_check_name(self):
self.do_test_get_settings(CHECK_NAME='name', expected=self.get_settings(check_name='name'))
self.do_test_get_settings(CHECK_NAME=None, expected=self.get_settings(check_name='Unit Test Results'))
self.do_test_get_settings(CHECK_NAME=None, expected=self.get_settings(check_name='Test Results'))

def test_get_settings_comment_title(self):
self.do_test_get_settings(COMMENT_TITLE=None, CHECK_NAME=None, expected=self.get_settings(comment_title='Unit Test Results', check_name='Unit Test Results'))
self.do_test_get_settings(COMMENT_TITLE='title', CHECK_NAME=None, expected=self.get_settings(comment_title='title', check_name='Unit Test Results'))
self.do_test_get_settings(COMMENT_TITLE=None, CHECK_NAME=None, expected=self.get_settings(comment_title='Test Results', check_name='Test Results'))
self.do_test_get_settings(COMMENT_TITLE='title', CHECK_NAME=None, expected=self.get_settings(comment_title='title', check_name='Test Results'))
self.do_test_get_settings(COMMENT_TITLE='title', CHECK_NAME='name', expected=self.get_settings(comment_title='title', check_name='name'))
self.do_test_get_settings(COMMENT_TITLE=None, CHECK_NAME='name', expected=self.get_settings(comment_title='name', check_name='name'))

Expand Down Expand Up @@ -462,7 +462,7 @@ def do_test_get_settings(self,
GITHUB_GRAPHQL_URL='http://github.graphql.url/', #defaults to github
GITHUB_RETRIES='2',
TEST_CHANGES_LIMIT='10', # not an int
CHECK_NAME='check name', # defaults to 'Unit Test Results'
CHECK_NAME='check name', # defaults to 'Test Results'
GITHUB_TOKEN='token',
GITHUB_REPOSITORY='repo',
COMMIT='commit', # defaults to get_commit_sha(event, event_name)
Expand Down

0 comments on commit 54910ea

Please sign in to comment.