-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8731 from Agoric/mfig-ci-external-prs
ci: allow externally forked PRs to pass CI
- Loading branch information
Showing
4 changed files
with
105 additions
and
76 deletions.
There are no files selected for viewing
This file contains 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 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,84 @@ | ||
name: Manage integration check | ||
|
||
on: | ||
workflow_run: | ||
workflows: ['Integration tests'] | ||
|
||
jobs: | ||
create-check: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
check_id: ${{ steps.create-check.outputs.result }} | ||
steps: | ||
- name: Create check | ||
uses: actions/github-script@v6 | ||
id: create-check | ||
if: ${{ github.event.action == 'requested' || github.event.action == 'in_progress' }} | ||
with: | ||
script: | | ||
const external_id = context.payload.workflow_run.html_url; | ||
const head_sha = context.payload.workflow_run.head_sha; | ||
const runs = await github.paginate(github.rest.checks.listForRef, { | ||
...context.repo, | ||
ref: head_sha, | ||
check_name: "integration-test-result", | ||
external_id, | ||
}) | ||
core.debug(`integration-test-result check runs: ${JSON.stringify(runs, null, 2)}`); | ||
const filtRuns = runs.filter(run => run.status !== 'completed'); | ||
const descRuns = filtRuns.sort((a, b) => Date.parse(b.started_at) - Date.parse(a.started_at)); | ||
const run = descRuns[0]; | ||
if (run) { | ||
// Check already exists. | ||
return run.id; | ||
} | ||
const check = await github.rest.checks.create({ | ||
...context.repo, | ||
head_sha, | ||
name: "integration-test-result", | ||
status: "in_progress", | ||
external_id, | ||
output: { | ||
title: "Integration Test Aggregate Result", | ||
summary: `Synthetic check capturing the result of the <a href="${context.payload.workflow_run.html_url}">integration-test workflow run</a>`, | ||
} | ||
}); | ||
return check.data.id; | ||
update-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Update check result | ||
uses: actions/github-script@v6 | ||
if: ${{ github.event.action == 'completed' }} | ||
with: | ||
result-encoding: string | ||
script: | | ||
// Update the check run | ||
const external_id = context.payload.workflow_run.html_url; | ||
const head_sha = context.payload.workflow_run.head_sha; | ||
const runs = await github.paginate(github.rest.checks.listForRef, { | ||
...context.repo, | ||
ref: head_sha, | ||
check_name: "integration-test-result", | ||
external_id, | ||
}) | ||
core.debug(`integration-test-result check runs: ${JSON.stringify(runs, null, 2)}`); | ||
const filtRuns = runs.filter(run => run.status !== 'completed'); | ||
const descRuns = filtRuns.sort((a, b) => Date.parse(b.started_at) - Date.parse(a.started_at)); | ||
const run = descRuns[0]; | ||
if (!run) { | ||
core.setFailed(`No integration-test-result check found for commit ${head_sha} ${external_id}`); | ||
return; | ||
} | ||
console.log('Latest integration-test-result check run:', run.html_url) | ||
await github.rest.checks.update({ | ||
...context.repo, | ||
check_run_id: run.id, | ||
status: "completed", | ||
conclusion: context.payload.workflow_run.conclusion, | ||
}); | ||
return run.id |
This file contains 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 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