Add Code Coverage GH action #2089
Workflow file for this run
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: Tests | |
| on: | |
| pull_request: | |
| push: | |
| # trying and staging branches are for BORS config | |
| branches: | |
| - trying | |
| - staging | |
| - main | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| integration_tests: | |
| # 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: integration-tests | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build | |
| run: cargo build --verbose | |
| - name: Meilisearch (latest version) setup with Docker | |
| run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --no-analytics --master-key=masterKey | |
| - name: Run tests | |
| run: cargo test --verbose | |
| - name: Cargo check | |
| uses: actions-rs/cargo@v1 | |
| with: | |
| command: check | |
| args: --workspace --all-targets --all | |
| - name: Cargo check no default features | |
| uses: actions-rs/cargo@v1 | |
| with: | |
| command: check | |
| args: --workspace --all-targets --all --no-default-features | |
| linter: | |
| name: clippy-check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install clippy | |
| run: rustup component add clippy | |
| - name: Run linter (clippy) | |
| # Will fail when encountering warnings | |
| run: cargo clippy -- -D warnings | |
| formatter: | |
| name: rust-format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run formatter | |
| run: cargo fmt --all -- --check | |
| readme_check: | |
| name: readme-check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check the README.md file is up-to-date | |
| run: sh scripts/check-readme.sh | |
| wasm_build: | |
| name: wasm-build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build | |
| run: | | |
| rustup target add wasm32-unknown-unknown | |
| cargo check -p web_app --target wasm32-unknown-unknown | |
| yaml-lint: | |
| name: Yaml linting check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Yaml lint check | |
| uses: ibiqlik/action-yamllint@v3 | |
| with: | |
| config_file: .yamllint.yml | |
| coverage: | |
| # Will not run if the actor is Dependabot (dependabot PRs) | |
| # Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR) | |
| if: github.actor != 'dependabot[bot]' && !( github.event_name == 'pull_request' && startsWith(github.base_ref, 'bump-meilisearch-v') ) | |
| runs-on: ubuntu-latest | |
| needs: integration_tests | |
| 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: | | |
| set -euo pipefail | |
| 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 |