Skip to content

Commit 617ebcc

Browse files
committed
Stop testing PostGIS on Windows
Because of installation reliability issues
1 parent 05e0427 commit 617ebcc

File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ jobs:
5959
is_release: ${{ steps.analyze_tag.outputs.is_release }}
6060
is_prerelease: ${{ steps.analyze_tag.outputs.is_prerelease }}
6161

62+
# Installing PostGIS on Windows is complicated/unreliable, so we don't test on it.
63+
# The NPGSQL_TEST_POSTGIS environment variable ensures that if PostGIS isn't installed,
64+
# the PostGIS tests fail and therefore fail the build.
65+
env:
66+
NPGSQL_TEST_POSTGIS: ${{ startsWith(matrix.os, 'windows') ? 'false' : 'true' }}
67+
6268
steps:
6369
- name: Checkout
6470
uses: actions/checkout@v5
@@ -165,28 +171,6 @@ jobs:
165171
# Match Npgsql CI Docker image and stash one level up
166172
cp $GITHUB_WORKSPACE/.build/{server.crt,server.key,ca.crt} pgsql
167173
168-
# Find OSGEO version number
169-
OSGEO_VERSION=$(\
170-
curl -Ls https://download.osgeo.org/postgis/windows/pg${{ matrix.pg_major }} |
171-
sed -n 's/.*>postgis-bundle-pg${{ matrix.pg_major }}-\(${{ env.postgis_version }}.[0-9]*.[0-9]*\)x64.zip<.*/\1/p' |
172-
tail -n 1)
173-
if [ -z "$OSGEO_VERSION" ]; then
174-
OSGEO_VERSION=$(\
175-
curl -Ls https://download.osgeo.org/postgis/windows/pg${{ matrix.pg_major }}/archive |
176-
sed -n 's/.*>postgis-bundle-pg${{ matrix.pg_major }}-\(${{ env.postgis_version }}.[0-9]*.[0-9]*\)x64.zip<.*/\1/p' |
177-
tail -n 1)
178-
POSTGIS_PATH="archive/"
179-
else
180-
POSTGIS_PATH=""
181-
fi
182-
183-
# Install PostGIS
184-
echo "Installing PostGIS (version: ${OSGEO_VERSION})"
185-
POSTGIS_FILE="postgis-bundle-pg${{ matrix.pg_major }}-${OSGEO_VERSION}x64"
186-
curl -o postgis.zip -L https://download.osgeo.org/postgis/windows/pg${{ matrix.pg_major }}/${POSTGIS_PATH}${POSTGIS_FILE}.zip
187-
unzip postgis.zip -d postgis
188-
cp -a postgis/$POSTGIS_FILE/. pgsql/
189-
190174
# Start PostgreSQL
191175
pgsql/bin/initdb -D pgsql/PGDATA -E UTF8 -U postgres
192176
SOCKET_DIR=$(echo "$LOCALAPPDATA\Temp" | sed 's|\\|/|g')

test/Npgsql.Tests/TestUtil.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ public static async Task IgnoreOnRedshift(NpgsqlConnection conn, string? ignoreT
100100
}
101101
}
102102

103-
public static async Task<bool> IsPgPrerelease(NpgsqlConnection conn)
104-
=> ((string) (await conn.ExecuteScalarAsync("SELECT version()"))!).Contains("beta");
105-
106103
public static void EnsureExtension(NpgsqlConnection conn, string extension, string? minVersion = null)
107104
=> EnsureExtension(conn, extension, minVersion, async: false).GetAwaiter().GetResult();
108105

@@ -168,21 +165,19 @@ static async Task IgnoreIfFeatureNotSupported(NpgsqlConnection conn, string test
168165

169166
public static async Task EnsurePostgis(NpgsqlConnection conn)
170167
{
171-
var isPreRelease = await IsPgPrerelease(conn);
172168
try
173169
{
174170
await EnsureExtensionAsync(conn, "postgis");
175171
}
176-
catch (PostgresException e) when (e.SqlState == PostgresErrorCodes.UndefinedFile)
172+
catch (PostgresException)
177173
{
178-
// PostGIS packages aren't available for PostgreSQL prereleases
179-
if (isPreRelease)
174+
if (Environment.GetEnvironmentVariable("NPGSQL_TEST_POSTGIS")?.ToLower(CultureInfo.InvariantCulture) is "1" or "true")
180175
{
181-
Assert.Ignore($"PostGIS could not be installed, but PostgreSQL is prerelease ({conn.ServerVersion}), ignoring test suite.");
176+
throw;
182177
}
183178
else
184179
{
185-
throw;
180+
Assert.Ignore($"PostGIS isn't installed, skipping tests.");
186181
}
187182
}
188183
}

0 commit comments

Comments
 (0)