Skip to content

Commit b0be3dd

Browse files
authored
feat: make --checkCI optionable for git-node-land (#528)
1 parent 9006b30 commit b0be3dd

File tree

5 files changed

+37
-24
lines changed

5 files changed

+37
-24
lines changed

components/git/land.js

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const LandingSession = require('../../lib/landing_session');
99
const epilogue = require('./epilogue');
1010
const yargs = require('yargs');
1111

12-
const landOptions = {
12+
const landActions = {
1313
apply: {
1414
describe: 'Apply a patch with the given PR id',
1515
type: 'number'
@@ -31,18 +31,32 @@ const landOptions = {
3131
describe: 'Abort the current landing session',
3232
type: 'boolean'
3333
},
34+
backport: {
35+
describe: 'Land a backport PR onto a staging branch',
36+
default: false,
37+
type: 'boolean'
38+
},
39+
autorebase: {
40+
describe: 'Automatically rebase branches with multiple commits',
41+
default: false,
42+
type: 'boolean'
43+
},
44+
fixupAll: {
45+
describe: 'Automatically fixup all commits to the first one dismissing ' +
46+
'other commit messages',
47+
default: false,
48+
type: 'boolean'
49+
}
50+
};
51+
52+
const landOptions = {
3453
yes: {
3554
type: 'boolean',
3655
default: false,
3756
describe: 'Assume "yes" as answer to all prompts and run ' +
3857
'non-interactively. If an undesirable situation occurs, such as a pull ' +
3958
'request or commit check fails, then git node land will abort.'
4059
},
41-
backport: {
42-
describe: 'Land a backport PR onto a staging branch',
43-
default: false,
44-
type: 'boolean'
45-
},
4660
skipRefs: {
4761
describe: 'Prevent adding Fixes and Refs information to commit metadata',
4862
default: false,
@@ -53,22 +67,17 @@ const landOptions = {
5367
default: false,
5468
type: 'boolean'
5569
},
56-
autorebase: {
57-
describe: 'Automatically rebase branches with multiple commits',
58-
default: false,
59-
type: 'boolean'
60-
},
61-
fixupAll: {
62-
describe: 'Automatically fixup all commits to the first one dismissing ' +
63-
'other commit messages',
64-
default: false,
70+
checkCI: {
71+
describe: 'Query Jenkins CI results when checking the PR',
72+
default: true,
6573
type: 'boolean'
6674
}
6775
};
6876

6977
function builder(yargs) {
7078
return yargs
71-
.options(landOptions).positional('prid', {
79+
.options(Object.assign({}, landOptions, landActions))
80+
.positional('prid', {
7281
describe: 'ID or URL of the Pull Request'
7382
})
7483
.epilogue(epilogue)
@@ -109,9 +118,7 @@ function handler(argv) {
109118
}
110119

111120
const provided = [];
112-
for (const type of Object.keys(landOptions)) {
113-
// Those are not actions.
114-
if (['yes', 'skipRefs', 'lint'].includes(type)) continue;
121+
for (const type of Object.keys(landActions)) {
115122
if (argv[type]) {
116123
provided.push(type);
117124
}

components/metadata.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async function getMetadata(argv, skipRefs, cli) {
4040
cli.separator();
4141

4242
const checker = new PRChecker(cli, data, request, argv);
43-
const status = await checker.checkAll(argv.checkComments);
43+
const status = await checker.checkAll(argv.checkComments, argv.checkCI);
4444
return {
4545
status,
4646
request,

lib/landing_session.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ const LINT_RESULTS = {
2323

2424
class LandingSession extends Session {
2525
constructor(cli, req, dir,
26-
{ prid, backport, lint, autorebase, fixupAll } = {}) {
26+
{ prid, backport, lint, autorebase, fixupAll, checkCI } = {}) {
2727
super(cli, dir, prid);
2828
this.req = req;
2929
this.backport = backport;
3030
this.lint = lint;
3131
this.autorebase = autorebase;
3232
this.fixupAll = fixupAll;
3333
this.expectedCommitShas = [];
34+
this.checkCI = !!checkCI;
3435
}
3536

3637
get argv() {

lib/pr_checker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,19 @@ class PRChecker {
6868
return this.argv.waitTimeMultiApproval;
6969
}
7070

71-
async checkAll(checkComments = false) {
71+
async checkAll(checkComments = false, checkCI = true) {
7272
const status = [
7373
this.checkCommitsAfterReview(),
74-
await this.checkCI(),
7574
this.checkReviewsAndWait(new Date(), checkComments),
7675
this.checkMergeableState(),
7776
this.checkPRState(),
7877
this.checkGitConfig()
7978
];
8079

80+
if (checkCI) {
81+
status.push(await this.checkCI());
82+
}
83+
8184
if (this.data.authorIsNew()) {
8285
status.push(this.checkAuthor());
8386
}

lib/session.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Session {
5252
}
5353

5454
get argv() {
55+
// TODO(joyeecheung): remove this and make argv an object
5556
return {
5657
owner: this.owner,
5758
repo: this.repo,
@@ -62,7 +63,8 @@ class Session {
6263
waitTimeMultiApproval: this.waitTimeMultiApproval,
6364
updateDeprecations: this.updateDeprecations,
6465
ciType: this.ciType,
65-
prid: this.prid
66+
prid: this.prid,
67+
checkCI: this.checkCI
6668
};
6769
}
6870

0 commit comments

Comments
 (0)