Skip to content

Commit 3576c22

Browse files
authored
Merge pull request #37 from adRise/fix_forgot_run_build
bugfix: forgot to run "yarn build" for the latest release
2 parents f6b9193 + 855b1d3 commit 3576c22

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

.husky/pre-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
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
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"lint": "eslint -c eslint.config.js src",
66
"test": "jest src --coverage --verbose",
77
"jest-dev": "jest src --coverage --verbose --watch",
8-
"build": "ncc build src/index.js -o dest"
8+
"build": "ncc build src/index.js -o dest",
9+
"prepare": "husky"
910
},
1011
"repository": "[email protected]:adRise/update-pr-branch.git",
1112
"license": "MIT",
@@ -22,6 +23,7 @@
2223
"eslint": "^9.2.0",
2324
"eslint-plugin-jest": "^28.5.0",
2425
"globals": "^15.3.0",
26+
"husky": "^9.1.5",
2527
"jest": "^29.7.0"
2628
}
2729
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,6 +2395,11 @@ human-signals@^2.1.0:
23952395
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0"
23962396
integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==
23972397

2398+
husky@^9.1.5:
2399+
version "9.1.5"
2400+
resolved "https://registry.yarnpkg.com/husky/-/husky-9.1.5.tgz#2b6edede53ee1adbbd3a3da490628a23f5243b83"
2401+
integrity sha512-rowAVRUBfI0b4+niA4SJMhfQwc107VLkBUgEYYAOQAbqDCnra1nYh83hF/MDmhYs9t9n1E3DuKOrs2LYNC+0Ag==
2402+
23982403
ignore@^5.2.0:
23992404
version "5.3.1"
24002405
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef"

0 commit comments

Comments
 (0)