Skip to content

Commit

Permalink
Remove closing of WIP Prs (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankita240796 authored Jun 13, 2020
1 parent e90f0d2 commit c83620d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 48 deletions.
11 changes: 4 additions & 7 deletions lib/checkWipDraftPR.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ module.exports.checkWIP = async (context) => {
if (isDraftPr(pullRequest) || isWIPPr(pullRequest)) {
const hasSkipCIMessage = await isSkipCICommit(context);
if (!hasSkipCIMessage) {
// Assign PR author.
var assigneeParams = context.issue({ assignees: [prAuthor] });
await context.github.issues.addAssignees(assigneeParams);

const link = 'here'.link(
'https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia' +
'#wip--draft-pull-requests');
Expand All @@ -77,13 +81,6 @@ module.exports.checkWIP = async (context) => {
body: commentBody,
});
await context.github.issues.createComment(commentParams);

// Close Pull Request.
const closePRParams = context.repo({
issue_number: pullRequest.number,
state: 'closed',
});
await context.github.issues.update(closePRParams);
}
}
};
81 changes: 40 additions & 41 deletions spec/checkWipDraftPRSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Oppiabot\'s', () => {
github = {
issues: {
createComment: jasmine.createSpy('createComment').and.resolveTo({}),
update: jasmine.createSpy('update').and.resolveTo({})
addAssignees: jasmine.createSpy('addAssignees').and.resolveTo({}),
}
};

Expand Down Expand Up @@ -98,6 +98,17 @@ describe('Oppiabot\'s', () => {
});
});

it('assigns PR author', () => {
expect(github.issues.addAssignees).toHaveBeenCalled();
const params = {
repo: pullRequestEditedPayload.payload.repository.name,
owner: pullRequestEditedPayload.payload.repository.owner.login,
number: pullRequestEditedPayload.payload.pull_request.number,
assignees: ['testuser7777'],
};
expect(github.issues.addAssignees).toHaveBeenCalledWith(params);
});

it('creates comment for WIP PRs', () => {
expect(github.issues.createComment).toHaveBeenCalled();
expect(github.issues.createComment).toHaveBeenCalledTimes(1);
Expand All @@ -120,18 +131,6 @@ describe('Oppiabot\'s', () => {
body: commentBody
});
});

it('closes WIP PRs', () => {
expect(github.issues.update).toHaveBeenCalled();
expect(github.issues.update).toHaveBeenCalledTimes(1);

expect(github.issues.update).toHaveBeenCalledWith({
issue_number: pullRequestEditedPayload.payload.pull_request.number,
owner: pullRequestEditedPayload.payload.repository.owner.login,
repo: pullRequestEditedPayload.payload.repository.name,
state: 'closed'
});
});
});

describe('WIP PRs with skip prefix', () => {
Expand Down Expand Up @@ -166,12 +165,12 @@ describe('Oppiabot\'s', () => {
});
});

it('does not create comment for WIP PRs', () => {
expect(github.issues.createComment).not.toHaveBeenCalled();
it('does not assign PR author', () => {
expect(github.issues.addAssignees).not.toHaveBeenCalled();
});

it('does not close WIP PRs', () => {
expect(github.issues.update).not.toHaveBeenCalled();
it('does not create comment for WIP PRs', () => {
expect(github.issues.createComment).not.toHaveBeenCalled();
});
});

Expand All @@ -191,10 +190,10 @@ describe('Oppiabot\'s', () => {

expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalled();
expect(github.git.getCommit).toHaveBeenCalled();
expect(github.issues.addAssignees).toHaveBeenCalled();
expect(github.issues.addAssignees).toHaveBeenCalledTimes(1);
expect(github.issues.createComment).toHaveBeenCalled();
expect(github.issues.createComment).toHaveBeenCalledTimes(1);
expect(github.issues.update).toHaveBeenCalled();
expect(github.issues.update).toHaveBeenCalledTimes(1);
});

it('should check when PR is reopnend', async() => {
Expand All @@ -212,10 +211,10 @@ describe('Oppiabot\'s', () => {

expect(checkWipDraftPRModule.checkWIP).toHaveBeenCalled();
expect(github.git.getCommit).toHaveBeenCalled();
expect(github.issues.addAssignees).toHaveBeenCalled();
expect(github.issues.addAssignees).toHaveBeenCalledTimes(1);
expect(github.issues.createComment).toHaveBeenCalled();
expect(github.issues.createComment).toHaveBeenCalledTimes(1);
expect(github.issues.update).toHaveBeenCalled();
expect(github.issues.update).toHaveBeenCalledTimes(1);
});
});

Expand Down Expand Up @@ -260,6 +259,18 @@ describe('Oppiabot\'s', () => {
expect(args.payload.pull_request.title).toBe('Testing Draft');
});


it('assigns PR author', () => {
expect(github.issues.addAssignees).toHaveBeenCalled();
const params = {
repo: pullRequestEditedPayload.payload.repository.name,
owner: pullRequestEditedPayload.payload.repository.owner.login,
number: pullRequestEditedPayload.payload.pull_request.number,
assignees: ['testuser7777'],
};
expect(github.issues.addAssignees).toHaveBeenCalledWith(params);
});

it('creates comment for draft PRs', () => {
expect(github.issues.createComment).toHaveBeenCalled();
expect(github.issues.createComment).toHaveBeenCalledTimes(1);
Expand All @@ -281,18 +292,6 @@ describe('Oppiabot\'s', () => {
body: commentBody
});
});

it('closes draft PRs', () => {
expect(github.issues.update).toHaveBeenCalled();
expect(github.issues.update).toHaveBeenCalledTimes(1);

expect(github.issues.update).toHaveBeenCalledWith({
issue_number: pullRequestEditedPayload.payload.pull_request.number,
owner: pullRequestEditedPayload.payload.repository.owner.login,
repo: pullRequestEditedPayload.payload.repository.name,
state: 'closed'
});
});
});

describe('Draft PRs with skip prefix', () => {
Expand Down Expand Up @@ -336,12 +335,12 @@ describe('Oppiabot\'s', () => {
expect(args.payload.pull_request.title).toBe('Testing Draft');
});

it('does not create comment for draft PRs', () => {
expect(github.issues.createComment).not.toHaveBeenCalled();
it('does not assign PR author', () => {
expect(github.issues.addAssignees).not.toHaveBeenCalled();
});

it('does not close draft PRs', () => {
expect(github.issues.update).not.toHaveBeenCalled();
it('does not create comment for draft PRs', () => {
expect(github.issues.createComment).not.toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -370,12 +369,12 @@ describe('Oppiabot\'s', () => {
expect(github.git.getCommit).not.toHaveBeenCalled();
});

it('does not create a comment', () => {
expect(github.issues.createComment).not.toHaveBeenCalled();
it('does not assign PR author', () => {
expect(github.issues.addAssignees).not.toHaveBeenCalled();
});

it('does not close the PR', ()=> {
expect(github.issues.update).not.toHaveBeenCalled();
it('does not create a comment', () => {
expect(github.issues.createComment).not.toHaveBeenCalled();
});
});
});

0 comments on commit c83620d

Please sign in to comment.