Skip to content

Commit

Permalink
collect coverage for lantern_extras using grcov
Browse files Browse the repository at this point in the history
  • Loading branch information
var77 committed Oct 31, 2024
1 parent 7b0b553 commit 7573b80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,14 @@ jobs:
workspaces: |
lantern_cli
lantern_extras
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Setup test env
run: sudo su -c "PG_VERSION=$PG_VERSION SETUP_ENV=1 SETUP_POSTGRES=1 SETUP_TESTS=1 USE_SOURCE=1 ./ci/scripts/build-extras.sh"
env:
PG_VERSION: ${{ matrix.postgres }}
- name: Install extension
- name: Initialize pgrx
run: |
cargo install cargo-pgrx --version 0.12.7
cargo pgrx init "--pg$PG_VERSION" /usr/bin/pg_config
RUSTFLAGS="--cfg profile=\"ci-build\"" cargo pgrx install --sudo --pg-config /usr/bin/pg_config --package lantern_extras
env:
PG_VERSION: ${{ matrix.postgres }}
- name: Run postgres
Expand All @@ -189,11 +186,20 @@ jobs:
sudo chmod 777 -R /usr/lib/postgresql/15/lib/
sudo chmod 777 -R /usr/share/postgresql/15/extension/
- name: Run tests
run: cargo llvm-cov --workspace --lcov --output-path lantern-extras-lcov.info
run: |
export RUSTFLAGS='--cfg profile="ci-build" -C instrument-coverage'
export LLVM_PROFILE_FILE="$(pwd)/coverage-%p-%m.profraw"
cargo test
env:
OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }}
COHERE_TOKEN: ${{ secrets.COHERE_TOKEN }}
DB_URL: "postgres://[email protected]:5432/postgres"
- name: Collect coverage
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
cargo install grcov
rustup component add llvm-tools-preview
grcov *.profraw -s . --binary-path target/debug -t lcov --branch -o lantern-extras-lcov.info --ignore "{target/debug/build/*,lantern_cli/tests/*,lantern_cli/src/main.rs}"
- name: Upload lantern_extras coverage
uses: actions/upload-artifact@v4
if: ${{ startsWith(matrix.os, 'ubuntu') }}
Expand Down
7 changes: 6 additions & 1 deletion ci/scripts/build-extras.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ function configure_and_start_postgres() {
wait_for_pg

psql -U postgres -c "CREATE EXTENSION lantern" postgres
psql -U postgres -c "CREATE EXTENSION lantern_extras" postgres

extras_exists=$(psql -U postgres -t -c "SELECT coalesce('t', '') FROM pg_available_extensions WHERE name='lantern_extras'")

if [[ -n "$extras_exists" ]]; then
psql -U postgres -c "CREATE EXTENSION lantern_extras" postgres
fi
}

# Source unified utility functions
Expand Down

0 comments on commit 7573b80

Please sign in to comment.