Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 14 additions & 27 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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'"
Expand Down
Original file line number Diff line number Diff line change
@@ -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<bool> 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";
}
Loading