generated from im-open/javascript-action-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARCH-2011 - Fix assertion for status check & add check cleanup
- Loading branch information
1 parent
9eede81
commit b4f08a5
Showing
8 changed files
with
597 additions
and
65 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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,41 @@ | ||
module.exports = async (github, core, statusCheckId) => { | ||
core.info(`\nAsserting that status check '${statusCheckId} exists`); | ||
|
||
if (!statusCheckId || statusCheckId.trim() === '') { | ||
core.setFailed('The statusCheckId was not provided'); | ||
return; | ||
} | ||
|
||
let statusCheckToReturn; | ||
await github.rest.checks | ||
.get({ | ||
owner: 'im-open', | ||
repo: 'process-jest-test-results', | ||
check_run_id: statusCheckId.trim() | ||
}) | ||
.then(checkResponse => { | ||
core.info(`Status Check ${statusCheckId} exists.`); | ||
const rawCheck = checkResponse.data; | ||
|
||
statusCheckToReturn = { | ||
id: rawCheck.id, | ||
name: rawCheck.name, | ||
status: rawCheck.status, | ||
conclusion: rawCheck.conclusion, | ||
startedAt: rawCheck.started_at, | ||
completedAt: rawCheck.completed_at, | ||
title: rawCheck.output.title, | ||
summary: rawCheck.output.summary, | ||
prNumber: rawCheck.pull_requests.length > 0 ? rawCheck.pull_requests[0].number : null, | ||
text: rawCheck.output.text | ||
}; | ||
core.startGroup(`Check ${statusCheckId} details:`); | ||
console.log(statusCheckToReturn); | ||
core.endGroup(); | ||
}) | ||
.catch(error => { | ||
core.setFailed(`An error occurred retrieving status check ${statusCheckId}. Error: ${error.message}`); | ||
}); | ||
|
||
return statusCheckToReturn; | ||
}; |
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,79 @@ | ||
# Allow Failures Scenario | ||
|
||
![Generic badge](https://img.shields.io/badge/1/6-FAILED-red.svg) | ||
<details> | ||
<summary>Duration: 3.904 seconds</summary> | ||
<table> | ||
<tr> | ||
<th>Start:</th> | ||
<td><code>2024-02-23 20:44:35.369 UTC</code></td> | ||
</tr> | ||
<tr> | ||
<th>Finish:</th> | ||
<td><code>2024-02-23 20:44:39.273 UTC</code></td> | ||
</tr> | ||
<tr> | ||
<th>Duration:</th> | ||
<td><code>3.904 seconds</code></td> | ||
</tr> | ||
</table> | ||
</details> | ||
<details> | ||
<summary>Outcome: Failed | Total Tests: 6 | Passed: 5 | Failed: 1</summary> | ||
<table> | ||
<tr> | ||
<th>Total Test Suites:</th> | ||
<td>1</td> | ||
</tr> | ||
<tr> | ||
<th>Total Tests:</th> | ||
<td>6</td> | ||
</tr> | ||
<tr> | ||
<th>Failed Test Suites:</th> | ||
<td>1</td> | ||
</tr> | ||
<tr> | ||
<th>Failed Tests:</th> | ||
<td>1</td> | ||
</tr> | ||
<tr> | ||
<th>Passed Test Suites:</th> | ||
<td>0</td> | ||
</tr> | ||
<tr> | ||
<th>Passed Tests:</th> | ||
<td>5</td> | ||
</tr> | ||
</table> | ||
</details> | ||
<details> | ||
<summary>:x: should be able to open the additional reasons drawer and select a reason</summary> | ||
<table> | ||
<tr> | ||
<th>Title:</th> | ||
<td><code>should be able to open the additional reasons drawer and select a reason</code></td> | ||
</tr> | ||
<tr> | ||
<th>Status:</th> | ||
<td><code>failed</code></td> | ||
</tr> | ||
<tr> | ||
<th>Location:</th> | ||
<td><code>null</code></td> | ||
</tr> | ||
<tr> | ||
<th>Failure Messages:</th> | ||
<td><pre>Error: expect(jest.fn()).toHaveBeenCalledTimes(expected) | ||
|
||
Expected number of calls: 3 | ||
Received number of calls: 1 | ||
at toHaveBeenCalledTimes (C:\code\Selector.test.js:69:20) | ||
at call (C:\code\Selector.test.js:2:1) | ||
at Generator.tryCatch (C:\code\Selector.test.js:2:1) | ||
at Generator._invoke [as next] (C:\code\Selector.test.js:2:1) | ||
at asyncGeneratorStep (C:\code\Selector.test.js:2:1) | ||
at asyncGeneratorStep (C:\code\Selector.test.js:2:1)</pre></td> | ||
</tr> | ||
</table> | ||
</details> |
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,79 @@ | ||
# Ignore Failures Scenario | ||
|
||
![Generic badge](https://img.shields.io/badge/1/6-FAILED-red.svg) | ||
<details> | ||
<summary>Duration: 3.904 seconds</summary> | ||
<table> | ||
<tr> | ||
<th>Start:</th> | ||
<td><code>2024-02-23 20:44:35.369 UTC</code></td> | ||
</tr> | ||
<tr> | ||
<th>Finish:</th> | ||
<td><code>2024-02-23 20:44:39.273 UTC</code></td> | ||
</tr> | ||
<tr> | ||
<th>Duration:</th> | ||
<td><code>3.904 seconds</code></td> | ||
</tr> | ||
</table> | ||
</details> | ||
<details> | ||
<summary>Outcome: Failed | Total Tests: 6 | Passed: 5 | Failed: 1</summary> | ||
<table> | ||
<tr> | ||
<th>Total Test Suites:</th> | ||
<td>1</td> | ||
</tr> | ||
<tr> | ||
<th>Total Tests:</th> | ||
<td>6</td> | ||
</tr> | ||
<tr> | ||
<th>Failed Test Suites:</th> | ||
<td>1</td> | ||
</tr> | ||
<tr> | ||
<th>Failed Tests:</th> | ||
<td>1</td> | ||
</tr> | ||
<tr> | ||
<th>Passed Test Suites:</th> | ||
<td>0</td> | ||
</tr> | ||
<tr> | ||
<th>Passed Tests:</th> | ||
<td>5</td> | ||
</tr> | ||
</table> | ||
</details> | ||
<details> | ||
<summary>:x: should be able to open the additional reasons drawer and select a reason</summary> | ||
<table> | ||
<tr> | ||
<th>Title:</th> | ||
<td><code>should be able to open the additional reasons drawer and select a reason</code></td> | ||
</tr> | ||
<tr> | ||
<th>Status:</th> | ||
<td><code>failed</code></td> | ||
</tr> | ||
<tr> | ||
<th>Location:</th> | ||
<td><code>null</code></td> | ||
</tr> | ||
<tr> | ||
<th>Failure Messages:</th> | ||
<td><pre>Error: expect(jest.fn()).toHaveBeenCalledTimes(expected) | ||
|
||
Expected number of calls: 3 | ||
Received number of calls: 1 | ||
at toHaveBeenCalledTimes (C:\code\Selector.test.js:69:20) | ||
at call (C:\code\Selector.test.js:2:1) | ||
at Generator.tryCatch (C:\code\Selector.test.js:2:1) | ||
at Generator._invoke [as next] (C:\code\Selector.test.js:2:1) | ||
at asyncGeneratorStep (C:\code\Selector.test.js:2:1) | ||
at asyncGeneratorStep (C:\code\Selector.test.js:2:1)</pre></td> | ||
</tr> | ||
</table> | ||
</details> |
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,49 @@ | ||
# No Failures Scenario | ||
|
||
![Generic badge](https://img.shields.io/badge/6/6-PASSED-brightgreen.svg) | ||
<details> | ||
<summary>Duration: 5.688 seconds</summary> | ||
<table> | ||
<tr> | ||
<th>Start:</th> | ||
<td><code>2024-02-23 20:43:06.979 UTC</code></td> | ||
</tr> | ||
<tr> | ||
<th>Finish:</th> | ||
<td><code>2024-02-23 20:43:12.667 UTC</code></td> | ||
</tr> | ||
<tr> | ||
<th>Duration:</th> | ||
<td><code>5.688 seconds</code></td> | ||
</tr> | ||
</table> | ||
</details> | ||
<details> | ||
<summary>Outcome: Passed | Total Tests: 6 | Passed: 6 | Failed: 0</summary> | ||
<table> | ||
<tr> | ||
<th>Total Test Suites:</th> | ||
<td>1</td> | ||
</tr> | ||
<tr> | ||
<th>Total Tests:</th> | ||
<td>6</td> | ||
</tr> | ||
<tr> | ||
<th>Failed Test Suites:</th> | ||
<td>0</td> | ||
</tr> | ||
<tr> | ||
<th>Failed Tests:</th> | ||
<td>0</td> | ||
</tr> | ||
<tr> | ||
<th>Passed Test Suites:</th> | ||
<td>1</td> | ||
</tr> | ||
<tr> | ||
<th>Passed Tests:</th> | ||
<td>6</td> | ||
</tr> | ||
</table> | ||
</details> |
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,51 @@ | ||
module.exports = async (github, core, statusCheckId) => { | ||
core.info(`\nUpdate purposely failing status checks: '${statusCheckId}'`); | ||
|
||
if (!statusCheckId || statusCheckId.trim() === '') { | ||
return; | ||
} | ||
|
||
let actualCheck; | ||
await github.rest.checks | ||
.get({ | ||
owner: 'im-open', | ||
repo: 'process-jest-test-results', | ||
check_run_id: statusCheckId | ||
}) | ||
.then(response => { | ||
core.info(`Status Check ${statusCheckId} exists.`); | ||
actualCheck = response.data; | ||
}) | ||
.catch(error => { | ||
core.setFailed(`An error occurred retrieving status check ${statusCheckId}. Error: ${error.message}`); | ||
}); | ||
|
||
if (!actualCheck) { | ||
core.info('Returning since status check was not found.'); | ||
return; | ||
} | ||
|
||
const updatedText = `> [!IMPORTANT] | ||
> This status check was purposely created with a \`failure\` conclusion. We don't want this to prevent the PR from being merged though, so change the conclusion to \`neutral\` after the tests have run. | ||
${actualCheck.output.text}`; | ||
await github.rest.checks | ||
.update({ | ||
owner: 'im-open', | ||
repo: 'process-jest-test-results', | ||
check_run_id: statusCheckId, | ||
name: `${actualCheck.name} - UPDATED`, | ||
conclusion: 'neutral', | ||
output: { | ||
title: `${actualCheck.output.title}`, | ||
summary: `${actualCheck.output.summary}`, | ||
text: updatedText | ||
} | ||
}) | ||
.then(() => { | ||
core.info(`The status check '${statusCheckId}' was updated successfully.`); | ||
}) | ||
.catch(error => { | ||
core.info(`An error occurred updating status check '${statusCheckId}'. Error: ${error.message}`); | ||
core.info(`This status check can be ignored when determining whether the PR is ready to merge.`); | ||
}); | ||
}; |