Skip to content

Commit 855b1d3

Browse files
committed
test again
1 parent d9c2853 commit 855b1d3

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh
22
npm run build
3+
git add dest

dest/index.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31237,7 +31237,7 @@ const getMergeableStatus = async (pullNumber) => {
3123731237
/**
3123831238
* whether all checks passed
3123931239
*/
31240-
const areAllChecksPassed = async (sha) => {
31240+
const areAllChecksPassed = async (sha, allow_ongoing_checks) => {
3124131241
const octokit = getOctokit();
3124231242
const repo = github.context.repo;
3124331243
const {
@@ -31247,11 +31247,20 @@ const areAllChecksPassed = async (sha) => {
3124731247
ref: sha,
3124831248
});
3124931249

31250-
const hasUnfinishedOrFailedChecks = check_runs.some((item) => {
31251-
return item.status !== 'completed' || item.conclusion === 'failure';
31252-
});
31250+
let hasOffensiveChecks = false;
31251+
if (allow_ongoing_checks) {
31252+
// check whether there are ongoing checks
31253+
hasOffensiveChecks = check_runs.some((item) => {
31254+
return item.conclusion === 'failure';
31255+
});
31256+
} else {
31257+
// check whether there are unfinished or failed checks
31258+
hasOffensiveChecks = check_runs.some((item) => {
31259+
return item.status !== 'completed' || item.conclusion === 'failure';
31260+
});
31261+
}
3125331262

31254-
return !hasUnfinishedOrFailedChecks;
31263+
return !hasOffensiveChecks;
3125531264
};
3125631265

3125731266
/**
@@ -31291,7 +31300,9 @@ const getApprovalStatus = async (pullNumber) => {
3129131300
};
3129231301

3129331302
const filterApplicablePRs = (openPRs) => {
31294-
const includeNonAutoMergePRs = isStringFalse(github_core.getInput('require_auto_merge_enabled'));
31303+
const includeNonAutoMergePRs = isStringFalse(
31304+
github_core.getInput('require_auto_merge_enabled'),
31305+
);
3129531306
if (includeNonAutoMergePRs) {
3129631307
return openPRs;
3129731308
}
@@ -31308,6 +31319,9 @@ const getAutoUpdateCandidate = async (openPRs) => {
3130831319
const requirePassedChecks = isStringTrue(
3130931320
github_core.getInput('require_passed_checks'),
3131031321
);
31322+
const allowOngoingChecks = isStringTrue(
31323+
github_core.getInput('allow_ongoing_checks'),
31324+
);
3131131325
const applicablePRs = filterApplicablePRs(openPRs);
3131231326

3131331327
for (const pr of applicablePRs) {
@@ -31353,9 +31367,13 @@ const getAutoUpdateCandidate = async (openPRs) => {
3135331367
* need to note: the mergeable, and mergeable_state don't reflect the checks status
3135431368
*/
3135531369
if (requirePassedChecks) {
31356-
const didChecksPass = await areAllChecksPassed(sha);
31370+
const didChecksPass = await areAllChecksPassed(sha, allowOngoingChecks);
31371+
31372+
const reasonType = allowOngoingChecks
31373+
? 'failed check(s)'
31374+
: 'failed or ongoing check(s)';
3135731375
if (!didChecksPass) {
31358-
printFailReason(pullNumber, 'The PR has failed or ongoing check(s)');
31376+
printFailReason(pullNumber, `The PR has ${reasonType}`);
3135931377
continue;
3136031378
}
3136131379
}

0 commit comments

Comments
 (0)