Skip to content

Commit 0ea9df1

Browse files
committed
fix: add logs for outdated request-ci
1 parent 819e669 commit 0ea9df1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/pr_checker.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,10 @@ export default class PRChecker {
537537
const requestCiLabels = data.labeledEvents.findLast(
538538
({ createdAt, label: { name } }) => name === 'request-ci' && createdAt > updatedAt
539539
);
540-
if (requestCiLabels == null) return false;
540+
if (requestCiLabels == null) {
541+
cli.warn('Something was pushed to the Pull Request branch since the last request-ci label.');
542+
return false;
543+
}
541544

542545
const { actor: { login } } = requestCiLabels;
543546
const collaborators = Array.from(data.collaborators.values(),

test/unit/pr_checker.test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2120,6 +2120,15 @@ describe('PRChecker', () => {
21202120
});
21212121

21222122
it('should return false if PR has outdated request-ci from a collaborator', async() => {
2123+
const expectedLogs = {
2124+
warn: [
2125+
['No approving reviews found'],
2126+
['Something was pushed to the Pull Request branch since the last request-ci label.']
2127+
],
2128+
info: [],
2129+
error: []
2130+
};
2131+
21232132
const cli = new TestCLI();
21242133
data.getLabeledEvents = async() => {
21252134
data.labeledEvents = labeledEvents['old-request-ci-collaborator'];
@@ -2128,6 +2137,7 @@ describe('PRChecker', () => {
21282137

21292138
const status = await checker.checkCommitsAfterReviewOrLabel();
21302139
assert.strictEqual(status, false);
2140+
cli.assertCalledWith(expectedLogs);
21312141
});
21322142

21332143
it('should return true if PR has recent request-ci from a collaborator', async() => {
@@ -2247,7 +2257,7 @@ describe('PRChecker', () => {
22472257
cli.assertCalledWith(expectedLogs);
22482258
});
22492259

2250-
it('should return true if PR can be landed', () => {
2260+
it('should return false if PR was updated after approvals', () => {
22512261
const expectedLogs = {
22522262
warn: [
22532263
['Something was pushed to the Pull Request branch since the last approving review.']

0 commit comments

Comments
 (0)