-
Notifications
You must be signed in to change notification settings - Fork 27
251 lines (222 loc) · 9.55 KB
/
ci-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
name: Bazel CI
on:
workflow_call:
secrets:
BUILDBUDDY_ORG_API_KEY:
required: false
# Not using 'inputs' here, since we take no inputs at this time -- just the 'github' context.
# Note: on type workflow_run commit message would be github.event.workflow_run.head_commit.message
# https://stackoverflow.com/a/63619526
# Available data: https://stackoverflow.com/a/75715955
run-name: "@${{github.actor}} Bazel CI on ${{ github.ref_name }} - ${{ github.event.head_commit.message }}"
jobs:
bazel_build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, which is the CWD for
# the rest of the steps
- uses: actions/checkout@v4
with:
submodules: true
# Caches and restores the bazel build directory.
- name: Cache bazel build results
uses: actions/cache@v4
env:
cache-name: bazel-cache
with:
path: ~/.cache/bazel
key: bazel-${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
restore-keys: |
bazel-${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
bazel-${{ runner.os }}-${{ env.cache-name }}-master
bazel-${{ runner.os }}-${{ env.cache-name }}-
bazel-${{ runner.os }}-
${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
${{ runner.os }}-${{ env.cache-name }}-master
- if: ${{ steps.bazel-cache.outputs.cache-hit != 'true' }}
name: Print a stub message when there is a cache miss
continue-on-error: true
run: echo Stub action merely printing a notice that there was a cache miss
# More useful with e.g. npm.
- name: install deps without prebuilt SDL (bazel)
run: sudo apt-get update && sudo apt-get install autoconf automake libgl1-mesa-dev libglu1-mesa-dev libx11-dev libxext-dev libxrandr-dev libxrender-dev libasound-dev libalsaplayer-dev
- name: bazel build
run: bazel build //:yatc
bazel_test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: minimal test
bazel_target: //:minimal_test
- name: util test
bazel_target: //:util_test
needs: [bazel_build]
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, which is the CWD for
# the rest of the steps
- uses: actions/checkout@v4
with:
submodules: true
# Caches and restores the bazel build directory.
- name: Cache bazel build results
uses: actions/cache@v4
env:
cache-name: bazel-cache
with:
path: ~/.cache/bazel
key: bazel-${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
restore-keys: |
bazel-${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
bazel-${{ runner.os }}-${{ env.cache-name }}-master
bazel-${{ runner.os }}-${{ env.cache-name }}-
bazel-${{ runner.os }}-
${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
${{ runner.os }}-${{ env.cache-name }}-master
- if: ${{ steps.bazel-cache.outputs.cache-hit != 'true' }}
name: Print a stub message when there is a cache miss
continue-on-error: true
run: echo Stub action merely printing a notice that there was a cache miss
# More useful with e.g. npm.
- name: install deps without prebuilt SDL (bazel)
run: sudo apt-get update && sudo apt-get install autoconf automake libgl1-mesa-dev libglu1-mesa-dev libx11-dev libxext-dev libxrandr-dev libxrender-dev libasound-dev libalsaplayer-dev
- name: bazel test
run: bazel test ${{ matrix.bazel_target }}
- name: Upload test report
uses: actions/upload-artifact@v4
if: always() # Run even if the previous step fails
with:
name: junit-test-results-regular-${{ matrix.name }}
path: 'bazel-testlogs/**/test.xml'
# TODO: bazel-testlogs/name-of-test has also:
# * test.outputs/
# * test.outputs_manifest/
# * test.log
# * test.raw_splitlogs/
# * test.cache_status
# but they might not be worth uploading at this time.
retention-days: 90 # Maximum is 90d, default is repo settings.
- name: Upload test log
uses: actions/upload-artifact@v4
if: always() # Run even if the previous step fails
with:
name: junit-test-logs-regular-${{ matrix.name }}
path: 'bazel-testlogs/**/test.log'
# This fails unless there's write permission in the token. Hence the attempt
# to run as triggered by these workflows in another job, which might then
# work on pull requests as well. This needs further investigation.
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure() # always run even if the previous step fails
with:
commit: ${{github.event.workflow_run.head_sha}} # remove if we don't use separate workflow
report_paths: 'bazel-testlogs/**/test.xml'
continue-on-error: true
bazel_build_buildbuddy:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, which is the CWD for
# the rest of the steps
- uses: actions/checkout@v4
with:
submodules: true
# Caches and restores the bazel build directory.
- name: Cache bazel build results
uses: actions/cache@v4
env:
cache-name: bazel-cache
with:
path: ~/.cache/bazel
key: bazel-${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
restore-keys: |
bazel-${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
bazel-${{ runner.os }}-${{ env.cache-name }}-master
bazel-${{ runner.os }}-${{ env.cache-name }}-
bazel-${{ runner.os }}-
${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
${{ runner.os }}-${{ env.cache-name }}-master
- if: ${{ steps.bazel-cache.outputs.cache-hit != 'true' }}
name: Print a stub message when there is a cache miss
continue-on-error: true
run: echo Stub action merely printing a notice that there was a cache miss
# More useful with e.g. npm.
- name: rbe bazel build
run: bazel build --config=remote --build_metadata=ROLE=CI ${BUILDBUDDY_ORG_API_KEY:+--remote_header=x-buildbuddy-api-key=${BUILDBUDDY_ORG_API_KEY}} //:yatc
bazel_test_buildbuddy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: minimal test
bazel_target: //:minimal_test
- name: util test
bazel_target: //:util_test
needs: [bazel_build_buildbuddy]
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, which is the CWD for
# the rest of the steps
- uses: actions/checkout@v4
with:
submodules: true
# Caches and restores the bazel build directory.
- name: Cache bazel build results
uses: actions/cache@v4
env:
cache-name: bazel-cache
with:
path: ~/.cache/bazel
key: bazel-${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
restore-keys: |
bazel-${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
bazel-${{ runner.os }}-${{ env.cache-name }}-master
bazel-${{ runner.os }}-${{ env.cache-name }}-
bazel-${{ runner.os }}-
${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
${{ runner.os }}-${{ env.cache-name }}-master
- if: ${{ steps.bazel-cache.outputs.cache-hit != 'true' }}
name: Print a stub message when there is a cache miss
continue-on-error: true
run: echo Stub action merely printing a notice that there was a cache miss
# More useful with e.g. npm.
- name: rbe bazel test
run: bazel test --config=remote --build_metadata=ROLE=CI ${BUILDBUDDY_ORG_API_KEY:+--remote_header=x-buildbuddy-api-key=${BUILDBUDDY_ORG_API_KEY}} ${{ matrix.bazel_target }}
# Temporarily allow errors. This is known to fail at this time due to insufficient
# number of binary packages installed by the rules_libsdl12.
continue-on-error: true
env:
BUILDBUDDY_ORG_API_KEY: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
- name: Upload test report
uses: actions/upload-artifact@v4
if: always() # Run even if the previous step fails
with:
name: junit-test-results-buildbuddy-${{ matrix.name }}
path: 'bazel-testlogs/**/test.xml'
# TODO: bazel-testlogs/name-of-test has also:
# * test.outputs/
# * test.outputs_manifest/
# * test.log
# * test.raw_splitlogs/
# * test.cache_status
# but they might not be worth uploading at this time.
retention-days: 90 # Maximum and default is 90d but can be shortened.
- name: Upload test log
uses: actions/upload-artifact@v4
if: always() # Run even if the previous step fails
with:
name: junit-test-logs-buildbuddy-${{ matrix.name }}
path: 'bazel-testlogs/**/test.log'
- name: print ldd
run: ldd bazel-bin/util_test
continue-on-error: true
# This fails unless there's write permission in the token. Hence the attempt
# to run as triggered by these workflows in another job, which might then
# work on pull requests as well. This needs further investigation.
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure() # always run even if the previous step fails
with:
commit: ${{github.event.workflow_run.head_sha}} # remove if we don't use separate workflow
report_paths: 'bazel-testlogs/**/test.xml'
continue-on-error: true