Skip to content

Commit 62f266f

Browse files
authored
feat: ignore .md files when do requiresJenkinsRun check (#641)
1 parent f759e7a commit 62f266f

File tree

4 files changed

+148
-1
lines changed

4 files changed

+148
-1
lines changed

lib/pr_checker.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,13 @@ export default class PRChecker {
404404
return false;
405405
}
406406

407+
const files = pr.files.nodes;
408+
409+
// Don't require Jenkins run for doc-only change.
410+
if (files.every(({ path }) => path.endsWith('.md'))) {
411+
return false;
412+
}
413+
407414
const ciNeededFolderRx = /^(deps|lib|src|test)\//;
408415
const ciNeededToolFolderRx =
409416
/^tools\/(code_cache|gyp|icu|inspector|msvs|snapshot|v8_gypfiles)/;
@@ -416,7 +423,7 @@ export default class PRChecker {
416423
];
417424
const ciNeededExtensionList = ['.gyp', '.gypi', '.bat'];
418425

419-
return pr.files.nodes.some(
426+
return files.some(
420427
({ path }) =>
421428
ciNeededFolderRx.test(path) ||
422429
ciNeededToolFolderRx.test(path) ||
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"createdAt": "2022-07-12T11:55:42Z",
3+
"authorAssociation": "MEMBER",
4+
"author": {
5+
"login": "F3n67u",
6+
"email": "[email protected]",
7+
"name": "Feng Yu"
8+
},
9+
"url": "https://github.com/nodejs/node/pull/43796",
10+
"bodyHTML": "\n<p dir=\"auto\"><span class=\"issue-keyword tooltipped tooltipped-se\" aria-label=\"This pull request closes issue #43795.\">Fix</span> <a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1301950808\" data-permission-text=\"Title is private\" data-url=\"https://github.com/nodejs/node/issues/43795\" data-hovercard-type=\"issue\" data-hovercard-url=\"/nodejs/node/issues/43795/hovercard\" href=\"https://github.com/nodejs/node/issues/43795\">#43795</a></p>",
11+
"bodyText": "Fix #43795",
12+
"labels": { "nodes": [{ "name": "http" }] },
13+
"files": { "nodes": [{ "path": "lib/_http_server.js" }] },
14+
"title": "http: check if `socket` is null before destroy",
15+
"baseRefName": "main",
16+
"headRefName": "closeIdleConnections",
17+
"changedFiles": 1,
18+
"mergeable": "MERGEABLE",
19+
"closed": false,
20+
"closedAt": null,
21+
"merged": false,
22+
"mergedAt": null
23+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"createdAt": "2022-06-19T03:31:58Z",
3+
"authorAssociation": "MEMBER",
4+
"author": {
5+
"login": "F3n67u",
6+
"email": "[email protected]",
7+
"name": "Feng Yu"
8+
},
9+
"url": "https://github.com/nodejs/node/pull/43483",
10+
"bodyHTML": "\n<p dir=\"auto\">unicode-org/icu repo has renamed its default branch to main also, this pr update the link to unicode-org/icu old master branch.</p>",
11+
"bodyText": "unicode-org/icu repo has renamed its default branch to main also, this pr update the link to unicode-org/icu old master branch.",
12+
"labels": {
13+
"nodes": [
14+
{ "name": "tools" },
15+
{ "name": "i18n-api" },
16+
{ "name": "fast-track" },
17+
{ "name": "author ready" },
18+
{ "name": "icu" }
19+
]
20+
},
21+
"files": { "nodes": [{ "path": "tools/icu/README.md" }] },
22+
"title": "tools: update link of `ICU data slicer`",
23+
"baseRefName": "main",
24+
"headRefName": "doc/icu",
25+
"changedFiles": 1,
26+
"mergeable": "UNKNOWN",
27+
"closed": true,
28+
"closedAt": "2022-06-20T09:20:58Z",
29+
"merged": true,
30+
"mergedAt": "2022-06-20T09:20:58Z"
31+
}

test/unit/pr_checker.test.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,92 @@ describe('PRChecker', () => {
971971
});
972972
});
973973

974+
it('should succeed if doc-only changes in tools dir without Jenkins',
975+
async() => {
976+
const cli = new TestCLI();
977+
978+
const expectedLogs = {
979+
ok: [
980+
['Last GitHub CI successful']
981+
],
982+
info: [
983+
['Green GitHub CI is sufficient']
984+
]
985+
};
986+
987+
const data = {
988+
pr: pullRequests['doc-only-in-tools'],
989+
reviewers: allGreenReviewers,
990+
comments: [],
991+
reviews: approvingReviews,
992+
commits: githubCI['check-suite-success'],
993+
collaborators,
994+
authorIsNew: () => true,
995+
getThread() {
996+
return PRData.prototype.getThread.call(this);
997+
}
998+
};
999+
const checker = new PRChecker(
1000+
cli,
1001+
data,
1002+
{
1003+
json: sinon.stub().callsFake(await function() {
1004+
return undefined;
1005+
})
1006+
},
1007+
argv);
1008+
1009+
cli.clearCalls();
1010+
const status = await checker.checkCI();
1011+
assert(status);
1012+
cli.assertCalledWith(expectedLogs, {
1013+
ignore: ['startSpinner', 'updateSpinner', 'stopSpinner']
1014+
});
1015+
}
1016+
);
1017+
1018+
it('should fail if code changes without Jenkins', async() => {
1019+
const cli = new TestCLI();
1020+
1021+
const expectedLogs = {
1022+
error: [
1023+
['No Jenkins CI runs detected']
1024+
],
1025+
ok: [
1026+
['Last GitHub CI successful']
1027+
]
1028+
};
1029+
1030+
const data = {
1031+
pr: pullRequests['code-change'],
1032+
reviewers: allGreenReviewers,
1033+
comments: [],
1034+
reviews: approvingReviews,
1035+
commits: githubCI['check-suite-success'],
1036+
collaborators,
1037+
authorIsNew: () => true,
1038+
getThread() {
1039+
return PRData.prototype.getThread.call(this);
1040+
}
1041+
};
1042+
const checker = new PRChecker(
1043+
cli,
1044+
data,
1045+
{
1046+
json: sinon.stub().callsFake(await function() {
1047+
return undefined;
1048+
})
1049+
},
1050+
argv);
1051+
1052+
cli.clearCalls();
1053+
const status = await checker.checkCI();
1054+
assert(!status);
1055+
cli.assertCalledWith(expectedLogs, {
1056+
ignore: ['startSpinner', 'updateSpinner', 'stopSpinner']
1057+
});
1058+
});
1059+
9741060
it('should succeed if doc-only changes with failed Jenkins', async() => {
9751061
const cli = new TestCLI();
9761062

0 commit comments

Comments
 (0)