Yesterday I released v1.6.0 of the pgxn/pgxn-tools Docker image with a new command: pgrx-build-test
works much like the existing pg-build-test
utility for PGXS extensions, but for pgrx extensions. Here’s an example from pg-jsonschema-boon, a pgrx extension I’ve been working on:
name: 🧪 Test
on:
push:
jobs:
test:
runs-on: ubuntu-latest
container: pgxn/pgxn-tools
strategy:
matrix:
pg: [11, 12, 13, 14, 15, 16]
name: 🐘 Postgres ${{ matrix.pg }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Start PostgreSQL ${{ matrix.pg }}
run: pg-start ${{ matrix.pg }}
- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
- name: Test on PostgreSQL ${{ matrix.pg }}
run: pgrx-build-test
The format is the same as for pg-build-test
, starting with installing a specific version of Postgres from the Postgres Apt repository (supporting versions 8.2 – 17). It then adds the Swatinem/rust-cache action to speed up Rust builds by caching dependencies, and then simply calls pgrx-build-test
instead of pg-build-test
. Here’s what it does:
- Extracts the pgrx version from the
Cargo.toml
file and installs it (requires v0.11.4 or higher) - Initializes pgrx to use the Postgres installed by
pg-start
- Builds the extension with
cargo pgrx package
- Tests the extension with
cargo pgrx test
- Installs the extension with
cargo pgrx install
- Checks for a
Makefile
withinstallcheck
configured and, if it exists, runsmake installcheck
This last step allows one to include PGXS-style pg_regress
tests in addition to Rust/pgrx tests, as pg-jsonschema-boon does. Here’s a successful run.
Special thanks to Eric Ridge and @Jubilee for all the help and improvements in pgrx v0.11.4 that enable this to work transparently.
pgrx Release Pattern
The pattern for releasing a prgx extens