-
Notifications
You must be signed in to change notification settings - Fork 73
295 lines (242 loc) · 8.04 KB
/
ci-rust.yml
File metadata and controls
295 lines (242 loc) · 8.04 KB
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
name: CI - Rust
permissions:
contents: read
on:
push:
paths:
# NOTE: GitHub Actions do not allow using YAML references, the same path
# list is used below for the pull request event. Keep both lists in sync!!
# this file as well
- .github/workflows/ci-rust.yml
# any change in the rust subfolder
- rust/**
# except Markdown documentation
- "!rust/**.md"
# except the packaging
- "!rust/package/**"
# except the DBus configuration
- "!rust/share/**"
pull_request:
paths:
# NOTE: GitHub Actions do not allow using YAML references, the same path
# list is used above for the push event. Keep both lists in sync!!
# this file as well
- .github/workflows/ci-rust.yml
# any change in the rust subfolder
- rust/**
# except Markdown documentation
- "!rust/**.md"
# except the packaging
- "!rust/package/**"
# except the DBus configuration
- "!rust/share/**"
# allow running manually
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
# this makes the build slightly faster and the saved cache smaller
CARGO_INCREMENTAL: 0
jobs:
fmt:
# the default timeout is 6 hours, that's too much if the job gets stuck
timeout-minutes: 10
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./rust
steps:
- name: Git Checkout
uses: actions/checkout@v4
- name: Rust toolchain
run: |
rustup show
cargo --version
- name: Run rustfmt
run: cargo fmt --all -- --check
clippy:
# the default timeout is 6 hours, that's too much if the job gets stuck
timeout-minutes: 20
runs-on: ubuntu-latest
container:
image: registry.opensuse.org/opensuse/tumbleweed:latest
options: --security-opt seccomp=unconfined
steps:
- name: Configure and refresh repositories
# disable unused repositories to have faster refresh
run: zypper modifyrepo -d repo-non-oss repo-openh264 repo-update && ( zypper ref || zypper ref || zypper ref )
- name: Install required packages
run: zypper --non-interactive install --allow-downgrade
clang-devel
gcc-c++
git
libopenssl-3-devel
libsuseconnect
libzypp-devel
make
openssl-3
pam-devel
rustup
- name: Configure git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Git Checkout
uses: actions/checkout@v4
- name: Install Rust toolchains
run: rustup toolchain install stable
- name: Rust toolchain
run: |
rustup show
cargo --version
- name: Rust cache
uses: actions/cache@v4
with:
path: |
~/.cargo
rust/target
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- name: Run clippy linter
run: cargo clippy
working-directory: ./rust
tests:
# the default timeout is 6 hours, that's too much if the job gets stuck
timeout-minutes: 30
runs-on: ubuntu-latest
container:
image: registry.opensuse.org/opensuse/tumbleweed:latest
options: --security-opt seccomp=unconfined
env:
COVERAGE: 1
steps:
- name: Configure and refresh repositories
# disable unused repositories to have faster refresh
run: zypper modifyrepo -d repo-non-oss repo-openh264 repo-update && ( zypper ref || zypper ref || zypper ref )
- name: Install required packages
run: zypper --non-interactive install --allow-downgrade
clang-devel
dbus-1-daemon
gcc-c++
git
glibc-locale
golang-github-google-jsonnet
jq
libopenssl-3-devel
libsuseconnect
libzypp-devel
make
openssl-3
pam-devel
python-langtable-data
python3-openapi_spec_validator
rustup
timezone
util-linux-systemd
xkeyboard-config
- name: Configure git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Git Checkout
uses: actions/checkout@v4
- name: Install Rust toolchains
run: rustup toolchain install stable
- name: Rust toolchain
run: |
rustup show
cargo --version
- name: Prepare for tests
run: |
# create the /etc/agama.d/locales file with list of locales
mkdir -p /etc/agama.d
ls -1 -d /usr/lib/locale/*.utf8 | sed -e "s#/usr/lib/locale/##" -e "s#utf8#UTF-8#" >/etc/agama.d/locales
- name: Installed packages
run: rpm -qa
- name: Rust cache
id: cache-tests
uses: actions/cache@v4
with:
path: |
~/.cargo
rust/target-coverage
key: ${{ runner.os }}-cargo-tests-${{ hashFiles('**/Cargo.lock') }}
- name: Install Tarpaulin (for code coverage)
# skip the step completely if the cache has been restored
# this avoids refreshing the crates index and saves few seconds
if: steps.cache-tests.outputs.cache-hit != 'true'
run: cargo install cargo-tarpaulin
working-directory: ./rust
- name: Run the tests
# Compile into the ./target-coverage directory because tarpaulin uses special compilation
# flags, to avoid reusing the previous builds it always starts from scratch.
# The --skip-clean skips the cleanup and allows using the cached results.
# See https://github.com/xd009642/tarpaulin/discussions/772
run: cargo tarpaulin --workspace --all-targets --doc --engine llvm --out xml --target-dir target-coverage --skip-clean -- --nocapture
working-directory: ./rust
env:
# use the "stable" tool chain (installed by default) instead of the "nightly" default in tarpaulin
RUSTC_BOOTSTRAP: 1
RUSTUP_TOOLCHAIN: stable
RUST_BACKTRACE: full
RUSTFLAGS: --cfg ci
# send the code coverage for the Rust part to the coveralls.io
- name: Send coverage data to Coveralls
timeout-minutes: 10
# ignore errors in this step
continue-on-error: true
uses: coverallsapp/github-action@v2
with:
flag-name: rust
base-path: ./rust
format: cobertura
# Close the parallel build and inherit the Web parts (it needs a separate step, the "carryforward" flag can be used
# only with the "parallel-finished: true" option)
- name: Close the Coveralls build
timeout-minutes: 10
# ignore errors in this step
continue-on-error: true
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: "rust,service,web"
openapi:
# the default timeout is 6 hours, that's too much if the job gets stuck
timeout-minutes: 30
runs-on: ubuntu-latest
container:
image: registry.opensuse.org/opensuse/tumbleweed:latest
steps:
- name: Configure and refresh repositories
# disable unused repositories to have faster refresh
run: zypper modifyrepo -d repo-non-oss repo-openh264 repo-update && ( zypper ref || zypper ref || zypper ref )
- name: Install required packages
run: zypper --non-interactive install --allow-downgrade
clang-devel
gcc-c++
git
libopenssl-3-devel
libsuseconnect
libzypp-devel
make
openssl-3
pam-devel
python3-openapi_spec_validator
rustup
- name: Git Checkout
uses: actions/checkout@v4
- name: Install Rust toolchains
run: rustup toolchain install stable
- name: Rust toolchain
run: |
rustup show
cargo --version
- name: Installed packages
run: rpm -qa
- name: Rust cache
uses: actions/cache@v4
with:
path: |
~/.cargo
rust/target
key: ${{ runner.os }}-cargo-openapi-${{ hashFiles('**/Cargo.lock') }}
- name: Generate the OpenAPI specification
run: cargo xtask openapi
working-directory: ./rust
- name: Validate the OpenAPI specification
run: openapi-spec-validator out/openapi/*
working-directory: ./rust