Skip to content

Commit 3f51502

Browse files
committed
Revert "feat(ncu-ci): check for request-ci label (nodejs#806)"
This reverts commit 6cc2b1a.
1 parent 4a03216 commit 3f51502

11 files changed

+1
-209
lines changed

lib/ci/run_ci.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class RunPRJob {
2727
this.certifySafe =
2828
certifySafe ||
2929
Promise.all([this.prData.getReviews(), this.prData.getPR()]).then(() =>
30-
new PRChecker(cli, this.prData, request, {}).checkCommitsAfterReviewOrLabel()
30+
new PRChecker(cli, this.prData, request, {}).checkCommitsAfterReview()
3131
);
3232
}
3333

lib/pr_checker.js

-26
Original file line numberDiff line numberDiff line change
@@ -524,32 +524,6 @@ export default class PRChecker {
524524
return true;
525525
}
526526

527-
async checkCommitsAfterReviewOrLabel() {
528-
if (this.checkCommitsAfterReview()) return true;
529-
530-
await Promise.all([this.data.getLabeledEvents(), this.data.getCollaborators()]);
531-
532-
const {
533-
cli, data, pr
534-
} = this;
535-
536-
const { updatedAt } = pr.timelineItems;
537-
const requestCiLabels = data.labeledEvents.findLast(
538-
({ createdAt, label: { name } }) => name === 'request-ci' && createdAt > updatedAt
539-
);
540-
if (requestCiLabels == null) return false;
541-
542-
const { actor: { login } } = requestCiLabels;
543-
const collaborators = Array.from(data.collaborators.values(),
544-
(c) => c.login.toLowerCase());
545-
if (collaborators.includes(login.toLowerCase())) {
546-
cli.info('request-ci label was added by a Collaborator after the last push event.');
547-
return true;
548-
}
549-
550-
return false;
551-
}
552-
553527
checkCommitsAfterReview() {
554528
const {
555529
commits, reviews, cli, argv

lib/pr_data.js

-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
} from './user_status.js';
66

77
// lib/queries/*.gql file names
8-
const LABELED_EVENTS_QUERY = 'PRLabeledEvents';
98
const PR_QUERY = 'PR';
109
const REVIEWS_QUERY = 'Reviews';
1110
const COMMENTS_QUERY = 'PRComments';
@@ -34,7 +33,6 @@ export default class PRData {
3433
this.comments = [];
3534
this.commits = [];
3635
this.reviewers = [];
37-
this.labeledEvents = [];
3836
}
3937

4038
getThread() {
@@ -92,14 +90,6 @@ export default class PRData {
9290
]);
9391
}
9492

95-
async getLabeledEvents() {
96-
const { prid, owner, repo, cli, request, prStr } = this;
97-
const vars = { prid, owner, repo };
98-
cli.updateSpinner(`Getting labels from ${prStr}`);
99-
this.labeledEvents = (await request.gql(LABELED_EVENTS_QUERY, vars))
100-
.repository.pullRequest.timelineItems.nodes;
101-
}
102-
10393
async getComments() {
10494
const { prid, owner, repo, cli, request, prStr } = this;
10595
const vars = { prid, owner, repo };

lib/queries/PRLabeledEvents.gql

-19
This file was deleted.

test/fixtures/data.js

-9
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,3 @@ for (const subdir of readdirSync(path('./jenkins'))) {
134134
readJSON(`./jenkins/${subdir}/${item}`);
135135
}
136136
};
137-
138-
export const labeledEvents = {};
139-
140-
for (const item of readdirSync(path('./labeled_events'))) {
141-
if (!item.endsWith('.json')) {
142-
continue;
143-
}
144-
labeledEvents[basename(item, '.json')] = readJSON(`./labeled_events/${item}`);
145-
}

test/fixtures/first_timer_pr.json

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
}
2323
]
2424
},
25-
"timelineItems": { "updatedAt": "2017-10-24T11:13:43Z" },
2625
"title": "test: awesome changes",
2726
"baseRefName": "main",
2827
"headRefName": "awesome-changes"

test/fixtures/labeled_events/no-request-ci.json

-12
This file was deleted.

test/fixtures/labeled_events/old-request-ci-collaborator.json

-12
This file was deleted.

test/fixtures/labeled_events/recent-request-ci-collaborator.json

-12
This file was deleted.

test/fixtures/labeled_events/recent-request-ci-non-collaborator.json

-12
This file was deleted.

test/unit/pr_checker.test.js

-95
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import {
4141
semverMajorPR,
4242
conflictingPR,
4343
closedPR,
44-
labeledEvents,
4544
mergedPR,
4645
pullRequests
4746
} from '../fixtures/data.js';
@@ -2050,100 +2049,6 @@ describe('PRChecker', () => {
20502049
});
20512050
});
20522051

2053-
describe('checkCommitsAfterReviewOrLabel', () => {
2054-
it('should return true if PR passes post review checks', async() => {
2055-
const cli = new TestCLI();
2056-
const checker = new PRChecker(cli, {
2057-
pr: semverMajorPR,
2058-
reviewers: allGreenReviewers,
2059-
comments: commentsWithLGTM,
2060-
reviews: approvingReviews,
2061-
commits: simpleCommits,
2062-
collaborators,
2063-
authorIsNew: () => true,
2064-
getThread: PRData.prototype.getThread
2065-
}, {}, argv);
2066-
2067-
const status = await checker.checkCommitsAfterReviewOrLabel();
2068-
assert.strictEqual(status, true);
2069-
});
2070-
2071-
describe('without approvals', () => {
2072-
const data = {
2073-
pr: firstTimerPR,
2074-
reviewers: noReviewers,
2075-
comments: [],
2076-
reviews: [],
2077-
commits: [],
2078-
collaborators: [],
2079-
labeledEvents: [],
2080-
authorIsNew: () => true,
2081-
getThread: PRData.prototype.getThread,
2082-
getLabeledEvents: async() => {
2083-
data.labeledEvents = [];
2084-
},
2085-
getCollaborators: async() => {
2086-
data.collaborators = collaborators;
2087-
}
2088-
};
2089-
2090-
it('should return false if PR has no labels', async() => {
2091-
const cli = new TestCLI();
2092-
data.getLabeledEvents = async() => {
2093-
data.labeledEvents = [];
2094-
};
2095-
const checker = new PRChecker(cli, data, {}, argv);
2096-
2097-
const status = await checker.checkCommitsAfterReviewOrLabel();
2098-
assert.strictEqual(status, false);
2099-
});
2100-
2101-
it('should return false if PR has no request-ci label', async() => {
2102-
const cli = new TestCLI();
2103-
data.getLabeledEvents = async() => {
2104-
data.labeledEvents = labeledEvents['no-request-ci'];
2105-
};
2106-
const checker = new PRChecker(cli, data, {}, argv);
2107-
2108-
const status = await checker.checkCommitsAfterReviewOrLabel();
2109-
assert.strictEqual(status, false);
2110-
});
2111-
2112-
it('should return false if PR has request-ci from non-collaborator', async() => {
2113-
const cli = new TestCLI();
2114-
data.getLabeledEvents = async() => {
2115-
data.labeledEvents = labeledEvents['recent-request-ci-non-collaborator'];
2116-
};
2117-
const checker = new PRChecker(cli, data, {}, argv);
2118-
2119-
const status = await checker.checkCommitsAfterReviewOrLabel();
2120-
assert.strictEqual(status, false);
2121-
});
2122-
2123-
it('should return false if PR has outdated request-ci from a collaborator', async() => {
2124-
const cli = new TestCLI();
2125-
data.getLabeledEvents = async() => {
2126-
data.labeledEvents = labeledEvents['old-request-ci-collaborator'];
2127-
};
2128-
const checker = new PRChecker(cli, data, {}, argv);
2129-
2130-
const status = await checker.checkCommitsAfterReviewOrLabel();
2131-
assert.strictEqual(status, false);
2132-
});
2133-
2134-
it('should return true if PR has recent request-ci from a collaborator', async() => {
2135-
const cli = new TestCLI();
2136-
data.getLabeledEvents = async() => {
2137-
data.labeledEvents = labeledEvents['recent-request-ci-collaborator'];
2138-
};
2139-
const checker = new PRChecker(cli, data, {}, argv);
2140-
2141-
const status = await checker.checkCommitsAfterReviewOrLabel();
2142-
assert.strictEqual(status, true);
2143-
});
2144-
});
2145-
});
2146-
21472052
describe('checkCommitsAfterReview', () => {
21482053
const cli = new TestCLI();
21492054

0 commit comments

Comments
 (0)