-
-
Notifications
You must be signed in to change notification settings - Fork 1
228 lines (213 loc) · 6.86 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
220
221
222
223
224
225
226
227
228
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:
webpack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- run: cd redoc/src && npm install && npm run webpack
- run: git diff --exit-code redoc/src
test:
strategy:
fail-fast: false
matrix:
rust:
- name: MSRV
toolchain: "1.73"
nightly: false
- name: Stable
toolchain: stable
nightly: false
- name: beta
toolchain: beta
nightly: false
- name: nightly
toolchain: nightly
nightly: true
features:
- name: default
flags: ""
- name: openapi
flags: "--no-default-features --features openapi"
- name: full
flags: "--no-default-features --features full"
runs-on: ubuntu-latest
name: Test on Rust ${{matrix.rust.name}} with ${{matrix.features.name}} features
continue-on-error: ${{matrix.rust.nightly}}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
if: matrix.rust.name == 'MSRV'
- name: cargo -Z minimal-versions update
run: |
set -x
cargo -Z minimal-versions update
cargo update --precise 1.3.0 lazy_static
cargo update tracing
if: matrix.rust.name == 'MSRV'
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust.toolchain}}
id: rust-toolchain
- uses: actions/cache@v4
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}}"
- name: cargo test ${{matrix.features.flags}}
run: |
set -x
locked=
if [ "${{matrix.rust.name}}" == "MSRV" ]; then
export RUSTFLAGS="$RUSTFLAGS --cfg gotham_restful_deny_warnings"
locked="--locked"
fi
cargo test $locked ${{matrix.features.flags}}
test-trybuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.82"
id: rust-toolchain
- uses: actions/cache@v4
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}} (trybuild)"
- run: cargo test --no-default-features --features full --tests -- --ignored
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.78"
components: clippy
id: rust-toolchain
- uses: actions/cache@v4
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@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --all -- --check
- run: ./tests/ui/rustfmt.sh --check
readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker://ghcr.io/msrd0/cargo-doc2readme
with:
entrypoint: ./readme.sh
args: --check
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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@v4
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 --verbose \
--target-dir target/tarpaulin \
--no-default-features \
--features full \
--exclude-files 'derive/*' \
--exclude-files 'target/*' \
--ignore-panics --ignore-tests \
--out html --out json
- uses: actions/upload-artifact@v4
with:
name: tarpaulin-report
path: |
tarpaulin-report.json
tarpaulin-report.html
doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: |
~/.cargo
target
key: ${{runner.os}}-cargo-doc
- run: RUSTDOCFLAGS="$RUSTDOCFLAGS --cfg gotham_restful_deny_warnings" cargo doc --no-default-features --features full --no-deps
- run: tar cfJ rustdoc.tar.xz target/doc/
- uses: actions/upload-artifact@v4
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@v4
with:
ref: gh-pages
- uses: actions/download-artifact@v4
with:
name: rustdoc
- uses: actions/download-artifact@v4
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@v5
with:
commit_message: "GitHub Pages for ${{github.sha}}"