From 788eeee9c584057746077b6f69eddadae0908366 Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Mon, 5 Oct 2026 12:51:09 -0700 Subject: [PATCH 1/5] Verify extension builds on PG18 + Python 3.14 Parameterize the postgres major version in pgbuild/Makefile (PG_MAJOR, default 17 so existing builds are unchanged) and add an extension-build check workflow: on PRs touching the build, or on demand, it builds postgres + all extensions once on ubuntu x86_64 (Python 3.14, PG18 by default) and runs the test suite against the freshly built binaries. C/C++ compilation goes through ccache and cargo downloads are cached to keep repeat runs quick. --- .github/workflows/extension-build.yml | 142 ++++++++++++++++++++++++++ pgbuild/Makefile | 9 +- 2 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/extension-build.yml diff --git a/.github/workflows/extension-build.yml b/.github/workflows/extension-build.yml new file mode 100644 index 0000000..88829c6 --- /dev/null +++ b/.github/workflows/extension-build.yml @@ -0,0 +1,142 @@ +# Verifies that postgres and its extensions build on one reference config +# (currently: Python 3.14, Postgres 18, ubuntu x86_64). +# +# This exists for PRs that bump an extension version in pgbuild/Makefile +# (e.g. a new pgvector/pg_duckdb/pg_search release): the full +# multi-platform wheel matrix in build-and-test.yml is too heavy for +# that, so this job builds everything once and then runs the test suite +# against the freshly built binaries. +# +# It also runs on demand via workflow_dispatch, where pg_major, +# python_version and extensions can be overridden to trial a version +# bump before sending a PR. +name: Extension build check + +on: + pull_request: + paths: + - "pgbuild/**" + - "Makefile" + - ".github/workflows/extension-build.yml" + push: + branches: + - main + paths: + - "pgbuild/**" + - "Makefile" + - ".github/workflows/extension-build.yml" + workflow_dispatch: + inputs: + pg_major: + description: "Postgres major version to build" + required: false + default: "18" + python_version: + description: "Python version for the test run" + required: false + default: "3.14" + extensions: + description: "Space-separated extensions to build (empty = Makefile defaults)" + required: false + default: "" + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build PG${{ inputs.pg_major || '18' }} + extensions (py${{ inputs.python_version || '3.14' }}) + runs-on: ubuntu-latest + # Full from-scratch build (notably pg_duckdb static) can take a while; + # ccache + cargo caches below make repeat runs much faster. + timeout-minutes: 300 + env: + PG_MAJOR: ${{ inputs.pg_major || '18' }} + # Route all C/C++ compilation (postgres, pgvector, pg_duckdb, ...) through ccache. + CC: ccache gcc + CXX: ccache g++ + CCACHE_DIR: ${{ github.workspace }}/../.ccache + CCACHE_MAXSIZE: 5G + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python_version || '3.14' }} + + - name: Install build dependencies + run: | + sudo apt-get update + sudo apt-get install -y ccache bison flex gcc libssl-dev llvm-dev clang-dev pkg-config \ + cmake ninja-build liblz4-dev libcurl4-openssl-dev libglib2.0-dev libffi-dev jq + + - name: Install Rust toolchain + run: | + rustup update stable + rustup default stable + echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" + + - name: Install cargo-pgrx + # Latest release, since the pinned 0.16.1 in build-and-test.yml + # predates Postgres 18 support. + run: cargo install cargo-pgrx --locked + + - name: Restore ccache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/../.ccache + key: ccache-pg${{ inputs.pg_major || '18' }}-linux-x86_64-${{ hashFiles('pgbuild/Makefile', '.github/workflows/extension-build.yml') }} + restore-keys: | + ccache-pg${{ inputs.pg_major || '18' }}-linux-x86_64- + + - name: Restore cargo downloads + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: cargo-linux-x86_64-${{ hashFiles('pgbuild/Makefile', '.github/workflows/extension-build.yml') }} + restore-keys: | + cargo-linux-x86_64- + + - name: Reset ccache stats + run: ccache --zero-stats + + - name: Build postgres and extensions + env: + # Mirror build-and-test.yml on x86_64 linux. + RUSTFLAGS: "-C target-feature=+avx2,+fma" + EXTENSIONS_INPUT: ${{ inputs.extensions }} + run: | + args=(PG_MAJOR="$PG_MAJOR") + if [ -n "$EXTENSIONS_INPUT" ]; then args+=("EXTENSIONS=$EXTENSIONS_INPUT"); fi + make "${args[@]}" + + - name: Build pg_search + # Built separately in build-and-test.yml too (not in the default set). + if: ${{ inputs.extensions == '' }} + env: + RUSTFLAGS: "-C target-feature=+avx2,+fma" + run: make PG_MAJOR="$PG_MAJOR" EXTENSIONS=pg_search + + - name: Show ccache stats + if: always() + run: ccache --show-stats + + - name: Verify build output + run: | + BIN=src/pgembed/pginstall/bin + "$BIN/postgres" --version + "$BIN/pg_config" --version + ls -la src/pgembed/pginstall/lib/*.so + + - name: Install package with test extras + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[test]" + + - name: Run test suite against freshly built binaries + run: python -m pytest tests/ -q diff --git a/pgbuild/Makefile b/pgbuild/Makefile index 43ce2ed..03f88f8 100644 --- a/pgbuild/Makefile +++ b/pgbuild/Makefile @@ -49,8 +49,9 @@ pg_search: postgres $(INSTALL_PREFIX)/lib/pg_search.so pg_duckdb: postgres $(INSTALL_PREFIX)/lib/pg_duckdb.so ### postgres -POSTGRES_VERSION := 17-stable -POSTGRES_SRC := REL_17_STABLE +# Major postgres version to build. Override from the command line or CI, e.g. `make PG_MAJOR=18`. +PG_MAJOR ?= 17 +POSTGRES_SRC := REL_$(PG_MAJOR)_STABLE POSTGRES_BLD := $(POSTGRES_SRC) @@ -133,7 +134,7 @@ ifeq ($(RUST_EXTENSIONS_SUPPORTED),1) unset MAKELEVEL && unset MAKEFLAGS && unset MFLAGS \ && export PATH="$$HOME/.cargo/bin:$$PATH" \ && cd $(PGVECTORSCALE_DIR)/pgvectorscale \ - && cargo pgrx init --pg17 $(INSTALL_PREFIX)/bin/pg_config$(EXE_EXT) \ + && cargo pgrx init --pg$(PG_MAJOR) $(INSTALL_PREFIX)/bin/pg_config$(EXE_EXT) \ && cargo pgrx install --release else ifeq ($(OS),Windows_NT) $(error pgvectorscale build is not supported on Windows due to cargo-pgrx issues) @@ -184,7 +185,7 @@ ifeq ($(RUST_EXTENSIONS_SUPPORTED),1) unset MAKELEVEL && unset MAKEFLAGS && unset MFLAGS \ && export PATH="$$HOME/.cargo/bin:$$PATH" \ && cd $(PGSEARCH_SUBDIR) \ - && cargo pgrx init --pg17 $(INSTALL_PREFIX)/bin/pg_config$(EXE_EXT) \ + && cargo pgrx init --pg$(PG_MAJOR) $(INSTALL_PREFIX)/bin/pg_config$(EXE_EXT) \ && cargo pgrx install --release else ifeq ($(OS),Windows_NT) $(error pg_search build is not supported on Windows due to cargo-pgrx issues) From a60915b6ce1eba4f41e75848ad57d53a2a4ae50a Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Mon, 5 Oct 2026 14:31:24 -0700 Subject: [PATCH 2/5] extension-build CI: fix apt packages for ubuntu noble noble has no clang-dev/llvm-dev; use clang + libclang-dev instead. --- .github/workflows/extension-build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/extension-build.yml b/.github/workflows/extension-build.yml index 88829c6..92e938e 100644 --- a/.github/workflows/extension-build.yml +++ b/.github/workflows/extension-build.yml @@ -70,7 +70,9 @@ jobs: - name: Install build dependencies run: | sudo apt-get update - sudo apt-get install -y ccache bison flex gcc libssl-dev llvm-dev clang-dev pkg-config \ + # NB: noble has no clang-dev/llvm-dev metapackages; libclang-dev provides + # the libclang that bindgen (via cargo-pgrx) needs. + sudo apt-get install -y ccache bison flex gcc libssl-dev clang libclang-dev pkg-config \ cmake ninja-build liblz4-dev libcurl4-openssl-dev libglib2.0-dev libffi-dev jq - name: Install Rust toolchain From d35474710d1e0dcb573781deb886c9aedaaaf6a4 Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Mon, 5 Oct 2026 14:49:30 -0700 Subject: [PATCH 3/5] extension-build CI: use cargo-pgrx 0.16.1 Latest cargo-pgrx (0.19.x) refuses to build extensions pinned to pgrx 0.16.1, and 0.16.1 already supports Postgres 18, matching every pgrx-based extension pin (pgvectorscale, pg_search). --- .github/workflows/extension-build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/extension-build.yml b/.github/workflows/extension-build.yml index 92e938e..2371b2e 100644 --- a/.github/workflows/extension-build.yml +++ b/.github/workflows/extension-build.yml @@ -56,6 +56,9 @@ jobs: timeout-minutes: 300 env: PG_MAJOR: ${{ inputs.pg_major || '18' }} + # Must match the pgrx version pinned by the pgrx-based extensions + # (pgvectorscale, pg_search); 0.16.1 supports Postgres 18. + CARGO_PGRX_VERSION: "0.16.1" # Route all C/C++ compilation (postgres, pgvector, pg_duckdb, ...) through ccache. CC: ccache gcc CXX: ccache g++ @@ -82,9 +85,7 @@ jobs: echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" - name: Install cargo-pgrx - # Latest release, since the pinned 0.16.1 in build-and-test.yml - # predates Postgres 18 support. - run: cargo install cargo-pgrx --locked + run: cargo install cargo-pgrx --version "$CARGO_PGRX_VERSION" --locked - name: Restore ccache uses: actions/cache@v4 From 78cc131b7c68ae123040e11aa23df72d6075d0fc Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Mon, 5 Oct 2026 15:25:14 -0700 Subject: [PATCH 4/5] pgbuild: pass explicit --pg version to cargo pgrx install Without it, install falls back to auto-discovered system postgres (e.g. pg16 on GH runners) instead of the version registered via init. This also makes PG_MAJOR actually take effect for pgrx extensions. --- pgbuild/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pgbuild/Makefile b/pgbuild/Makefile index 03f88f8..07e89b7 100644 --- a/pgbuild/Makefile +++ b/pgbuild/Makefile @@ -135,7 +135,7 @@ ifeq ($(RUST_EXTENSIONS_SUPPORTED),1) && export PATH="$$HOME/.cargo/bin:$$PATH" \ && cd $(PGVECTORSCALE_DIR)/pgvectorscale \ && cargo pgrx init --pg$(PG_MAJOR) $(INSTALL_PREFIX)/bin/pg_config$(EXE_EXT) \ - && cargo pgrx install --release + && cargo pgrx install --release --pg$(PG_MAJOR) else ifeq ($(OS),Windows_NT) $(error pgvectorscale build is not supported on Windows due to cargo-pgrx issues) else @@ -186,7 +186,7 @@ ifeq ($(RUST_EXTENSIONS_SUPPORTED),1) && export PATH="$$HOME/.cargo/bin:$$PATH" \ && cd $(PGSEARCH_SUBDIR) \ && cargo pgrx init --pg$(PG_MAJOR) $(INSTALL_PREFIX)/bin/pg_config$(EXE_EXT) \ - && cargo pgrx install --release + && cargo pgrx install --release --pg$(PG_MAJOR) else ifeq ($(OS),Windows_NT) $(error pg_search build is not supported on Windows due to cargo-pgrx issues) else From 40544717c2fa552ea68b0b6e272f2da70e60ed63 Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Mon, 5 Oct 2026 15:50:42 -0700 Subject: [PATCH 5/5] pgbuild: point cargo pgrx install at our pg_config cargo pgrx install has no --pgXX flag; without --pg-config it uses the first pg_config on PATH, which on runners with system postgres silently builds the extension against the wrong major version. --- pgbuild/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pgbuild/Makefile b/pgbuild/Makefile index 07e89b7..015dc8b 100644 --- a/pgbuild/Makefile +++ b/pgbuild/Makefile @@ -135,7 +135,7 @@ ifeq ($(RUST_EXTENSIONS_SUPPORTED),1) && export PATH="$$HOME/.cargo/bin:$$PATH" \ && cd $(PGVECTORSCALE_DIR)/pgvectorscale \ && cargo pgrx init --pg$(PG_MAJOR) $(INSTALL_PREFIX)/bin/pg_config$(EXE_EXT) \ - && cargo pgrx install --release --pg$(PG_MAJOR) + && cargo pgrx install --release --pg-config $(INSTALL_PREFIX)/bin/pg_config$(EXE_EXT) else ifeq ($(OS),Windows_NT) $(error pgvectorscale build is not supported on Windows due to cargo-pgrx issues) else @@ -186,7 +186,7 @@ ifeq ($(RUST_EXTENSIONS_SUPPORTED),1) && export PATH="$$HOME/.cargo/bin:$$PATH" \ && cd $(PGSEARCH_SUBDIR) \ && cargo pgrx init --pg$(PG_MAJOR) $(INSTALL_PREFIX)/bin/pg_config$(EXE_EXT) \ - && cargo pgrx install --release --pg$(PG_MAJOR) + && cargo pgrx install --release --pg-config $(INSTALL_PREFIX)/bin/pg_config$(EXE_EXT) else ifeq ($(OS),Windows_NT) $(error pg_search build is not supported on Windows due to cargo-pgrx issues) else