Skip to content

Commit 896de1e

Browse files
committed
fix: stop Build Gate from passing when no build actually ran
Two issues introduced in #8822 caused PRs to show a green Build Gate without producing any build artifact: 1. concurrency.cancel-in-progress evaluated true for almost every pull_request event, so an incidental event (e.g. a transient draft toggle) cancelled the real in-flight Windows/macOS builds. 2. The Build Gate auto-passed whenever prebuild was skipped/cancelled (only required prebuild.result != success), which is exactly what happens after the cancellation above — leaving a green gate on a commit that was never built. Invert the cancel-in-progress logic to only cancel for events that will actually produce a new build, and make the gate fail closed for any prebuild outcome other than a successful "no Explorer/ changes" decision.
1 parent a0e665a commit 896de1e

1 file changed

Lines changed: 37 additions & 9 deletions

File tree

.github/workflows/build-unitycloud.yml

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,33 @@ on:
159159

160160
concurrency:
161161
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ inputs.install_source }}
162+
# Only cancel an in-flight build when the new event will actually produce a new useful build.
163+
# Otherwise an incidental pull_request event (e.g. converted_to_draft race, non-override label change)
164+
# would cancel a real in-progress build and let the new run skip prebuild/build, leaving the
165+
# Build Gate falsely green.
162166
cancel-in-progress: >-
163167
${{
164-
github.event_name != 'pull_request' ||
165-
(github.event.action != 'labeled' && github.event.action != 'unlabeled') ||
166-
github.event.label.name == 'force-build' ||
167-
github.event.label.name == 'clean-build' ||
168-
github.event.label.name == 'windows-only' ||
169-
github.event.label.name == 'macos-only'
168+
github.event_name == 'push' ||
169+
github.event_name == 'workflow_dispatch' ||
170+
github.event_name == 'merge_group' ||
171+
(
172+
github.event_name == 'pull_request' &&
173+
(
174+
github.event.action == 'opened' ||
175+
github.event.action == 'reopened' ||
176+
github.event.action == 'synchronize' ||
177+
github.event.action == 'ready_for_review' ||
178+
(
179+
(github.event.action == 'labeled' || github.event.action == 'unlabeled') &&
180+
(
181+
github.event.label.name == 'force-build' ||
182+
github.event.label.name == 'clean-build' ||
183+
github.event.label.name == 'windows-only' ||
184+
github.event.label.name == 'macos-only'
185+
)
186+
)
187+
)
188+
)
170189
}}
171190
172191
jobs:
@@ -888,12 +907,21 @@ jobs:
888907
should_build='${{ needs.prebuild.outputs.should_build }}'
889908
prebuild_result='${{ needs.prebuild.result }}'
890909
891-
# No Explorer/ changes, draft without override, or perf_test path — gate is not applicable.
892-
if [ "$prebuild_result" != "success" ] || [ "$should_build" != "true" ]; then
893-
echo "Gate not applicable (prebuild=$prebuild_result, should_build='$should_build'). Passing."
910+
# Legit no-op: prebuild ran and decided no build is needed (no Explorer/ changes).
911+
# The Prebuild job's "Skip build and test checks" step already posts per-target success
912+
# statuses for this case, so the gate can safely pass.
913+
if [ "$prebuild_result" = "success" ] && [ "$should_build" != "true" ]; then
914+
echo "Gate not applicable (prebuild ran, no Explorer/ changes). Passing."
894915
exit 0
895916
fi
896917
918+
# Any other prebuild outcome (skipped/cancelled/failure) means no real build happened.
919+
# Fail closed so an incidental PR event can't silently produce a green Build Gate.
920+
if [ "$prebuild_result" != "success" ]; then
921+
echo "::error::Prebuild did not succeed (result: $prebuild_result). No build produced for this commit; re-trigger the workflow (e.g. push a new commit or add the 'force-build' label)."
922+
exit 1
923+
fi
924+
897925
targets='${{ needs.prebuild.outputs.targets }}'
898926
echo "Targets that ran: $targets"
899927

0 commit comments

Comments
 (0)