Skip to content

Commit bac52c8

Browse files
authored
fix: stop Build Gate from passing when no build actually ran (#8861)
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 dd3dd4b commit bac52c8

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
@@ -168,14 +168,33 @@ on:
168168

169169
concurrency:
170170
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ inputs.install_source }}
171+
# Only cancel an in-flight build when the new event will actually produce a new useful build.
172+
# Otherwise an incidental pull_request event (e.g. converted_to_draft race, non-override label change)
173+
# would cancel a real in-progress build and let the new run skip prebuild/build, leaving the
174+
# Build Gate falsely green.
171175
cancel-in-progress: >-
172176
${{
173-
github.event_name != 'pull_request' ||
174-
(github.event.action != 'labeled' && github.event.action != 'unlabeled') ||
175-
github.event.label.name == 'force-build' ||
176-
github.event.label.name == 'clean-build' ||
177-
github.event.label.name == 'windows-only' ||
178-
github.event.label.name == 'macos-only'
177+
github.event_name == 'push' ||
178+
github.event_name == 'workflow_dispatch' ||
179+
github.event_name == 'merge_group' ||
180+
(
181+
github.event_name == 'pull_request' &&
182+
(
183+
github.event.action == 'opened' ||
184+
github.event.action == 'reopened' ||
185+
github.event.action == 'synchronize' ||
186+
github.event.action == 'ready_for_review' ||
187+
(
188+
(github.event.action == 'labeled' || github.event.action == 'unlabeled') &&
189+
(
190+
github.event.label.name == 'force-build' ||
191+
github.event.label.name == 'clean-build' ||
192+
github.event.label.name == 'windows-only' ||
193+
github.event.label.name == 'macos-only'
194+
)
195+
)
196+
)
197+
)
179198
}}
180199
181200
jobs:
@@ -935,12 +954,21 @@ jobs:
935954
should_build='${{ needs.prebuild.outputs.should_build }}'
936955
prebuild_result='${{ needs.prebuild.result }}'
937956
938-
# No Explorer/ changes, draft without override, or perf_test path — gate is not applicable.
939-
if [ "$prebuild_result" != "success" ] || [ "$should_build" != "true" ]; then
940-
echo "Gate not applicable (prebuild=$prebuild_result, should_build='$should_build'). Passing."
957+
# Legit no-op: prebuild ran and decided no build is needed (no Explorer/ changes).
958+
# The Prebuild job's "Skip build and test checks" step already posts per-target success
959+
# statuses for this case, so the gate can safely pass.
960+
if [ "$prebuild_result" = "success" ] && [ "$should_build" != "true" ]; then
961+
echo "Gate not applicable (prebuild ran, no Explorer/ changes). Passing."
941962
exit 0
942963
fi
943964
965+
# Any other prebuild outcome (skipped/cancelled/failure) means no real build happened.
966+
# Fail closed so an incidental PR event can't silently produce a green Build Gate.
967+
if [ "$prebuild_result" != "success" ]; then
968+
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)."
969+
exit 1
970+
fi
971+
944972
targets='${{ needs.prebuild.outputs.targets }}'
945973
echo "Targets that ran: $targets"
946974

0 commit comments

Comments
 (0)