-
-
Notifications
You must be signed in to change notification settings - Fork 2
212 lines (198 loc) · 6.24 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
name: Rust
on:
push:
branches: [main]
pull_request:
env:
RUSTDOCFLAGS: "--default-theme ayu"
RUST_BACKTRACE: "1"
# speed up build by using clang/lld
CC: "clang-14"
CXX: "clang++-14"
LD: "clang-14"
LDFLAGS: "-fuse-ld=lld-14"
RUSTFLAGS: "-C linker=clang-14 -C link-arg=-fuse-ld=lld-14"
jobs:
test:
strategy:
fail-fast: false
matrix:
rust:
- name: MSRV
toolchain: "1.58"
nightly: false
- name: Stable
toolchain: stable
nightly: false
- name: Beta
toolchain: beta
nightly: false
- name: Nightly
toolchain: nightly
nightly: true
runs-on: ubuntu-latest
name: Test (Rust ${{matrix.rust.name}})
continue-on-error: ${{matrix.rust.nightly}}
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust.toolchain}}
id: rust-toolchain
- uses: actions/cache@v3
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}}"
- run: cargo test --workspace -- --skip trybuild
test-trybuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.68"
id: rust-toolchain
- uses: actions/cache@v3
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}} (trybuild)"
- run: cargo test -- trybuild
clippy:
strategy:
fail-fast: false
matrix:
rust:
- name: MSRV
toolchain: "1.58"
nightly: false
- name: Nightly
toolchain: nightly
nightly: true
runs-on: ubuntu-latest
name: Clippy (Rust ${{matrix.rust.name}})
continue-on-error: ${{matrix.rust.nightly}}
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust.toolchain}}
components: clippy
id: rust-toolchain
- uses: actions/cache@v3
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}} (clippy)"
- run: cargo clippy --workspace --profile test -- -Dclippy::all
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --all -- --check
- run: ./tests/fail/rustfmt.sh --check
readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker://ghcr.io/msrd0/cargo-doc2readme
with:
entrypoint: ./readme.sh
args: --check
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
- name: Get Tarpaulin Version
id: tarpaulin-version
run: echo "version=$(wget -qO- 'https://crates.io/api/v1/crates/cargo-tarpaulin' | jq -r '.crate.max_stable_version')" >>$GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/cargo-tarpaulin
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-version.outputs.version}} tarpaulin ${{steps.tarpaulin-version.outputs.version}}"
- name: Install Tarpaulin
run: |
test -e ~/.cargo/bin/cargo-tarpaulin || cargo install cargo-tarpaulin --version ${{steps.tarpaulin-version.outputs.version}}
- name: Run Tarpaulin coverage tests
run: |
cargo tarpaulin -v \
--target-dir target/tarpaulin \
--workspace \
--all-features \
--exclude-files 'derive/*' \
--exclude-files 'serde/*' \
--exclude-files 'target/*' \
--ignore-panics --ignore-tests \
--out Html --out Json \
-- --skip trybuild
- uses: actions/upload-artifact@v3
with:
name: tarpaulin-report
path: |
tarpaulin-report.json
tarpaulin-report.html
doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
- uses: actions/cache@v3
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}} (rustdoc)"
- run: cargo doc --workspace --all-features
- run: tar cfJ rustdoc.tar.xz target/doc/
- uses: actions/upload-artifact@v3
with:
name: rustdoc
path: rustdoc.tar.xz
pages:
runs-on: ubuntu-latest
needs: [coverage, doc]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages
- uses: actions/download-artifact@v3
with:
name: rustdoc
- uses: actions/download-artifact@v3
with:
name: tarpaulin-report
- run: |
test ! -d ./doc || rm -r ./doc
tar xfJ rustdoc.tar.xz --strip-components=1
rm rustdoc.tar.xz
date >./doc/.timestamp
coverage=$(jq '.files | { covered: map(.covered) | add, coverable: map(.coverable) | add } | .covered / .coverable * 10000 | round | . / 100' tarpaulin-report.json)
color=$([[ $coverage < 80 ]] && printf yellow || printf brightgreen)
wget -qO coverage.svg "https://img.shields.io/badge/coverage-$coverage%25-$color"
git add ./doc coverage.svg || true
git status
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "GitHub Pages for ${{github.sha}}"
commit_user_name: "GitHub Actions"
commit_user_email: "actions@github.com"
commit_author: "GitHub Actions <actions@github.com>"