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

Add actor name option #460

Merged
merged 8 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ The list of most notable options:
|:-----|:-----:|:----------|
|`commit`|`${{env.GITHUB_SHA}}`|An alternative commit SHA to which test results are published. The `push` and `pull_request`events are handled, but for other [workflow events](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#push) `GITHUB_SHA` may refer to different kinds of commits. See [GitHub Workflow documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows) for details.|
|`github_token`|`${{github.token}}`|An alternative GitHub token, other than the default provided by GitHub Actions runner.|
|`github_actor`|`github-actions`|Used to find older comment to update. Note: this does not change the bot name while commenting. If you use any other GH app, you need provide that app name here. Otherwise all your run will create a new comment.|
|`github_retries`|`10`|Requests to the GitHub API are retried this number of times. The value must be a positive integer or zero.|
|`seconds_between_github_reads`|`0.25`|Sets the number of seconds the action waits between concurrent read requests to the GitHub API.|
|`seconds_between_github_writes`|`2.0`|Sets the number of seconds the action waits between concurrent write requests to the GitHub API.|
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ inputs:
description: 'GitHub API Access Token.'
default: ${{ github.token }}
required: false
github_actor:
description: 'The name of the actor that runs this action. Defaults to "github-actions"'
default: 'github-actions'
required: false
github_retries:
description: 'Requests to the GitHub API are retried this number of times. The value must be a positive integer or zero.'
default: '10'
Expand Down
4 changes: 4 additions & 0 deletions composite/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ inputs:
description: 'GitHub API Access Token.'
default: ${{ github.token }}
required: false
github_actor:
description: 'The name of the actor that runs this action. Defaults to "github-actions"'
default: 'github-actions'
required: false
github_retries:
description: 'Requests to the GitHub API are retried this number of times. The value must be a positive integer or zero.'
default: '10'
Expand Down
3 changes: 2 additions & 1 deletion python/publish/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
@dataclass(frozen=True)
class Settings:
token: str
actor: str
api_url: str
graphql_url: str
api_retries: int
Expand Down Expand Up @@ -734,7 +735,7 @@ def get_pull_request_comments(self, pull: PullRequest, order_by_updated: bool) -

def get_action_comments(self, comments: List[Mapping[str, Any]], is_minimized: Optional[bool] = False):
return list([comment for comment in comments
if comment.get('author', {}).get('login') == 'github-actions'
if comment.get('author', {}).get('login') == self._settings.actor
EnricoMi marked this conversation as resolved.
Show resolved Hide resolved
and (is_minimized is None or comment.get('isMinimized') == is_minimized)
and comment.get('body', '').startswith(f'## {self._settings.comment_title}\n')
and ('\nresults for commit ' in comment.get('body') or '\nResults for commit ' in comment.get('body'))])
2 changes: 2 additions & 0 deletions python/publish_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def get_settings(options: dict, gha: GithubAction) -> Settings:
annotations = get_annotations_config(options, event)
suite_logs_mode = get_var('REPORT_SUITE_LOGS', options) or default_report_suite_logs
ignore_runs = get_bool_var('IGNORE_RUNS', options, default=False)
actor = get_var('GITUHB_ACTOR', options) or 'github-actions'

fail_on = get_var('FAIL_ON', options) or 'test failures'
check_var(fail_on, 'FAIL_ON', 'Check fail mode', fail_on_modes)
Expand All @@ -458,6 +459,7 @@ def get_settings(options: dict, gha: GithubAction) -> Settings:

settings = Settings(
token=get_var('GITHUB_TOKEN', options),
actor=actor,
api_url=api_url,
graphql_url=graphql_url,
api_retries=int(retries),
Expand Down