Skip to content

Commit

Permalink
ci: add code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Oct 11, 2024
1 parent 96387c3 commit e69c014
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
comment: false

coverage:
status:
project:
default:
threshold: 100% # make CI green
patch:
default:
threshold: 100% # make CI green

ignore:
- "**/tests"
- "**/benches"
- "**/examples"
39 changes: 39 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Coverage

on:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: actions-rust-lang/[email protected]
with:
components: llvm-tools-preview

- name: Install just & cargo-llvm-cov
uses: taiki-e/[email protected]
with:
tool: just,cargo-llvm-cov

- name: Generate code coverage
run: just test-coverage-codecov

- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
files: codecov.json
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions codecov.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/oas3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/oas3.svg)
<br />
[![CI](https://github.com/x52dev/oas3-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/x52dev/oas3-rs/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/x52dev/oas3/branch/main/graph/badge.svg)](https://codecov.io/gh/x52dev/oas3)
[![codecov](https://codecov.io/gh/x52dev/oas3-rs/branch/main/graph/badge.svg)](https://codecov.io/gh/x52dev/oas3-rs)
![Version](https://img.shields.io/crates/msrv/oas3.svg)
[![Download](https://img.shields.io/crates/d/oas3.svg)](https://crates.io/crates/oas3)

Expand Down
8 changes: 8 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ test toolchain="":
cargo {{ toolchain }} test --doc --workspace --all-features
RUSTDOCFLAGS="-D warnings" cargo {{ toolchain }} doc --workspace --no-deps --all-features

# Test workspace and generate Codecov coverage file
test-coverage-codecov toolchain="":
cargo {{ toolchain }} llvm-cov --workspace --all-features --codecov --output-path codecov.json

# Test workspace and generate LCOV coverage file
test-coverage-lcov toolchain="":
cargo {{ toolchain }} llvm-cov --workspace --all-features --lcov --output-path lcov.info

# Document crates in workspace.
doc *args:
RUSTDOCFLAGS="--cfg=docsrs -Dwarnings" cargo +nightly doc --workspace --all-features {{ args }}

0 comments on commit e69c014

Please sign in to comment.