Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add logs for outdated request-ci #867

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/pr_checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,10 @@ export default class PRChecker {
const requestCiLabels = data.labeledEvents.findLast(
({ createdAt, label: { name } }) => name === 'request-ci' && createdAt > updatedAt
);
if (requestCiLabels == null) return false;
if (requestCiLabels == null) {
cli.warn('Something was pushed to the Pull Request branch since the last request-ci label.');
return false;
}

const { actor: { login } } = requestCiLabels;
const collaborators = Array.from(data.collaborators.values(),
Expand Down
12 changes: 11 additions & 1 deletion test/unit/pr_checker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,15 @@ describe('PRChecker', () => {
});

it('should return false if PR has outdated request-ci from a collaborator', async() => {
const expectedLogs = {
warn: [
['No approving reviews found'],
['Something was pushed to the Pull Request branch since the last request-ci label.']
],
info: [],
error: []
};

const cli = new TestCLI();
data.getLabeledEvents = async() => {
data.labeledEvents = labeledEvents['old-request-ci-collaborator'];
Expand All @@ -2128,6 +2137,7 @@ describe('PRChecker', () => {

const status = await checker.checkCommitsAfterReviewOrLabel();
assert.strictEqual(status, false);
cli.assertCalledWith(expectedLogs);
});

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

it('should return true if PR can be landed', () => {
it('should return false if PR was updated after approvals', () => {
const expectedLogs = {
warn: [
['Something was pushed to the Pull Request branch since the last approving review.']
Expand Down
Loading