Skip to content
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
30 changes: 20 additions & 10 deletions .github/actions/update-check/action.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: "update-check-action"
description: "Creates or updates a check for a specific PR"
description: "Creates or updates a check for a specific PR and/or a comment"
inputs:
pull_request_number:
description: "Number of the pull request to update checks in"
required: true
check_name:
description: "Name of the check to update"
required: true
required: false
conclusion:
description: "Conclusion to set for the check"
required: true
required: false
github_token:
description: "GitHub token to authenticate with"
default: ${{ github.token }}
Expand All @@ -25,7 +25,7 @@ runs:
steps:
- uses: actions/github-script@v6
id: update-check-run
if: ${{ always() }}
if: always() && inputs.check_name != '' && inputs.conclusion != ''
env:
number: ${{ inputs.pull_request_number }}
check_name: ${{ inputs.check_name }}
Expand Down Expand Up @@ -63,7 +63,7 @@ runs:
return result;
- uses: actions/github-script@v6
id: comment
if: ${{ always() }}
if: always()
env:
number: ${{ inputs.pull_request_number }}
run_id: ${{ inputs.run_id }}
Expand All @@ -83,21 +83,31 @@ runs:
exclude_pull_requests: true
});

const message = "The CI workflow run with tests that require additional secrets finished as " + process.env.conclusion + ": " + run.html_url
const started = "The CI workflow run with tests that require additional secrets has been started: " + run.html_url
const finished = "The CI workflow run with tests that require additional secrets finished as " + process.env.conclusion + ": " + run.html_url
const comments = await github.paginate(github.rest.issues.listComments.endpoint.merge({
...context.repo,
issue_number: process.env.number
}))
const exists = comments.filter(comment => comment.body === message).length != 0
const comment = comments.find(comment => comment.body === started || comment.body === finished)

if (comment !== undefined) {
if (comment.body === finished) {
return;
}
Comment on lines +95 to +97
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks unreachable. Even if you comment twice for same SHA two different runs will be started if the automation hasn't posted a comment yet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action is called from the test jobs created from a matrix, so there can be more than one. This is done to signal the original PR about the failure as early as possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one deserves comment IMO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the workflow?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, in the body of this if block would make sense

const { data: result } = await github.rest.issues.updateComment({
...context.repo,
comment.id,
body: finished
});

if (exists) {
return;
return result;
}

const { data: result } = await github.rest.issues.createComment({
...context.repo,
issue_number: process.env.number,
body: message
body: started
});

return result;
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,16 @@ jobs:
github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.args.named.sha &&
format('refs/pull/{0}/head', github.event.client_payload.pull_request.number) || '' }}
- uses: ./.github/actions/setup
- name: Update PR check
uses: ./.github/actions/update-check
if: >-
always() &&
github.event_name == 'repository_dispatch' &&
github.event.client_payload.slash_command.args.named.sha != '' &&
github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.args.named.sha
with:
pull_request_number: ${{ github.event.client_payload.pull_request.number }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Maven validate
run: |
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
Expand Down