Skip to content

Commit c2d6a67

Browse files
authored
Merge pull request #654 from Alirexaa/patch-1
Add Code Coverage GH action
2 parents b9567c6 + 06d3ea6 commit c2d6a67

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/coverage.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Code Coverage
2+
3+
on:
4+
pull_request:
5+
push:
6+
# trying and staging branches are for BORS config
7+
branches:
8+
- trying
9+
- staging
10+
- main
11+
12+
permissions:
13+
contents: read
14+
issues: write
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
19+
jobs:
20+
coverage:
21+
# Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR)
22+
# Will still run for each push to bump-meilisearch-v*
23+
# Will not run if the actor is Dependabot (dependabot PRs)
24+
if: github.event_name != 'pull_request' || !startsWith(github.base_ref, 'bump-meilisearch-v') || github.actor != 'dependabot[bot]'
25+
runs-on: ubuntu-latest
26+
name: Code Coverage
27+
steps:
28+
- uses: actions/checkout@v4
29+
# Nightly Rust is used for cargo llvm-cov --doc below.
30+
- uses: dtolnay/rust-toolchain@nightly
31+
with:
32+
components: llvm-tools-preview
33+
- name: Install cargo-llvm-cov
34+
uses: taiki-e/install-action@v2
35+
with:
36+
tool: cargo-llvm-cov
37+
- name: Meilisearch (latest version) setup with Docker
38+
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --no-analytics --master-key=masterKey
39+
- name: Collect coverage data
40+
# Generate separate reports for tests and doctests, and combine them.
41+
run: |
42+
cargo llvm-cov --no-report --all-features --workspace
43+
cargo llvm-cov --no-report --doc --all-features --workspace
44+
cargo llvm-cov report --doctests --codecov --output-path codecov.json
45+
- name: Upload coverage reports to Codecov
46+
uses: codecov/codecov-action@v5
47+
with:
48+
token: ${{ secrets.CODECOV_TOKEN }}
49+
files: codecov.json
50+
fail_ci_if_error: true

0 commit comments

Comments
 (0)