4040 - uses : actions/checkout@v4
4141
4242 - name : Setup Rust
43- uses : dtolnay/rust-toolchain@nightly
43+ uses : dtolnay/rust-toolchain@master
4444 with :
45+ toolchain : nightly-2022-08-22
4546 components : rustfmt, clippy
4647
4748 - name : Cache cargo registry
7677 - uses : actions/checkout@v4
7778
7879 - name : Setup Rust
79- uses : dtolnay/rust-toolchain@nightly
80+ uses : dtolnay/rust-toolchain@master
81+ with :
82+ toolchain : nightly-2022-08-22
8083
8184 - name : Cache cargo registry
8285 uses : actions/cache@v4
@@ -95,16 +98,65 @@ jobs:
9598 - name : Run doc tests
9699 run : cargo test --doc --verbose
97100
98- # Build package - only runs if lint and test pass
101+ # Test coverage - ensures we maintain high test coverage
102+ coverage :
103+ name : Test Coverage
104+ runs-on : ubuntu-latest
105+ steps :
106+ - uses : actions/checkout@v4
107+
108+ - name : Setup Rust nightly
109+ uses : dtolnay/rust-toolchain@master
110+ with :
111+ toolchain : nightly-2022-08-22
112+
113+ # Install tarpaulin using pre-built binary (avoids compilation issues)
114+ - name : Install cargo-tarpaulin
115+ run : |
116+ curl -sL https://github.com/xd009642/tarpaulin/releases/download/0.31.5/cargo-tarpaulin-x86_64-unknown-linux-gnu.tar.gz | tar xz
117+ chmod +x cargo-tarpaulin
118+ sudo mv cargo-tarpaulin /usr/local/bin/
119+
120+ - name : Cache cargo registry
121+ uses : actions/cache@v4
122+ with :
123+ path : |
124+ ~/.cargo/registry
125+ ~/.cargo/git
126+ target
127+ key : ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
128+ restore-keys : |
129+ ${{ runner.os }}-cargo-coverage-
130+
131+ - name : Run coverage
132+ run : cargo-tarpaulin --out Xml --output-dir coverage
133+
134+ - name : Check coverage threshold
135+ run : |
136+ # Extract coverage percentage from output
137+ COVERAGE=$(cargo-tarpaulin --out Stdout 2>&1 | grep -oP '\d+\.\d+(?=% coverage)' | tail -1)
138+ echo "Coverage: $COVERAGE%"
139+
140+ # Check if coverage meets threshold (90%)
141+ if (( $(echo "$COVERAGE < 90" | bc -l) )); then
142+ echo "::error::Coverage ($COVERAGE%) is below 90% threshold"
143+ exit 1
144+ fi
145+
146+ echo "Coverage check passed: $COVERAGE% >= 90%"
147+
148+ # Build package - only runs if lint, test, and coverage pass
99149 build :
100150 name : Build Package
101151 runs-on : ubuntu-latest
102- needs : [lint, test]
152+ needs : [lint, test, coverage ]
103153 steps :
104154 - uses : actions/checkout@v4
105155
106156 - name : Setup Rust
107- uses : dtolnay/rust-toolchain@nightly
157+ uses : dtolnay/rust-toolchain@master
158+ with :
159+ toolchain : nightly-2022-08-22
108160
109161 - name : Cache cargo registry
110162 uses : actions/cache@v4
@@ -172,7 +224,9 @@ jobs:
172224 fetch-depth : 0
173225
174226 - name : Setup Rust
175- uses : dtolnay/rust-toolchain@nightly
227+ uses : dtolnay/rust-toolchain@master
228+ with :
229+ toolchain : nightly-2022-08-22
176230
177231 - name : Check if version changed
178232 id : version_check
@@ -218,7 +272,9 @@ jobs:
218272 token : ${{ secrets.GITHUB_TOKEN }}
219273
220274 - name : Setup Rust
221- uses : dtolnay/rust-toolchain@nightly
275+ uses : dtolnay/rust-toolchain@master
276+ with :
277+ toolchain : nightly-2022-08-22
222278
223279 - name : Configure git
224280 run : |
0 commit comments