diff --git a/.github/actions/win-postgres/action.yml b/.github/actions/win-postgres/action.yml new file mode 100644 index 000000000..6bae12470 --- /dev/null +++ b/.github/actions/win-postgres/action.yml @@ -0,0 +1,26 @@ +name: Set up postgresql on Windows + +runs: + using: composite + steps: + - name: Download postgis + run: | + if (!(Test-Path "C:\postgis.zip")){(new-object net.webclient).DownloadFile("https://osm2pgsql.org/ci/winbuild/postgis-bundle-pg14-3.2.0x64.zip", "c:\postgis.zip")} + 7z x c:\postgis.zip -oc:\postgis_archive + shell: pwsh + - name: Install postgis + run: | + echo "Root: $PGROOT, Bin: $PGBIN" + cp -r c:/postgis_archive/postgis-bundle-*/* "$PGROOT" + shell: bash + - name: Start PostgreSQL on Windows + run: | + $pgService = Get-Service -Name postgresql* + Set-Service -InputObject $pgService -Status running -StartupType automatic + Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru + shell: pwsh + - name: Create test tablespace + run: | + mkdir c:\tablespace + & $env:PGBIN\psql -c "CREATE TABLESPACE tablespacetest LOCATION 'c:/tablespace'" + shell: pwsh diff --git a/.github/actions/win-test/action.yml b/.github/actions/win-test/action.yml index 1db0557f3..7e24c6394 100644 --- a/.github/actions/win-test/action.yml +++ b/.github/actions/win-test/action.yml @@ -4,7 +4,7 @@ runs: using: composite steps: - name: Test - run: ctest --output-on-failure -C Release -L NoDB + run: ctest --output-on-failure -C Release shell: bash working-directory: build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcc4f8242..1afa6f372 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -216,33 +216,75 @@ jobs: - uses: ./.github/actions/ubuntu-prerequisites - uses: ./.github/actions/build-and-test - windows-2019: - runs-on: windows-2019 + windows: + strategy: + matrix: + os: [windows-2019, windows-2022] + runs-on: ${{ matrix.os }} env: GETOPT_INCLUDE_DIR: ${{ github.workspace }}/../wingetopt/src GETOPT_LIBRARY: ${{ github.workspace }}/../wingetopt/build/Release/wingetopt.lib + VCPKG_DEFAULT_BINARY_CACHE: C:/vcpkg_binary_cache steps: - uses: actions/checkout@v2 + - uses: actions/cache@v2 with: - submodules: true + path: | + C:/vcpkg_binary_cache + key: vcpkg-binary-cache-${{ matrix.os }} + - uses: actions/cache@v2 + with: + path: | + C:/postgis.zip + key: postgis-cache + - name: Prepare cache + run: if [ ! -d C:/vcpkg_binary_cache ]; then mkdir C:/vcpkg_binary_cache; fi + shell: bash + - uses: ./.github/actions/win-postgres - uses: ./.github/actions/win-install - uses: ./.github/actions/win-getopt - uses: ./.github/actions/win-cmake - uses: ./.github/actions/win-build - uses: ./.github/actions/win-test + - name: Package osm2pgsql + run: | + mkdir c:/artifact/ + mkdir c:/artifact/osm2pgsql-bin + cp -r Release/* ../README.md ../COPYING ../*.style ../scripts ../flex-config c:/artifact/osm2pgsql-bin/ + shell: bash + working-directory: build + if: matrix.os == 'windows-2022' + - name: 'Upload Artifact' + uses: actions/upload-artifact@v2 + with: + name: osm2pgsql-win64 + path: c:/artifact + if: matrix.os == 'windows-2022' - windows-2022: + windows-package: + needs: windows runs-on: windows-2022 env: - GETOPT_INCLUDE_DIR: ${{ github.workspace }}/../wingetopt/src - GETOPT_LIBRARY: ${{ github.workspace }}/../wingetopt/build/Release/wingetopt.lib + OSMURL: https://download.geofabrik.de/europe/monaco-latest.osm.bz2 steps: - uses: actions/checkout@v2 + - uses: actions/cache@v2 with: - submodules: true - - uses: ./.github/actions/win-install - - uses: ./.github/actions/win-getopt - - uses: ./.github/actions/win-cmake - - uses: ./.github/actions/win-build - - uses: ./.github/actions/win-test + path: | + C:/postgis.zip + key: postgis-cache + - uses: actions/download-artifact@v2 + with: + name: osm2pgsql-win64 + - uses: ./.github/actions/win-postgres + - name: Set up database + run: | + & $env:PGBIN\createdb osm + & $env:PGBIN\psql -d osm -c "CREATE EXTENSION hstore; CREATE EXTENSION postgis;" + shell: pwsh + - name: Get test data + run: (new-object net.webclient).DownloadFile($env:OSMURL, "testfile.osm.bz2") + - name: Exceute osm2pgsql + run: ./osm2pgsql-bin/osm2pgsql --slim -d osm testfile.osm.bz2 + shell: bash diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index c23492ccf..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,125 +0,0 @@ -environment: - global: - BZIP2_VER: 1.0.8.0 - EXPAT_VER: 2.4.1 - PROJ_VER: 7.0.1 - ZLIB_VER: 1.2.11 - LUA_VER: 5.3.4 - LUA_INCLUDE_DIR: C:\lua\include - LUA_LIBRARIES: C:\lua\lua53.lib - LUA_DLL: C:\lua\lua53.dll - WINGETOPT_VER: v0.95 - GETOPT_INCLUDE_DIR: C:\wingetopt\src - GETOPT_LIBRARY: C:\wingetopt\build\wingetopt.lib - BZIP2_INCLUDE_DIR: C:\bzip2\dev - BZIP2_LIBRARY: C:\bzip2\dll - BOOST_PATH: C:\Libraries\boost_1_77_0 - POSTGRESQL_VER: 11.2 - TESTS_POSTGRESQL_ROOT: C:\Progra~1\PostgreSQL\9.6 - POSTGIS_VER: 2.4.3 - POSTGIS_URL: "https://osm2pgsql.org/ci/winbuild/postgis-bundle-pg96-2.4.3x64.zip" - PGUSER: postgres - PGPASSWORD: Password12! - -os: Visual Studio 2019 - -services: - - postgresql96 - -clone_folder: c:\osm2pgsql - -clone_depth: 1 - -init: - - git config --global core.autocrlf input - - set bz2_dll_url=https://github.com/philr/bzip2-windows/releases/download/v%BZIP2_VER%/bzip2-dll-%BZIP2_VER%-win-x64.zip - - set bz2_dev_url=https://github.com/philr/bzip2-windows/releases/download/v%BZIP2_VER%/bzip2-dev-%BZIP2_VER%-win-x64.zip - - set vcvarsall_arg=amd64 - - set conda_path=C:\Miniconda36-x64\Scripts - - set python_path=C:\Python38-x64 - - set conda_library_path=C:\Miniconda36-x64\envs\osm2pgsql\Library - - set lua_url=https://osm2pgsql.org/ci/winbuild/lua_x64.zip - - set build_type=Release - - '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"' - -install: - - set PATH=%TESTS_POSTGRESQL_ROOT%\bin;%python_path%;%PATH%;%conda_path% - - cd c:\ - - conda config --set always_yes yes - - conda create --name osm2pgsql - - activate osm2pgsql - - conda install expat=%EXPAT_VER% proj=%PROJ_VER% zlib=%ZLIB_VER% postgresql=%POSTGRESQL_VER% - - ps: if (!(Test-Path "C:\bzip2_dll_x64.zip")){(new-object net.webclient).DownloadFile($env:bz2_dll_url, "C:\bzip2_dll_x64.zip")} - - 7z x -y C:\bzip2_dll_x64.zip -o%BZIP2_LIBRARY% - - ps: if (!(Test-Path "C:\bzip2_dev_x64.zip")){(new-object net.webclient).DownloadFile($env:bz2_dev_url, "C:\bzip2_dev_x64.zip")} - - 7z x -y C:\bzip2_dev_x64.zip -o%BZIP2_INCLUDE_DIR% - - ps: if (!(Test-Path "C:\lua_x64.zip")){(new-object net.webclient).DownloadFile($env:lua_url, "C:\lua_x64.zip")} - - 7z x -y C:\lua_x64.zip -oC:\lua - - ps: if (!(Test-Path "C:\postgis.zip")){(new-object net.webclient).DownloadFile($env:POSTGIS_URL, "C:\postgis.zip")} - - 7z x C:\postgis.zip -oC:\postgis - - xcopy /e /y /q C:\postgis\postgis-bundle-pg96-2.4.3x64 %TESTS_POSTGRESQL_ROOT% - - git clone https://github.com/alex85k/wingetopt -b %WINGETOPT_VER% C:\wingetopt - - python -V - - python -m pip install psycopg2 - -before_build: - - cd C:\wingetopt - - mkdir build - - cd build - - cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%build_type% - - nmake - -build_script: - - mkdir c:\osm2pgsql\build - - cd c:\osm2pgsql\build - - > - cmake .. -LA -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%build_type% -DBUILD_TESTS=ON - -DLUA_INCLUDE_DIR=%LUA_INCLUDE_DIR% -DLUA_LIBRARIES=%LUA_LIBRARIES% - -DGETOPT_INCLUDE_DIR=%GETOPT_INCLUDE_DIR% -DGETOPT_LIBRARY=%GETOPT_LIBRARY% - -DBOOST_ROOT=%BOOST_PATH% -DBoost_USE_STATIC_LIBS=ON - -DBZIP2_INCLUDE_DIR=%BZIP2_INCLUDE_DIR% - -DBZIP2_LIBRARIES=%BZIP2_INCLUDE_DIR%\libbz2.lib - - nmake - -after_build: - - mkdir osm2pgsql-bin - - copy /y *.exe osm2pgsql-bin - - copy /y ..\*.style osm2pgsql-bin - - copy /y ..\*.lua osm2pgsql-bin - - copy /y %conda_library_path%\bin\libpq.dll osm2pgsql-bin - - copy /y %conda_library_path%\bin\zlib.dll osm2pgsql-bin - - copy /y %conda_library_path%\bin\expat.dll osm2pgsql-bin - - copy /y %conda_library_path%\bin\gssapi64.dll osm2pgsql-bin - - copy /y %conda_library_path%\bin\libcrypto-1_1-x64.dll osm2pgsql-bin - - copy /y %conda_library_path%\bin\libssl-1_1-x64.dll osm2pgsql-bin - - copy /y %conda_library_path%\bin\comerr64.dll osm2pgsql-bin - - copy /y %conda_library_path%\bin\krb5_64.dll osm2pgsql-bin - - copy /y %conda_library_path%\bin\k5sprt64.dll osm2pgsql-bin - - copy /y %conda_library_path%\bin\wshelp64.dll osm2pgsql-bin - - copy /y %BZIP2_LIBRARY%\libbz2.dll osm2pgsql-bin - - copy /y %LUA_DLL% osm2pgsql-bin - - 7z a c:\osm2pgsql\osm2pgsql_%build_type%_x64.zip osm2pgsql-bin -tzip - -before_test: - - cd c:\ - - mkdir temp - - cacls temp /T /E /G Users:F - - cacls temp /T /E /G "Network Service":F - - | - psql -c "CREATE TABLESPACE tablespacetest LOCATION 'c:/temp'" - - set PATH=c:\osm2pgsql\build\osm2pgsql-bin;%PATH% - - set PROJ_LIB=%conda_library_path%\share\proj - -test_script: - - cd c:\osm2pgsql\build - #- ctest -VV -L NoDB - - ctest -VV -LE FlatNodes # enable when Postgis will be available - -artifacts: - - path: osm2pgsql_%build_type%_x64.zip - -cache: - - C:\lua_x64.zip -> appveyor.yml - - C:\bzip2_dev_x64.zip -> appveyor.yml - - C:\bzip2_dll_x64.zip -> appveyor.yml - - C:\postgis.zip -> appveyor.yml diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bc4989051..3d56d4478 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -131,6 +131,7 @@ if (PYTHONINTERP_FOUND) set_tests_properties(regression-test-pbf PROPERTIES TIMEOUT ${TESTING_TIMEOUT}) set_tests_properties(regression-test-pbf PROPERTIES FIXTURES_REQUIRED Tablespace) + set_tests_properties(regression-test-pbf PROPERTIES ENVIRONMENT OSM2PGSQL_BINARY=$) message(STATUS "Added test: regression-test-pbf (needs Python with psycopg2 module)") else() message(WARNING "Can not find python, regression test disabled") diff --git a/tests/regression-test.py.in b/tests/regression-test.py.in index 7235cf18a..48ec948cc 100755 --- a/tests/regression-test.py.in +++ b/tests/regression-test.py.in @@ -1,5 +1,6 @@ #! @PYTHON_EXECUTABLE@ -B +import os import sys import unittest @@ -7,7 +8,7 @@ sys.path.insert(1, '@CMAKE_CURRENT_SOURCE_DIR@') from regression import * -CONFIG['executable'] = '@osm2pgsql_BINARY_DIR@/osm2pgsql' +CONFIG['executable'] = os.environ['OSM2PGSQL_BINARY'] CONFIG['test_data_path'] = '@CMAKE_CURRENT_SOURCE_DIR@/data' CONFIG['default_data_path'] = '@osm2pgsql_SOURCE_DIR@' CONFIG['have_lua'] = '@HAVE_LUA@' == '1'