-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-35101][INFRA] Add GitHub status check in PR instead of a comment #32193
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a7dbce3
Create checks
HyukjinKwon 71b7949
Make it pretty, and rename
HyukjinKwon 3a27c74
Update .github/workflows/notify_test_workflow.yml
HyukjinKwon eb47ff7
Update .github/workflows/notify_test_workflow.yml
HyukjinKwon 48ad606
Address comments and cleanup
HyukjinKwon b96db67
Keep the credit
Yikun 480243c
Log Sha and ref
HyukjinKwon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| # | ||
|
|
||
| name: Update build status workflow | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "*/15 * * * *" | ||
HyukjinKwon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| jobs: | ||
| update: | ||
| name: Update build status | ||
| runs-on: ubuntu-20.04 | ||
| steps: | ||
| - name: "Update build status" | ||
| uses: actions/github-script@v3 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const endpoint = 'GET /repos/:owner/:repo/pulls?state=:state' | ||
| const params = { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| state: 'open' | ||
| } | ||
| // See https://docs.github.com/en/graphql/reference/enums#mergestatestatus | ||
| const maybeReady = ['behind', 'clean', 'draft', 'has_hooks', 'unknown', 'unstable']; | ||
| // Iterate open PRs | ||
| for await (const prs of github.paginate.iterator(endpoint,params)) { | ||
| // Each page | ||
| for await (const pr of prs.data) { | ||
| console.log('SHA: ' + pr.head.sha) | ||
| console.log(' Mergeable status: ' + pr.mergeable_state) | ||
| if (pr.mergeable_state == null || maybeReady.includes(pr.mergeable_state)) { | ||
| const checkRuns = await github.request('GET /repos/{owner}/{repo}/commits/{ref}/check-runs', { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| ref: pr.head.sha | ||
HyukjinKwon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }) | ||
| // Iterator GitHub Checks in the PR | ||
| for await (const cr of checkRuns.data.check_runs) { | ||
| if (cr.name == 'Build and test') { | ||
| // text contains parameters to make request in JSON. | ||
| const params = JSON.parse(cr.output.text) | ||
HyukjinKwon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Get the workflow run in the forked repository | ||
| const run = await github.request('GET /repos/{owner}/{repo}/actions/runs/{run_id}', params) | ||
| // Keep syncing the status of the checks | ||
| if (run.data.status == 'completed') { | ||
| console.log(' Run ' + cr.id + ': set status (' + run.data.status + ') and conclusion (' + run.data.conclusion + ')') | ||
| const response = await github.request('PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}', { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| check_run_id: cr.id, | ||
| output: cr.output, | ||
| status: run.data.status, | ||
| conclusion: run.data.conclusion | ||
| }) | ||
| } else { | ||
| console.log(' Run ' + cr.id + ': set status (' + run.data.status + ')') | ||
| const response = await github.request('PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}', { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| check_run_id: cr.id, | ||
| output: cr.output, | ||
| status: run.data.status, | ||
| }) | ||
| } | ||
| break | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.