@@ -12,110 +12,186 @@ env:
1212 RUST_BACKTRACE : short
1313
1414jobs :
15- clippy :
15+ # Extract MSRV once and share across jobs
16+ get_msrv :
1617 runs-on : ubuntu-latest
17-
18+ outputs :
19+ version : ${{ steps.rust_msrv.outputs.version }}
1820 steps :
1921 - uses : actions/checkout@v4
20- - name : Install libudev (Linux only)
21- if : runner.os == 'Linux'
22- run : sudo apt-get update && sudo apt-get -y install libudev-dev libsystemd-dev
23- - uses : Swatinem/ rust-cache@v2
24- - name : Run clippy
25- run : cargo clippy --all-targets --all-features -- -D clippy::all -D clippy::nursery
22+ - name : Get MSRV
23+ id : rust_msrv
24+ run : |
25+ RUST_MSRV="$(grep '^ rust-version' Cargo.toml | sed 's/.*"\(.*\)".*/\1/')"
26+ echo "Found MSRV: $RUST_MSRV"
27+ echo "version=$RUST_MSRV" >> "$GITHUB_OUTPUT"
2628
2729 cargo-fmt :
2830 runs-on : ubuntu-latest
29-
3031 steps :
3132 - uses : actions/checkout@v4
3233 - name : Run cargo fmt
3334 run : cargo fmt --check
3435
35- cargo-doc :
36- runs-on : ubuntu-latest
36+ clippy :
37+ runs-on : warp-ubuntu-latest-x64-4x
38+ steps :
39+ - uses : actions/checkout@v4
40+ - name : Install libudev
41+ run : sudo apt-get update && sudo apt-get -y install libudev-dev libsystemd-dev
42+ - uses : Swatinem/rust-cache@v2
43+ with :
44+ cache-provider : warpbuild
45+ shared-key : " linux-stable-clippy"
46+ cache-all-crates : true
47+ - name : Run clippy
48+ run : cargo clippy --all-targets --all-features -- -D clippy::all -D clippy::nursery
3749
50+ cargo-doc :
51+ runs-on : warp-ubuntu-latest-x64-4x
3852 steps :
3953 - uses : actions/checkout@v4
40- - name : Install libudev (Linux only)
41- if : runner.os == 'Linux'
54+ - name : Install libudev
4255 run : sudo apt-get update && sudo apt-get -y install libudev-dev libsystemd-dev
43- - name : run cargo doc
56+ - uses : Swatinem/rust-cache@v2
57+ with :
58+ cache-provider : warpbuild
59+ shared-key : " linux-stable-doc"
60+ cache-all-crates : true
61+ - name : Run cargo doc
4462 run : RUSTDOCFLAGS="-D warnings" cargo doc --all-features --document-private-items
4563
4664 check-windows :
4765 needs : cargo-fmt
4866 runs-on : windows-latest
49-
5067 steps :
5168 - uses : actions/checkout@v4
5269 - uses : Swatinem/rust-cache@v2
70+ with :
71+ shared-key : " windows-stable"
72+ cache-all-crates : true
5373 - name : Run cargo check
5474 run : cargo check --release --all-features
5575
5676 no_features_check :
5777 needs : cargo-fmt
58- runs-on : ubuntu-latest
78+ runs-on : warp- ubuntu-latest-x64-4x
5979 steps :
6080 - uses : actions/checkout@v4
6181 - uses : Swatinem/rust-cache@v2
82+ with :
83+ cache-provider : warpbuild
84+ shared-key : " linux-stable-no-features"
85+ cache-all-crates : true
6286 - name : Run cargo check
6387 run : cargo check --no-default-features
6488
6589 examples :
6690 needs : cargo-fmt
67- runs-on : ubuntu-latest
91+ runs-on : warp- ubuntu-latest-x64-4x
6892 steps :
6993 - uses : actions/checkout@v4
7094 - uses : Swatinem/rust-cache@v2
71- - name : Install libudev (Linux only)
72- if : runner.os == 'Linux'
95+ with :
96+ cache-provider : warpbuild
97+ shared-key : " linux-stable-examples"
98+ cache-all-crates : true
99+ - name : Install libudev
73100 run : sudo apt-get update && sudo apt-get -y install libudev-dev libsystemd-dev
74101 - name : Run examples
75102 run : |
76103 cd api/examples
77104 ./run_all.sh
78105
79- get_msrv :
80- runs-on : ubuntu-latest
81- outputs :
82- version : ${{ steps.rust_msrv.outputs.version }}
83- steps :
84- - uses : actions/checkout@v4
85- - name : Get MSRV
86- id : rust_msrv
87- run : |
88- RUST_MSRV="$(cat Cargo.toml | sed -n 's/rust-version *= *"\(.*\)"/\1/p')"
89- echo "Found MSRV: $RUST_MSRV"
90- echo "version=$RUST_MSRV" >> "$GITHUB_OUTPUT"
91-
92106 test :
93107 needs : [cargo-fmt, get_msrv]
94108 strategy :
95109 fail-fast : false
96110 matrix :
97- platform : [ubuntu-latest, warp-macos-latest-arm64-6x]
111+ platform : [warp- ubuntu-latest-x64-4x , warp-macos-latest-arm64-6x]
98112 toolchain :
99113 - stable
100- - ${{ needs.get_msrv.outputs.version }}
114+ - msrv
101115 runs-on : ${{ matrix.platform }}
102- name : CI with ${{ matrix.toolchain }}
116+ name : Test ${{ matrix.toolchain }} on ${{ matrix.platform }}
117+ env :
118+ NEAR_SANDBOX_RPC_TIMEOUT_SECS : 30
103119 steps :
104120 - uses : actions/checkout@v4
105- - name : " ${{ matrix.toolchain }}"
106- uses : actions-rs/toolchain@v1
107- with :
108- profile : minimal
109- toolchain : ${{ matrix.toolchain }}
110- default : true
121+
122+ - name : Determine Rust version
123+ id : rust-version
124+ run : |
125+ if [ "${{ matrix.toolchain }}" = "msrv" ]; then
126+ echo "version=${{ needs.get_msrv.outputs.version }}" >> "$GITHUB_OUTPUT"
127+ else
128+ echo "version=stable" >> "$GITHUB_OUTPUT"
129+ fi
130+ shell : bash
131+
132+ - name : Install Rust ${{ steps.rust-version.outputs.version }}
133+ run : |
134+ rustup toolchain install ${{ steps.rust-version.outputs.version }} --profile minimal
135+ rustup override set ${{ steps.rust-version.outputs.version }}
136+
111137 - uses : Swatinem/rust-cache@v2
138+ with :
139+ cache-provider : warpbuild
140+ shared-key : " ${{ runner.os }}-${{ steps.rust-version.outputs.version }}"
141+ cache-all-crates : true
142+
112143 - name : Install libudev (Linux only)
113144 if : runner.os == 'Linux'
114145 run : sudo apt-get update && sudo apt-get -y install libudev-dev libsystemd-dev
115- - name : Check with stable features
146+
147+ - name : Install cargo-nextest
148+ uses : taiki-e/install-action@v2
149+ with :
150+ tool : nextest
151+
152+ - name : Check with all features
116153 run : cargo check --examples --all-features
117- - name : Run tests
118- run : cargo test --all-features
154+
155+ - name : Run tests with nextest
156+ run : cargo nextest run --all-features --profile ci
157+
158+ coverage :
159+ needs : [get_msrv]
160+ runs-on : warp-ubuntu-latest-x64-4x
161+ steps :
162+ - uses : actions/checkout@v4
163+
164+ - name : Install LLVM and system dependencies
165+ run : |
166+ sudo apt-get update
167+ sudo apt-get install -y llvm lld libudev-dev libsystemd-dev
168+
169+ - name : Install Rust ${{ needs.get_msrv.outputs.version }}
170+ run : |
171+ rustup toolchain install ${{ needs.get_msrv.outputs.version }} --profile minimal
172+ rustup override set ${{ needs.get_msrv.outputs.version }}
173+ rustup component add rust-src --toolchain ${{ needs.get_msrv.outputs.version }}
174+
175+ - uses : Swatinem/rust-cache@v2
176+ with :
177+ cache-provider : warpbuild
178+ shared-key : " linux-${{ needs.get_msrv.outputs.version }}-coverage"
179+ cache-all-crates : true
180+
181+ - name : Install cargo-llvm-cov and nextest
182+ uses : taiki-e/install-action@v2
183+ with :
184+ tool : cargo-llvm-cov,nextest
185+
186+ - name : Generate code coverage
187+ run : cargo llvm-cov nextest --all-features --profile ci --lcov --output-path lcov.info
188+
189+ - name : Upload coverage to Codecov
190+ uses : codecov/codecov-action@v4
191+ with :
192+ files : lcov.info
193+ fail_ci_if_error : true
194+
119195 spellcheck :
120196 runs-on : ubuntu-latest
121197 steps :
0 commit comments