Skip to content

Commit 28f2c6a

Browse files
authored
Coverage, CI updates, lints (#20)
1 parent e368d44 commit 28f2c6a

File tree

6 files changed

+81
-46
lines changed

6 files changed

+81
-46
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,40 @@ defaults:
1414
shell: bash
1515

1616
jobs:
17-
test:
18-
name: Test
17+
ci:
18+
name: CI
1919
runs-on: ubuntu-latest
2020
steps:
21+
#############################################################
22+
## Full test
23+
##
24+
- if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
25+
uses: Swatinem/rust-cache@v2
2126
- uses: taiki-e/install-action@v2
2227
with: { tool: just }
2328
- uses: actions/checkout@v4
24-
- name: Ensure this crate has not yet been published (on release)
25-
if: github.event_name == 'release'
29+
- if: github.event_name == 'release'
30+
name: Ensure this crate has not yet been published (on release)
2631
run: just check-if-published
27-
- uses: Swatinem/rust-cache@v2
28-
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
29-
- run: just ci-test
32+
- run: RUST_BACKTRACE=1 just ci-test
3033
- name: Check semver
3134
uses: obi1kenobi/cargo-semver-checks-action@v2
32-
33-
msrv:
34-
name: Test MSRV
35-
runs-on: ubuntu-latest
36-
steps:
37-
- uses: taiki-e/install-action@v2
38-
with: { tool: just }
39-
- uses: actions/checkout@v4
40-
- uses: Swatinem/rust-cache@v2
41-
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
42-
- name: Read crate metadata
43-
id: metadata
44-
run: echo "rust-version=$(sed -ne 's/rust-version *= *\"\(.*\)\"/\1/p' Cargo.toml)" >> $GITHUB_OUTPUT
35+
#############################################################
36+
## Test MSRV
37+
##
38+
- name: Read MSRV
39+
id: msrv
40+
run: echo "value=$(sed -ne 's/rust-version *= *\"\(.*\)\"/\1/p' Cargo.toml)" >> $GITHUB_OUTPUT
4541
- name: Install Rust
4642
uses: dtolnay/rust-toolchain@stable
4743
with:
48-
toolchain: ${{ steps.metadata.outputs.rust-version }}
44+
toolchain: ${{ steps.msrv.outputs.value }}
4945
- run: just ci-test-msrv
50-
51-
publish:
52-
name: Publish to crates.io
53-
if: startsWith(github.ref, 'refs/tags/')
54-
needs: [ test, msrv ]
55-
runs-on: ubuntu-latest
56-
steps:
57-
- uses: actions/checkout@v4
58-
- name: Publish to crates.io
46+
#############################################################
47+
## Publish to crates.io
48+
##
49+
- if: startsWith(github.ref, 'refs/tags/')
50+
name: Publish to crates.io
5951
run: cargo publish
6052
env:
6153
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/coverage.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Code coverage
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths-ignore: [ '**.md' ]
7+
pull_request:
8+
branches: [ main ]
9+
paths-ignore: [ '**.md' ]
10+
workflow_dispatch:
11+
12+
jobs:
13+
coverage:
14+
runs-on: ubuntu-latest
15+
env:
16+
CARGO_TERM_COLOR: always
17+
steps:
18+
- name: Checkout sources
19+
uses: actions/checkout@v4
20+
- uses: Swatinem/rust-cache@v2
21+
22+
- uses: taiki-e/install-action@v2
23+
with: { tool: 'just,cargo-llvm-cov' }
24+
- name: Generate code coverage
25+
run: just ci-coverage
26+
- name: Upload coverage to Codecov
27+
uses: codecov/codecov-action@v5
28+
with:
29+
token: ${{ secrets.CODECOV_TOKEN }}
30+
files: target/llvm-cov/codecov.info
31+
fail_ci_if_error: true

.gitignore

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1+
**/*.rs.bk
2+
*.pdb
13
.idea
24
.vscode
3-
venv
4-
5-
### Rust template
6-
# Generated by Cargo
7-
# will have compiled files and executables
85
debug/
96
target/
7+
temp/
8+
tmp/
9+
venv/
1010

11-
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
12-
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
11+
# This is a library, no lock
1312
Cargo.lock
14-
15-
# These are backup files generated by rustfmt
16-
**/*.rs.bk
17-
18-
# MSVC Windows builds of rustc generate these, which store debugging information
19-
*.pdb

LICENSE-MIT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MIT License
22

33
Copyright (c) 2021 Ashcon Mohseninia
4-
Copyright (c) 2023-2025 Yuri Astrakhan
4+
Copyright (c) 2023-2025 Yuri Astrakhan <[email protected]>
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![docs.rs](https://img.shields.io/docsrs/automotive_diag)](https://docs.rs/automotive_diag)
66
[![crates.io license](https://img.shields.io/crates/l/automotive_diag)](https://github.com/nyurik/automotive_diag/blob/main/LICENSE-APACHE)
77
[![CI build](https://github.com/nyurik/automotive_diag/actions/workflows/ci.yml/badge.svg)](https://github.com/nyurik/automotive_diag/actions)
8+
[![Codecov](https://img.shields.io/codecov/c/github/nyurik/automotive_diag)](https://app.codecov.io/gh/nyurik/automotive_diag)
89

910
This crate provides low-level `no_std` structs and enums of
1011
the [Unified Diagnostic Services](https://en.wikipedia.org/wiki/Unified_Diagnostic_Services) (ISO-14229-1),

justfile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ clean:
88
cargo clean
99
rm -f Cargo.lock
1010

11-
# Update all dependencies, including the breaking changes. Requires nightly toolchain (install with `rustup install nightly`)
11+
# Update all dependencies, including breaking changes. Requires nightly toolchain (install with `rustup install nightly`)
1212
update:
1313
cargo +nightly -Z unstable-options update --breaking
1414
cargo update
1515

16+
# Find unused dependencies. Install it with `cargo install cargo-udeps`
17+
udeps:
18+
cargo +nightly udeps --all-targets --workspace --all-features
19+
20+
# Check semver compatibility with prior published version. Install it with `cargo install cargo-semver-checks`
21+
semver *ARGS:
22+
cargo semver-checks {{ARGS}}
23+
1624
# Find the minimum supported Rust version (MSRV) using cargo-msrv extension, and update Cargo.toml
1725
msrv:
1826
cargo msrv find --write-msrv --ignore-lockfile
@@ -47,9 +55,19 @@ check:
4755
RUSTFLAGS='-D warnings' cargo check --workspace --all-targets
4856
RUSTFLAGS='-D warnings' cargo check --no-default-features --features with-uds --all-targets
4957

58+
# Generate code coverage report
59+
coverage *ARGS="--no-clean --open":
60+
cargo llvm-cov --workspace --all-targets --include-build-script {{ARGS}}
61+
62+
# Generate code coverage report to upload to codecov.io
63+
ci-coverage: && \
64+
(coverage '--codecov --output-path target/llvm-cov/codecov.info')
65+
# ATTENTION: the full file path above is used in the CI workflow
66+
mkdir -p target/llvm-cov
67+
5068
# Run all tests
5169
test:
52-
RUSTFLAGS='-D warnings' cargo test
70+
RUSTFLAGS='-D warnings' cargo test --workspace --all-targets
5371
RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-kwp2000
5472
RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-obd2
5573
RUSTFLAGS='-D warnings' cargo test --no-default-features --features with-uds

0 commit comments

Comments
 (0)