@@ -29,7 +29,7 @@ inputs:
29
29
version :
30
30
required : false
31
31
description : A pinned Bazel version to use
32
- default : ' 5.1.1 '
32
+ default : ' '
33
33
type : string
34
34
bazel :
35
35
required : false
68
68
credentials-file : ${{ steps.auth.outputs.credentials-file }}
69
69
bazel-cache : ${{ inputs.bazel-cache }}
70
70
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
+
71
87
- name : Get Linux bazelisk path
72
88
if : runner.os == 'Linux'
73
89
shell : bash
@@ -88,14 +104,14 @@ runs:
88
104
uses : actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
89
105
with :
90
106
path : ${{ env.BAZELISK_PATH }}
91
- key : bazel-${{ runner.os }}-${{ inputs.version }}
107
+ key : bazel-${{ runner.os }}-${{ env.BAZEL_VERSION }}
92
108
93
109
- name : Restore Bazelisk
94
110
if : ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }}
95
111
uses : actions/cache/restore@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
96
112
with :
97
113
path : ${{ env.BAZELISK_PATH }}
98
- key : bazel-${{ runner.os }}-${{ inputs.version }}
114
+ key : bazel-${{ runner.os }}-${{ env.BAZEL_VERSION }}
99
115
100
116
- name : Hook up repository Cache
101
117
shell : bash
@@ -108,35 +124,12 @@ runs:
108
124
109
125
- name : Pin Bazel version
110
126
shell : bash
111
- run : echo "USE_BAZEL_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
127
+ run : echo "USE_BAZEL_VERSION=${{ env.BAZEL_VERSION }}" >> $GITHUB_ENV
112
128
113
129
- name : Output Bazel version
114
130
shell : bash
115
131
run : bazelisk version
116
132
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
-
140
133
- name : Run Bash
141
134
if : ${{ inputs.bash }}
142
135
run : ${{ inputs.bash }}
0 commit comments