From 8effea6a2764b17be680d854beacecaace033b9c Mon Sep 17 00:00:00 2001 From: Zacharias Knudsen Date: Wed, 6 Nov 2024 09:36:05 +0100 Subject: [PATCH] macos tests --- .github/workflows/documentation.yml | 2 +- .github/workflows/pgxn.yml | 2 +- .github/workflows/test-linux.yml | 15 +++++------ .github/workflows/test-macos.yml | 41 ++++++++++++++++++----------- .github/workflows/test-windows.yml | 2 +- cmake/AddPostgreSQLExtension.cmake | 15 ++++++----- cmake/FindPostgreSQL.cmake | 3 ++- include/CMakeLists.txt | 2 +- 8 files changed, 46 insertions(+), 36 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index e4b05cfe..17bb96f0 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -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" diff --git a/.github/workflows/pgxn.yml b/.github/workflows/pgxn.yml index fe103202..180cec41 100644 --- a/.github/workflows/pgxn.yml +++ b/.github/workflows/pgxn.yml @@ -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 diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 4b3b799c..b6dba89c 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -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 diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 738074ac..75e45beb 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -11,27 +11,38 @@ 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 }} -DCMAKE_REQUIRED_INCLUDES=/usr/local/include - name: Build run: cmake --build build --config ${{ matrix.config }} @@ -39,8 +50,8 @@ jobs: - 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 }} diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 0d3648ba..34618b68 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -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 diff --git a/cmake/AddPostgreSQLExtension.cmake b/cmake/AddPostgreSQLExtension.cmake index e316ad39..a9a8cf77 100644 --- a/cmake/AddPostgreSQLExtension.cmake +++ b/cmake/AddPostgreSQLExtension.cmake @@ -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 @@ -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} diff --git a/cmake/FindPostgreSQL.cmake b/cmake/FindPostgreSQL.cmake index 6d5b30e8..4a81262b 100644 --- a/cmake/FindPostgreSQL.cmake +++ b/cmake/FindPostgreSQL.cmake @@ -60,10 +60,11 @@ 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}") + # list(APPEND PostgreSQL_INCLUDE_DIRS "/usr/local/include") endif() # ---------------------------------------------------------------------------- diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 81837359..458c2fd9 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -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)