damccorm commented on code in PR #27210:
URL: https://github.com/apache/beam/pull/27210#discussion_r1237358980
##########
.github/actions/rerun-job-action/action.yml:
##########
@@ -0,0 +1,118 @@
+name: "Rerun Job Action"
+description: Re-runs a job that is attached to the PR as Check Run
+inputs:
+ pull_request_url:
+ description: "The URL of the PR"
+ required: true
+ github_repository:
+ description: "The GitHub repository"
+ required: true
+ github_token:
+ description: "The GitHub token"
+ required: true
+ github_job:
+ description: "The GitHub job"
+ required: true
+ github_current_run_id:
+ description: "The GitHub current run id. Not the same that is fetched in
this action"
+ required: true
+
+
+runs:
+ using: composite
+ steps:
+ - name: Get Last Commit SHA
+ shell: bash
+ run: |
+ URL=${{inputs.pull_request_url}}/commits
+ PRSHA=$(curl \
+ -H 'Authorization: Bearer ${{inputs.github_token}}' \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ -s $URL | jq -r '.[-1].sha' )
+ echo prsha=$PRSHA >> $GITHUB_ENV
+
+ - name: Get Status for PR Job
+ id: get_status
+ shell: bash
+ run: |
+
URL="${{github.api_url}}/repos/${{inputs.github_repository}}/commits/${{env.prsha}}/check-runs"
+ STATUS=$(curl \
+ -H 'Authorization: Bearer ${{inputs.github_token}}' \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ -s $URL | jq -r '.check_runs | .[] |
select(.name=="${{inputs.github_job}}") | .status')
+ echo status=$STATUS >> $GITHUB_ENV
+
+ - name: Get Conclusion for PR Job
Review Comment:
Can we consolidate this with the last one since we're making the same
request twice and just pulling out a different field?
##########
.github/actions/rerun-job-action/action.yml:
##########
@@ -0,0 +1,118 @@
+name: "Rerun Job Action"
Review Comment:
I think this will need the Apache header (can copy/paste from any workflow).
Also, could you add a brief comment description of the purpose of this
composite action, including how to use it (ideally with a code snippet) and
required permissions (again ideally with a code snippet). I think the
permissions should be `repo: read` (even if we don't need this, virtually every
job will), `pull-requests: write`, and `checks: read` (might actually need to
be `statuses` instead of `checks`?)
##########
.github/actions/rerun-job-action/action.yml:
##########
@@ -0,0 +1,118 @@
+name: "Rerun Job Action"
+description: Re-runs a job that is attached to the PR as Check Run
+inputs:
+ pull_request_url:
+ description: "The URL of the PR"
+ required: true
+ github_repository:
+ description: "The GitHub repository"
+ required: true
+ github_token:
+ description: "The GitHub token"
+ required: true
+ github_job:
+ description: "The GitHub job"
+ required: true
+ github_current_run_id:
+ description: "The GitHub current run id. Not the same that is fetched in
this action"
+ required: true
+
+
+runs:
+ using: composite
+ steps:
+ - name: Get Last Commit SHA
+ shell: bash
+ run: |
+ URL=${{inputs.pull_request_url}}/commits
+ PRSHA=$(curl \
+ -H 'Authorization: Bearer ${{inputs.github_token}}' \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ -s $URL | jq -r '.[-1].sha' )
+ echo prsha=$PRSHA >> $GITHUB_ENV
+
+ - name: Get Status for PR Job
+ id: get_status
+ shell: bash
+ run: |
+
URL="${{github.api_url}}/repos/${{inputs.github_repository}}/commits/${{env.prsha}}/check-runs"
+ STATUS=$(curl \
+ -H 'Authorization: Bearer ${{inputs.github_token}}' \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ -s $URL | jq -r '.check_runs | .[] |
select(.name=="${{inputs.github_job}}") | .status')
+ echo status=$STATUS >> $GITHUB_ENV
+
+ - name: Get Conclusion for PR Job
+ id: get_conclusion
+ shell: bash
+ run: |
+
URL="${{github.api_url}}/repos/${{inputs.github_repository}}/commits/${{env.prsha}}/check-runs"
+ CONCLUSION=$(curl \
+ -H 'Authorization: Bearer ${{inputs.github_token}}' \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ -s $URL | jq -r '.check_runs | .[] |
select(.name=="${{inputs.github_job}}") | .conclusion')
+ echo conclusion=$CONCLUSION >> $GITHUB_ENV
+
+ - name: Enable Rerun
+ if: ${{env.status == 'completed' && (env.conclusion == 'success' ||
env.conclusion == 'skipped')}}
+ shell: bash
+ run: echo rerun=false >> $GITHUB_ENV
+
+ - name: Get Check Suide ID
Review Comment:
```suggestion
- name: Get Check Suite ID
```
##########
.github/actions/rerun-job-action/action.yml:
##########
@@ -0,0 +1,118 @@
+name: "Rerun Job Action"
+description: Re-runs a job that is attached to the PR as Check Run
+inputs:
+ pull_request_url:
+ description: "The URL of the PR"
+ required: true
+ github_repository:
+ description: "The GitHub repository"
+ required: true
+ github_token:
+ description: "The GitHub token"
+ required: true
+ github_job:
+ description: "The GitHub job"
+ required: true
+ github_current_run_id:
+ description: "The GitHub current run id. Not the same that is fetched in
this action"
+ required: true
+
+
+runs:
+ using: composite
+ steps:
+ - name: Get Last Commit SHA
+ shell: bash
+ run: |
+ URL=${{inputs.pull_request_url}}/commits
+ PRSHA=$(curl \
+ -H 'Authorization: Bearer ${{inputs.github_token}}' \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ -s $URL | jq -r '.[-1].sha' )
+ echo prsha=$PRSHA >> $GITHUB_ENV
+
+ - name: Get Status for PR Job
+ id: get_status
+ shell: bash
+ run: |
+
URL="${{github.api_url}}/repos/${{inputs.github_repository}}/commits/${{env.prsha}}/check-runs"
+ STATUS=$(curl \
+ -H 'Authorization: Bearer ${{inputs.github_token}}' \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ -s $URL | jq -r '.check_runs | .[] |
select(.name=="${{inputs.github_job}}") | .status')
+ echo status=$STATUS >> $GITHUB_ENV
+
+ - name: Get Conclusion for PR Job
+ id: get_conclusion
+ shell: bash
+ run: |
+
URL="${{github.api_url}}/repos/${{inputs.github_repository}}/commits/${{env.prsha}}/check-runs"
+ CONCLUSION=$(curl \
+ -H 'Authorization: Bearer ${{inputs.github_token}}' \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ -s $URL | jq -r '.check_runs | .[] |
select(.name=="${{inputs.github_job}}") | .conclusion')
+ echo conclusion=$CONCLUSION >> $GITHUB_ENV
+
+ - name: Enable Rerun
+ if: ${{env.status == 'completed' && (env.conclusion == 'success' ||
env.conclusion == 'skipped')}}
Review Comment:
A comment explaining our logic here would probably help (basically, we can't
use the rerun api if the status is completed and it succeeded or was skipped).
I guess this does mean that trigger phrases won't status correctly for jobs
that have already succeeded or are skipped, I think that's fine though
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]