Skip to content

Commit

Permalink
Update action yml + lint
Browse files Browse the repository at this point in the history
  • Loading branch information
blombard committed Oct 3, 2020
1 parent 0f47c18 commit 55e3102
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: 'Review reminder'
description: 'Send reminders to authors, reviewers... of a pull request'
description: 'Send reminders to requested reviewers of a pull request'
author: 'Baptiste Lombard'
branding:
icon: 'bell'
color: 'yellow'
inputs:
token:
description: 'The GITHUB_TOKEN secret'
description: 'Your GITHUB_TOKEN secret'
required: true
reminder-comment:
description: 'Message to the requested reviewers'
Expand Down
7 changes: 1 addition & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ const run = async () => {
const octokit = github.getOctokit(token);
const owner = github.context.payload.sender && github.context.payload.sender.login;
const repo = github.context.payload.repositor && github.context.payload.repository.name;

const { data } = await octokit.pulls.list({
owner,
repo,
state: 'open',
});
const { data } = await octokit.pulls.list({ owner, repo, state: 'open' });

data.forEach(({ requested_reviewers, updated_at, number }) => {
if (rightTimeForReminder(updated_at, daysBeforeReminder)) {
Expand Down
10 changes: 5 additions & 5 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const nock = require('nock');
const run = require('./index.js');

const inputs = {
'token': 'foo',
token: 'foo',
'reminder-comment': "Don't forget to review this PR !",
'days-before-reminder': '1',
};

function mockGetInput(requestResponse) {
return function (name, options) { // eslint-disable-line no-unused-vars
return function (name, options) { // eslint-disable-line
return requestResponse[name];
};
}
Expand All @@ -22,10 +22,10 @@ describe('Run the test suite', () => {

nock('https://api.github.com')
.get(`/repos/${repoOwner}//pulls?state=open`)
.reply(200, [{ requested_reviewers: [{ login: 'foo' }], updated_at: '2011-01-26T19:01:12.000Z', number: 1 }])
.reply(200, [{ requested_reviewers: [{ login: 'foo' }], updated_at: '2011-01-26T19:01:12.000Z', number: 1 }]);
nock('https://api.github.com')
.post(`/repos/${repoOwner}//issues/1/comments`, { body: "Hey @foo ! Don't forget to review this PR !" })
.reply(200, {})
.reply(200, {});

test('it should be a success when the params are good', async () => {
core.getInput = jest.fn().mockImplementation(mockGetInput(inputs));
Expand All @@ -34,7 +34,7 @@ describe('Run the test suite', () => {
});

test('it should be a failure when no params are given', async () => {
core.getInput.mockReset()
core.getInput.mockReset();
await run();
expect(core.setFailed).toHaveBeenCalled();
});
Expand Down

0 comments on commit 55e3102

Please sign in to comment.