Skip to content

Commit 93e587d

Browse files
HyukjinKwondchvn
authored andcommitted
[SPARK-37879][INFRA] Show test report in GitHub Actions builds from PRs
### What changes were proposed in this pull request? This PR proposes to show the link of Check run view instead of Actions view. Previously, when you add a new custom Check, e.g., [test_report.yml](https://github.com/apache/spark/blob/master/.github/workflows/test_report.yml), Actions view also showed this Check. Now, seems GitHub Actions changed the behaviour - Actions view always includes the jobs initiated by the specific Workflow e.g., [build_and_test.yml](https://github.com/apache/spark/blob/master/.github/workflows/build_and_test.yml) does not include the custom Check added from [test_report.yml](https://github.com/apache/spark/blob/master/.github/workflows/test_report.yml). To work around this problem, this PR proposes to show the link of: Check run view e.g., https://github.com/apache/spark/runs/4785069876 ("Report test results" is included) instead of Actions view e.g., https://github.com/apache/spark/actions/runs/1686013487 ("Report test results" is missing) . After this PR, when developers click the link here: ![Screen Shot 2022-01-12 at 10 07 26 PM](https://user-images.githubusercontent.com/6477701/149146026-80f3ac26-ba06-411f-9cb8-f5395ffd8432.png) it will open a Check run view instead of Actions view which does not have test report tab. ### Why are the changes needed? For developers to see the test report, and they can easily detect which test is failed. ### Does this PR introduce _any_ user-facing change? No, dev-only ### How was this patch tested? Manually tested at HyukjinKwon#51. Closes apache#35179 from HyukjinKwon/show-test-report. Authored-by: Hyukjin Kwon <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 428ee92 commit 93e587d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

.github/workflows/notify_test_workflow.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@ jobs:
3838
with:
3939
github-token: ${{ secrets.GITHUB_TOKEN }}
4040
script: |
41-
const endpoint = 'GET /repos/:owner/:repo/actions/workflows/:id/runs?&branch=:branch'
41+
const endpoint = 'GET /repos/:owner/:repo/commits/:ref/check-runs'
4242
4343
// TODO: Should use pull_request.user and pull_request.user.repos_url?
4444
// If a different person creates a commit to another forked repo,
4545
// it wouldn't be able to detect.
4646
const params = {
4747
owner: context.payload.pull_request.head.repo.owner.login,
4848
repo: context.payload.pull_request.head.repo.name,
49-
id: 'build_and_test.yml',
50-
branch: context.payload.pull_request.head.ref,
49+
ref: context.payload.pull_request.head.ref,
5150
}
5251
5352
console.log('Ref: ' + context.payload.pull_request.head.ref)
@@ -68,7 +67,7 @@ jobs:
6867
const head_sha = context.payload.pull_request.head.sha
6968
let status = 'queued'
7069
71-
if (!runs || runs.data.workflow_runs.length === 0) {
70+
if (!runs || runs.data.check_runs.filter(r => r.name === "Configure jobs").length === 0) {
7271
status = 'completed'
7372
const conclusion = 'action_required'
7473
@@ -100,15 +99,15 @@ jobs:
10099
}
101100
})
102101
} else {
103-
const runID = runs.data.workflow_runs[0].id
102+
const runID = runs.data.check_runs.filter(r => r.name === "Configure jobs")[0].id
104103
105-
if (runs.data.workflow_runs[0].head_sha != context.payload.pull_request.head.sha) {
104+
if (runs.data.check_runs[0].head_sha != context.payload.pull_request.head.sha) {
106105
throw new Error('There was a new unsynced commit pushed. Please retrigger the workflow.');
107106
}
108107
109108
const runUrl = 'https://github.com/'
110109
+ context.payload.pull_request.head.repo.full_name
111-
+ '/actions/runs/'
110+
+ '/runs/'
112111
+ runID
113112
114113
github.checks.create({

0 commit comments

Comments
 (0)