Skip to content

Commit

Permalink
Merge pull request #37 from adRise/fix_forgot_run_build
Browse files Browse the repository at this point in the history
bugfix: forgot to run "yarn build" for the latest release
  • Loading branch information
zhiyelee authored Sep 1, 2024
2 parents f6b9193 + 855b1d3 commit 3576c22
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
npm run build
git add dest
34 changes: 26 additions & 8 deletions dest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31237,7 +31237,7 @@ const getMergeableStatus = async (pullNumber) => {
/**
* whether all checks passed
*/
const areAllChecksPassed = async (sha) => {
const areAllChecksPassed = async (sha, allow_ongoing_checks) => {
const octokit = getOctokit();
const repo = github.context.repo;
const {
Expand All @@ -31247,11 +31247,20 @@ const areAllChecksPassed = async (sha) => {
ref: sha,
});

const hasUnfinishedOrFailedChecks = check_runs.some((item) => {
return item.status !== 'completed' || item.conclusion === 'failure';
});
let hasOffensiveChecks = false;
if (allow_ongoing_checks) {
// check whether there are ongoing checks
hasOffensiveChecks = check_runs.some((item) => {
return item.conclusion === 'failure';
});
} else {
// check whether there are unfinished or failed checks
hasOffensiveChecks = check_runs.some((item) => {
return item.status !== 'completed' || item.conclusion === 'failure';
});
}

return !hasUnfinishedOrFailedChecks;
return !hasOffensiveChecks;
};

/**
Expand Down Expand Up @@ -31291,7 +31300,9 @@ const getApprovalStatus = async (pullNumber) => {
};

const filterApplicablePRs = (openPRs) => {
const includeNonAutoMergePRs = isStringFalse(github_core.getInput('require_auto_merge_enabled'));
const includeNonAutoMergePRs = isStringFalse(
github_core.getInput('require_auto_merge_enabled'),
);
if (includeNonAutoMergePRs) {
return openPRs;
}
Expand All @@ -31308,6 +31319,9 @@ const getAutoUpdateCandidate = async (openPRs) => {
const requirePassedChecks = isStringTrue(
github_core.getInput('require_passed_checks'),
);
const allowOngoingChecks = isStringTrue(
github_core.getInput('allow_ongoing_checks'),
);
const applicablePRs = filterApplicablePRs(openPRs);

for (const pr of applicablePRs) {
Expand Down Expand Up @@ -31353,9 +31367,13 @@ const getAutoUpdateCandidate = async (openPRs) => {
* need to note: the mergeable, and mergeable_state don't reflect the checks status
*/
if (requirePassedChecks) {
const didChecksPass = await areAllChecksPassed(sha);
const didChecksPass = await areAllChecksPassed(sha, allowOngoingChecks);

const reasonType = allowOngoingChecks
? 'failed check(s)'
: 'failed or ongoing check(s)';
if (!didChecksPass) {
printFailReason(pullNumber, 'The PR has failed or ongoing check(s)');
printFailReason(pullNumber, `The PR has ${reasonType}`);
continue;
}
}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"lint": "eslint -c eslint.config.js src",
"test": "jest src --coverage --verbose",
"jest-dev": "jest src --coverage --verbose --watch",
"build": "ncc build src/index.js -o dest"
"build": "ncc build src/index.js -o dest",
"prepare": "husky"
},
"repository": "git@github.com:adRise/update-pr-branch.git",
"license": "MIT",
Expand All @@ -22,6 +23,7 @@
"eslint": "^9.2.0",
"eslint-plugin-jest": "^28.5.0",
"globals": "^15.3.0",
"husky": "^9.1.5",
"jest": "^29.7.0"
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2395,6 +2395,11 @@ human-signals@^2.1.0:
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0"
integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==

husky@^9.1.5:
version "9.1.5"
resolved "https://registry.yarnpkg.com/husky/-/husky-9.1.5.tgz#2b6edede53ee1adbbd3a3da490628a23f5243b83"
integrity sha512-rowAVRUBfI0b4+niA4SJMhfQwc107VLkBUgEYYAOQAbqDCnra1nYh83hF/MDmhYs9t9n1E3DuKOrs2LYNC+0Ag==

ignore@^5.2.0:
version "5.3.1"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef"
Expand Down

0 comments on commit 3576c22

Please sign in to comment.