Enable coverage #45
This file contains 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: CI | |
on: [ push, pull_request ] | |
jobs: | |
test: | |
env: | |
POSTGRESQL: 16 | |
runs-on: ubuntu-latest | |
name: ${{ matrix.name }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
components: rustfmt,llvm-tools-preview | |
- name: Install dependencies | |
run: | | |
curl -s https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main $POSTGRESQL" > /etc/apt/sources.list.d/pgdg.list' | |
sudo apt-get update | |
sudo apt-get install postgresql-$POSTGRESQL postgresql-server-dev-$POSTGRESQL | |
- name: Prepare postgresql | |
run: | | |
sudo sh -c "echo 'host all all samehost trust' > /etc/postgresql/$POSTGRESQL/main/pg_hba.conf" | |
sudo pg_ctlcluster $POSTGRESQL main restart | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
target/ | |
key: cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: cargo- | |
- name: Format check | |
run: cargo fmt --check | |
- name: Test | |
run: cargo test | |
env: | |
DATABASE_URL: postgres://postgres@localhost:5433/ | |
RUSTFLAGS: "-Cinstrument-coverage" | |
RUSTDOCFLAGS: "-Cinstrument-coverage" | |
LLVM_PROFILE_FILE: "${{ github.workspace }}/default_%m_%p.profraw" | |
- name: Collect coverage | |
run: | | |
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.19/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar -xjf- | |
./grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --keep-only 'repology-*/*' --ignore '**/tests.rs' --ignore '*/tests' -o coverage.lcov | |
- name: Submit coverage | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
files: ./coverage.lcov | |
token: ${{ secrets.CODECOV_TOKEN }} |