-
Notifications
You must be signed in to change notification settings - Fork 16
219 lines (210 loc) · 7.53 KB
/
rust.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
name: Build & Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
pre-flight-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: rustfmt
- name: Check formatting
run: cargo fmt --check
cargo-nextest:
needs: pre-flight-check
strategy:
matrix:
os: [ubuntu-latest, macOS-latest] #Todo add windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Build and cache cargo-nextest
uses: ./.github/actions/build-and-cache-rust-tool
with:
rust-toolchain: stable
check-and-install-cmd: cargo-nextest --version > /dev/null || cargo install cargo-nextest --locked
print-version-cmd: cargo-nextest --version
cache-key: cache-1-${{ runner.os }}-cargo-nextest
artifact-path: ~/.cargo/bin/cargo-nextest
artifact-name: ${{ runner.os }}-cargo-nextest
grcov:
needs: pre-flight-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and cache grcov
uses: ./.github/actions/build-and-cache-rust-tool
with:
rust-toolchain: nightly
rust-components: llvm-tools-preview
check-and-install-cmd: grcov --version > /dev/null || cargo install grcov
print-version-cmd: grcov --version
cache-key: cache-1-${{ runner.os }}-grcov
artifact-path: ~/.cargo/bin/grcov
artifact-name: ${{ runner.os }}-grcov
build-test:
needs: cargo-nextest
strategy:
matrix:
os: [ubuntu-latest, macOS-latest] #Todo add windows-latest
toolchain: [stable, beta]
include:
- os: ubuntu-latest
toolchain: nightly
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.toolchain != 'stable' }}
steps:
- uses: actions/checkout@v3
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
- name: Create version_info file
run: |
rustc --version > version_info
cargo --version >> version_info
cargo clippy --version >> version_info
cat version_info
- name: Setup cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cache-1-${{ runner.os }}-toolchain-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.toml', '**/build.rs', 'version_info') }}
- name: Download cargo-nextest artifact
uses: actions/download-artifact@v3
with:
name: ${{ runner.os }}-cargo-nextest
path: ~/.cargo/bin
- name: Make cargo-nextest artifact executable
run: |
chmod +x ~/.cargo/bin/cargo-nextest
- name: Install dependencies
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt update
sudo apt install -y libacl1-dev
fi
- name: Build
run: cargo build --all --examples
- if: runner.os == 'Linux' && matrix.toolchain == 'stable'
name: Run clippy # clippy can reuse the previous build artifacts
run: cargo clippy
- name: Run tests
run: cargo nextest run --test-threads 1
coverage:
needs: [cargo-nextest, grcov]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly
components: llvm-tools-preview
- name: Create version_info file
run: |
rustc --version > version_info
cargo --version >> version_info
cat version_info
- name: Setup cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: coverage-llvm-tools-preview-cache-1-${{ runner.os }}-toolchain-nightly-${{ hashFiles('**/Cargo.toml', '**/build.rs', 'version_info') }}
- name: Remove outdated files from cache
run: |
find . -type f -wholename "**/lcov.info" -exec rm {} \;
find . -type f -wholename "**/*.profraw" -exec rm {} \;
rm -rf target/debug/coverage-html
- name: Download artifact cargo-nextest
uses: actions/download-artifact@v3
with:
name: ${{ runner.os }}-cargo-nextest
path: ~/.cargo/bin
- name: Download artifact grcov
uses: actions/download-artifact@v3
with:
name: ${{ runner.os }}-grcov
path: ~/.cargo/bin
- name: Make cargo-nextest and grcov artifacts executable
run: |
chmod +x ~/.cargo/bin/cargo-nextest
chmod +x ~/.cargo/bin/grcov
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y libacl1-dev
- name: Build
env:
LLVM_PROFILE_FILE: target/debug/llvm-profile-files/iceoryx-rs-%p-%m.profraw
RUSTFLAGS: -Cinstrument-coverage
run: cargo build
- name: Run test
env:
LLVM_PROFILE_FILE: target/debug/llvm-profile-files/iceoryx-rs-%p-%m.profraw
RUSTFLAGS: -Cinstrument-coverage
run: cargo nextest run --test-threads 1
- name: Generate coverage results for html artifacts
run: |
grcov \
target/debug/llvm-profile-files \
iceoryx-sys/target/debug/llvm-profile-files \
--binary-path target/debug \
--source-dir . \
--output-type html \
--branch \
--ignore-not-existing \
--ignore "examples/*" \
--ignore "iceoryx-sys/build.rs" \
--ignore "iceoryx-sys/src/roudi_environment.rs" \
--ignore "src/tests/*" \
--ignore "**/.cargo/*" \
--output-path target/debug/coverage-html
sed -i 's/coverage/grcov/' target/debug/coverage-html/coverage.json
- name: Archive coverage-html artifacts
uses: actions/upload-artifact@v3
with:
name: coverage-html
path: target/debug/coverage-html/*
retention-days: 90
- name: Generate coverage report for Codecov
run: |
grcov \
target/debug/llvm-profile-files \
iceoryx-sys/target/debug/llvm-profile-files \
--binary-path target/debug \
--source-dir . \
--output-type lcov \
--branch \
--ignore-not-existing \
--ignore "examples/*" \
--ignore "iceoryx-sys/build.rs" \
--ignore "iceoryx-sys/src/roudi_environment.rs" \
--ignore "src/tests/*" \
--ignore "**/.cargo/*" \
--output-path target/debug/lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: target/debug/lcov.info
fail_ci_if_error: true