Skip to content

Commit

Permalink
fix(pr-checker): shouldn't fail on SKIPPED
Browse files Browse the repository at this point in the history
SKIPPED status on GitHub API doesn't necessarily mean a run failed. For
example, the staleComment and fastTrack Actions on nodejs/node will skip
if the last event was not a comment or label, respectively.
  • Loading branch information
mmarchini committed Jun 10, 2021
1 parent 147ceae commit a578cd7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/pr_checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const HOUR = MINUTE * 60;
const WAIT_TIME_MULTI_APPROVAL = 24 * 2;
const WAIT_TIME_SINGLE_APPROVAL = 24 * 7;

const GITHUB_SUCCESS_CONCLUSIONS = ['SUCCESS', 'NEUTRAL', 'SKIPPED'];

const {
REVIEW_SOURCES: { FROM_COMMENT, FROM_REVIEW_COMMENT }
} = require('./reviews');
Expand Down Expand Up @@ -335,7 +337,7 @@ class PRChecker {
return false;
}

if (!['SUCCESS', 'NEUTRAL'].includes(conclusion)) {
if (!GITHUB_SUCCESS_CONCLUSIONS.includes(conclusion)) {
cli.error('Last GitHub CI failed');
return false;
}
Expand Down Expand Up @@ -372,7 +374,7 @@ class PRChecker {
return false;
}

if (!['SUCCESS', 'NEUTRAL'].includes(conclusion)) {
if (!GITHUB_SUCCESS_CONCLUSIONS.includes(conclusion)) {
cli.error('Last GitHub CI failed');
return false;
}
Expand Down
20 changes: 20 additions & 0 deletions test/fixtures/github-ci/check-suite-skipped.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"commit": {
"committedDate": "2017-10-26T12:10:20Z",
"oid": "9d098ssiskj8dhd39js0sjd0cn2ng4is9n40sj12d",
"messageHeadline": "doc: add api description README",
"author": {
"login": "foo"
},
"checkSuites": {
"nodes": [
{
"status": "COMPLETED",
"conclusion": "SKIPPED"
}
]
}
}
}
]
19 changes: 19 additions & 0 deletions test/unit/pr_checker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,25 @@ describe('PRChecker', () => {
cli.assertCalledWith(expectedLogs);
});

it('should succeed if check suite status skipped', async() => {
const cli = new TestCLI();

const expectedLogs = {
info: [
['Last GitHub CI successful']
]
};

const commits = githubCI['check-suite-skipped'];
const data = Object.assign({}, baseData, { commits });

const checker = new PRChecker(cli, data, {}, testArgv);

const status = await checker.checkCI();
assert(status);
cli.assertCalledWith(expectedLogs);
});

it('should succeed if commit status succeeded', async() => {
const cli = new TestCLI();

Expand Down

0 comments on commit a578cd7

Please sign in to comment.