-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
484 lines (457 loc) · 13.8 KB
/
.gitlab-ci.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
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
stages:
- check-format
- clippy
- ignored
- test
- additional-test
- bench
- release
- comparison
variables:
CARGO_HOME: $CI_PROJECT_DIR/.cargo
# Install additional packages, like a C compiler and cmake
#before_script:
#- apt-get update -yqq
#- apt-get install -yqq --no-install-recommends build-essential cmake
default:
before_script:
- cd crates
- sed -i s/'git.*=.*git@projects'/"git=\"https:\/\/gitlab-ci-token:${CI_JOB_TOKEN}@projects"/ rtlola-interpreter/Cargo.toml
- sed -i s/'git.*=.*git@projects'/"git=\"https:\/\/gitlab-ci-token:${CI_JOB_TOKEN}@projects"/ rtlola-io-plugins/Cargo.toml
- sed -i s/'git.*=.*git@projects'/"git=\"https:\/\/gitlab-ci-token:${CI_JOB_TOKEN}@projects"/ rtlola-cli/Cargo.toml
- sed -i s/'git.*=.*git@projects'/"git=\"https:\/\/gitlab-ci-token:${CI_JOB_TOKEN}@projects"/ rtlola-interpreter-macros/Cargo.toml
# Use cargo to check the source code formatting
format:cli:
stage: check-format
tags:
- docker
image: rustlang/rust:nightly
script:
- rustup component add rustfmt
- rustc --version && cargo --version # Print version info for debugging
- cargo fmt -p rtlola-cli --verbose -- --check
format:plugins:
stage: check-format
tags:
- docker
image: rustlang/rust:nightly
script:
- rustup component add rustfmt
- rustc --version && cargo --version # Print version info for debugging
- cargo fmt -p rtlola-io-plugins --verbose -- --check
# Use cargo to check the source code formatting
format:interpreter:
stage: check-format
tags:
- docker
image: rustlang/rust:nightly
script:
- rustup component add rustfmt
- rustc --version && cargo --version # Print version info for debugging
- cargo fmt -p rtlola-interpreter --verbose -- --check
format:macros:
stage: check-format
tags:
- docker
image: rustlang/rust:nightly
script:
- rustup component add rustfmt
- rustc --version && cargo --version # Print version info for debugging
- cargo fmt -p rtlola-interpreter-macros --verbose -- --check
# Use cargo to run clippy (Rust linter)
clippy:cli:
stage: clippy
tags:
- docker
image: rust:latest
needs: ["format:cli"]
cache:
key: "cli"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
script:
- rustup component add clippy
- rustc --version && cargo --version # Print version info for debugging
- cargo clippy -p rtlola-cli
clippy:plugins:
stage: clippy
tags:
- docker
image: rust:latest
needs: ["format:plugins"]
cache:
key: "plugins"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
script:
- rustup component add clippy
- rustc --version && cargo --version # Print version info for debugging
- cargo clippy -p rtlola-io-plugins --all-features
# Use cargo to run clippy (Rust linter)
clippy:interpreter:
stage: clippy
tags:
- docker
image: rust:latest
needs: ["format:interpreter"]
cache:
key: "interpreter"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
script:
- rustup component add clippy
- rustc --version && cargo --version # Print version info for debugging
- cargo clippy -p rtlola-interpreter
clippy:macros:
stage: clippy
tags:
- docker
image: rust:latest
needs: ["format:macros"]
cache:
key: "macros"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
script:
- rustup component add clippy
- rustc --version && cargo --version # Print version info for debugging
- cargo clippy -p rtlola-interpreter-macros
# Check that every ignored test has an accompanying comment
ignored:interpreter:
stage: ignored
tags:
- docker
image: alpine:latest
needs: ["clippy:interpreter"]
script:
- ./check_ignored_tests_without_comment.sh
allow_failure: true
# Use cargo to test the project on stable toolchain
test:interpreter:
stage: test
tags:
- docker
image: rust:latest
needs: ["ignored:interpreter"]
cache:
key: "interpreter"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends libpcap-dev
- rustc --version && cargo --version # Print version info for debugging
- cargo test -p rtlola-interpreter --all --verbose
test:macros:
stage: test
tags:
- docker
image: rust:latest
needs: ["clippy:macros"]
cache:
key: "macros"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends libpcap-dev
- rustc --version && cargo --version # Print version info for debugging
- cargo test -p rtlola-interpreter-macros --all --verbose
# Use cargo to test the project on stable toolchain
test:plugins:
stage: test
tags:
- docker
image: rust:latest
needs: ["clippy:plugins"]
cache:
key: "plugins"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends libpcap-dev
- rustc --version && cargo --version # Print version info for debugging
- cargo test -p rtlola-io-plugins --verbose --all-features
# Run the tool by checking the number of triggers fired
test:cli:
stage: test
tags:
- docker
image: rust:latest
needs: ["clippy:cli"]
cache:
key: "cli"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends libpcap-dev python3-pip
- pip3 install --break-system-packages junit-xml
- python3 ./rtlola-cli/rtlola-interpreter-e2e-tests.py
artifacts:
when: always
reports:
junit: crates/tests/e2e-results.xml
# Use cargo to test the project on stable toolchain on windows
test:windows:
stage: additional-test
tags:
- windows
- rust
needs: ["test:cli", "test:plugins", "test:interpreter", "test:macros"]
variables:
CARGO_HOME: "C:\\Users\\react\\.cargo"
before_script:
- cd crates
- (get-content rtlola-cli\Cargo.toml) | %{$_ -replace "git.*=.*git@projects","git=`"https://gitlab-ci-token:${CI_JOB_TOKEN}@projects"} | set-content rtlola-cli\Cargo.toml
- (get-content rtlola-io-plugins\Cargo.toml) | %{$_ -replace "git.*=.*git@projects","git=`"https://gitlab-ci-token:${CI_JOB_TOKEN}@projects"} | set-content rtlola-io-plugins\Cargo.toml
- (get-content rtlola-interpreter\Cargo.toml) | %{$_ -replace "git.*=.*git@projects","git=`"https://gitlab-ci-token:${CI_JOB_TOKEN}@projects"} | set-content rtlola-interpreter\Cargo.toml
- (get-content rtlola-interpreter-macros\Cargo.toml) | %{$_ -replace "git.*=.*git@projects","git=`"https://gitlab-ci-token:${CI_JOB_TOKEN}@projects"} | set-content rtlola-interpreter-macros\Cargo.toml
- rustup update
- rustc --version
- cargo --version
script:
- cargo test -p rtlola-cli
- cargo test -p rtlola-io-plugins --no-default-features --features csv_plugin
- cargo test -p rtlola-interpreter
- cargo test -p rtlola-interpreter-macros
# Use cargo to test the project on nightly toolchain
test:nightly:
stage: additional-test
tags:
- docker
image: rustlang/rust:nightly
needs: ["test:cli", "test:plugins", "test:interpreter", "test:macros"]
cache:
key: "build-nightly"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
variables:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "json5format-%m.profraw"
script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends libpcap-dev python3-junit.xml
- cargo install cargo2junit
- curl -L https://github.com/mozilla/grcov/releases/download/v0.6.1/grcov-linux-x86_64.tar.bz2 | tar jxf -
- rustup component add llvm-tools-preview
- (rm -r ./target/debug/coverage/) || true
- rustc --version && cargo --version # Print version info for debugging
- (cargo test -- -Z unstable-options --format json | $CARGO_HOME/bin/cargo2junit > results.xml) || true # ignore the return code so that we can show the complete output (including ignored tests)
- python3 ./rtlola-cli/rtlola-interpreter-e2e-tests.py || true # count the e2e test for coverage but keep going
- ./grcov . --ignore ".cargo/*" --binary-path ./target/debug/ -s . -t html --branch --ignore-not-existing --llvm -o ./target/debug/coverage/
- cat ./target/debug/coverage/index.html
- cargo test --all --verbose
allow_failure: true
coverage: '/linesPercentage \w+">\d+\.\d+ /'
artifacts:
when: always
paths:
- crates/target/debug/coverage/
reports:
junit: crates/results.xml
test:online_e2e:
stage: additional-test
only:
- merge_requests
- pipelines
- tags
- web
tags:
- docker
image: rust:latest
cache:
key: "cli"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends libpcap-dev python3-pip
- pip3 install --break-system-packages junit-xml
- python3 ./rtlola-cli/rtlola-interpreter-e2e-tests.py --online
artifacts:
when: always
reports:
junit: crates/tests/e2e-results.xml
test:wasm:
stage: additional-test
needs: ["test:cli", "test:plugins", "test:interpreter", "test:macros"]
tags:
- docker
image: rust:latest
cache:
key: "wasm"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
script:
- rustup target add wasm32-unknown-unknown
- rustc --version
- cargo --version
- cargo check -p rtlola-interpreter --target wasm32-unknown-unknown --no-default-features
## Use cargo to run the benchmarks
#cargo:bench:
# stage: bench
# only:
# - merge_requests
# - pipelines
# - tags
# - web
# tags:
# - docker
# image: rustlang/rust:nightly
# needs: ["test:windows", "test:nightly", "test:online_e2e"]
# cache:
# key: "build-nightly"
# policy: pull-push
# paths:
# - crates/target/
# - $CARGO_HOME
# script:
# - apt-get update -yqq
# - apt-get install -yqq --no-install-recommends libpcap-dev
# - rustc --version && cargo --version # Print version info for debugging
# - cargo bench --quiet | grep -e 'bench:' | tee bench_results.txt # TODO: actually compare the results
# - sed s/'test '// bench_results.txt | sed -e s/' ... bench:'// | sed -e s/,//g | sed -e "s|ns/iter.*$||" > metrics.txt
# artifacts:
# name: "bench_results"
# paths:
# - bench_results.txt
# expire_in: 5 yrs
# reports:
# metrics: metrics.txt
# allow_failure: true
# For the release build we do not use the Cargo.lock file, because we haven't investigated how it interacts with different platforms.
# Windows, Linux, and MacOS could resolve to different Cargo.lock files.
# However, we keep the Cargo.lock files as artifacts.
#release-windows:
# stage: release
# only:
# - tags
# - web
# - triggers
# tags:
# - windows
# - rust
# variables:
# RUSTFLAGS: "-C target-feature=+crt-static"
# before_script:
# - (get-content Cargo.toml) | %{$_ -replace "git@projects","gitlab-ci-token:${CI_JOB_TOKEN}@projects"} | set-content Cargo.toml
# - rustup update
# - rustc --version
# - cargo --version
# script:
# - rustup run stable-msvc cargo build --release --target x86_64-pc-windows-msvc --features public
# artifacts:
# name: "rtlola-interpreter-windows-${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}"
# paths:
# - target/x86_64-pc-windows-msvc/release/rtlola-interpreter.exe
# - Cargo.lock
#release-windows-gnu:
# stage: release
# only:
# - tags
# - web
# - triggers
# tags:
# - windows
# - rust
# before_script:
# - cd evaluator
# - rustup update
# - rustc --version && cargo --version # Print version info for debugging
# script:
# - rustup run stable-gnu cargo build --release --target x86_64-pc-windows-gnu --features public
# artifacts:
# name: "rtlola-interpreter-windows-gnu-${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}"
# paths:
# - target/x86_64-pc-windows-gnu/release/rtlola-interpreter.exe
# - Cargo.lock
release-linux:
stage: release
tags:
- docker
image: rust:latest
rules:
- if: $CI_COMMIT_BRANCH == "development"
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
cache:
key: "cli"
policy: pull-push
paths:
- crates/target/
- $CARGO_HOME
script:
- cd rtlola-cli
- rustc --version && cargo --version # Print version info for debugging
- cargo update
- cargo build --release --features public
artifacts:
name: "rtlola-cli-linux-${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}"
paths:
- crates/target/release/rtlola-cli
comparison-merge-request:
stage: comparison
needs: ["release-linux"]
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
variables:
INTERPRETER_REF: $CI_MERGE_REQUEST_REF_PATH
trigger:
project: group-finkbeiner/tools/RTLola/rtlola-backends-comparison
branch: main
comparison-branch:
stage: comparison
needs: ["release-linux"]
rules:
- if: $CI_COMMIT_BRANCH == "development"
- if: $CI_COMMIT_BRANCH == "main"
variables:
INTERPRETER_REF: $CI_COMMIT_BRANCH
trigger:
project: group-finkbeiner/tools/RTLola/rtlola-backends-comparison
branch: main
#release-macos:
# stage: release
# only:
# - tags
# - web
# - triggers
# tags:
# - macos
# variables:
# MACOSX_DEPLOYMENT_TARGET: "10.7"
# before_script:
# - cd evaluator
# - rustup update
# - rustc --version && cargo --version # Print version info for debugging
# script:
# - rustup run stable-msvc cargo build --release --target x86_64-apple-darwin --features public
# artifacts:
# name: "rtlola-interpreter-macos-${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}"
# paths:
# - target/x86_64-apple-darwin/release/rtlola-interpreter
# - Cargo.lock