Skip to content

Commit c3c14bd

Browse files
committed
Add code coverage in GitHub Actions
1 parent f86621e commit c3c14bd

File tree

3 files changed

+56
-9
lines changed

3 files changed

+56
-9
lines changed

.github/workflows/rust.yml

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,69 @@
1+
---
12
name: Rust
23

34
on:
45
push:
56
branches: [ "main" ]
7+
paths:
8+
- 'Cargo.toml'
9+
- 'Cargo.lock'
10+
- 'src/**'
11+
- 'crates/**'
12+
- 'bins/**'
13+
- '.github/workflows/rust.yml'
614
pull_request:
715
branches: [ "main" ]
16+
paths:
17+
- 'Cargo.toml'
18+
- 'Cargo.lock'
19+
- 'src/**'
20+
- 'crates/**'
21+
- 'bins/**'
22+
- '.github/workflows/rust.yml'
823

924
env:
1025
CARGO_TERM_COLOR: always
1126

1227
jobs:
1328
build:
29+
name: Build and Test
30+
runs-on: ${{ matrix.os }}
31+
strategy:
32+
matrix:
33+
os: [ ubuntu-latest, macos-latest, windows-latest ]
34+
steps:
35+
- uses: actions/checkout@v4
36+
- name: Check format
37+
run: cargo fmt --check
38+
- name: Build
39+
run: cargo build --verbose
40+
- uses: taiki-e/install-action@nextest
41+
- name: Run tests
42+
run: cargo nextest run --verbose --all-features
43+
- name: Run doctests
44+
run: cargo test --doc --verbose --all-features
1445

46+
codecov:
47+
name: Code Coverage
1548
runs-on: ubuntu-latest
16-
49+
env:
50+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1751
steps:
18-
- uses: actions/checkout@v3
19-
- name: Build
20-
run: cargo build --verbose
21-
- name: Run tests
22-
run: cargo test --tests --verbose
23-
- name: Run doctests
24-
run: cargo test --doc --verbose
52+
- uses: actions/checkout@v4
53+
- name: Build
54+
run: cargo build --verbose
55+
- uses: dtolnay/rust-toolchain@stable
56+
with:
57+
components: llvm-tools-preview
58+
- name: Install cargo-llvm-cov
59+
uses: taiki-e/install-action@cargo-llvm-cov
60+
- name: Install nextest
61+
uses: taiki-e/install-action@nextest
62+
- name: Generate code coverage
63+
run: cargo llvm-cov nextest --all-features --workspace --lcov --output-path lcov.info
64+
- name: Upload coverage to Codecov
65+
uses: codecov/codecov-action@v4.0.1
66+
with:
67+
token: ${{ secrets.CODECOV_TOKEN }}
68+
files: lcov.info
69+
fail_ci_if_error: true

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# A query string builder for percent encoding key-value pairs
22

3+
[![codecov](https://codecov.io/gh/sunsided/query-string-builder/graph/badge.svg?token=HUCXM04DOG)](https://codecov.io/gh/sunsided/query-string-builder)
4+
35
This is a tiny helper crate for simplifying the construction of URL query strings.
46
The initial `?` question mark is automatically prepended.
57

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl QueryString {
218218
impl Display for QueryString {
219219
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
220220
if self.pairs.is_empty() {
221-
return Ok(());
221+
Ok(())
222222
} else {
223223
write!(f, "?")?;
224224
for (i, pair) in self.pairs.iter().enumerate() {

0 commit comments

Comments
 (0)