Skip to content

Commit b79f55a

Browse files
authored
Generate test coverage report in CircleCI (#110)
* coverage? * generate_coverage * +x * 1.62.1 * 62 * ignore * store * quote
1 parent b828e62 commit b79f55a

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

.circleci/config.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ jobs:
99
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
1010
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
1111
docker:
12-
- image: cimg/rust:1.58.1
12+
- image: cimg/rust:1.62.0
1313
environment:
1414
RUST_LOG: info
15+
RUSTFLAGS: "-C instrument-coverage"
16+
LLVM_PROFILE_FILE: "pgcat-%m.profraw"
1517
- image: postgres:14
1618
# auth:
1719
# username: mydockerhub-user
@@ -32,16 +34,19 @@ jobs:
3234
command: "cargo fmt --check"
3335
- run:
3436
name: "Install dependencies"
35-
command: "sudo apt-get update && sudo apt-get install -y psmisc postgresql-contrib-12 postgresql-client-12 ruby ruby-dev libpq-dev python3 python3-pip"
37+
command: "sudo apt-get update && sudo apt-get install -y psmisc postgresql-contrib-12 postgresql-client-12 ruby ruby-dev libpq-dev python3 python3-pip lcov llvm-11"
38+
- run:
39+
name: "Install rust tools"
40+
command: "cargo install cargo-binutils rustfilt && rustup component add llvm-tools-preview"
3641
- run:
3742
name: "Build"
3843
command: "cargo build"
3944
- run:
40-
name: "Test"
41-
command: "cargo test"
42-
- run:
43-
name: "Test end-to-end"
44-
command: "bash .circleci/run_tests.sh"
45+
name: "Tests"
46+
command: "cargo test && bash .circleci/run_tests.sh && .circleci/generate_coverage.sh"
47+
- store_artifacts:
48+
path: /tmp/cov
49+
destination: coverage-data
4550
- save_cache:
4651
key: cargo-lock-2-{{ checksum "Cargo.lock" }}
4752
paths:

.circleci/generate_coverage.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
rust-profdata merge -sparse pgcat-*.profraw -o pgcat.profdata
4+
5+
rust-cov export -ignore-filename-regex="rustc|registry" -Xdemangler=rustfilt -instr-profile=pgcat.profdata --object ./target/debug/pgcat --format lcov > ./lcov.info
6+
7+
genhtml lcov.info --output-directory /tmp/cov --prefix $(pwd)

0 commit comments

Comments
 (0)