Skip to content

Commit

Permalink
macos tests (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachasme authored Nov 6, 2024
1 parent a82472f commit 3bb95f4
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
documentation:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pgxn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install PGXN Client
run: sudo pip install pgxnclient
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@ jobs:
name: linux 🐘${{ matrix.pg }} (${{ matrix.config }})

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- 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
41 changes: 26 additions & 15 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,47 @@ 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
- uses: actions/checkout@v4

- name: Setup pg_validate_extupgrade
uses: baptiste0928/cargo-install@v3
with:
crate: pg_validate_extupgrade
git: https://github.com/rjuju/pg_validate_extupgrade

# - name: Cache Cargo
# uses: actions/cache@v3
# with:
# path: ~/.cargo
# key: ${{ runner.os }}-cargo-2023
- 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
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 }}

- 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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: windows-2022

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Fix default PostgreSQL version on Windows Runner
run: $env:PGBIN >> $env:GITHUB_PATH
Expand Down
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
4 changes: 3 additions & 1 deletion cmake/FindPostgreSQL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ endif(WIN32)
# Platform fixes: MacOS
# https://github.com/postgres/postgres/blob/master/src/makefiles/Makefile.darwin
set(PostgreSQL_LINK_FLAGS "")
# @TODO: Find out if the cannot be done in a more cmakey way
# @TODO: Find out if this can be done in a more cmakey way
if(APPLE)
find_program(PostgreSQL_EXECUTABLE postgres REQUIRED NO_DEFAULT_PATH PATHS ${PostgreSQL_BIN_DIR})
set(PostgreSQL_LINK_FLAGS "-bundle_loader ${PostgreSQL_EXECUTABLE}")
# @TODO: Is it possible to remove this and use a cmake flag instead?
list(APPEND PostgreSQL_INCLUDE_DIRS "/usr/local/include")
endif()

# ----------------------------------------------------------------------------
Expand Down

0 comments on commit 3bb95f4

Please sign in to comment.