Skip to content

Commit 1250758

Browse files
committed
collect coverage for lantern_extras using grcov
1 parent cc9e703 commit 1250758

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

.github/workflows/build.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ jobs:
6666
- name: Build Lantern CLI
6767
id: build_cli
6868
run: sudo sh -c "PACKAGE_CLI=1 GITHUB_OUTPUT=$GITHUB_OUTPUT ./ci/scripts/build-extras.sh"
69-
if: ${{ matrix.postgres == 15 }} # run only once
69+
if: ${{ matrix.postgres == 17 }} # run only once
7070
- name: Upload archive package artifacts
7171
if: ${{ github.event_name == 'workflow_dispatch' && inputs.create_release }}
7272
uses: actions/upload-artifact@v4
7373
with:
7474
name: ${{ steps.build.outputs.archive_package_name }}
7575
path: ${{ steps.build.outputs.archive_package_path }}
7676
- name: Upload Lantern CLI artifacts
77-
if: ${{ matrix.postgres == 15 && github.event_name == 'workflow_dispatch' && inputs.create_release }} # run only once
77+
if: ${{ matrix.postgres == 17 && github.event_name == 'workflow_dispatch' && inputs.create_release }} # run only once
7878
uses: actions/upload-artifact@v4
7979
with:
8080
name: ${{ steps.build_cli.outputs.cli_package_name }}

.github/workflows/test.yaml

+18-9
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ jobs:
6565
env:
6666
PG_VERSION: ${{ matrix.postgres }}
6767
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
68-
ENABLE_COVERAGE: ${{ (startsWith(matrix.os, 'ubuntu') && matrix.postgres == 15) && '1' || '0' }}
68+
ENABLE_COVERAGE: ${{ (startsWith(matrix.os, 'ubuntu') && matrix.postgres == 17) && '1' || '0' }}
6969
- name: Run tests linux
7070
id: test-linux
7171
run: sudo su postgres -c "PG_VERSION=$PG_VERSION ./ci/scripts/run-tests-linux.sh"
7272
env:
7373
PG_VERSION: ${{ matrix.postgres }}
74-
ENABLE_COVERAGE: ${{ (startsWith(matrix.os, 'ubuntu') && matrix.postgres == 15) && '1' || '0' }}
74+
ENABLE_COVERAGE: ${{ (startsWith(matrix.os, 'ubuntu') && matrix.postgres == 17) && '1' || '0' }}
7575
if: ${{ !startsWith(matrix.os, 'mac') }}
7676
# integration tests
7777
- name: Set LANTERN_CLI_PATH variable
@@ -92,7 +92,7 @@ jobs:
9292
- name: Collect coverage files
9393
id: collect-cov-files
9494
run: sudo su postgres -c "cd /tmp/lantern/lantern_hnsw/build && make cover"
95-
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.postgres == 15 }}
95+
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.postgres == 17 }}
9696

9797
- name: Run update tests linux
9898
id: update-test-linux
@@ -137,7 +137,7 @@ jobs:
137137
/tmp/pg-out.log
138138
/tmp/pg-error.log
139139
- name: Upload lantern coverage
140-
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.postgres == 15 }}
140+
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.postgres == 17 }}
141141
uses: actions/upload-artifact@v4
142142
with:
143143
name: lantern-lcov.info
@@ -167,8 +167,6 @@ jobs:
167167
workspaces: |
168168
lantern_cli
169169
lantern_extras
170-
- name: Install cargo-llvm-cov
171-
uses: taiki-e/install-action@cargo-llvm-cov
172170
- name: Setup test env
173171
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"
174172
env:
@@ -178,7 +176,9 @@ jobs:
178176
cargo install cargo-pgrx --version 0.12.7
179177
cargo pgrx init "--pg$PG_VERSION" /usr/bin/pg_config
180178
sed -i -e "s/default = .*/default=[\"pg${PG_VERSION}\"]/" lantern_extras/Cargo.toml
181-
RUSTFLAGS="--cfg profile=\"ci-build\"" cargo pgrx install --sudo --pg-config /usr/bin/pg_config --package lantern_extras
179+
export RUSTFLAGS='--cfg profile="ci-build" -C instrument-coverage'
180+
export LLVM_PROFILE_FILE="$(pwd)/coverage-%p-%m.profraw"
181+
cargo pgrx install --sudo --pg-config /usr/bin/pg_config --package lantern_extras
182182
env:
183183
PG_VERSION: ${{ matrix.postgres }}
184184
- name: Run postgres
@@ -192,14 +192,23 @@ jobs:
192192
env:
193193
PG_VERSION: ${{ matrix.postgres }}
194194
- name: Run tests
195-
run: cargo llvm-cov --workspace --lcov --output-path lantern-extras-lcov.info
195+
run: |
196+
export RUSTFLAGS='--cfg profile="ci-build" -C instrument-coverage'
197+
export LLVM_PROFILE_FILE="$(pwd)/coverage-%p-%m.profraw"
198+
cargo test
196199
env:
197200
OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }}
198201
COHERE_TOKEN: ${{ secrets.COHERE_TOKEN }}
199202
DB_URL: "postgres://[email protected]:5432/postgres"
203+
- name: Collect coverage
204+
if: ${{ startsWith(matrix.os, 'ubuntu') }}
205+
run: |
206+
cargo install grcov
207+
rustup component add llvm-tools-preview
208+
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}"
200209
- name: Upload lantern_extras coverage
201210
uses: actions/upload-artifact@v4
202-
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.postgres == 15}}
211+
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.postgres == 17}}
203212
with:
204213
name: lantern-extras-lcov.info
205214
path: ./lantern-extras-lcov.info

0 commit comments

Comments
 (0)