name: Coverage
permissions:
contents: read
on:
pull_request:
branches: [main]
push:
branches-ignore:
- main
- release-plz-*
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
coverage:
name: Code Coverage
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8
env:
MYSQL_DATABASE: mysql_store
MYSQL_USER: mysql
MYSQL_PASSWORD: mysql
MYSQL_ROOT_PASSWORD: mysql
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost -u root -pmysql"
--health-interval=10s
--health-timeout=5s
--health-retries=5
postgres:
image: postgres:18
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
mongodb:
image: mongo:8
env:
MONGO_INITDB_DATABASE: mongo_store
MONGO_INITDB_ROOT_USERNAME: mongodb
MONGO_INITDB_ROOT_PASSWORD: mongodb
ports:
- 27017:27017
options: >-
--health-cmd="mongosh --eval 'db.runCommand({ping: 1})' --quiet"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
run: uv python install 3.12
- name: Setup Python Env & Seed
run: |
uv sync --directory=scripts
source scripts/.venv/bin/activate
python scripts/seed.py
- name: Install protobuf compiler
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-tarpaulin
uses: taiki-e/install-action@cargo-tarpaulin
- name: Cache cargo registry
uses: actions/cache@v5.0.1
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
- name: Generate code coverage
run: cargo tarpaulin --all-features --verbose --timeout 600 --out xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v5
with:
file: cobertura.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}