1 Commits

Author SHA1 Message Date
ec14a479c8 feat: fetch data for prs that need retest 2018-10-18 09:50:42 -07:00
2 changed files with 10 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
import dotenv from 'dotenv';
import createRepo from './lib/create_repo.mjs'; import createRepo from './lib/create_repo.mjs';
import getComments from './lib/get_comments.mjs'; import getComments from './lib/get_comments.mjs';
import getPull from './lib/get_pull.mjs'; import getPull from './lib/get_pull.mjs';
@@ -5,17 +6,20 @@ import getCommits from './lib/get_commits.mjs';
import getCommitStatus from './lib/get_commit_status.mjs'; import getCommitStatus from './lib/get_commit_status.mjs';
import History from './lib/history.mjs'; import History from './lib/history.mjs';
dotenv.config();
export default async function() { export default async function() {
// parse repo name from cli and create repo instance // parse repo name from cli and create repo instance
const repo = createRepo(process.argv.splice(2)[0]); const repo = createRepo(process.argv.splice(2)[0]);
const { COMMENT_BODY_REGEXP, COMMENT_BODY_REGEXP_FLAGS, COMMENT_ACTOR } = process.env;
// load the history module // load the history module
const history = new History(); const history = new History();
// fetch comment info from event stream, filter for only new comments // fetch comment info from event stream, filter for only new comments
const comments = (await getComments(repo, { const comments = (await getComments(repo, {
body: /build failed/i, body: new RegExp(COMMENT_BODY_REGEXP, COMMENT_BODY_REGEXP_FLAGS),
actor: 'elasticmachine', actor: COMMENT_ACTOR,
})).filter(comment => !history.get(comment.id)); })).filter(comment => !history.get(comment.id));
// read pull data, filter out any closed pulls // read pull data, filter out any closed pulls

View File

@@ -8,8 +8,11 @@ function usageError() {
export default function(repo) { export default function(repo) {
if (typeof repo !== 'string' || repo.length === 0) usageError(); if (typeof repo !== 'string' || repo.length === 0) usageError();
const settings = {
token: process.env.GITHUB_ACCESS_TOKEN,
};
const octo = new Octokat(); const octo = new Octokat(settings);
const [owner, name] = repo.split('/'); const [owner, name] = repo.split('/');
if (!owner || !name) usageError(); if (!owner || !name) usageError();