-
Notifications
You must be signed in to change notification settings - Fork 11
199 lines (174 loc) · 5.67 KB
/
test.yml
File metadata and controls
199 lines (174 loc) · 5.67 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
name: Test & Release
on:
push:
branches: [ main ]
pull_request:
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: '-D warnings'
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: short
jobs:
# Extract MSRV once and share across jobs
get_msrv:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.rust_msrv.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get MSRV
id: rust_msrv
run: |
RUST_MSRV="$(grep '^rust-version' Cargo.toml | sed 's/.*"\(.*\)".*/\1/')"
echo "Found MSRV: $RUST_MSRV"
echo "version=$RUST_MSRV" >> "$GITHUB_OUTPUT"
cargo-fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run cargo fmt
run: cargo fmt --check
clippy:
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v4
- name: Install libudev
run: sudo apt-get update && sudo apt-get -y install libudev-dev libsystemd-dev
- uses: Swatinem/rust-cache@v2
with:
cache-provider: warpbuild
shared-key: "linux-stable-clippy"
cache-all-crates: true
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D clippy::all -D clippy::nursery
cargo-doc:
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v4
- name: Install libudev
run: sudo apt-get update && sudo apt-get -y install libudev-dev libsystemd-dev
- uses: Swatinem/rust-cache@v2
with:
cache-provider: warpbuild
shared-key: "linux-stable-doc"
cache-all-crates: true
- name: Run cargo doc
run: RUSTDOCFLAGS="-D warnings" cargo doc --all-features --document-private-items
check-windows:
needs: cargo-fmt
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
shared-key: "windows-stable"
cache-all-crates: true
- name: Run cargo check
run: cargo check --release --all-features
no_features_check:
needs: cargo-fmt
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
cache-provider: warpbuild
shared-key: "linux-stable-no-features"
cache-all-crates: true
- name: Run cargo check
run: cargo check --no-default-features
examples:
needs: cargo-fmt
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
cache-provider: warpbuild
shared-key: "linux-stable-examples"
cache-all-crates: true
- name: Install libudev
run: sudo apt-get update && sudo apt-get -y install libudev-dev libsystemd-dev
- name: Run examples
run: |
cd api/examples
./run_all.sh
test:
needs: [cargo-fmt, get_msrv]
strategy:
fail-fast: false
matrix:
platform: [warp-ubuntu-latest-x64-4x, warp-macos-latest-arm64-6x]
toolchain:
- stable
- msrv
runs-on: ${{ matrix.platform }}
name: Test ${{ matrix.toolchain }} on ${{ matrix.platform }}
env:
NEAR_SANDBOX_RPC_TIMEOUT_SECS: 30
steps:
- uses: actions/checkout@v4
- name: Determine Rust version
id: rust-version
run: |
if [ "${{ matrix.toolchain }}" = "msrv" ]; then
echo "version=${{ needs.get_msrv.outputs.version }}" >> "$GITHUB_OUTPUT"
else
echo "version=stable" >> "$GITHUB_OUTPUT"
fi
shell: bash
- name: Install Rust ${{ steps.rust-version.outputs.version }}
run: |
rustup toolchain install ${{ steps.rust-version.outputs.version }} --profile minimal
rustup override set ${{ steps.rust-version.outputs.version }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: warpbuild
shared-key: "${{ runner.os }}-${{ steps.rust-version.outputs.version }}"
cache-all-crates: true
- name: Install libudev (Linux only)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get -y install libudev-dev libsystemd-dev
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: nextest
- name: Check with all features
run: cargo check --examples --all-features
- name: Run tests with nextest
run: cargo nextest run --all-features --profile ci
coverage:
needs: [get_msrv]
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v4
- name: Install LLVM and system dependencies
run: |
sudo apt-get update
sudo apt-get install -y llvm lld libudev-dev libsystemd-dev
- name: Install Rust ${{ needs.get_msrv.outputs.version }}
run: |
rustup toolchain install ${{ needs.get_msrv.outputs.version }} --profile minimal
rustup override set ${{ needs.get_msrv.outputs.version }}
rustup component add rust-src --toolchain ${{ needs.get_msrv.outputs.version }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: warpbuild
shared-key: "linux-${{ needs.get_msrv.outputs.version }}-coverage"
cache-all-crates: true
- name: Install cargo-llvm-cov and nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov,nextest
- name: Generate code coverage
run: cargo llvm-cov nextest --all-features --profile ci --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: lcov.info
fail_ci_if_error: true
spellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: streetsidesoftware/cspell-action@v8