-
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.
- Loading branch information
Showing
328 changed files
with
15,073 additions
and
5,045 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
This file was deleted.
Oops, something went wrong.
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,82 @@ | ||
name: Get latest check | ||
description: "Get the latest integration-test-result check associated with the workflow's commit" | ||
|
||
inputs: | ||
create-if-needed: | ||
description: 'Create a new check if a previous check is not suitable' | ||
default: false | ||
|
||
outputs: | ||
run_id: | ||
description: 'The id of the integration-test-result check' | ||
value: ${{ steps.attach-check.outputs.result }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Attach integration-test-result check | ||
id: attach-check | ||
uses: actions/github-script@v6 | ||
env: | ||
CREATE_IF_NEEDED: '${{ inputs.create-if-needed }}' | ||
with: | ||
result-encoding: string | ||
script: | | ||
let createIfNeeded = process.env.CREATE_IF_NEEDED === 'true' | ||
let runId; | ||
const currentWorkflowRunUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` | ||
const head_sha = context.eventName === 'pull_request' ? | ||
context.payload.pull_request.head.sha : context.sha | ||
async function attachRun(run) { | ||
if (!run) { | ||
core.setFailed(`No integration-test-result check found for commit ${head_sha}`) | ||
return | ||
} | ||
console.log('Latest integration-test-result check run:', run.html_url) | ||
if (run.status === 'completed') { | ||
core.setFailed(`Latest integration-test-result check status is already completed`) | ||
return | ||
} | ||
if (run.output.summary) { | ||
if (run.output.summary.includes(currentWorkflowRunUrl)) { | ||
console.log('Latest integration-test-result check is already attached to this workflow run, using.') | ||
return run.id | ||
} else { | ||
core.setFailed(`Latest integration-test-result check found attached to workflow run: ${run.output.summary}`) | ||
return | ||
} | ||
} | ||
const res = await github.rest.checks.update({ | ||
...context.repo, | ||
check_run_id: run.id, | ||
output: { | ||
title: 'Integration Test Aggregate Result', | ||
summary: `Synthetic check capturing the result of the <a href="${currentWorkflowRunUrl}">integration-test workflow run</a>`, | ||
}, | ||
}) | ||
console.log(`Attached integration-test-result check to this workflow run`) | ||
return run.id | ||
} | ||
const runs = await github.paginate(github.rest.checks.listForRef, { | ||
...context.repo, | ||
ref: head_sha, | ||
check_name: "integration-test-result", | ||
}) | ||
core.debug(`integration-test-result check runs: ${JSON.stringify(runs, null, 2)}`) | ||
runId = await attachRun(runs.sort((a, b) => Date.parse(b.started_at) - Date.parse(a.started_at))[0]) | ||
if (!runId && createIfNeeded) { | ||
process.exitCode = 0 | ||
const res = await github.rest.checks.create({ | ||
...context.repo, | ||
head_sha, | ||
name: "integration-test-result", | ||
}) | ||
core.debug('check create response: ${JSON.stringify(res, null, 2)}') | ||
console.log('created integration-test-result check:', res.data.html_url) | ||
runId = await attachRun(res.data) | ||
} | ||
return runId |
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
Oops, something went wrong.