Skip to content

Commit

Permalink
fix type in reviewers
Browse files Browse the repository at this point in the history
  • Loading branch information
JCorrivo committed Feb 11, 2021
1 parent 07cbb10 commit 6dd275a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
28 changes: 14 additions & 14 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
identify_reviewers_by_changed_files,
identify_reviewers_by_author,
should_request_review,
fetch_default_reviwers,
fetch_default_reviewers,
randomly_pick_reviewers,
} = require('./reviewer');

Expand Down Expand Up @@ -43,22 +43,22 @@ async function run() {
core.info('Identifying reviewers based on the author');
const reviewers_based_on_author = identify_reviewers_by_author({ config, author });

core.info('Adding other group membres to reviwers if group assignment feature is on');
const reviwers_from_same_teams = fetch_other_group_members({ config, author });
core.info('Adding other group membres to reviewers if group assignment feature is on');
const reviewers_from_same_teams = fetch_other_group_members({ config, author });

let reviewers = [ ...new Set([ ...reviewers_based_on_files, ...reviewers_based_on_author, ...reviwers_from_same_teams ]) ];
let reviewers = [ ...new Set([ ...reviewers_based_on_files, ...reviewers_based_on_author, ...reviewers_from_same_teams ]) ];

if (reviewers.length === 0) {
core.info('Matched no reviwers');
const default_reviwers = fetch_default_reviwers({ config, excludes: [ author ] });
core.info('Matched no reviewers');
const default_reviewers = fetch_default_reviewers({ config, excludes: [ author ] });

if (default_reviwers.length === 0) {
core.info('No default reviwers are matched; terminating the process');
if (default_reviewers.length === 0) {
core.info('No default reviewers are matched; terminating the process');
return;
}

core.info('Falling back to the default reviwers');
reviewers.push(...default_reviwers);
core.info('Falling back to the default reviewers');
reviewers.push(...default_reviewers);
}

core.info('Randomly picking reviewers if the number of reviewers is set');
Expand Down
8 changes: 4 additions & 4 deletions src/reviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function fetch_other_group_members({ author, config }) {

function identify_reviewers_by_changed_files({ config, changed_files, excludes = [] }) {
if (!config.files) {
core.info('A "files" key does not exist in config; returning no reviwers for changed files.');
core.info('A "files" key does not exist in config; returning no reviewers for changed files.');
return [];
}

Expand All @@ -55,7 +55,7 @@ function identify_reviewers_by_changed_files({ config, changed_files, excludes =

function identify_reviewers_by_author({ config, 'author': specified_author }) {
if (!(config.reviewers && config.reviewers.per_author)) {
core.info('"per_author" is not set; returning no reviwers for the author.');
core.info('"per_author" is not set; returning no reviewers for the author.');
return [];
}

Expand Down Expand Up @@ -100,7 +100,7 @@ function should_request_review({ title, is_draft, config }) {
return !ignored_keywords.some((keyword) => title.includes(keyword));
}

function fetch_default_reviwers({ config, excludes = [] }) {
function fetch_default_reviewers({ config, excludes = [] }) {
if (!config.reviewers || !Array.isArray(config.reviewers.defaults)) {
return [];
}
Expand Down Expand Up @@ -137,6 +137,6 @@ module.exports = {
identify_reviewers_by_changed_files,
identify_reviewers_by_author,
should_request_review,
fetch_default_reviwers,
fetch_default_reviewers,
randomly_pick_reviewers,
};
2 changes: 1 addition & 1 deletion test/github.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('github', function() {
github.getOctokit.returns(octokit);
});

it('assigns reviwers', async function() {
it('assigns reviewers', async function() {
const reviewers = [ 'mario', 'princess-peach' ];
await assign_reviewers(reviewers);

Expand Down
8 changes: 4 additions & 4 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('index', function() {
expect(github.assign_reviewers.calledOnce).to.be.false;
});

it('does not request review if no reviwers are matched and default reviweres are not set', async function() {
it('does not request review if no reviewers are matched and default reviweres are not set', async function() {
const config = {
reviewers: {
groups: {
Expand Down Expand Up @@ -171,7 +171,7 @@ describe('index', function() {
expect(github.assign_reviewers.calledOnce).to.be.false;
});

it('requests review to the default reviwers if no reviwers are matched', async function() {
it('requests review to the default reviewers if no reviewers are matched', async function() {
const config = {
reviewers: {
defaults: [ 'dr-mario', 'mario-brothers' ],
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('index', function() {
expect(github.assign_reviewers.lastCall.args[0]).to.have.members([ 'dr-mario', 'mario' ]);
});

it('requests review based on reviwers per author', async function() {
it('requests review based on reviewers per author', async function() {
const config = {
reviewers: {
defaults: [ 'dr-mario' ],
Expand Down Expand Up @@ -233,7 +233,7 @@ describe('index', function() {
expect(github.assign_reviewers.lastCall.args[0]).to.have.members([ 'mario', 'waluigi' ]);
});

it('requests review based on reviwers per author when a group is used as an auther setting', async function() {
it('requests review based on reviewers per author when a group is used as an auther setting', async function() {
const config = {
reviewers: {
defaults: [ 'dr-mario' ],
Expand Down
18 changes: 9 additions & 9 deletions test/reviewer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {
identify_reviewers_by_changed_files,
identify_reviewers_by_author,
should_request_review,
fetch_default_reviwers,
fetch_default_reviewers,
randomly_pick_reviewers,
} = require('../src/reviewer');
const { expect } = require('chai');
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('reviewer', function() {
expect(identify_reviewers_by_changed_files({ config, changed_files })).to.have.members([ 'mario', 'luigi', 'wario', 'waluigi', 'princess-peach', 'toad' ]);
});

it('excludes specified reviwers in the "excludes" option', function() {
it('excludes specified reviewers in the "excludes" option', function() {
const changed_files = [ 'super-star', 'frontend/file', 'backend/file' ];
const excludes = [ 'wario', 'waluigi' ];
expect(identify_reviewers_by_changed_files({ config, changed_files, excludes })).to.have.members([ 'mario', 'luigi', 'princess-peach', 'toad' ]);
Expand All @@ -133,15 +133,15 @@ describe('reviewer', function() {

it('returns nothing when config does not have a "per-author" key', function() {
const author = 'THIS DOES NOT MATTER';
expect(identify_reviewers_by_author({ config: { reviwers: {} }, author })).to.deep.equal([]);
expect(identify_reviewers_by_author({ config: { reviewers: {} }, author })).to.deep.equal([]);
});

it('returns nothing when the author does not exist in the "per-author" settings', function() {
const author = 'toad';
expect(identify_reviewers_by_author({ config, author })).to.deep.equal([]);
});

it('returns the reviwers for the author', function() {
it('returns the reviewers for the author', function() {
const author = 'yoshi';
expect(identify_reviewers_by_author({ config, author })).to.have.members([ 'mario', 'luige' ]);
});
Expand Down Expand Up @@ -271,8 +271,8 @@ describe('reviewer', function() {
});
});

describe('fetch_default_reviwers()', function() {
it('fetches the default reviwers', function() {
describe('fetch_default_reviewers()', function() {
it('fetches the default reviewers', function() {
const config = {
reviewers: {
defaults: [ 'dr-mario', 'mario-brothers' ],
Expand All @@ -281,10 +281,10 @@ describe('reviewer', function() {
},
},
};
expect(fetch_default_reviwers({ config })).to.have.members([ 'dr-mario', 'mario', 'luigi' ]);
expect(fetch_default_reviewers({ config })).to.have.members([ 'dr-mario', 'mario', 'luigi' ]);
});

it('fetches the default reviwers exluding specified ones in the excludes option', function() {
it('fetches the default reviewers exluding specified ones in the excludes option', function() {
const config = {
reviewers: {
defaults: [ 'dr-mario', 'mario-brothers' ],
Expand All @@ -293,7 +293,7 @@ describe('reviewer', function() {
},
},
};
expect(fetch_default_reviwers({ config, excludes: [ 'luigi' ] })).to.have.members([ 'dr-mario', 'mario' ]);
expect(fetch_default_reviewers({ config, excludes: [ 'luigi' ] })).to.have.members([ 'dr-mario', 'mario' ]);
});
});

Expand Down

0 comments on commit 6dd275a

Please sign in to comment.