-
Notifications
You must be signed in to change notification settings - Fork 29
164 lines (141 loc) · 4.73 KB
/
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
on:
pull_request: {}
push:
branches: main
name: Continuous integration
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
RUST:
- nightly
steps:
- uses: actions/checkout@v4.2.2
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8
with:
toolchain: ${{ matrix.RUST }}
components: rustfmt, clippy
- uses: actions/cache@v4.1.2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.RUST }}-cargo-2-${{ hashFiles('**/Cargo.toml') }}
- run: cargo fmt --all -- --check
- run: cargo clippy --workspace --all-targets -- -D warnings
- run: cargo clippy --workspace --all-targets --all-features -- -D warnings
ci:
runs-on: ubuntu-latest
strategy:
matrix:
RUST:
# MSRV
- VERSION: "1.59.0"
FLAGS: ""
- VERSION: stable
FLAGS: ""
- VERSION: stable
FLAGS: "--no-default-features --features std"
- VERSION: stable
FLAGS: "--no-default-features"
SKIP_TESTS: true
- VERSION: beta
FLAGS: ""
- VERSION: beta
FLAGS: "--no-default-features --features std"
- VERSION: nightly
FLAGS: ""
- VERSION: nightly
FLAGS: "--no-default-features --features std"
- VERSION: nightly
FLAGS: "-Z minimal-versions"
steps:
- uses: actions/checkout@v4.2.2
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8
with:
toolchain: ${{ matrix.RUST.VERSION }}
- uses: actions/cache@v4.1.2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.RUST.VERSION }}-cargo-2-${{ hashFiles('**/Cargo.toml') }}
- run: |
cargo generate-lockfile
cargo update -p libc --precise 0.2.163
if: matrix.RUST.VERSION == '1.59.0'
- run: cargo check --workspace --tests ${{ matrix.RUST.FLAGS }}
- run: cargo test --workspace ${{ matrix.RUST.FLAGS }}
if: "${{ !matrix.RUST.SKIP_TESTS }}"
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8
with:
toolchain: 1.76.0
components: llvm-tools-preview
- run: sudo apt update && sudo apt-get install -y lcov
- uses: actions/cache@v4.1.2
id: cargo-cache
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-5-${{ hashFiles('**/Cargo.toml') }}
- run: cargo test
env:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "rust-cov/cov-%m-%p.profraw"
- name: Compute coverage HTML
run: |
set -xe
LIBDIR=$(rustc --print target-libdir)
$LIBDIR/../bin/llvm-profdata merge -sparse rust-cov/*.profraw -o cargo-test-rust-cov.profdata
$LIBDIR/../bin/llvm-cov export \
$( \
for file in \
$( \
RUSTFLAGS="-Cinstrument-coverage" \
cargo test --tests --no-run --message-format=json \
| jq -r "select(.profile.test == true) | .filenames[]" \
); \
do \
printf "%s %s " -object $file; \
done \
) \
-instr-profile=cargo-test-rust-cov.profdata \
--ignore-filename-regex='/.cargo/registry' \
--ignore-filename-regex='/rustc/' \
--ignore-filename-regex='/.rustup/toolchains/' --format=lcov > cargo-test.lcov
genhtml cargo-test.lcov -o coverage-html | tee output.log
- uses: actions/upload-artifact@v4.4.3
with:
name: coverage-html
path: coverage-html
- name: Check coverage
run: |
import re
with open("output.log") as f:
[line] = [l for l in f if l.startswith(" lines......:")]
coverage = float(re.search("([\d\.]+)%", line).group(1))
if coverage < 100:
raise ValueError(f"Coverage too low: {coverage}")
shell: python