-
Notifications
You must be signed in to change notification settings - Fork 100
Add Code Coverage GH action #654
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
base: main
Are you sure you want to change the base?
Changes from all commits
3b70ea6
e783b40
6296993
47e1266
9722db2
06d3ea6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||||||||||||||||||||
Comment on lines
+37
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add a health check to ensure Meilisearch is ready before coverage runs - - name: Meilisearch (latest version) setup with Docker
- run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --no-analytics --master-key=masterKey
+ - name: Meilisearch (latest version) setup with Docker
+ run: |
+ docker run -d --name meilisearch -p 7700:7700 getmeili/meilisearch:latest meilisearch --no-analytics --master-key=masterKey
+ # Wait until Meilisearch is healthy
+ until curl --silent --fail http://localhost:7700/health; do
+ sleep 1
+ done This ensures the service is reachable before coverage collection begins. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||
- 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Fix the conditional logic to properly skip bump and Dependabot PRs
The current
if
uses OR (||
) in a way that still runs the job for bump-meilisearch PRs and Dependabot PRs, contrary to the intended behavior. To skip when it's a PR and either the base ref starts withbump-meilisearch-v
or the actor is Dependabot, update to:This ensures only non-PR events or PRs targeting non-bump branches by non-Dependabot actors will run.
🤖 Prompt for AI Agents