Skip to content

Commit

Permalink
Add PGXN test, plus PG 11/12/13/14/15 tests (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachasme authored Nov 23, 2022
1 parent 0623a64 commit ef145fc
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 32 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/pgxn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: pgxn

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
pgxn:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Install PGXN Client
run: sudo pip install pgxnclient

- name: Install PostgreSQL server dependencies
run: sudo apt install postgresql-server-dev-14 postgis

- name: Bundle for PGXN
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --target=pgxn
- name: Prepare PostgreSQL
run: |
sudo systemctl start postgresql.service
sudo -u postgres -i createuser --superuser runner
sudo -u postgres -i createdb runner
psql -c "CREATE EXTENSION postgis;"
- name: Install
run: sudo pgxn install ./h3-*.zip

- name: Load
run: pgxn load h3

- name: Check
run: pgxn check h3
22 changes: 14 additions & 8 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,25 @@ jobs:
strategy:
matrix:
config: [Release, Debug]
pg: [15, 14, 13, 12, 11]

runs-on: ubuntu-22.04

name: Linux ${{ matrix.config }} 🐘${{ matrix.pg }}

steps:
- uses: actions/checkout@v3

- name: Install pg_validate_extupgrade
run: cargo install --locked --git https://github.com/rjuju/pg_validate_extupgrade.git

- name: Install PostgreSQL server dependencies
run: sudo apt install postgresql-server-dev-14 postgis
- name: Setup PostgreSQL ${{ matrix.pg }}
run: |
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -p -i -v ${{ matrix.pg }}
sudo apt-get -y install postgresql-${{ matrix.pg }}-postgis-3
sudo -u postgres -i createuser --superuser runner
sudo -u postgres -i createdb runner
psql -c "CREATE EXTENSION postgis;"
- name: Generate
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }}
Expand All @@ -32,13 +40,11 @@ jobs:
- name: Install
run: sudo cmake --install build --component h3-pg

- name: Prepare PostgreSQL
run: |
sudo systemctl start postgresql.service
sudo -u postgres -i createuser --superuser runner
sudo -u postgres -i createdb runner
- name: Test
env:
PGHOST: /var/run/postgresql
run: ctest --test-dir build --output-on-failure --build-config ${{ matrix.config }}

- name: Print regression diffs
if: ${{ failure() }}
run: cat build/*/test/regression.diffs
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
# and oldest tested versions of CMake. This will ensure
# you pick up the best policies.

# FetchContent_MakeAvailable in version 3.14
cmake_minimum_required(VERSION 3.14..3.24)
# Keep minimum version in sync with:
# https://github.com/uber/h3/blob/master/CMakeLists.txt
cmake_minimum_required(VERSION 3.20..3.24)

if(POLICY CMP0135)
# Set the timestamps of all extracted contents to the time of the extraction
Expand All @@ -37,8 +38,11 @@ project(
# (But usually don't do this, except maybe for C++ standard)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Allow forcing PostgreSQL version
set(POSTGRESQL_VERSION $ENV{POSTGRESQL_VERSION} CACHE STRING "PostgreSQL version major")

# Find packages go here.
find_package(PostgreSQL REQUIRED)
find_package(PostgreSQL ${POSTGRESQL_VERSION} REQUIRED)
include(AddPostgreSQLExtension)

# https://cliutils.gitlab.io/modern-cmake/chapters/testing.html
Expand Down Expand Up @@ -67,6 +71,6 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND PostgreSQL_INDENT)
endif()

add_custom_target(pgxn
COMMAND git archive --format zip --prefix="${PROJECT_NAME}-${PROJECT_VERSION}/" -o ${PROJECT_NAME}-${PROJECT_VERSION}.zip HEAD
COMMAND git archive --format zip --prefix="h3-${PROJECT_VERSION}/" -o h3-${PROJECT_VERSION}.zip HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@

# this file only exists to support pgxnclient

.PHONY: all generate build install installcheck format
.PHONY: all install installcheck

all: build

generate:
all:
cmake -B build -DCMAKE_BUILD_TYPE=Release

build: generate
cmake --build build

install: build
install:
cmake --install build --component h3-pg

installcheck: install
installcheck:
ctest --output-on-failure --build-config Release
14 changes: 7 additions & 7 deletions cmake/FindPostgreSQL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

# https://www.postgresql.org/support/versioning/
set(PostgreSQL_SUPPORTED_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
"15" "14" "13" "12" "11" "10")
"15" "14" "13" "12" "11")

# Use `FIND_VERSION` to locate specific version of pg_config, or fallback to known versions
if(FIND_VERSION)
list(PREPEND PostgreSQL_SUPPORTED_VERSIONS "${FIND_VERSION}")
if(PostgreSQL_FIND_VERSION)
list(PREPEND PostgreSQL_SUPPORTED_VERSIONS "${PostgreSQL_FIND_VERSION_MAJOR}")
endif()

foreach(suffix ${PostgreSQL_SUPPORTED_VERSIONS})
Expand All @@ -17,15 +17,15 @@ foreach(suffix ${PostgreSQL_SUPPORTED_VERSIONS})
"PostgreSQL/${suffix}/bin")
endif()
if(UNIX)
list(APPEND PostgreSQL_CONFIG_PATH_SUFFIXES
"bin")
list(APPEND PostgreSQL_CONFIG_HINTS
"/usr/lib/postgresql/${suffix}/bin")
endif()
endforeach()

# Configuration will be based on values gathered from `pg_config`
find_program(PostgreSQL_CONFIG pg_config REQUIRED
PATH_SUFFIXES
${PostgreSQL_CONFIG_PATH_SUFFIXES}
HINTS ${PostgreSQL_CONFIG_HINTS}
PATH_SUFFIXES ${PostgreSQL_CONFIG_PATH_SUFFIXES}
)

# Grab information about the installed version of PostgreSQL
Expand Down
4 changes: 2 additions & 2 deletions h3_postgis/sql/install/05-regions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ AS $$ SELECT h3_cells_to_multi_polygon_wkb($1)::geography $$ IMMUTABLE STRICT PA

--@ availability: unreleased
--@ refid: h3_cells_to_multi_polygon_geometry_agg
CREATE OR REPLACE AGGREGATE h3_cells_to_multi_polygon_geometry(h3index) (
CREATE AGGREGATE h3_cells_to_multi_polygon_geometry(h3index) (
sfunc = array_append,
stype = h3index[],
finalfunc = h3_cells_to_multi_polygon_geometry,
Expand All @@ -66,7 +66,7 @@ CREATE OR REPLACE AGGREGATE h3_cells_to_multi_polygon_geometry(h3index) (

--@ availability: unreleased
--@ refid: h3_cells_to_multi_polygon_geography_agg
CREATE OR REPLACE AGGREGATE h3_cells_to_multi_polygon_geography(h3index) (
CREATE AGGREGATE h3_cells_to_multi_polygon_geography(h3index) (
sfunc = array_append,
stype = h3index[],
finalfunc = h3_cells_to_multi_polygon_geography,
Expand Down
4 changes: 2 additions & 2 deletions h3_postgis/sql/updates/h3_postgis--4.0.2--4.0.3.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ CREATE OR REPLACE FUNCTION
h3_cells_to_multi_polygon_geography(h3index[]) RETURNS geography
AS $$ SELECT h3_cells_to_multi_polygon_wkb($1)::geography $$ IMMUTABLE STRICT PARALLEL SAFE LANGUAGE SQL;

CREATE OR REPLACE AGGREGATE h3_cells_to_multi_polygon_geometry(h3index) (
CREATE AGGREGATE h3_cells_to_multi_polygon_geometry(h3index) (
sfunc = array_append,
stype = h3index[],
finalfunc = h3_cells_to_multi_polygon_geometry,
parallel = safe
);

CREATE OR REPLACE AGGREGATE h3_cells_to_multi_polygon_geography(h3index) (
CREATE AGGREGATE h3_cells_to_multi_polygon_geography(h3index) (
sfunc = array_append,
stype = h3index[],
finalfunc = h3_cells_to_multi_polygon_geography,
Expand Down
2 changes: 1 addition & 1 deletion scripts/bundle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

cmake -B build -DCMAKE_BUILD_TYPE=Debug
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --target=pgxn

0 comments on commit ef145fc

Please sign in to comment.