Compare commits
1 Commits
master
...
8fc14f8c88
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fc14f8c88 |
@@ -6,11 +6,14 @@ import getPull from './lib/get_pull.mjs';
|
|||||||
import getCommits from './lib/get_commits.mjs';
|
import getCommits from './lib/get_commits.mjs';
|
||||||
import getCommitStatus from './lib/get_commit_status.mjs';
|
import getCommitStatus from './lib/get_commit_status.mjs';
|
||||||
import createPullComment from './lib/create_pull_comment.mjs';
|
import createPullComment from './lib/create_pull_comment.mjs';
|
||||||
|
import execAndCheck from './lib/exec_and_check.mjs';
|
||||||
import History from './lib/history.mjs';
|
import History from './lib/history.mjs';
|
||||||
|
|
||||||
// load env vars from .env file
|
// load env vars from .env file
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
|
const sleep = async ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
|
||||||
async function ghActionBot() {
|
async function ghActionBot() {
|
||||||
// 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]);
|
||||||
@@ -22,6 +25,7 @@ async function ghActionBot() {
|
|||||||
PULL_LABEL_FILTER,
|
PULL_LABEL_FILTER,
|
||||||
PULL_AUTHOR_FILTER,
|
PULL_AUTHOR_FILTER,
|
||||||
PULL_RETEST_BODY,
|
PULL_RETEST_BODY,
|
||||||
|
ACTION_CHECK_DELAY = 3000,
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
// load the history module
|
// load the history module
|
||||||
@@ -90,7 +94,23 @@ async function ghActionBot() {
|
|||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
records.map(record =>
|
records.map(record =>
|
||||||
createPullComment(repo, record.pull.number, PULL_RETEST_BODY, { delete: true })
|
execAndCheck(
|
||||||
|
() => createPullComment(repo, record.pull.number, PULL_RETEST_BODY, { delete: true }),
|
||||||
|
async () => {
|
||||||
|
logger.debug(`CHECK #${record.pull.number}: verify state change`);
|
||||||
|
// wait for the ci to restart
|
||||||
|
|
||||||
|
await sleep(ACTION_CHECK_DELAY);
|
||||||
|
|
||||||
|
// check that the commit status is now pending
|
||||||
|
const buildStatus = await getCommitStatus(repo, record.commit.sha);
|
||||||
|
return buildStatus.state === 'pending';
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
history.remove(record.comment);
|
||||||
|
logger.error(`Pull comment failed to trigger action on pull #${record.pull.number}`);
|
||||||
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user