Skip to content

Commit

Permalink
macos tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zachasme committed Nov 6, 2024
1 parent a82472f commit 8563c56
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 13 deletions.
67 changes: 63 additions & 4 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ jobs:
strategy:
matrix:
config: [Release, Debug]
pg: [14]
pg: [16, 15, 14, 13, 12, 11]

runs-on: macos-14

name: macos 🐘${{ matrix.pg }} (${{ matrix.config }})

steps:
- uses: actions/checkout@v3

Expand All @@ -27,11 +29,18 @@ jobs:
# - name: Install pg_validate_extupgrade
# run: cargo install --locked --git https://github.com/rjuju/pg_validate_extupgrade.git

- name: Install PostgreSQL and PostGIS
run: brew install postgresql@${{ matrix.pg }} postgis
- name: Install (& link) PostgreSQL
run: |
brew install postgresql@${{ matrix.pg }}
brew link postgresql@${{ matrix.pg }}
# brew link --force gettext #building pg>=15 fails without this
# - name: Fix gettext linkage for PostgreSQL >= 15
# if: ${{ matrix.pg >= 15 }}
# run: brew unlink gettext && brew link -n --force gettext

- name: Generate
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }}
run: VERBOSE=true cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_FLAGS=-I/usr/local/include

- name: Build
run: cmake --build build --config ${{ matrix.config }}
Expand All @@ -48,3 +57,53 @@ jobs:
- name: Print regression diffs
if: ${{ failure() }}
run: cat build/*/regression.diffs

env: # something wrong with gettext
CXXFLAGS: -I/usr/local/include
CPPFLAGS: -I/usr/local/include

# ----- PostGIS tests -----
# I postgis on homebrew is pg@14 only, so I'm keeping this test separate
macos-12-postgis:
strategy:
matrix:
config: [Release, Debug]
runs-on: macos-12

name: macos 🐘14 w/ postgis@3 (homebrew)

steps:
- uses: actions/checkout@v3

- name: Cache Cargo
uses: actions/cache@v3
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-2023

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

- name: Install PostGIS
run: brew install postgis

- name: Generate
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }}

- name: Build
run: cmake --build build --config ${{ matrix.config }}

- name: Install
run: sudo cmake --install build --component h3-pg --config ${{ matrix.config }}

- name: Prepare PostgreSQL
run: |
pg_ctl start -D /usr/local/var/postgresql@14 --wait
createdb runner
- name: Test
run: ctest --test-dir build --output-on-failure --build-config ${{ matrix.config }}

- name: Print regression diffs
if: ${{ failure() }}
run: cat build/*/regression.diffs
15 changes: 8 additions & 7 deletions cmake/AddPostgreSQLExtension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ function(PostgreSQL_add_extension LIBRARY_NAME)
# Link extension to PostgreSQL
target_link_libraries(${LIBRARY_NAME} PRIVATE PostgreSQL::PostgreSQL)

# Fix apple missing symbols
# Handle macOS specifics
if(APPLE)
# Fix apple missing symbols
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS ${PostgreSQL_LINK_FLAGS})

# Since Postgres 16, the shared library extension on macOS is `dylib`, not `so`.
# Ref https://github.com/postgres/postgres/commit/b55f62abb2c2e07dfae99e19a2b3d7ca9e58dc1a
if (${PostgreSQL_VERSION_MAJOR} VERSION_GREATER_EQUAL "16")
set_target_properties (${LIBRARY_NAME} PROPERTIES SUFFIX ".dylib")
endif()
endif()

# Final touches on output file
Expand All @@ -44,12 +51,6 @@ function(PostgreSQL_add_extension LIBRARY_NAME)
PREFIX "" # Avoid lib* prefix on output file
)

# Since Postgres 16, the shared library extension on macOS is `dylib`, not `so`.
# Ref https://github.com/postgres/postgres/commit/b55f62abb2c2e07dfae99e19a2b3d7ca9e58dc1a
if (APPLE AND ${PostgreSQL_VERSION_MAJOR} VERSION_GREATER_EQUAL "16")
set_target_properties (${LIBRARY_NAME} PROPERTIES SUFFIX ".dylib")
endif()

# Install .so/.dll to pkglib-dir
install(
TARGETS ${LIBRARY_NAME}
Expand Down
6 changes: 5 additions & 1 deletion cmake/FindPostgreSQL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

# https://www.postgresql.org/support/versioning/
set(PostgreSQL_SUPPORTED_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
<<<<<<< HEAD
"17" "16" "15" "14" "13")
=======
"16" "15" "14" "13" "12" "11")
>>>>>>> 1880bf9 (libintl troubles)

# Use `FIND_VERSION` to locate specific version of pg_config, or fallback to known versions
if(PostgreSQL_FIND_VERSION)
Expand Down Expand Up @@ -41,7 +45,7 @@ execute_process(COMMAND ${PostgreSQL_CONFIG} --pkglibdir OUTPUT_VARIABLE
# @TODO: Figure out if we need _INCLUDE_DIR and/or _PKG_INCLUDE_DIR

# Create include dirs list
list(APPEND PostgreSQL_INCLUDE_DIRS "${PostgreSQL_INCLUDE_DIR}" "${PostgreSQL_PKG_INCLUDE_DIR}" "${PostgreSQL_SERVER_INCLUDE_DIR}")
list(APPEND PostgreSQL_INCLUDE_DIRS "${PostgreSQL_INCLUDE_DIR}" "/usr/local/include" "${PostgreSQL_PKG_INCLUDE_DIR}" "${PostgreSQL_SERVER_INCLUDE_DIR}")
list(APPEND PostgreSQL_LIBRARY_DIRS "${PostgreSQL_LIBRARY_DIR}")

# Set library to search for (which is different on WIN32)
Expand Down
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ target_link_libraries(postgresql_h3_shared
PRIVATE PostgreSQL::PostgreSQL
)
target_include_directories(postgresql_h3_shared
INTERFACE ./
INTERFACE ./ /usr/local/include
)
set_target_properties(postgresql_h3_shared PROPERTIES POSITION_INDEPENDENT_CODE True)

0 comments on commit 8563c56

Please sign in to comment.