Add Code Coverage GH action #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code Coverage | |
on: | |
pull_request: | |
push: | |
# trying and staging branches are for BORS config | |
branches: | |
- trying | |
- staging | |
- main | |
permissions: | |
contents: read | |
issues: write | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
coverage: | |
# Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR) | |
# Will still run for each push to bump-meilisearch-v* | |
if: github.event_name != 'pull_request' || !startsWith(github.base_ref, 'bump-meilisearch-v') | |
runs-on: ubuntu-latest | |
name: Code Coverage | |
steps: | |
- uses: actions/checkout@v4 | |
# Nightly Rust is used for cargo llvm-cov --doc below. | |
- uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: llvm-tools-preview | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-llvm-cov | |
- name: Meilisearch (latest version) setup with Docker | |
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --no-analytics --master-key=masterKey | |
- name: Collect coverage data | |
# Generate separate reports for tests and doctests, and combine them. | |
run: | | |
cargo llvm-cov --no-report --all-features --workspace | |
cargo llvm-cov --no-report --doc --all-features --workspace | |
cargo llvm-cov report --doctests --codecov --output-path codecov.json | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: codecov.json | |
fail_ci_if_error: true |