2 Commits

Author SHA1 Message Date
8bdab1f9db fix: hide debugging output when value is '0' 2019-02-19 17:24:29 -07:00
1863239c06 feat: check for pending status after comment
keep re-trying until state changes to pending, up to 3 times. if state does not change, remove from history so another run will retry
2019-02-19 17:24:29 -07:00
2 changed files with 6 additions and 4 deletions

View File

@@ -25,7 +25,7 @@ async function ghActionBot() {
PULL_LABEL_FILTER,
PULL_AUTHOR_FILTER,
PULL_RETEST_BODY,
ACTION_CHECK_DELAY = 3000,
ACTION_RETRY_DELAY = 3000,
} = process.env;
// load the history module
@@ -100,7 +100,7 @@ async function ghActionBot() {
logger.debug(`CHECK #${record.pull.number}: verify state change`);
// wait for the ci to restart
await sleep(ACTION_CHECK_DELAY);
await sleep(ACTION_RETRY_DELAY);
// check that the commit status is now pending
const buildStatus = await getCommitStatus(repo, record.commit.sha);

View File

@@ -1,4 +1,4 @@
export default async function execAndCheck(fn, test, onFailure = () => {}, opts = { tries: 3 }) {
export default async function execAndCheck(fn, test, onFailure = () => {}) {
let count = 0;
const tryExec = async () => {
@@ -9,9 +9,11 @@ export default async function execAndCheck(fn, test, onFailure = () => {}, opts
const res = await test();
if (res) return;
const { ACTION_RETRY_COUNT = 3 } = process.env;
// if retry limit is hit, call failure function
count += 1;
if (count >= opts.tries) return onFailure(); // eslint-disable-line consistent-return
if (count >= ACTION_RETRY_COUNT) return onFailure(); // eslint-disable-line consistent-return
// retry the function and retest the results
return tryExec(); // eslint-disable-line consistent-return