Skip to content

Add Code Coverage GH action #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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*
# Will not run if the actor is Dependabot (dependabot PRs)
if: github.event_name != 'pull_request' || !startsWith(github.base_ref, 'bump-meilisearch-v') || github.actor != 'dependabot[bot]'
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
Loading