Вот что сработало для меня:
https://api.github.com/repos/ethereum/EIPs/commits/<ref>/statuses
по какой-то причине видит только статусы моих сторонних проверок CI. Таким образом, даже если другие тесты не пройдены, учитываются только тесты CI.
Поэтому я использовал это свойство, чтобы проверять его каждые 30 секунд, а затем прерывать работу в случае возникновения ошибки; вот код для этого:
// HACK (alita): check the CI status and only continue if the CI is successful
const checkCIStatus = async () => {
const Github = getOctokit(GITHUB_TOKEN);
const pr = await requirePr()
const status = await Github.repos.getCombinedStatusForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: pr.head.ref
}).then(res => res.data.state)
console.log(`status is '${status}'...`)
if (status === "failure") {
setFailed("CI checks failed; bot can only merge if CI checks pass")
throw "CI checks failed; bot can only merge if CI checks pass"
}
return status === "success";
}
export const pauseInterval = (checker, next, timeout) => async () => {
const status = await checker();
if (!status) {
setTimeout(pauseInterval(checker, next, timeout), timeout);
} else {
return next()
}
}
// only runs the bot if the CI statuses pass; checks every 30 seconds
export const main = pauseInterval(checkCIStatus, _main, CHECK_STATUS_INTERVAL)
выход из успеха
status is 'pending'...
status is 'pending'...
status is 'pending'...
status is 'pending'...
status is 'pending'...
status is 'pending'...
status is 'pending'...
status is 'pending'...
status is 'pending'...
status is 'pending'...
status is 'pending'...
status is 'success'...
<normal action outputs>
вывод из неудачных проверок
status is 'pending'...
status is 'pending'...
(node:1603) UnhandledPromiseRejectionWarning: CI checks failed; bot can only merge if CI checks pass
status is 'failure'...
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1603) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1603) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
В частности, это действительно возможно только в пользовательском действии, но вы, вероятно, могли бы создать простой файл действия/js, который мог бы выполнять такое же поведение и рассматриваться как действие перед данным действием. Если у вас это было, и это не удалось / удалось при успехе или ошибке, вы могли бы условно вызвать свое действие в скрипте Github yaml.
17.04.2021