forked from wpilibsuite/allwpilib
-
Notifications
You must be signed in to change notification settings - Fork 0
325 lines (256 loc) · 13 KB
/
bazel.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
name: Bazel
on: [pull_request, push]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build-windows:
strategy:
fail-fast: false
matrix:
include:
- { name: "Windows (native)", os: windows-2022, action: "test", config: "--config=windows --noenable_bzlmod", }
- { name: "Windows (bzlmod)", os: windows-2022, action: "test", config: "--config=windows --enable_bzlmod", }
- { name: "Windows (arm)", os: windows-2022, action: "build", config: "--config=windows_arm --noenable_bzlmod", }
- { name: "Windows (arm bzlmod)", os: windows-2022, action: "build", config: "--config=windows_arm --enable_bzlmod", }
- { name: "Windows (roborio)", os: windows-2022, action: "build", config: "--config=roborio --noenable_bzlmod", }
# - { name: "Windows (roborio bzlmod)", os: windows-2022, action: "build", config: "--config=roborio --enable_bzlmod", }
- { name: "Windows (bullseye32)", os: windows-2022, action: "build", config: "--config=bullseye32 --noenable_bzlmod", }
- { name: "Windows (bullseye32 bzlmod)", os: windows-2022, action: "build", config: "--config=bullseye32 --enable_bzlmod", }
- { name: "Windows (bullseye64)", os: windows-2022, action: "build", config: "--config=bullseye64 --noenable_bzlmod", }
- { name: "Windows (bullseye64 bzlmod)", os: windows-2022, action: "build", config: "--config=bullseye64 --enable_bzlmod", }
- { name: "Windows (raspi32)", os: windows-2022, action: "build", config: "--config=raspi32 --noenable_bzlmod", }
- { name: "Windows (raspi32 bzlmod)", os: windows-2022, action: "build", config: "--config=raspi32 --enable_bzlmod", }
name: "Build ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
architecture: x64
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
- name: Build Release allowing failures
run: bazel --output_user_root=C:\\bazelroot build -k ... -c opt --config=ci ${{ matrix.config }} --nojava_header_compilation --verbose_failures || true
shell: bash
- name: Build Release
run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... -c opt --config=ci ${{ matrix.config }} --nojava_header_compilation --verbose_failures
shell: bash
- name: Build Debug allowing failures
run: bazel --output_user_root=C:\\bazelroot build -k ... -c dbg --config=ci ${{ matrix.config }} --nojava_header_compilation --verbose_failures || true
shell: bash
# TODO enable. Unit test is failing
# - name: Build Debug
# run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... -c dbg --config=ci ${{ matrix.config }} --nojava_header_compilation --verbose_failures
# shell: bash
build-mac:
strategy:
fail-fast: false
matrix:
include:
- { name: "Mac (native)", os: macos-14, action: "test", config: "--config=macos --noenable_bzlmod", }
- { name: "Mac (bzlmod)", os: macos-14, action: "test", config: "--config=macos --enable_bzlmod" }
- { name: "Mac (roborio)", os: macos-14, action: "build", config: "--config=roborio --noenable_bzlmod", }
- { name: "Mac (roborio bzlmod)", os: macos-14, action: "build", config: "--config=roborio --enable_bzlmod" }
- { name: "Mac (bullseye32)", os: macos-14, action: "build", config: "--config=bullseye32 --noenable_bzlmod", }
- { name: "Mac (bullseye32 bzlmod)", os: macos-14, action: "build", config: "--config=bullseye32 --enable_bzlmod" }
- { name: "Mac (bullseye64)", os: macos-14, action: "build", config: "--config=bullseye64 --noenable_bzlmod", }
- { name: "Mac (bullseye64 bzlmod)", os: macos-14, action: "build", config: "--config=bullseye64 --enable_bzlmod" }
- { name: "Mac (raspi32)", os: macos-14, action: "build", config: "--config=raspi32 --noenable_bzlmod", }
- { name: "Mac (raspi32 bzlmod)", os: macos-14, action: "build", config: "--config=raspi32 --enable_bzlmod" }
name: "${{ matrix.name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
- name: Build Release allowing failures
run: bazel build -k ... -c opt --config=ci ${{ matrix.config }} --nojava_header_compilation --verbose_failures || true
shell: bash
- name: Build Release
run: bazel ${{ matrix.action }} -k ... -c opt --config=ci ${{ matrix.config }} --nojava_header_compilation --verbose_failures
shell: bash
- name: Build Debug allowing failures
run: bazel build -k ... -c dbg --config=ci ${{ matrix.config }} --nojava_header_compilation --verbose_failures || true
shell: bash
- name: Build Debug
run: bazel ${{ matrix.action }} -k ... -c dbg --config=ci ${{ matrix.config }} --nojava_header_compilation --verbose_failures
shell: bash
# - name: Check Lockfile update
# run: git --no-pager diff --exit-code HEAD
build-linux:
strategy:
fail-fast: false
matrix:
include:
- { container: "wpilib/ubuntu-base:22.04", action: "test", artifact-name: "Linux (native)", config: "--config=linux --noenable_bzlmod", }
- { container: "wpilib/ubuntu-base:22.04", action: "test", artifact-name: "Linux (bzlmod)", config: "--config=linux --enable_bzlmod" }
- { container: "wpilib/ubuntu-base:22.04", action: "build", artifact-name: "Linux (roborio)", config: "--config=roborio --noenable_bzlmod", }
- { container: "wpilib/ubuntu-base:22.04", action: "build", artifact-name: "Linux (roborio bzlmod)", config: "--config=roborio --enable_bzlmod" }
- { container: "wpilib/ubuntu-base:22.04", action: "build", artifact-name: "Linux (bullseye32)", config: "--config=bullseye32 --noenable_bzlmod", }
- { container: "wpilib/ubuntu-base:22.04", action: "build", artifact-name: "Linux (bullseye32 bzlmod)", config: "--config=bullseye32 --enable_bzlmod" }
- { container: "wpilib/ubuntu-base:22.04", action: "build", artifact-name: "Linux (bullseye64)", config: "--config=bullseye64 --noenable_bzlmod", }
- { container: "wpilib/ubuntu-base:22.04", action: "build", artifact-name: "Linux (bullseye64 bzlmod)", config: "--config=bullseye64 --enable_bzlmod" }
- { container: "wpilib/ubuntu-base:22.04", action: "build", artifact-name: "Linux (raspi32)", config: "--config=raspi32 --noenable_bzlmod", }
- { container: "wpilib/ubuntu-base:22.04", action: "build", artifact-name: "Linux (raspi32 bzlmod)", config: "--config=raspi32 --enable_bzlmod" }
runs-on: ubuntu-22.04
name: "Build - ${{ matrix.artifact-name }}"
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: bazelbuild/setup-bazelisk@v3
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
- name: Build Release and allow failures
run: bazel build ... -c opt --config=ci ${{ matrix.config }} -k --verbose_failures || true
- name: Build Release and Test
run: bazel ${{ matrix.action }} ... -c opt --config=ci ${{ matrix.config }} -k --verbose_failures
- name: Build Debug and allow failures
run: bazel build ... -c dbg --config=ci ${{ matrix.config }} -k --verbose_failures || true
- name: Build Debug and Test
run: bazel ${{ matrix.action }} ... -c dbg --config=ci ${{ matrix.config }} -k --verbose_failures
repin-maven:
strategy:
fail-fast: false
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: bazel run --noenable_bzlmod @unpinned_maven//:pin
- run: git diff HEAD
- uses: actions/upload-artifact@v4
with:
name: Re-pinned maven
path: shared/bazel/deps/maven_install.json
build-sanitizers:
strategy:
fail-fast: false
matrix:
include:
- config: "tsan"
- config: "asan"
- config: "ubsan"
runs-on: ubuntu-22.04
container: wpilib/ubuntu-base:22.04
name: "Sanitizer ${{ matrix.config }}"
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: bazelbuild/setup-bazelisk@v3
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
- name: Build and Test
run: bazel test -k --config=ci --config=linux --noenable_bzlmod --config=${{ matrix.config }} //...
build-coverage:
runs-on: ubuntu-22.04
name: "Code Coverage"
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- name: Install LCOV
run: sudo apt-get install -y lcov
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
- name: Build, allow buildbudy failure
run: bazel coverage --config=ci --config=linux --noenable_bzlmod -k -- //... -//simulation/halsim_gui:halsim_gui-test -//sysid:sysid-test
- name: genhtml
run: |
genhtml bazel-out/_coverage/_coverage_report.dat -o coverage_report/combined
- uses: actions/upload-artifact@v4
with:
name: "Coverage"
path: coverage_report
buildifier:
name: "buildifier"
runs-on: ubuntu-22.04
steps:
- name: Set up Go 1.15.x
uses: actions/setup-go@v5
with:
go-version: 1.15.x
id: go
- name: Install Buildifier
run: |
cd $(mktemp -d)
GO111MODULE=on go get github.com/bazelbuild/buildtools/buildifier@6.0.0
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- name: Run buildifier
run: buildifier -warnings all --lint=fix -r .
- name: Check Output
run: git --no-pager diff --exit-code HEAD
- name: Generate diff
run: git diff HEAD > bazel-lint-fixes.patch
if: ${{ failure() }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-bazel-lint-fixes
path: bazel-lint-fixes.patch
if: ${{ failure() }}
unused_deps:
name: "unused_deps"
runs-on: ubuntu-22.04
steps:
- name: Set up Go 1.15.x
uses: actions/setup-go@v5
with:
go-version: 1.15.x
id: go
- uses: actions/checkout@v4
- name: Install Unused Deps
run: |
cd $(mktemp -d)
GO111MODULE=on go get github.com/bazelbuild/buildtools/unused_deps@5.1.0
- name: Install Buildozer
run: |
cd $(mktemp -d)
GO111MODULE=on go get github.com/bazelbuild/buildtools/buildozer@5.1.0
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
- name: Dump Platform Flag
run: |
echo "# Flags for unused deps" > user.bazelrc
echo "build --config=linux" >> user.bazelrc
echo "build --config=ci" >> user.bazelrc
echo "build --build_tag_filters=-wpi-cpp-gui" >> user.bazelrc
echo "build --test_tag_filters=-wpi-cpp-gui" >> user.bazelrc
echo "common --noenable_bzlmod" >> user.bazelrc
- name: Debug userrc
run: cat user.bazelrc
- name: Prep unused deps
run: bazel query --tool_tag=unused_deps --keep_going "kind('(kt|java|android)_*', //...)" || true
- name: Run unused deps
run: unused_deps -cquery //... > buildozer-cmds.sh
- name: Show unused deps
run: cat buildozer-cmds.sh
- uses: actions/upload-artifact@v4
with:
name: Upload Unused Deps Script
path: buildozer-cmds.sh
- name: Fix unused deps
run: chmod +x buildozer-cmds.sh && ./buildozer-cmds.sh
- name: Generate diff
run: git diff > bazel-unused-deps-fixes.patch
- name: Check Output
run: git --no-pager diff --exit-code HEAD
- uses: actions/upload-artifact@v4
with:
name: Upload Unused Deps Patch
path: bazel-unused-deps-fixes.patch
if: ${{ failure() }}