-
Notifications
You must be signed in to change notification settings - Fork 5
391 lines (330 loc) · 12.8 KB
/
workflow.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
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
name: linting-and-tests
on:
push:
branches:
- main
pull_request:
# Automatically stop old builds on the same branch/PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
jobs:
pre-commit-checks:
name: Pre-commit Checks
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Run pre-commit-conda
uses: quantco/pre-commit-conda@v1
mypy-typechecking:
name: Mypy Type Checks
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup mamba
uses: ./.github/actions/mamba
- name: Install repository
run: |
python -m pip install --no-build-isolation --no-deps --disable-pip-version-check -e .
micromamba run -n modyn pip install -r dev-requirements.txt
- name: Run mypy
run: mypy .
pylint:
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup mamba
uses: ./.github/actions/mamba
- name: Pylint
run: |
micromamba run -n modyn pylint --version
micromamba run -n modyn pylint modyn
unittests:
timeout-minutes: 25
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup mamba
uses: ./.github/actions/mamba
- name: Pytest
run: |
set -o pipefail
micromamba run -n modyn pytest modyn --cache-clear --cov-report=xml --cov-fail-under=82
- name: Upload codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
format:
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DoozyX/[email protected]
with:
source: "modyn"
extensions: "hpp,cpp"
clangFormatVersion: 16
tidy:
timeout-minutes: 60
runs-on: ubuntu-latest
env:
CLANG_TIDY: clang-tidy-15
RUN_CLANG_TIDY: run-clang-tidy-15
steps:
- uses: actions/checkout@v2
- name: Install clang-tidy
run: |
sudo apt update
sudo apt install -y clang-tidy-15
cmake --version
- name: Configure CMake
working-directory: ${{github.workspace}}
run: bash scripts/clang-tidy.sh build
- name: Run clang-tidy
working-directory: ${{github.workspace}}
run: bash scripts/clang-tidy.sh run_tidy
cpp_build_and_test:
name: Build + Test (C++)
runs-on: ubuntu-latest
timeout-minutes: 60
outputs:
line-coverage: ${{steps.run_test_with_coverage.outputs.LINE_COVERAGE}}
branch-coverage: ${{steps.run_test_with_coverage.outputs.BRANCH_COVERAGE}}
strategy:
fail-fast: false
matrix:
build-type: [Release, Debug]
compiler:
- { c: gcc, cxx: g++, version: 11 }
- { c: gcc, cxx: g++, version: 12 }
- { c: clang, cxx: clang++, version: 14 }
- { c: clang, cxx: clang++, version: 17, coverage: true }
include:
# Currently, there is a linking error with zlib if we use clang 16 for sanitizers
# Let's investigate this when clang > 14 is os default - one problem could be the external clang installation
- compiler: { c: clang, cxx: clang++, version: 14 }
build-type: Tsan
- compiler: { c: clang, cxx: clang++, version: 14 }
build-type: Asan
exclude:
# gcc-12 causes a false-positive memory error in release (https://github.com/google/googletest/issues/4108)
- compiler: { c: gcc, cxx: g++, version: 12 }
build-type: Release
env:
CC: ${{matrix.compiler.c}}-${{matrix.compiler.version}}
CXX: ${{matrix.compiler.cxx}}-${{matrix.compiler.version}}
CCACHE_BASEDIR: ${{github.workspace}}
steps:
- uses: actions/checkout@v2
- name: Install ccache
run: |
sudo apt update
sudo apt install -y ccache
- name: Install clang version
if: ${{ matrix.compiler.version > 14 }}
uses: KyleMayes/install-llvm-action@v1
with:
version: ${{ matrix.compiler.version }}.0
env: true
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}//build
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build
# fdebug-prefix-map is for ccache to not have absolute paths interfere with caching, see https://ccache.dev/manual/3.6.html#_compiling_in_different_directories
run: >
cmake ${{github.workspace}}
-DCMAKE_BUILD_TYPE=${{matrix.build-type}}
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_FLAGS="-fdebug-prefix-map=${{github.workspace}}/build=."
-DMODYN_BUILD_PLAYGROUND=ON
-DMODYN_BUILD_TESTS=ON
-DMODYN_BUILD_STORAGE=ON
-DMODYN_TEST_COVERAGE=${{matrix.compiler.coverage && 'ON' || 'OFF'}}
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --build . --target modyn modyn-test playground --config ${{matrix.build-type}} -- -j8
- name: Run tests
timeout-minutes: 20
working-directory: ${{github.workspace}}/build/modyn/tests
shell: bash
env:
{
"TSAN_OPTIONS": "halt_on_error=1",
"UBSAN_OPTIONS": "print_stacktrace=1:halt_on_error=1",
}
run: ./modyn-test
# The next two steps are solely related to creating coverage reports and will only run coverage in the compiler matrix is set to true
- name: Create Coverage Report
if: ${{ matrix.compiler.coverage && matrix.build-type == 'Debug' }}
working-directory: ${{github.workspace}}/build/modyn/tests
run: |
llvm-profdata-14 merge -sparse default.profraw -o tests.profdata
llvm-cov-14 report -instr-profile tests.profdata -object modyn-test -ignore-filename-regex="build\/" -ignore-filename-regex="\/test\/" -show-region-summary=false | tail -1 | sed 's/%//g' | tr -s " " > output.txt
llvm-cov-14 show -instr-profile tests.profdata -object modyn-test -format=html -output-dir=coverage -ignore-filename-regex="build\/" -ignore-filename-regex="\/test\/" -show-region-summary=false
echo ::set-output name=LINE_COVERAGE::"$(cat output.txt | cut -d ' ' -f 7)"
echo ::set-output name=BRANCH_COVERAGE::"$(cat output.txt | cut -d ' ' -f 10)"
id: run_test_with_coverage
- name: Upload HTML coverage report
if: ${{ matrix.compiler.coverage && matrix.build-type == 'Debug' }}
uses: actions/upload-artifact@v4
with:
name: coverage-results
path: ${{github.workspace}}/build/modyn/tests/coverage
cpp_coverage_main:
name: C++ Test Coverage (gets coverage of main branch, currently not main branch because no C++ on main)
runs-on: ubuntu-latest
timeout-minutes: 60
env:
CC: clang-17
CXX: clang++-17
outputs:
line-coverage: ${{steps.run_main_test_with_coverage.outputs.LINE_COVERAGE}}
branch-coverage: ${{steps.run_main_test_with_coverage.outputs.BRANCH_COVERAGE}}
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Install clang 17
uses: KyleMayes/install-llvm-action@v1
with:
version: 17.0
env: true
- name: Create Build Environment
run: |
cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build
run: >
cmake ${{github.workspace}} -DCMAKE_BUILD_TYPE=Debug
-DMODYN_BUILD_PLAYGROUND=ON -DMODYN_BUILD_TESTS=ON -DMODYN_BUILD_STORAGE=ON -DMODYN_TEST_COVERAGE=ON
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --build . --config Debug --target modyn modyn-test -- -j8
- name: Run tests
working-directory: ${{github.workspace}}/build/modyn/tests
shell: bash
run: ./modyn-test
- name: Create Coverage Report for main branch
working-directory: ${{github.workspace}}/build/modyn/tests
run: |
llvm-profdata-14 merge -sparse default.profraw -o tests.profdata
llvm-cov-14 report -instr-profile tests.profdata -object modyn-test -ignore-filename-regex="build\/" -ignore-filename-regex="\/test\/" -show-region-summary=false | tail -1 | sed 's/%//g' | tr -s " " > output.txt
echo ::set-output name=LINE_COVERAGE::"$(cat output.txt | cut -d ' ' -f 7)"
echo ::set-output name=BRANCH_COVERAGE::"$(cat output.txt | cut -d ' ' -f 10)"
id: run_main_test_with_coverage
cpp_comment_on_pr:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
name: Comment Coverage Results
needs: [cpp_build_and_test, cpp_coverage_main]
timeout-minutes: 5
steps:
- name: Calculate changes
shell: bash
run: |
echo ::set-output name=line-changes::"$(awk 'BEGIN {printf "%+.2f", ${{ needs.cpp_build_and_test.outputs.line-coverage }}-${{ needs.cpp_coverage_main.outputs.line-coverage }}; exit}')"
echo ::set-output name=branch-changes::"$(awk 'BEGIN {printf "%+.2f", ${{ needs.cpp_build_and_test.outputs.branch-coverage }}-${{ needs.cpp_coverage_main.outputs.branch-coverage }}; exit}')"
id: calculation
- name: Comment on PR
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
![Line Coverage: ${{ needs.cpp_build_and_test.outputs.line-coverage }}%](https://img.shields.io/badge/Line_Coverage-${{ needs.cpp_build_and_test.outputs.line-coverage }}%20%25-informational) <sup>(${{ steps.calculation.outputs.line-changes }} % to main)</sup>
![Branch Coverage: ${{ needs.cpp_build_and_test.outputs.branch-coverage }}%](https://img.shields.io/badge/Branch_Coverage-${{ needs.cpp_build_and_test.outputs.branch-coverage }}%20%25-informational) <sup>(${{ steps.calculation.outputs.branch-changes }} % to main)</sup>
### Integration Tests ###
# We have them in the same workflow because it's impossible to have a simple "if workflow A runs through completely, then workflow B should run" pipeline on Github currently
# Checks whether the base container works correctly.
dockerized-unittests:
timeout-minutes: 180
runs-on: ubuntu-latest
needs:
- pre-commit-checks
- mypy-typechecking
- pylint
- unittests
- cpp_build_and_test
- tidy
- format
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup base container
uses: ./.github/actions/base
- name: Setup dev-requirements and run pytest within container
run: docker run modynbase mamba run -n modyn bash -c "pip install -r dev-requirements.txt && echo Running pytest && pytest"
integrationtests-debug:
timeout-minutes: 180
runs-on: ubuntu-latest
needs:
- pre-commit-checks
- mypy-typechecking
- pylint
- unittests
- cpp_build_and_test
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Start docker compose and exit when tests run through
run: bash scripts/run_integrationtests.sh Debug
integrationtests-asan:
timeout-minutes: 180
runs-on: ubuntu-latest
needs:
- pre-commit-checks
- mypy-typechecking
- pylint
- unittests
- cpp_build_and_test
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Start docker compose and exit when tests run through
run: bash scripts/run_integrationtests.sh Asan
integrationtests-tsan:
timeout-minutes: 180
runs-on: ubuntu-latest
needs:
- pre-commit-checks
- mypy-typechecking
- pylint
- unittests
- cpp_build_and_test
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Start docker compose and exit when tests run through
run: bash scripts/run_integrationtests.sh Tsan
integrationtests-release:
timeout-minutes: 180
runs-on: ubuntu-latest
needs:
- pre-commit-checks
- mypy-typechecking
- pylint
- unittests
- cpp_build_and_test
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Start docker compose and exit when tests run through
run: bash scripts/run_integrationtests.sh Release