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 36d1d6c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 30 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Cache Cargo
uses: actions/cache@v3
- name: Setup pg_validate_extupgrade
uses: baptiste0928/cargo-install@v3
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-2024
crate: pg_validate_extupgrade
git: https://github.com/rjuju/pg_validate_extupgrade

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

- name: Setup PostgreSQL ${{ matrix.pg }}
- name: Setup PostgreSQL
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
Expand Down
45 changes: 31 additions & 14 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,57 @@ jobs:
strategy:
matrix:
config: [Release, Debug]
pg: [14]
pg: [17, 16, 15, 14, 13]

runs-on: macos-14
runs-on: macos-13

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

steps:
- uses: actions/checkout@v3

# - name: Cache Cargo
# uses: actions/cache@v3
# with:
# path: ~/.cargo
# key: ${{ runner.os }}-cargo-2023
- name: Setup pg_validate_extupgrade
uses: baptiste0928/cargo-install@v3
with:
crate: pg_validate_extupgrade
git: https://github.com/rjuju/pg_validate_extupgrade

- name: Setup PostgreSQL
run: |
brew install postgresql@${{ matrix.pg }}
brew unlink postgresql@${{ matrix.pg }}
brew link --overwrite postgresql@${{ matrix.pg }}
brew services run postgresql@${{ matrix.pg }}
# - name: Install pg_validate_extupgrade
# run: cargo install --locked --git https://github.com/rjuju/pg_validate_extupgrade.git
- name: Setup PostGIS
run: brew install postgis
if: ${{ matrix.pg == 17 || matrix.pg == 14 }}

- name: Install PostgreSQL and PostGIS
run: brew install postgresql@${{ matrix.pg }} postgis
- name: Fix gettext linkage for PostgreSQL >= 15
run: |
brew unlink gettext && brew link --overwrite --force gettext
ls /usr/local/lib | grep libintl
if: ${{ matrix.pg >= 15 }}

- 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 -DCMAKE_PREFIX_PATH=/opt/homebrew

- 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: brew services start postgresql@${{ matrix.pg }}
- name: Create test database (for pg_validate_extupgrade)
run: 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

env: # something wrong with gettext
CXXFLAGS: -I/usr/local/include
CPPFLAGS: -I/usr/local/include
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
1 change: 1 addition & 0 deletions cmake/FindPostgreSQL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ execute_process(COMMAND ${PostgreSQL_CONFIG} --libdir OUTPUT_VARIABLE
execute_process(COMMAND ${PostgreSQL_CONFIG} --pkglibdir OUTPUT_VARIABLE PostgreSQL_PKG_LIBRARY_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)

# @TODO: Figure out if we need _INCLUDE_DIR and/or _PKG_INCLUDE_DIR
set(WIP_APPLE_INCLUDE_DIR "/usr/local/include")

# Create include dirs list
list(APPEND PostgreSQL_INCLUDE_DIRS "${PostgreSQL_INCLUDE_DIR}" "${PostgreSQL_PKG_INCLUDE_DIR}" "${PostgreSQL_SERVER_INCLUDE_DIR}")
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 36d1d6c

Please sign in to comment.