Skip to content

Commit 6ff3421

Browse files
authored
Merge pull request #11 from linksplatform/issue-10-1f8f48957f80
feat: 100% tests coverage infrastructure
2 parents d1544e6 + 7eebdf4 commit 6ff3421

File tree

11 files changed

+919
-10
lines changed

11 files changed

+919
-10
lines changed

.github/workflows/release.yml

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ jobs:
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
@@ -76,7 +77,9 @@ jobs:
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: |

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
debug/
44
target/
55

6-
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6+
# For libraries, Cargo.lock is traditionally gitignored, but we commit it
7+
# to ensure reproducible builds with nightly-2022-08-22 dependency versions.
78
# See https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8-
Cargo.lock
9+
# Cargo.lock
910

1011
# These are backup files generated by rustfmt
1112
**/*.rs.bk

Cargo.lock

Lines changed: 213 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Added
2+
- Test coverage infrastructure using cargo-tarpaulin with 90% minimum threshold
3+
- Comprehensive unit tests achieving 94.57% code coverage
4+
- rust-toolchain.toml to pin nightly-2022-08-22 for stable feature compatibility
5+
- Coverage check job in CI/CD pipeline to prevent coverage regression
6+
7+
### Changed
8+
- CI workflow now requires coverage check to pass before build

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "nightly-2022-08-22"

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ pub use converters::{AddrToRaw, RawToAddr};
2222
pub use flow::Flow;
2323
pub use hybrid::Hybrid;
2424
pub use link_type::LinkType;
25-
pub use links::{Links, ReadHandler, WriteHandler, Error};
25+
pub use links::{Error, Links, ReadHandler, WriteHandler};
2626
pub use point::Point;
2727
pub use query::{Query, ToQuery};

0 commit comments

Comments
 (0)