From aa0fb307f519330528a2da91b33c5017c48c077c Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Wed, 15 Feb 2023 10:22:37 -0800 Subject: [PATCH] Implement a workaround for macOS/Bazel flakes. See https://github.com/bazelbuild/bazel/issues/17437 for more details. PiperOrigin-RevId: 509869860 --- .github/actions/bazel/action.yml | 11 +++++++++++ .github/actions/internal/bazel-setup/action.yml | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/actions/bazel/action.yml b/.github/actions/bazel/action.yml index 141527db0267d..a247b2d255229 100644 --- a/.github/actions/bazel/action.yml +++ b/.github/actions/bazel/action.yml @@ -98,6 +98,17 @@ runs: run: ${{ inputs.bash }} shell: bash + # Xcode has a warmup period that can frequently exceed the 2m timeout + # that Bazel uses internally. If we warm it up in advance w/o a timeout, + # Bazel's call will run in seconds. + # See https://github.com/bazelbuild/bazel/issues/17437 for more details. + - name: Warm up Xcode + if: ${{ runner.os == 'macOS' }} + shell: bash + run: | + bazelisk build @bazel_tools//tools/osx:xcode_locator.m + time xcrun --sdk macosx clang -mmacosx-version-min=10.9 -fobjc-arc -framework CoreServices -framework Foundation -o xcode-locator-bin $(bazel info output_base)/external/bazel_tools/tools/osx/xcode_locator.m + - name: Run Bazel if: ${{ !inputs.bash }} run: >- diff --git a/.github/actions/internal/bazel-setup/action.yml b/.github/actions/internal/bazel-setup/action.yml index 20e724199fdeb..0ef5d5a2266ac 100644 --- a/.github/actions/internal/bazel-setup/action.yml +++ b/.github/actions/internal/bazel-setup/action.yml @@ -42,7 +42,9 @@ runs: - name: Initialize MacOS-specific Bazel flags if: runner.os == 'macOS' shell: bash - run: echo "BAZEL_FLAGS=$BAZEL_FLAGS --xcode_version_config=//.github:host_xcodes" >> $GITHUB_ENV + run: | + echo "BAZEL_FLAGS=$BAZEL_FLAGS --xcode_version_config=//.github:host_xcodes" >> $GITHUB_ENV + echo "DEVELOPER_DIR=${{ env.DEVELOPER_DIR || '/Applications/Xcode_14.1.app/Contents/Developer' }}" >> $GITHUB_ENV - name: Configure Bazel caching # Skip bazel cache for local act runs due to issue with credential files