Skip to content
Closed
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
31 changes: 25 additions & 6 deletions .github/workflows/notify_test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const endpoint = 'GET /repos/:owner/:repo/actions/workflows/:id/runs?&branch=:branch'
const check_run_endpoint = 'GET /repos/:owner/:repo/commits/:ref/check-runs'

// TODO: Should use pull_request.user and pull_request.user.repos_url?
// If a different person creates a commit to another forked repo,
Expand All @@ -49,6 +50,11 @@ jobs:
id: 'build_and_test.yml',
branch: context.payload.pull_request.head.ref,
}
const check_run_params = {
owner: context.payload.pull_request.head.repo.owner.login,
repo: context.payload.pull_request.head.repo.name,
ref: context.payload.pull_request.head.ref,
}

console.log('Ref: ' + context.payload.pull_request.head.ref)
console.log('SHA: ' + context.payload.pull_request.head.sha)
Expand Down Expand Up @@ -100,16 +106,29 @@ jobs:
}
})
} else {
const runID = runs.data.workflow_runs[0].id
const run_id = runs.data.workflow_runs[0].id

if (runs.data.workflow_runs[0].head_sha != context.payload.pull_request.head.sha) {
throw new Error('There was a new unsynced commit pushed. Please retrigger the workflow.');
}

const runUrl = 'https://github.com/'
// Here we get check run ID to provide Check run view instead of Actions view, see also SPARK-37879.
const check_runs = await github.request(check_run_endpoint, check_run_params)
const check_run_head = check_runs.data.check_runs.filter(r => r.name === "Configure jobs")[0]

if (check_run_head.head_sha != context.payload.pull_request.head.sha) {
throw new Error('There was a new unsynced commit pushed. Please retrigger the workflow.');
}

const check_run_url = 'https://github.com/'
+ context.payload.pull_request.head.repo.full_name
+ '/runs/'
+ check_run_head.id

const actions_url = 'https://github.com/'
+ context.payload.pull_request.head.repo.full_name
+ '/actions/runs/'
+ runID
+ run_id

github.checks.create({
owner: context.repo.owner,
Expand All @@ -119,13 +138,13 @@ jobs:
status: status,
output: {
title: 'Test results',
summary: '[See test results](' + runUrl + ')',
summary: '[See test results](' + check_run_url + ')',
text: JSON.stringify({
owner: context.payload.pull_request.head.repo.owner.login,
repo: context.payload.pull_request.head.repo.name,
run_id: runID
run_id: run_id
})
},
details_url: runUrl,
details_url: actions_url,
Copy link
Member Author

Choose a reason for hiding this comment

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

Actually I think we can even remove this but let me keep it as is for now (https://github.community/t/create-a-check-run-details-url-is-not-being-set/166002). This is currently just a metadata for now.

})
}