Skip to content

Add Code Coverage GH action #3

Add Code Coverage GH action

Add Code Coverage GH action #3

Workflow file for this run

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