fix(ci): keep the pre-merge check green in report mode (#7311)
* fix(ci): keep the pre-merge check off the report-mode failures * fix(ci): fail the pre-merge check in block mode without a base commit * fix(ci): report every pre-merge failure the way its mode asks The merge step now separates a base commit it cannot fetch from a merge it cannot do, both failures print an annotation, and a spec pins the mode wiring of the three Policy workflows. * test(ci): type the Policy workflow assertions --------- Co-authored-by: imccyu <[email protected]>
This commit is contained in:
1 parent
ae38375654
commit
df469ea6ff
3 files changed
+75
-6
No files matched your search
@@ -57,28 +57,51 @@ jobs:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Merge the checked base-branch commit
|
||||
# Merging is the precondition of the build below, so a failure here warns and skips it in `report` mode and fails
|
||||
# in `block` mode.
|
||||
- id: merge
|
||||
name: Merge the checked base-branch commit
|
||||
env:
|
||||
CHECK_MODE: ${{ vars.MERGE_POLICY_PRE_MERGE }}
|
||||
BASE_SHA: ${{ needs.master.outputs.base_sha }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
SINCE: ${{ needs.master.outputs.since }}
|
||||
run: |
|
||||
[[ "$BASE_SHA" =~ ^[0-9a-f]{40}$ && "$SINCE" =~ ^[0-9]+$ ]] || { echo "::error::the master diff check reported no base commit"; exit 1; }
|
||||
git fetch --no-tags --no-write-fetch-head --shallow-since="$SINCE" origin "$HEAD_SHA" "$BASE_SHA"
|
||||
git -c user.name=pr-check -c [email protected] merge --no-ff --no-edit -m "Merge $BASE_SHA into $HEAD_SHA" "$BASE_SHA"
|
||||
stop() {
|
||||
if [ "$CHECK_MODE" = block ]; then
|
||||
echo "::error title=Pre-Merge Check::$1"
|
||||
exit 1
|
||||
fi
|
||||
echo "::warning title=Pre-Merge Check::$1"
|
||||
exit 0
|
||||
}
|
||||
if [[ ! "$BASE_SHA" =~ ^[0-9a-f]{40}$ || ! "$SINCE" =~ ^[0-9]+$ ]]; then
|
||||
stop "the master diff check reported no base commit, so nothing was merged or compiled"
|
||||
fi
|
||||
git fetch --no-tags --no-write-fetch-head --shallow-since="$SINCE" origin "$HEAD_SHA" "$BASE_SHA" ||
|
||||
stop "the base commit $BASE_SHA could not be fetched, so nothing was merged or compiled"
|
||||
git -c user.name=pr-check -c [email protected] merge --no-ff --no-edit -m "Merge $BASE_SHA into $HEAD_SHA" "$BASE_SHA" ||
|
||||
stop "the pull request cannot merge $BASE_SHA; merge master into it and push, then this check runs again"
|
||||
echo "merged=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: pnpm/[email protected]
|
||||
if: steps.merge.outputs.merged == 'true'
|
||||
|
||||
- uses: actions/[email protected]
|
||||
if: steps.merge.outputs.merged == 'true'
|
||||
with:
|
||||
node-version: '24'
|
||||
package-manager-cache: false
|
||||
|
||||
- name: Run the pre-merge command
|
||||
if: steps.merge.outputs.merged == 'true'
|
||||
env:
|
||||
CHECK_MODE: ${{ vars.MERGE_POLICY_PRE_MERGE }}
|
||||
run: |
|
||||
if ! bash -euxo pipefail -c 'pnpm install --frozen-lockfile && pnpm exec tsx scripts/compile-referenced-projects.ts host-contracts && pnpm exec tsx scripts/compile-referenced-projects.ts client'; then
|
||||
if [ "$CHECK_MODE" = block ]; then exit 1; fi
|
||||
if [ "$CHECK_MODE" = block ]; then
|
||||
echo "::error title=Pre-Merge Check::the merged tree does not install or compile"
|
||||
exit 1
|
||||
fi
|
||||
echo "::warning title=Pre-Merge Check::the merged tree does not install or compile; this check does not block"
|
||||
fi
|
||||
Reference in new issue
Block a user