diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6cc3dbfca..e62c7b10f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,10 +25,13 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-22.04, windows-2022] + os: [ubuntu-22.04] pg_major: [16, 15, 14, 13] config: [Release] include: + - os: windows-2022 + pg_major: 16 + config: Release - os: ubuntu-22.04 pg_major: 16 config: Debug @@ -41,6 +44,12 @@ jobs: is_release: ${{ steps.analyze_tag.outputs.is_release }} is_prerelease: ${{ steps.analyze_tag.outputs.is_prerelease }} + # Installing PostGIS on Windows is complicated/unreliable, so we don't test on it. + # The NPGSQL_TEST_POSTGIS environment variable ensures that if PostGIS isn't installed, + # the PostGIS tests fail and therefore fail the build. + env: + NPGSQL_TEST_POSTGIS: ${{ !startsWith(matrix.os, 'windows') }} + steps: - name: Checkout uses: actions/checkout@v4 @@ -91,34 +100,12 @@ jobs: curl -o pgsql.zip -L https://get.enterprisedb.com/postgresql/postgresql-${EDB_VERSION}-windows-x64-binaries.zip unzip pgsql.zip -x 'pgsql/include/**' 'pgsql/doc/**' 'pgsql/pgAdmin 4/**' 'pgsql/StackBuilder/**' - # Match Npgsql CI Docker image and stash one level up - cp $GITHUB_WORKSPACE/.build/{server.crt,server.key} pgsql - - # Find OSGEO version number - OSGEO_VERSION=$(\ - curl -Ls https://download.osgeo.org/postgis/windows/pg${{ matrix.pg_major }} | - sed -n 's/.*>postgis-bundle-pg${{ matrix.pg_major }}-\(${{ env.postgis_version }}.[0-9]*.[0-9]*\)x64.zip<.*/\1/p' | - tail -n 1) - if [ -z "$OSGEO_VERSION" ]; then - OSGEO_VERSION=$(\ - curl -Ls https://download.osgeo.org/postgis/windows/pg${{ matrix.pg_major }}/archive | - sed -n 's/.*>postgis-bundle-pg${{ matrix.pg_major }}-\(${{ env.postgis_version }}.[0-9]*.[0-9]*\)x64.zip<.*/\1/p' | - tail -n 1) - POSTGIS_PATH="archive/" - else - POSTGIS_PATH="" - fi - - # Install PostGIS - echo "Installing PostGIS (version: ${OSGEO_VERSION})" - POSTGIS_FILE="postgis-bundle-pg${{ matrix.pg_major }}-${OSGEO_VERSION}x64" - curl -o postgis.zip -L https://download.osgeo.org/postgis/windows/pg${{ matrix.pg_major }}/${POSTGIS_FILE}.zip - unzip postgis.zip -d postgis - cp -a postgis/$POSTGIS_FILE/. pgsql/ - # Start PostgreSQL pgsql/bin/initdb -D pgsql/PGDATA -E UTF8 -U postgres - pgsql/bin/pg_ctl -D pgsql/PGDATA -l logfile -o '-c max_connections=200 -c max_prepared_transactions=10 -c ssl=true -c ssl_cert_file=../server.crt -c ssl_key_file=../server.key' start + if ! pgsql/bin/pg_ctl -D pgsql/PGDATA -l logfile -o '-c max_connections=200 -c max_prepared_transactions=10' start; then + cat logfile + exit 1 + fi # Configure test account pgsql/bin/psql -U postgres -c "CREATE ROLE npgsql_tests SUPERUSER LOGIN PASSWORD 'npgsql_tests'" diff --git a/test/EFCore.PG.FunctionalTests/TestUtilities/RequiresPostgisAttribute.cs b/test/EFCore.PG.FunctionalTests/TestUtilities/RequiresPostgisAttribute.cs index 65df7c2043..d8eedb0957 100644 --- a/test/EFCore.PG.FunctionalTests/TestUtilities/RequiresPostgisAttribute.cs +++ b/test/EFCore.PG.FunctionalTests/TestUtilities/RequiresPostgisAttribute.cs @@ -1,11 +1,13 @@ -namespace Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; +using System.Globalization; + +namespace Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] public sealed class RequiresPostgisAttribute : Attribute, ITestCondition { public ValueTask IsMetAsync() - => new(TestEnvironment.IsPostgisAvailable); + => new(TestEnvironment.IsPostgisAvailable || Environment.GetEnvironmentVariable("NPGSQL_TEST_POSTGIS")?.ToLower(CultureInfo.InvariantCulture) is "1" or "true"); public string SkipReason - => "Requires PostGIS"; + => "PostGIS isn't installed, skipping"; }