forked from googleapis/google-cloud-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
283 lines (280 loc) · 10.5 KB
/
windows-cmake.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
name: Windows-Builds
on:
workflow_call:
inputs:
checkout-ref:
required: true
description: "The ref we want to compile"
type: string
full-matrix:
required: true
description: "Build the full matrix"
type: boolean
sccache-mode:
required: true
description: "READ_WRITE or DISABLED"
type: string
vcpkg-cache-mode:
required: true
description: "read or readwrite"
type: string
execute-integration-tests:
required: true
description: "Integration tests require credentials."
type: boolean
permissions:
contents: read
jobs:
cmake:
name: cmake + ${{ matrix.msvc }} + ${{ matrix.arch }} + ${{ matrix.build_type }} + ${{ matrix.shard }}
runs-on: windows-2022
permissions:
contents: 'read'
id-token: 'write'
strategy:
# Continue other builds even if one fails
fail-fast: false
matrix:
exclude-from-full-trick: [ true ]
msvc: [ msvc-2022 ]
build_type: [ Debug, Release ]
arch: [ x64, x86 ]
shard: [Core1, Core2, Compute, Shard1, Shard2, Shard3, Other]
exclude:
# Also skip shards (Compute and Other) that contain only generated code.
- exclude-from-full-trick: ${{ ! inputs.full-matrix }}
shard: Compute
- exclude-from-full-trick: ${{ ! inputs.full-matrix }}
shard: Shard1
- exclude-from-full-trick: ${{ ! inputs.full-matrix }}
shard: Shard2
- exclude-from-full-trick: ${{ ! inputs.full-matrix }}
shard: Shard3
- exclude-from-full-trick: ${{ ! inputs.full-matrix }}
shard: Other
# No need to duplicate testing with x86 mode and Debug mode
- arch: x86
build_type: Debug
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
ref: ${{ inputs.checkout-ref }}
- uses: google-github-actions/auth@v2
if: ${{ inputs.sccache-mode == 'READ_WRITE' && inputs.vcpkg-cache-mode == 'readwrite' }}
with:
create_credentials_file: true
credentials_json: ${{ secrets.BUILD_CACHE_KEY }}
- uses: actions/setup-python@v5
id: py311
with:
python-version: '3.11'
- uses: google-github-actions/setup-gcloud@v2
env:
CLOUDSDK_PYTHON: ${{ steps.py311.outputs.python-path }}
# TODO(14314) - remove this VC Toolset workaround
- name: Select VC Toolset
id: vctoolset
shell: bash
run: |
# upb does not compile with the compiler that comes with the 14.40.33807
# VC toolset. To workaround this, we list the available toolset
# versions, then pick the latest one that is not 14.40.*. If 14.40.* is
# the only compiler version, we use that.
#
# See https://github.com/protocolbuffers/protobuf/issues/17032 for more
# details.
toolset_versions=($(ls "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC"))
echo "Available VC toolsets: ${toolset_versions[@]}"
toolset_version=""
for v in "${toolset_versions[@]}"; do
if [ -z "${toolset_version}" ]; then
toolset_version=${v}
elif ! echo ${v} | grep -q "^14\.40\."; then
toolset_version=${v}
fi
done
echo "Using VC toolset: ${toolset_version}"
echo "toolset_version=${toolset_version}" >> "${GITHUB_OUTPUT}"
- name: Dynamic Configuration
id: dynamic
shell: bash
run: |
echo "vcpkg-version=$(cat ci/etc/vcpkg-version.txt)" >> "${GITHUB_OUTPUT}"
core1_features=(bigtable pubsub pubsublite)
core2_features=(spanner storage)
# These are the libraries with the most "clients". To build the list
# run something like this and create shards:
#
# git grep -l 'class.*Client' 'google/cloud/**_client.h' |
# egrep -v "(bigtable/|internal/|pubsub/|pubsublite/|spanner/|storage/)" |
# cut -f -3 -d/| sort | uniq -c | sort -n |
# awk '{ s += $1; print s, $0}'
#
shard1_features=(
appengine
dataproc
discoveryengine
monitoring
retail
sql
dialogflow_cx
dialogflow_es
aiplatform
)
shard2_features=(
beyondcorp
billing
binaryauthorization
gkemulticloud
logging
notebooks
osconfig
servicecontrol
speech
support
video
datacatalog
iam
kms
run
talent
contentwarehouse
dataplex
bigquery
bigquerycontrol
resourcemanager
)
shard3_features=(
securesourcemanager
securitycentermanagement
servicehealth
servicemanagement
serviceusage
shell
storagecontrol
storageinsights
storagetransfer
tasks
telcoautomation
texttospeech
timeseriesinsights
translate
videointelligence
vmmigration
vmwareengine
vpcaccess
webrisk
websecurityscanner
workstations
automl
cloudbuild
cloudcontrolspartner
composer
containeranalysis
datastore
eventarc
functions
iap
language
metastore
networkconnectivity
networkservices
policytroubleshooter
profiler
redis
securitycenter
servicedirectory
tpu
trace
vision
workflows
)
if [[ "${{ matrix.shard }}" == "Core1" ]]; then
features="$(printf ",%s" "${core1_features[@]}")"
echo "features=${features:1}" >> "${GITHUB_OUTPUT}"
elif [[ "${{ matrix.shard }}" == "Core2" ]]; then
features="$(printf ",%s" "${core2_features[@]}")"
echo "features=${features:1}" >> "${GITHUB_OUTPUT}"
elif [[ "${{matrix.shard}}" == "Compute" ]]; then
echo "features=compute" >> "${GITHUB_OUTPUT}"
elif [[ "${{matrix.shard}}" == "Shard1" ]]; then
features="$(printf ",%s" "${shard1_features[@]}")"
echo "features=${features:1}" >> "${GITHUB_OUTPUT}"
elif [[ "${{matrix.shard}}" == "Shard2" ]]; then
features="$(printf ",%s" "${shard2_features[@]}")"
echo "features=${features:1}" >> "${GITHUB_OUTPUT}"
elif [[ "${{matrix.shard}}" == "Shard3" ]]; then
features="$(printf ",%s" "${shard3_features[@]}")"
echo "features=${features:1}" >> "${GITHUB_OUTPUT}"
else
# The "-" before the first element gets consumed somewhere, so pad
# it out.
skipped_features=(null)
skipped_features+=("${core1_features[@]}")
skipped_features+=("${core2_features[@]}")
skipped_features+=(compute)
skipped_features+=("${shard1_features[@]}")
skipped_features+=("${shard2_features[@]}")
skipped_features+=("${shard3_features[@]}")
# We use vcpkg in this build, which ships with Protobuf v21.x.
# Both `asset` and `channel` require Protobuf >= 23.x to compile on
# Windows.
skipped_features+=(asset channel)
skipped="$(printf ",-%s" "${skipped_features[@]}")"
echo "features=__ga_libraries__,__experimental_libraries__,${skipped:2}" >> "${GITHUB_OUTPUT}"
fi
- name: Download and Install CMake
shell: bash
run: |
choco install -y cmake --version 3.29.2 || \
(sleep 60 ; choco install -y cmake --version 3.29.2) || \
(sleep 120 ; choco install -y cmake --version 3.29.2)
- name: Download and Install sccache
if: ${{ inputs.sccache-mode != 'DISABLED' }}
working-directory: "${{runner.temp}}"
shell: bash
run: |
curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.5.4/sccache-v0.5.4-x86_64-pc-windows-msvc.tar.gz | \
tar -zxf - --strip-components=1
chmod +x sccache.exe
mv sccache.exe /c/Users/runneradmin/.cargo/bin
- name: Download and Install vcpkg
shell: bash
run: |
cd "${TEMP}"
mkdir -p .build/vcpkg
curl -fsSL "https://github.com/microsoft/vcpkg/archive/${{ steps.dynamic.outputs.vcpkg-version }}.tar.gz" |
tar -C .build/vcpkg --strip-components=1 -zxf -
.build/vcpkg/bootstrap-vcpkg.sh -disableMetrics
# TODO(14314) - remove this VC Toolset workaround
echo "set(VCPKG_PLATFORM_TOOLSET_VERSION ${{ steps.vctoolset.outputs.toolset_version }})" >> .build/vcpkg/triplets/x64-windows.cmake
echo "set(VCPKG_PLATFORM_TOOLSET_VERSION ${{ steps.vctoolset.outputs.toolset_version }})" >> .build/vcpkg/triplets/x86-windows.cmake
# go/github-actions#gha-bestpractices explains why we use a SHA instead of
# a named version for this runner. We could avoid using this runner with the
# ideas from:
# https://github.com/microsoft/vswhere/wiki/Find-VC
# Note that in other runners the publisher is GitHub. If we trust GitHub
# to run the VM, we should trust their runners.
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # @v1.13.0
with:
arch: ${{ matrix.arch }}
# TODO(14314) - remove this VC Toolset workaround
toolset: ${{ steps.vctoolset.outputs.toolset_version }}
- name: Build google-cloud-cpp
shell: bash
run: |
export VCPKG_ROOT="${TEMP}/.build/vcpkg"
export CLOUDSDK_PYTHON="${{ steps.py311.outputs.python-path }}"
# Put the CMake output in a directory with more space and keep it short
# to avoid running into the MSVC limits.
export CMAKE_OUT='c:\b'
export EXECUTE_INTEGRATION_TESTS=${{ inputs.execute-integration-tests }}
ci/gha/builds/windows-cmake.sh ${{ matrix.build_type }} ${{ steps.dynamic.outputs.features }}
env:
SCCACHE_GCS_BUCKET: cloud-cpp-community-gha-cache
SCCACHE_GCS_KEY_PREFIX: sccache/${{ matrix.msvc }}/${{ matrix.arch}}/${{ matrix.build_type }}
SCCACHE_GCS_RW_MODE: ${{ inputs.sccache-mode }}
SCCACHE_IGNORE_SERVER_IO_ERROR: 1
VCPKG_BINARY_SOURCES: x-gcs,gs://cloud-cpp-community-gha-cache/vcpkg-cache/${{ matrix.msvc }},${{ inputs.vcpkg-cache-mode }}
VCPKG_TRIPLET: ${{ matrix.arch }}-windows
GHA_TEST_BUCKET: "gcs-grpc-team-cloud-cpp-testing-bucket"