Skip to content

Commit bef2f06

Browse files
authored
Stop testing PostGIS on Windows in CI (#6275) (#3649)
Because of installation reliability issues
1 parent 2f2cb7d commit bef2f06

2 files changed

Lines changed: 11 additions & 25 deletions

File tree

.github/workflows/build.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ jobs:
3737
is_release: ${{ steps.analyze_tag.outputs.is_release }}
3838
is_prerelease: ${{ steps.analyze_tag.outputs.is_prerelease }}
3939

40+
# Installing PostGIS on Windows is complicated/unreliable, so we don't test on it.
41+
# The NPGSQL_TEST_POSTGIS environment variable ensures that if PostGIS isn't installed,
42+
# the PostGIS tests fail and therefore fail the build.
43+
env:
44+
NPGSQL_TEST_POSTGIS: ${{ !startsWith(matrix.os, 'windows') }}
45+
4046
steps:
4147
- name: Checkout
4248
uses: actions/checkout@v5
@@ -89,28 +95,6 @@ jobs:
8995
# Match Npgsql CI Docker image and stash one level up
9096
cp $GITHUB_WORKSPACE/.build/{server.crt,server.key} pgsql
9197
92-
# Find OSGEO version number
93-
OSGEO_VERSION=$(\
94-
curl -Ls https://download.osgeo.org/postgis/windows/pg${{ matrix.pg_major }} |
95-
sed -n 's/.*>postgis-bundle-pg${{ matrix.pg_major }}-\(${{ env.postgis_version }}.[0-9]*.[0-9]*\)x64.zip<.*/\1/p' |
96-
tail -n 1)
97-
if [ -z "$OSGEO_VERSION" ]; then
98-
OSGEO_VERSION=$(\
99-
curl -Ls https://download.osgeo.org/postgis/windows/pg${{ matrix.pg_major }}/archive |
100-
sed -n 's/.*>postgis-bundle-pg${{ matrix.pg_major }}-\(${{ env.postgis_version }}.[0-9]*.[0-9]*\)x64.zip<.*/\1/p' |
101-
tail -n 1)
102-
POSTGIS_PATH="archive/"
103-
else
104-
POSTGIS_PATH=""
105-
fi
106-
107-
# Install PostGIS
108-
echo "Installing PostGIS (version: ${OSGEO_VERSION})"
109-
POSTGIS_FILE="postgis-bundle-pg${{ matrix.pg_major }}-${OSGEO_VERSION}x64"
110-
curl -o postgis.zip -L https://download.osgeo.org/postgis/windows/pg${{ matrix.pg_major }}/${POSTGIS_FILE}.zip
111-
unzip postgis.zip -d postgis
112-
cp -a postgis/$POSTGIS_FILE/. pgsql/
113-
11498
# Start PostgreSQL
11599
pgsql/bin/initdb -D pgsql/PGDATA -E UTF8 -U postgres
116100
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
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
namespace Microsoft.EntityFrameworkCore.TestUtilities;
1+
using System.Globalization;
2+
3+
namespace Microsoft.EntityFrameworkCore.TestUtilities;
24

35
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
46
public sealed class RequiresPostgisAttribute : Attribute, ITestCondition
57
{
68
public ValueTask<bool> IsMetAsync()
7-
=> new(TestEnvironment.IsPostgisAvailable);
9+
=> new(TestEnvironment.IsPostgisAvailable || Environment.GetEnvironmentVariable("NPGSQL_TEST_POSTGIS")?.ToLower(CultureInfo.InvariantCulture) is "1" or "true");
810

911
public string SkipReason
10-
=> "Requires PostGIS";
12+
=> "PostGIS isn't installed, skipping";
1113
}

0 commit comments

Comments
 (0)