Skip to content

Commit b092321

Browse files
committed
[SPARK-37879][INFRA] Show test report in GitHub Actions builds from PRs
### What changes were proposed in this pull request? This PR is a retry of #35179. This PR does the same thing - replacing Actions view to Check run view for `See test results` link. The main difference with the PR #35179 is that we now keep the Actions run id as is as metadata so this Actions run id can be used to update the status of tests in PRs at Apache Spark: https://github.com/apache/spark/blob/85efc85f9aa93b3fac9e591c96efa38d4414adf8/.github/workflows/update_build_status.yml#L63-L74 Now this PR shouldn't affect [update_build_status.yml](https://github.com/apache/spark/blob/master/.github/workflows/update_build_status.yml) which was the main reason of a followup and revert. ### 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? Tested in HyukjinKwon#51. Closes #35193 from HyukjinKwon/SPARK-37879-retry. Authored-by: Hyukjin Kwon <gurwls223@apache.org> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
1 parent 1431a4a commit b092321

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

.github/workflows/notify_test_workflow.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
github-token: ${{ secrets.GITHUB_TOKEN }}
4040
script: |
4141
const endpoint = 'GET /repos/:owner/:repo/actions/workflows/:id/runs?&branch=:branch'
42+
const check_run_endpoint = 'GET /repos/:owner/:repo/commits/:ref/check-runs'
4243
4344
// TODO: Should use pull_request.user and pull_request.user.repos_url?
4445
// If a different person creates a commit to another forked repo,
@@ -49,6 +50,11 @@ jobs:
4950
id: 'build_and_test.yml',
5051
branch: context.payload.pull_request.head.ref,
5152
}
53+
const check_run_params = {
54+
owner: context.payload.pull_request.head.repo.owner.login,
55+
repo: context.payload.pull_request.head.repo.name,
56+
ref: context.payload.pull_request.head.ref,
57+
}
5258
5359
console.log('Ref: ' + context.payload.pull_request.head.ref)
5460
console.log('SHA: ' + context.payload.pull_request.head.sha)
@@ -100,16 +106,29 @@ jobs:
100106
}
101107
})
102108
} else {
103-
const runID = runs.data.workflow_runs[0].id
109+
const run_id = runs.data.workflow_runs[0].id
104110
105111
if (runs.data.workflow_runs[0].head_sha != context.payload.pull_request.head.sha) {
106112
throw new Error('There was a new unsynced commit pushed. Please retrigger the workflow.');
107113
}
108114
109-
const runUrl = 'https://github.com/'
115+
// Here we get check run ID to provide Check run view instead of Actions view, see also SPARK-37879.
116+
const check_runs = await github.request(check_run_endpoint, check_run_params)
117+
const check_run_head = check_runs.data.check_runs.filter(r => r.name === "Configure jobs")[0]
118+
119+
if (check_run_head.head_sha != context.payload.pull_request.head.sha) {
120+
throw new Error('There was a new unsynced commit pushed. Please retrigger the workflow.');
121+
}
122+
123+
const check_run_url = 'https://github.com/'
124+
+ context.payload.pull_request.head.repo.full_name
125+
+ '/runs/'
126+
+ check_run_head.id
127+
128+
const actions_url = 'https://github.com/'
110129
+ context.payload.pull_request.head.repo.full_name
111130
+ '/actions/runs/'
112-
+ runID
131+
+ run_id
113132
114133
github.checks.create({
115134
owner: context.repo.owner,
@@ -119,13 +138,13 @@ jobs:
119138
status: status,
120139
output: {
121140
title: 'Test results',
122-
summary: '[See test results](' + runUrl + ')',
141+
summary: '[See test results](' + check_run_url + ')',
123142
text: JSON.stringify({
124143
owner: context.payload.pull_request.head.repo.owner.login,
125144
repo: context.payload.pull_request.head.repo.name,
126-
run_id: runID
145+
run_id: run_id
127146
})
128147
},
129-
details_url: runUrl,
148+
details_url: actions_url,
130149
})
131150
}

0 commit comments

Comments
 (0)