Skip to content

Commit 7247c93

Browse files
Workaround flaky mac timeouts (#15)
* Workaround flaky mac timeouts * Remove old hack that's no longer necessary
1 parent 5458b4f commit 7247c93

File tree

1 file changed

+20
-27
lines changed

1 file changed

+20
-27
lines changed

bazel/action.yml

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ inputs:
2929
version:
3030
required: false
3131
description: A pinned Bazel version to use
32-
default: '5.1.1'
32+
default: ''
3333
type: string
3434
bazel:
3535
required: false
@@ -68,6 +68,22 @@ runs:
6868
credentials-file: ${{ steps.auth.outputs.credentials-file }}
6969
bazel-cache: ${{ inputs.bazel-cache }}
7070

71+
# Earlier versions of Bazel cause relatively high flake rates due to
72+
# https://github.com/bazelbuild/bazel/issues/17437. Default to 6.2.0 where
73+
# the BAZEL_OSX_EXECUTE_TIMEOUT environment variable can override this
74+
# timeout.
75+
- name: Workaround mac timeouts
76+
if: runner.os == 'macOS'
77+
shell: bash
78+
run: |
79+
echo "BAZEL_VERSION=${{ inputs.version || '6.1.0' }}" >> $GITHUB_ENV
80+
echo "BAZEL_OSX_EXECUTE_TIMEOUT=600" >> $GITHUB_ENV
81+
82+
- name: Select default Bazel version
83+
if: runner.os != 'macOS'
84+
shell: bash
85+
run: echo "BAZEL_VERSION=${{ inputs.version || '5.1.1' }}" >> $GITHUB_ENV
86+
7187
- name: Get Linux bazelisk path
7288
if: runner.os == 'Linux'
7389
shell: bash
@@ -88,14 +104,14 @@ runs:
88104
uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
89105
with:
90106
path: ${{ env.BAZELISK_PATH }}
91-
key: bazel-${{ runner.os }}-${{ inputs.version }}
107+
key: bazel-${{ runner.os }}-${{ env.BAZEL_VERSION }}
92108

93109
- name: Restore Bazelisk
94110
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }}
95111
uses: actions/cache/restore@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
96112
with:
97113
path: ${{ env.BAZELISK_PATH }}
98-
key: bazel-${{ runner.os }}-${{ inputs.version }}
114+
key: bazel-${{ runner.os }}-${{ env.BAZEL_VERSION}}
99115

100116
- name: Hook up repository Cache
101117
shell: bash
@@ -108,35 +124,12 @@ runs:
108124

109125
- name: Pin Bazel version
110126
shell: bash
111-
run: echo "USE_BAZEL_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
127+
run: echo "USE_BAZEL_VERSION=${{ env.BAZEL_VERSION }}" >> $GITHUB_ENV
112128

113129
- name: Output Bazel version
114130
shell: bash
115131
run: bazelisk version
116132

117-
# Bazel has multiple Xcode calls with hardcoded timeouts. Many of these
118-
# end up timing out on our github runners, causing flakes on every mac
119-
# build that invoked Bazel. To work around this, we manually inoke these
120-
# calls before running Bazel to make sure they end up in Xcode's cache for
121-
# quicker runs later. All of these calls are obtained from xcrun calls in
122-
# https://github.com/bazelbuild/bazel/blob/e8a69f5d5acaeb6af760631490ecbf73e8a04eeb/tools/cpp/osx_cc_configure.bzl.
123-
# See https://github.com/bazelbuild/bazel/issues/17437 for more details.
124-
# TODO(b/269503614) Remove this once Bazel provides an official solution.
125-
- name: Warm up Xcode
126-
if: ${{ runner.os == 'macOS' }}
127-
shell: bash
128-
run: |
129-
mkdir -p mac_bazel_workaround
130-
bazelisk ${{ steps.bazel.outputs.bazel-startup-flags }} build @bazel_tools//tools/osx:xcode_locator.m $BAZEL_FLAGS
131-
XCODE_LOCATOR_FLAGS="--sdk macosx clang -mmacosx-version-min=10.9 -fobjc-arc -framework CoreServices -framework Foundation"
132-
SINGLE_ARCH_COMPILE_FLAGS="--sdk macosx clang -mmacosx-version-min=10.9 -std=c++11 -lc++ -O3"
133-
COMPILE_FLAGS="$SINGLE_ARCH_COMPILE_FLAGS -arch arm64 -arch x86_64 -Wl,-no_adhoc_codesign -Wl,-no_uuid -O3"
134-
time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $XCODE_LOCATOR_FLAGS -o mac_bazel_workaround/xcode-locator-bin $(bazel info output_base)/external/bazel_tools/tools/osx/xcode_locator.m
135-
time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $SINGLE_ARCH_COMPILE_FLAGS -o mac_bazel_workaround/libtool_check_unique $(bazel info output_base)/external/bazel_tools/tools/objc/libtool_check_unique.cc
136-
time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $COMPILE_FLAGS -o mac_bazel_workaround/libtool_check_unique $(bazel info output_base)/external/bazel_tools/tools/objc/libtool_check_unique.cc
137-
time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $SINGLE_ARCH_COMPILE_FLAGS -o mac_bazel_workaround/wrapped_clang $(bazel info output_base)/external/bazel_tools/tools/osx/crosstool/wrapped_clang.cc
138-
time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $COMPILE_FLAGS -o mac_bazel_workaround/wrapped_clang $(bazel info output_base)/external/bazel_tools/tools/osx/crosstool/wrapped_clang.cc
139-
140133
- name: Run Bash
141134
if: ${{ inputs.bash }}
142135
run: ${{ inputs.bash }}

0 commit comments

Comments
 (0)