From fdb3c1a8728fe36651e9caa80895bee767ad6870 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Wed, 14 Oct 2026 20:21:17 +0200 Subject: [PATCH] [9.0] Align Windows CI with 10.0 Stop overlaying PostGIS DLLs on the Windows PostgreSQL distribution, retain one Windows PostgreSQL 17 Release leg, and remove unused SSL setup. Require PostGIS tests on Linux and print the PostgreSQL startup log on failure. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 43f55a65-2fd6-4cf0-9bf3-4c9877da3bf4 --- .github/workflows/build.yml | 41 +++++++------------ .../TestUtilities/RequiresPostgisAttribute.cs | 8 ++-- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 165798132d..ce60e705b3 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: [17, 16, 15, 14, 13] config: [Release] include: + - os: windows-2022 + pg_major: 17 + config: Release - os: ubuntu-22.04 pg_major: 17 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"; }