feat: add retest comment, delete it
This commit is contained in:
@@ -4,6 +4,7 @@ import getComments from './lib/get_comments.mjs';
|
||||
import getPull from './lib/get_pull.mjs';
|
||||
import getCommits from './lib/get_commits.mjs';
|
||||
import getCommitStatus from './lib/get_commit_status.mjs';
|
||||
import { createComment, deleteComment } from './lib/comments.mjs';
|
||||
import History from './lib/history.mjs';
|
||||
|
||||
// load env vars from .env file
|
||||
@@ -12,7 +13,13 @@ dotenv.config();
|
||||
export default async function() {
|
||||
// parse repo name from cli and create repo instance
|
||||
const repo = createRepo(process.argv.splice(2)[0]);
|
||||
const { COMMENT_BODY_REGEXP, COMMENT_BODY_REGEXP_FLAGS, COMMENT_ACTOR } = process.env;
|
||||
const {
|
||||
COMMENT_BODY_REGEXP,
|
||||
COMMENT_BODY_REGEXP_FLAGS,
|
||||
COMMENT_ACTOR,
|
||||
PULL_LABEL_FILTER,
|
||||
PULL_RETEST_BODY,
|
||||
} = process.env;
|
||||
|
||||
// load the history module
|
||||
const history = new History();
|
||||
@@ -23,11 +30,14 @@ export default async function() {
|
||||
actor: COMMENT_ACTOR,
|
||||
})).filter(comment => !history.get(comment.id));
|
||||
|
||||
// read pull data, filter out any closed pulls
|
||||
// read pull data
|
||||
const pulls = (await Promise.all(
|
||||
comments.map(async comment => {
|
||||
const pull = await getPull(repo, comment.number);
|
||||
if (pull.state !== 'open') return false;
|
||||
|
||||
if (pull.state !== 'open') return false; // filter out any closed pulls
|
||||
if (PULL_LABEL_FILTER && !pull.labels.includes(PULL_LABEL_FILTER)) return false; // filter on label
|
||||
|
||||
return { comment, pull };
|
||||
})
|
||||
)).filter(Boolean);
|
||||
@@ -43,8 +53,15 @@ export default async function() {
|
||||
})
|
||||
)).filter(Boolean);
|
||||
|
||||
console.log(records);
|
||||
process.exit();
|
||||
console.log(`Found ${records.length} outstanding failures`);
|
||||
|
||||
await Promise.all(
|
||||
records.map(async record => {
|
||||
console.log(`Re-testing PR #${record.pull.number}`);
|
||||
const comment = await createComment(repo, records[0].pull.number, PULL_RETEST_BODY);
|
||||
await deleteComment(repo, comment.id);
|
||||
})
|
||||
);
|
||||
|
||||
/*
|
||||
|
||||
@@ -52,12 +69,12 @@ export default async function() {
|
||||
|
||||
- [x] keep track of seen comment ids, only process new ones
|
||||
- [x] check the pr's status and only retest if no longer "Pending"
|
||||
- [ ] add a retest comment
|
||||
- [x] add a retest comment
|
||||
- POST /repos/:owner/:repo/issues/:number/comments
|
||||
- [x] delete the retest comment
|
||||
- [ ] delete the build comment
|
||||
- DELETE /repos/:owner/:repo/issues/comments/:comment_id
|
||||
- [ ] delete ALL build failure comments
|
||||
- [ ] delete the retest comment
|
||||
- DELETE /repos/:owner/:repo/issues/comments/:comment_id
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user