-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
95 lines (84 loc) · 2.32 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
# Use Rust docker image, see: https://hub.docker.com/_/rust/
image: rust:latest
variables:
CARGO_HOME: $CI_PROJECT_DIR/cargo
# Caches some files for improved CI Times
cache:
paths:
- $CARGO_HOME
#- ./target/
# Defines stages which are to be executed
stages:
- format
- build
- test
# ------------- Stage 1: Format----------------
Rust and Cargo Version:
stage: format
script:
- rustc --version && cargo --version
Cargo Format:
stage: format
before_script:
- rustup component add rustfmt
script:
- cargo fmt --verbose --all -- --check
# ------------- Stage 2: Build ----------------
Build lib:
stage: build
script:
- cargo build
Build examples:
stage: build
# artifacts:
# paths:
# - ./target/debug/examples/p2p_crust
# - ./target/debug/examples/p2p_libp2p
script:
- cargo build --examples
# ------------- Stage 3: Test ----------------
# Not necessary as this is just a lib
# Cargo testbuild lib:
# stage: test
# script:
# - cargo build --release
Cargo Clippy:
stage: test
allow_failure: true
before_script:
- rustup component add clippy
script:
- cargo clippy --all-targets --all-features -- -D warnings
Cargo-test:
stage: test
script:
- cargo test
artifacts:
paths:
#- target/debug/
# Build the python environment as in README and run demo1.py and demo2.py
Integration-tests:
stage: test
before_script:
- apt-get update && apt-get install -y python3 python3-venv python3-pip # Install Python
- cargo build --examples
script:
- python3 -m venv venv # Create virtual environment
- source venv/bin/activate # Activate virtual environment
- pip install --upgrade pip # Upgrade pip
- pip install "mosaik>=3.3" # Install requirements
# Run examples and check outputs
- python3 examples/demo1.py > output1.txt
- cargo run --example controller & python3 examples/demo2.py > output2.txt
- diff output1.txt examples/expected_output/demo1_output.txt
- diff output2.txt examples/expected_output/demo2_output.txt
# Error: "Failed to run tests: ASLR disable failed: EPERM: Operation not permitted"
# https://github.com/xd009642/tarpaulin/issues/146
# Cargo test coverage:
# stage: coverage
# before_script:
# - cargo install cargo-tarpaulin
# script:
# - cargo tarpaulin
# dependencies:
# - Cargo-test