-
Notifications
You must be signed in to change notification settings - Fork 0
287 lines (251 loc) · 12.1 KB
/
ci-tests.yaml
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
---
# This workflow runs after a pull-request has been approved by a reviewer.
name: CI Tests
on:
pull_request:
types: [opened, synchronize, ready_for_review]
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
pre-commit:
# runs on github hosted runner
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
get-date:
# We use the date to label caches. A cache is a a "hit" if the date is the
# request binary and date are the same as what is stored in the cache.
# This essentially means the first job to run on a given day for a given
# binary will always be a "miss" and will have to build the binary then
# upload it as that day's binary to upload. While this isn't the most
# efficient way to do this, the alternative was to run take a hash of the
# `src` directory contents and use it as a hash. We found there to be bugs
# with the hash function where this task would timeout. This approach is
# simple, works, and still provides some level of caching.
runs-on: ubuntu-latest
outputs:
date: ${{ steps.date.outputs.date }}
steps:
- name: Get the current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
unittests-all-opt:
runs-on: [self-hosted, linux, x64]
if: github.event.pull_request.draft == false
container: ghcr.io/gem5/ubuntu-24.04_all-dependencies:latest
needs: [pre-commit, get-date] # only runs if pre-commit passes.
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
# Restore the cache if available. As this just builds the unittests
# we only obtain the cache and do not provide if if is not
# available.
- name: Cache build/ALL
uses: actions/cache/restore@v4
with:
path: build/ALL
key: testlib-build-all-${{ needs.get-date.outputs.date }}
restore-keys: |
testlib-build-all
- name: CI Unittests
working-directory: ${{ github.workspace }}
run: scons --no-compress-debug build/ALL/unittests.opt -j $(nproc)
- run: echo "This job's status is ${{ job.status }}."
testlib-quick-matrix:
runs-on: [self-hosted, linux, x64]
if: github.event.pull_request.draft == false
# In order to make sure the environment is exactly the same, we run in
# the same container we use to build gem5 and run the testlib tests. This
container: ghcr.io/gem5/ubuntu-24.04_all-dependencies:latest
needs: [pre-commit]
steps:
- uses: actions/checkout@v4
# Unfortunately the image doesn't have jq installed.
# We therefore need to install it as a step here.
- name: Install jq
run: apt update && apt install -y jq
- name: Get directories for testlib-quick
working-directory: ${{ github.workspace }}/tests
id: dir-matrix
run: echo "test-dirs-matrix=$(find gem5/* -type d -maxdepth 0 | jq -ncR '[inputs]')" >>$GITHUB_OUTPUT
- name: Get the build targets for testlib-quick-gem5-builds
working-directory: ${{ github.workspace }}/tests
id: build-matrix
run: echo "build-matrix=$(./main.py list --build-targets -q | jq -ncR '[inputs]')" >>$GITHUB_OUTPUT
outputs:
build-matrix: ${{ steps.build-matrix.outputs.build-matrix }}
test-dirs-matrix: ${{ steps.dir-matrix.outputs.test-dirs-matrix }}
clang-fast-compilation:
# gem5 binaries built in `quick-gem5-builds` always use GCC.
# Clang is more strict than GCC. This job checks that gem5 compiles
# with Clang. It compiles build/ALL/gem5.fast to maximize the change
# for compilation error to be exposed.
runs-on: [self-hosted, linux, x64]
if: github.event.pull_request.draft == false
container: ghcr.io/gem5/clang-version-18:latest
needs: [pre-commit]
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
- name: Clang Compilation
working-directory: ${{ github.workspace }}
run: scons build/ALL/gem5.fast -j $(nproc)
testlib-quick-gem5-builds:
runs-on: [self-hosted, linux, x64]
if: github.event.pull_request.draft == false
container: ghcr.io/gem5/ubuntu-24.04_all-dependencies:latest
needs: [pre-commit, testlib-quick-matrix, get-date]
strategy:
matrix:
build-target: ${{ fromJson(needs.testlib-quick-matrix.outputs.build-matrix) }}
steps:
- uses: actions/checkout@v4
- name: Cache build/ALL
uses: actions/cache@v4
if: ${{ endsWith(matrix.build-target, 'build/ALL/gem5.opt') }}
with:
path: build/ALL
key: testlib-build-all-${{ needs.get-date.outputs.date }}
restore-keys: |
testlib-build-all
- name: Build gem5
run: scons --no-compress-debug ${{ matrix.build-target }} -j $(nproc)
# Upload the gem5 binary as an artifact.
# Note: the "achor.txt" file is a hack to make sure the paths are
# preserverd in the artifact. The upload-artifact action finds the
# closest common directory and uploads everything relative to that.
# E.g., if we upload "build/ARM/gem5.opt" and "build/RISCV/gem5.opt"
# Then upload-artifact will upload "ARM/gem5.opt" and "RISCV/gem5.opt",
# stripping the "build" directory. By adding the "anchor.txt" file, we
# ensure the "build" directory is preserved.
- run: echo "anchor" > anchor.txt
- uses: actions/upload-artifact@v4
with:
name: ci-tests-${{ github.run_number }}-testlib-quick-all-gem5-builds
path: |
build/*/gem5.*
anchor.txt
retention-days: 7
testlib-quick-execution:
runs-on: [self-hosted, linux, x64]
if: github.event.pull_request.draft == false
container: ghcr.io/gem5/ubuntu-24.04_all-dependencies:latest
needs: [pre-commit, testlib-quick-matrix, testlib-quick-gem5-builds]
timeout-minutes: 360 # 6 hours
strategy:
fail-fast: false
matrix:
test-dir: ${{ fromJson(needs.testlib-quick-matrix.outputs.test-dirs-matrix) }}
steps:
- name: Clean runner
run: rm -rf ./* || true rm -rf ./.??* || true rm -rf ~/.cache || true
# Checkout the repository then download the gem5.opt artifact.
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ci-tests-${{ github.run_number }}-testlib-quick-all-gem5-builds
# Check that the gem5.opt artifact exists and is executable.
- name: Chmod gem5.{opt,debug,fast} to be executable
run: |
find . -name "gem5.opt" -exec chmod u+x {} \;
find . -name "gem5.debug" -exec chmod u+x {} \;
find . -name "gem5.fast" -exec chmod u+x {} \;
# Run the testlib quick tests in the given directory.
- name: Run "tests/${{ matrix.test-dir }}" TestLib quick tests
id: run-tests
working-directory: ${{ github.workspace }}/tests
run: ./main.py run --skip-build -vv -j$(nproc) ${{ matrix.test-dir }}
# Get the basename of the matrix.test-dir path (to name the artifact).
- name: Sanatize test-dir for artifact name
id: sanitize-test-dir
if: success() || failure()
run: echo "sanatized-test-dir=$(echo '${{ matrix.test-dir }}' | sed 's/\//-/g')" >> $GITHUB_OUTPUT
# Upload the tests/testing-results directory as an artifact.
- name: upload results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ci-tests-run-${{ github.run_number }}-attempt-${{ github.run_attempt }}-testlib-quick-${{ steps.sanitize-test-dir.outputs.sanatized-test-dir
}}-status-${{ steps.run-tests.outcome }}-output
path: tests/testing-results
retention-days: 30
pyunit:
runs-on: [self-hosted, linux, x64]
if: github.event.pull_request.draft == false
container: ghcr.io/gem5/ubuntu-24.04_all-dependencies:latest
needs: [pre-commit, testlib-quick-gem5-builds]
timeout-minutes: 30
steps:
# Checkout the repository then download the builds.
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ci-tests-${{ github.run_number }}-testlib-quick-all-gem5-builds
# Check that the gem5 binaries exist and are executable.
- name: Chmod gem5.{opt,debug,fast} to be executable
run: |
find . -name "gem5.opt" -exec chmod u+x {} \;
find . -name "gem5.debug" -exec chmod u+x {} \;
find . -name "gem5.fast" -exec chmod u+x {} \;
# Run the pyunit tests.
# Note: these are all quick tests.
- name: Run The pyunit tests
id: run-tests
working-directory: ${{ github.workspace }}/tests
run: ./main.py run --skip-build -vv -j$(nproc) pyunit
# Upload the tests/testing-results directory as an artifact.
- name: Upload pyunit test results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ci-tests-run-${{ github.run_number }}-attempt-${{ github.run_attempt }}-pyunit-status-${{ steps.run-tests.outcome }}-output
path: tests/testing-results
retention-days: 30
gpu-tests:
runs-on: [self-hosted, linux, x64]
container: ghcr.io/gem5/gcn-gpu:latest
timeout-minutes: 180
needs: [pre-commit, get-date]
steps:
- uses: actions/checkout@v4
# Obtain the cache if available. If not available this will upload
# this job's instance of the cache.
- name: Cache build/VEGA_X86
uses: actions/cache@v4
with:
path: build/VEGA_X86
key: testlib-build-vega-${{ needs.get-date.outputs.date }}
restore-keys: |
testlib-build-vega
# Build the VEGA_X86/gem5.opt binary.
- name: Build VEGA_X86/gem5.opt
run: scons --no-compress-debug build/VEGA_X86/gem5.opt -j`nproc`
# Run the GPU tests.
- name: Run Testlib GPU Tests
working-directory: ${{ github.workspace }}/tests
run: ./main.py run --skip-build -vvv -t $(nproc) --host gcn_gpu gem5/gpu
# Upload the tests/testing-results directory as an artifact.
- name: Upload results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ci-tests-run-${{ github.run_number }}-attempt-${{ github.run_attempt }}-gpu-status-${{ steps.run-tests.outcome }}-output
path: tests/testing-results
retention-days: 30
ci-tests:
# It is 'testlib-quick' which needs to pass for the pull request to be
# merged. This job is a dummy job that depends on all the other jobs.
runs-on: ubuntu-latest
needs:
- testlib-quick-execution
- pyunit
- clang-fast-compilation
- unittests-all-opt
- pre-commit
- gpu-tests
steps:
- run: echo "This job's status is ${{ job.status }}."