Skip to content

Commit a578cd7

Browse files
committed
fix(pr-checker): shouldn't fail on SKIPPED
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.
1 parent 147ceae commit a578cd7

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

lib/pr_checker.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const HOUR = MINUTE * 60;
77
const WAIT_TIME_MULTI_APPROVAL = 24 * 2;
88
const WAIT_TIME_SINGLE_APPROVAL = 24 * 7;
99

10+
const GITHUB_SUCCESS_CONCLUSIONS = ['SUCCESS', 'NEUTRAL', 'SKIPPED'];
11+
1012
const {
1113
REVIEW_SOURCES: { FROM_COMMENT, FROM_REVIEW_COMMENT }
1214
} = require('./reviews');
@@ -335,7 +337,7 @@ class PRChecker {
335337
return false;
336338
}
337339

338-
if (!['SUCCESS', 'NEUTRAL'].includes(conclusion)) {
340+
if (!GITHUB_SUCCESS_CONCLUSIONS.includes(conclusion)) {
339341
cli.error('Last GitHub CI failed');
340342
return false;
341343
}
@@ -372,7 +374,7 @@ class PRChecker {
372374
return false;
373375
}
374376

375-
if (!['SUCCESS', 'NEUTRAL'].includes(conclusion)) {
377+
if (!GITHUB_SUCCESS_CONCLUSIONS.includes(conclusion)) {
376378
cli.error('Last GitHub CI failed');
377379
return false;
378380
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"commit": {
4+
"committedDate": "2017-10-26T12:10:20Z",
5+
"oid": "9d098ssiskj8dhd39js0sjd0cn2ng4is9n40sj12d",
6+
"messageHeadline": "doc: add api description README",
7+
"author": {
8+
"login": "foo"
9+
},
10+
"checkSuites": {
11+
"nodes": [
12+
{
13+
"status": "COMPLETED",
14+
"conclusion": "SKIPPED"
15+
}
16+
]
17+
}
18+
}
19+
}
20+
]

test/unit/pr_checker.test.js

+19
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,25 @@ describe('PRChecker', () => {
14271427
cli.assertCalledWith(expectedLogs);
14281428
});
14291429

1430+
it('should succeed if check suite status skipped', async() => {
1431+
const cli = new TestCLI();
1432+
1433+
const expectedLogs = {
1434+
info: [
1435+
['Last GitHub CI successful']
1436+
]
1437+
};
1438+
1439+
const commits = githubCI['check-suite-skipped'];
1440+
const data = Object.assign({}, baseData, { commits });
1441+
1442+
const checker = new PRChecker(cli, data, {}, testArgv);
1443+
1444+
const status = await checker.checkCI();
1445+
assert(status);
1446+
cli.assertCalledWith(expectedLogs);
1447+
});
1448+
14301449
it('should succeed if commit status succeeded', async() => {
14311450
const cli = new TestCLI();
14321451

0 commit comments

Comments
 (0)