-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The new script, `.ci/test-cover`, handles the test coverage, installing needed dependencies and generating the report. Rename the "Lint Code" workflow job to "Lint and Cover" and add steps to generate and publish a coverage report. Also fix test failures due to missing `postgresql.auto.conf` file by removing the data directory from the `targets` directory, so it won't be cached. This gets all the tests passing consistently. Add common tasks to the `Makefile`, including building, installing, and testing entirely based on the version reported by `pg_config`. Add license and code coverage badges to the README, and document using `make` to build and install the extension. Also, simplify the `V2019_09` and `V2020_12` draft names to `V2019` and `V2020`.
- Loading branch information
Showing
7 changed files
with
130 additions
and
35 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Determine the version of PostgreSQL. | ||
if [ -z ${1+x} ] || [ -z ${2+x} ]; then | ||
echo "ERROR: No PostgreSQL OR PGRX version number passed to $0" | ||
echo "Usage:" | ||
echo " $0 \$PG_VERSION \$PGRX_VERSION" | ||
exit 2 | ||
fi | ||
|
||
PGVERSION=${1:-} | ||
PGRXVERSION=${2:-} | ||
|
||
# Must be absolute to get all the data files from Postgres, too. | ||
DESTDIR="${PWD}/target/cover" | ||
|
||
rustup component add llvm-tools | ||
cargo install grcov "cargo-pgrx@${PGRXVERSION}" | ||
|
||
export RUSTFLAGS="-Cinstrument-coverage" | ||
if [ "$(uname -o)" = "Darwin" ]; then | ||
export RUSTFLAGS="-Clink-arg=-Wl,-undefined,dynamic_lookup $RUSTFLAGS" | ||
fi | ||
|
||
export LLVM_PROFILE_FILE="${DESTDIR}/default_%m_%p.profraw" | ||
cargo test --all --no-default-features --features "pg${PGVERSION} pg_test" -- --nocapture | ||
|
||
grcov "${DESTDIR}" \ | ||
--ignore '**/clang-sys*/**' \ | ||
--ignore '**/pgrx-pg-sys*/**' \ | ||
--ignore "$HOME/.cargo/**" \ | ||
--ignore-not-existing \ | ||
--excl-start 'begin_impossible!' \ | ||
--excl-stop 'end_impossible!' \ | ||
--llvm \ | ||
--binary-path "target/debug/" \ | ||
-s . \ | ||
--branch \ | ||
-o "${DESTDIR}" \ | ||
--output-types html,cobertura | ||
|
||
xmllint --xpath "concat('Coverage: ', 100 * string(//coverage/@line-rate), '%')" "${DESTDIR}/cobertura.xml" | ||
|
||
if [ "$(uname -o)" = "Darwin" ] && [ -z "$CI" ]; then | ||
open "${DESTDIR}/html/index.html" | ||
fi |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
PG_CONFIG ?= $(shell which pg_config) | ||
PGRXV="$(shell perl -nE '/^pgrx\s+=\s"=?([^"]+)/ && do { say $$1; exit }' Cargo.toml)" | ||
PGV=$(shell perl -E 'shift =~ /(\d+)/ && say $$1' "$(shell $(PG_CONFIG) --version)") | ||
|
||
.DEFAULT_GOAL: package # Build jsonshcmea for the PostgreSQL cluster identified by pg_config. | ||
package: | ||
@cargo pgrx package --pg-config "$(PG_CONFIG)" | ||
|
||
.PHONY: install # Install jsonschema into the PostgreSQL cluster identified by pg_config. | ||
install: | ||
@cargo pgrx install --release --pg-config "$(PG_CONFIG)" | ||
|
||
.PHONY: test # Run the full test suite against the PostgreSQL version identified by pg_config. | ||
test: | ||
@cargo test --all --no-default-features --features "pg$(PGV) pg_test" -- --nocapture | ||
|
||
.PHONY: install-check # An alias for the test target for PGXS compatability. | ||
install-check: test | ||
|
||
.PHONY: cover # Run cover tests and generate & open a report. | ||
cover: | ||
@./.ci/test-cover "$(PGV)" "$(PGRXV)" | ||
|
||
.PHONY: pg-version # Print the current PGRX version from Cargo.toml | ||
pgrx-version: | ||
@echo $(PGRXV) | ||
|
||
.PHONY: pg-version # Print the current Postgres version reported by pg_config. | ||
pg-version: Cargo.toml | ||
@echo $(PGV) | ||
|
||
## cleaan: Remove build artifacts and intermediate files. | ||
clean: target | ||
@cargo clean |
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
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
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