-
Notifications
You must be signed in to change notification settings - Fork 1.2k
345 lines (293 loc) · 11.8 KB
/
build_test.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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# Copyright 2021 Google Inc. All Rights Reserved.
#
# Distributed under MIT license.
# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
# Workflow for building and running tests under Ubuntu
name: Build/Test
on:
push:
branches:
- master
pull_request:
types: [opened, reopened, labeled, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
ubuntu_build:
name: Build and test ${{ matrix.name }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
# TODO: consider running this combination in docker
#- name: cmake:gcc4.4
# TODO: consider running this combination in docker
#- name: cmake:gcc7
- name: cmake:gcc9
build_system: cmake
c_compiler: gcc-9
cxx_compiler: g++-9
os: ubuntu-20.04
# TODO: consider running this combination in docker
#- name: cmake:clang3.5
- name: cmake:clang15
build_system: cmake
c_compiler: clang-15
cxx_compiler: clang++15
- name: cmake:clang15:asan
build_system: cmake
sanitizer: address
c_compiler: clang-15
cxx_compiler: clang++15
- name: cmake:clang15:tsan
build_system: cmake
sanitizer: thread
c_compiler: clang-15
cxx_compiler: clang++15
- name: cmake:clang15:ubsan
build_system: cmake
sanitizer: undefined
c_compiler: clang-15
cxx_compiler: clang++-15
c_flags: -fno-sanitize-recover=undefined,integer
- name: cmake:qemu-arm-neon-gcc
build_system: cmake
c_compiler: arm-linux-gnueabihf-gcc
cxx_compiler: arm-linux-gnueabihf-g++
c_flags: -march=armv7-a -mfloat-abi=hard -mfpu=neon
extra_apt_pkgs: gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user
- name: cmake-osx:clang
build_system: cmake
c_compiler: clang
cxx_compiler: clang++
os: macos-latest
- name: cmake-osx:gcc
build_system: cmake
c_compiler: gcc
cxx_compiler: g++
os: macos-latest
- name: cmake-win64:msvc-rel
build_system: cmake
cmake_generator: Visual Studio 17 2022
cmake_config: Release
os: windows-latest
- name: cmake-win64:msvc-dbg
build_system: cmake
cmake_generator: Visual Studio 17 2022
cmake_config: Debug
os: windows-latest
- name: fuzz:clang15
build_system: fuzz
c_compiler: clang-15
cxx_compiler: clang++15
# TODO: consider running this combination in docker
#- name: python2.7:gcc5
# TODO: consider running this combination in docker
#- name: python27:clang9
# build_system: python
# c_compiler: clang-9
# python_version: 2.7
# cxx_compiler: clang++-9
# os: ubuntu-20.04
# TODO: consider running this combination in docker
#- name: python27-win
# build_system: python
# python_version: 2.7
# # TODO: investigate why win-builds can't run tests
# py_setuptools_cmd: build_ext
# os: windows-2016
# TODO: consider running this combination in docker
#- name: python3.6:gcc5
# TODO: consider running this combination in docker
#- name: python3.7:gcc5
# TODO: consider running this combination in docker
#- name: python3.8:gcc5
- name: python3.10:clang15
build_system: python
python_version: "3.10"
c_compiler: clang-15
cxx_compiler: clang++-15
- name: python3.10-win
build_system: python
python_version: "3.10"
# TODO: investigate why win-builds can't run tests
py_setuptools_cmd: build_ext
os: windows-2019
- name: maven
build_system: maven
- name: bazel:root
build_system: bazel
bazel_project: .
- name: bazel:go
build_system: bazel
bazel_project: go
- name: bazel:java
build_system: bazel
bazel_project: java
- name: bazel:research
build_system: bazel
bazel_project: research
- name: bazel-osx:root
build_system: bazel
bazel_project: .
os: macos-latest
- name: bazel-osx:go
build_system: bazel
bazel_project: go
os: macos-latest
- name: bazel-osx:java
build_system: bazel
bazel_project: java
os: macos-latest
- name: bazel-osx:research
build_system: bazel
bazel_project: research
os: macos-latest
- name: bazel-win:root
build_system: bazel
bazel_project: .
os: windows-latest
# TODO: use single dll on windows, otherwise it fails to link
#- name: bazel-win:go
# build_system: bazel
# bazel_project: go
# os: windows-latest
- name: bazel-win:java
build_system: bazel
bazel_project: java
os: windows-latest
- name: bazel-win:research
build_system: bazel
bazel_project: research
os: windows-latest
env:
CC: ${{ matrix.c_compiler || 'gcc' }}
CXX: ${{ matrix.cxx_compiler || 'gcc' }}
steps:
- name: Install extra deps @ Ubuntu
if: ${{ runner.os == 'Linux' }}
# Already installed: bazel, clang{13-15}, cmake, gcc{9.5-13.1}, java{8,11,17,21}, maven, python{3.10}
run: |
EXTRA_PACKAGES="${{ matrix.extra_apt_pkgs || '' }}"
sudo apt update
sudo apt install -y ${EXTRA_PACKAGES}
- name: Checkout the source
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
submodules: false
fetch-depth: 1
#- name: Checkout VC9 for Python
# if: ${{ runner.os == 'Windows' && matrix.build_system == 'python' && matrix.python_version == '2.7' }}
# uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
# with:
# repository: reider-roque/sulley-win-installer
# path: third_party/VCForPython27
- name: Configure / Build / Test with CMake
if: ${{ matrix.build_system == 'cmake' }}
run: |
export ASAN_OPTIONS=detect_leaks=0
declare -a CMAKE_OPTIONS=()
CMAKE_OPTIONS+=("-DCMAKE_VERBOSE_MAKEFILE=ON")
[ ! -z '${{ matrix.c_compiler || '' }}' ] && CMAKE_OPTIONS+=(-DCMAKE_C_COMPILER='${{ matrix.c_compiler }}')
[ ! -z '${{ matrix.cxx_compiler || '' }}' ] && CMAKE_OPTIONS+=(-DCMAKE_CXX_COMPILER='${{ matrix.cxx_compiler }}')
[ ! -z '${{ matrix.sanitizer || '' }}' ] && CMAKE_OPTIONS+=(-DENABLE_SANITIZER='${{ matrix.sanitizer }}')
[ ! -z '${{ matrix.cmake_generator || '' }}' ] && export CMAKE_GENERATOR='${{ matrix.cmake_generator }}'
declare -a CMAKE_BUILD_OPTIONS=()
[ ! -z '${{ matrix.cmake_config || '' }}' ] && CMAKE_BUILD_OPTIONS+=(--config '${{ matrix.cmake_config }}')
declare -a CMAKE_TEST_OPTIONS=()
[ ! -z '${{ matrix.cmake_config || '' }}' ] && CMAKE_TEST_OPTIONS+=(-C '${{ matrix.cmake_config }}')
cmake -B out . ${CMAKE_OPTIONS[*]} -DCMAKE_C_FLAGS='${{ matrix.c_flags || '' }}'
cmake --build out ${CMAKE_BUILD_OPTIONS[*]}
cd out; ctest ${CMAKE_TEST_OPTIONS[*]}; cd ..
- name: Quick Fuzz
if: ${{ matrix.build_system == 'fuzz' }}
run: |
mkdir ${RUNNER_TEMP}/decode_corpora
unzip java/org/brotli/integration/fuzz_data.zip -d ${RUNNER_TEMP}/decode_corpora
cd ${GITHUB_WORKSPACE}/c/fuzz
bazelisk build --config=asan-libfuzzer :decode_fuzzer
for f in `ls ${RUNNER_TEMP}/decode_corpora`
do
echo "Testing $f"
./bazel-bin/decode_fuzzer_bin ${RUNNER_TEMP}/decode_corpora/$f
done
- name: Build with Bazel
if: ${{ matrix.build_system == 'bazel' }}
run: |
cd ${GITHUB_WORKSPACE}/${{ matrix.bazel_project }}
bazelisk build -c opt ...:all
- name: Fix symlinks for Bazel (Windows)
if: ${{ matrix.build_system == 'bazel' && runner.os == 'Windows' && matrix.bazel_project == 'java' }}
shell: python
run: |
import fnmatch
import os
import os.path
from shutil import copyfile
os.chdir('${{ matrix.bazel_project }}')
print('Searching for manifests in ' + os.getcwd())
matches = []
for root, dirnames, filenames in os.walk('bazel-bin\\org\\brotli'):
for filename in fnmatch.filter(filenames, '*.runfiles_manifest'):
matches.append(os.path.join(root, filename))
for match in matches:
print('Scanning manifest ' + match)
runfiles = match[:-len('_manifest')]
with open(match) as manifest:
for entry in manifest:
entry = entry.strip()
if not entry.startswith("_main"):
continue
if entry.startswith("_main/external"):
continue
(alias, space, link) = entry.partition(' ')
if alias.endswith('.jar') or alias.endswith('.exe'):
continue
link = link.replace('/', '\\')
alias = alias.replace('/', '\\')
dst = os.path.join(runfiles, alias)
if not os.path.exists(dst):
print(link + ' -> ' + dst)
parent = os.path.dirname(dst)
if not os.path.exists(parent):
os.makedirs(parent)
copyfile(link, dst)
print('Finished resolving symlinks')
- name: Test with Bazel
if: ${{ matrix.build_system == 'bazel' }}
run: |
cd ${GITHUB_WORKSPACE}/${{ matrix.bazel_project }}
bazelisk query "tests(...)" --output=label > ${RUNNER_TEMP}/tests.lst
[ -s ${RUNNER_TEMP}/tests.lst ] && bazelisk test -c opt ...:all
bazelisk clean
- name: Build / Test with Maven
if: ${{ matrix.build_system == 'maven' }}
run: |
export MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
cd java/org/brotli
mvn -B install
# TODO(eustas): nuke maven build?
# cd integration
# mvn -B verify
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
if: ${{ matrix.build_system == 'python' }}
with:
python-version: ${{ matrix.python_version }}
# TODO: investigate, why msiexec hangs
#- name: Install VC9 for Python
# if: ${{ runner.os == 'Windows' && matrix.build_system == 'python' && matrix.python_version == '2.7' }}
# run: |
# echo "070474db76a2e625513a5835df4595df9324d820f9cc97eab2a596dcbc2f5cbf third_party/VCForPython27/VCForPython27.msi" | sha256sum --check --status
# msiexec ALLUSERS=1 /qn /norestart /i third_party/VCForPython27/VCForPython27.msi /l*v ${RUNNER_TEMP}/msiexec.log
# cat ${RUNNER_TEMP}/msiexec.log
- name: Build / Test with Python
if: ${{ matrix.build_system == 'python' }}
run: |
python -VV
python -c "import sys; sys.exit('Invalid python version') if '.'.join(map(str,sys.version_info[0:2])) != '${{ matrix.python_version }}' else True"
python setup.py ${{ matrix.py_setuptools_cmd || 'test'}}