@@ -675,3 +675,51 @@ jobs:
675675 - name : Verify debugger-shell build
676676 shell : bash
677677 run : node scripts/debugger-shell/build-binary.js
678+
679+ # Require this job in branch protection instead of a platform-specific build.
680+ # Unlike the builds, it reports a result even when a platform is intentionally skipped.
681+ native_builds_gate :
682+ runs-on : ubuntu-latest
683+ needs : [check_code_changes, build_android, test_ios_rntester]
684+ if : ${{ always() && github.repository == 'react/react-native' }}
685+ steps :
686+ - name : Verify required native builds
687+ shell : bash
688+ env :
689+ CODE_CHANGES_RESULT : ${{ needs.check_code_changes.result }}
690+ ANY_CODE_CHANGE : ${{ needs.check_code_changes.outputs.any_code_change }}
691+ SHOULD_TEST_ANDROID : ${{ needs.check_code_changes.outputs.should_test_android }}
692+ SHOULD_TEST_IOS : ${{ needs.check_code_changes.outputs.should_test_ios }}
693+ ANDROID_RESULT : ${{ needs.build_android.result }}
694+ IOS_RESULT : ${{ needs.test_ios_rntester.result }}
695+ run : |
696+ set -e
697+
698+ if [[ "$CODE_CHANGES_RESULT" != success ]]; then
699+ echo "::error::Could not determine which native builds are required ($CODE_CHANGES_RESULT)"
700+ exit 1
701+ fi
702+
703+ check_build() {
704+ local platform="$1" required="$2" result="$3"
705+ if [[ "$required" == true ]]; then
706+ if [[ "$result" != success ]]; then
707+ echo "::error::$platform build required but finished with $result"
708+ return 1
709+ fi
710+ elif [[ "$result" != skipped && "$result" != success ]]; then
711+ echo "::error::$platform build was not required but finished with $result"
712+ return 1
713+ fi
714+ echo "$platform build: $result (required: $required)"
715+ }
716+
717+ android_required=false
718+ ios_required=false
719+ if [[ "$ANY_CODE_CHANGE" == true ]]; then
720+ android_required="$SHOULD_TEST_ANDROID"
721+ ios_required="$SHOULD_TEST_IOS"
722+ fi
723+
724+ check_build Android "$android_required" "$ANDROID_RESULT"
725+ check_build iOS "$ios_required" "$IOS_RESULT"
0 commit comments