Skip to content

Commit

Permalink
ci: add code coverage workflow with llvm-cov (#246)
Browse files Browse the repository at this point in the history
# Rationale for this change

Coverage reports help a lot with code quality and review.

# What changes are included in this PR?

* Added llvm-cov workflow.

# Are these changes tested?

Yes.

---------

Co-authored-by: Jay White <[email protected]>
  • Loading branch information
varshith257 and JayWhite2357 authored Oct 11, 2024
1 parent 140faf1 commit 98452c4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,41 @@ jobs:
- name: Run clippy::pedantic for proof-of-sql-parser
run: cargo clippy --lib -p proof-of-sql-parser -- -D clippy::pedantic

coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y clang lld
- uses: taiki-e/install-action@cargo-llvm-cov
- name: Clean Previous Coverage Artifacts
run: cargo llvm-cov clean --workspace
- name: Run Tests to Generate Coverage Data (All Features)
run: cargo llvm-cov --no-report --all-features
#- name: Run Tests to Generate Coverage Data (Rayon Only)
# run: cargo llvm-cov --no-report --no-default-features --features="rayon"
#- name: Run Tests to Generate Coverage Data (Blitzar Only)
# run: cargo llvm-cov --no-report --no-default-features --features="blitzar"
#- name: Run Tests to Generate Coverage Data (std only)
# run: cargo llvm-cov --no-report --no-default-features --features="std"
- name: Generate Final LCOV Report (Merged Coverage)
run: cargo llvm-cov report --summary-only --fail-under-lines 90
# Future CodeCov Integration
# To integrate with CodeCov in the future,, follow these steps:
# 1. Add the CodeCov token to the repository secrets.
# 2. Use the CodeCov Action to upload the coverage report. For more detailed info refer to [CodeCov Documentation](https://docs.codecov.com/docs).
#
# - name: Generate Final LCOV Report (Merged Coverage)
# run: cargo llvm-cov report --lcov --output-path lcov.info --fail-under-lines 95
# - name: Upload Coverage to Codecov
# uses: codecov/codecov-action@v2
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: lcov.info
# fail_ci_if_error: true

# Run cargo fmt --all -- --config imports_granularity=Crate,group_imports=One --check
format:
name: Format
Expand Down
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The following guideline is heavily based on the [Angular Project Guideline](http
- [Submitting a Pull Request (PR)](#submit-pr)
- [Addressing review feedback](#address-review)
- [Updating the commit message](#updating-commit-message)
- [Running Code Coverage Locally](#coverage-locally)
- [After your pull request is merged](#after-pr-merged)
- [Coding Rules](#rules)
- [Commit Message Guidelines](#commit-guidelines)
Expand Down Expand Up @@ -246,6 +247,12 @@ In order to update the commit message of the last commit on your branch:
NOTE: If you need to update the commit message of an earlier commit, you can use `git rebase` in interactive mode. See the [git docs](https://git-scm.com/docs/git-rebase#_interactive_mode) for more details.
### <a name="coverage-locally"></a> Running Code Coverage Locally
To run code coverage locally, install `cargo-llvm-cov` by following the instructions here: [cargo-llvm-cov Installation](https://github.com/taiki-e/cargo-llvm-cov).
For users of VSCode, you can display coverage reports directly in the IDE by following these instructions: [Display Coverage in VSCode](https://github.com/taiki-e/cargo-llvm-cov?tab=readme-ov-file#display-coverage-in-vs-code).
You can exclude specific functions from coverage by adding an attribute to your code: [Exclude Functions from Coverage](https://github.com/taiki-e/cargo-llvm-cov?tab=readme-ov-file#exclude-function-from-coverage).
### <a name="after-pr-merged"></a> After your pull request is merged
Expand Down Expand Up @@ -275,7 +282,6 @@ After your pull request is merged, you can safely delete your branch and pull th
git pull --ff upstream main
```
## <a name="rules"></a> Coding Rules
To ensure consistency throughout the source code, keep these rules in mind as you are working:
Expand Down

0 comments on commit 98452c4

Please sign in to comment.