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
129 changes: 129 additions & 0 deletions .github/workflows/on-push-do-ci-build-postgis-pgvector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Build & Test - Extensions - PostGIS / PgVector

# Dedicated workflow for the Marten.PostGIS and Marten.PgVector test projects.
# Each suite needs a Postgres image with the matching extension preinstalled —
# the default `postgres:15-alpine` service container used by the other CI
# workflows doesn't ship `postgis` or `vector`, so we run two jobs side-by-side
# with officially-maintained extension images.

on:
push:
branches:
- master
paths-ignore:
- 'documentation/**'
- 'docs/**'
- 'azure-pipelines.yml'
pull_request:
branches:
- master
paths-ignore:
- 'documentation/**'
- 'docs/**'
- 'azure-pipelines.yml'

env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
pg_db: marten_testing
pg_user: postgres
CONFIGURATION: Release
FRAMEWORK: net9.0
DISABLE_TEST_PARALLELIZATION: true
DEFAULT_SERIALIZER: "Newtonsoft"
NUKE_TELEMETRY_OPTOUT: true

jobs:
postgis:
name: PostGIS extension tests
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: postgis/postgis:17-3.5
ports:
- 5432:5432
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: ${{ env.pg_db }}
NAMEDATALEN: 150
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--user postgres
steps:
- uses: actions/checkout@v6

- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
9.0.x
10.0.x

- name: Optimize database for running tests faster
run: |
PG_CONTAINER_NAME=$(docker ps --filter expose=5432/tcp --format {{.Names}})
docker exec $PG_CONTAINER_NAME bash -c "echo -e '\nfsync = off' >> /var/lib/postgresql/data/postgresql.conf"
docker exec $PG_CONTAINER_NAME bash -c "echo -e '\nfull_page_writes = off' >> /var/lib/postgresql/data/postgresql.conf"
docker exec $PG_CONTAINER_NAME bash -c "echo -e '\nsynchronous_commit = off' >> /var/lib/postgresql/data/postgresql.conf"
docker container restart $PG_CONTAINER_NAME
shell: bash

- name: compile
run: ./build.sh compile
shell: bash

- name: test-postgis
if: ${{ success() || failure() }}
run: ./build.sh TestPostGIS
shell: bash

pgvector:
name: PgVector extension tests
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: pgvector/pgvector:pg17
ports:
- 5432:5432
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: ${{ env.pg_db }}
NAMEDATALEN: 150
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--user postgres
steps:
- uses: actions/checkout@v6

- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
9.0.x
10.0.x

- name: Optimize database for running tests faster
run: |
PG_CONTAINER_NAME=$(docker ps --filter expose=5432/tcp --format {{.Names}})
docker exec $PG_CONTAINER_NAME bash -c "echo -e '\nfsync = off' >> /var/lib/postgresql/data/postgresql.conf"
docker exec $PG_CONTAINER_NAME bash -c "echo -e '\nfull_page_writes = off' >> /var/lib/postgresql/data/postgresql.conf"
docker exec $PG_CONTAINER_NAME bash -c "echo -e '\nsynchronous_commit = off' >> /var/lib/postgresql/data/postgresql.conf"
docker container restart $PG_CONTAINER_NAME
shell: bash

- name: compile
run: ./build.sh compile
shell: bash

- name: test-pgvector
if: ${{ success() || failure() }}
run: ./build.sh TestPgVector
shell: bash
2 changes: 2 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"TestMultiTenancy",
"TestNodaTime",
"TestPatching",
"TestPgVector",
"TestPostGIS",
"TestValueTypes"
]
},
Expand Down
4 changes: 4 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.14.15" />
<PackageVersion Include="Neovolve.Logging.Xunit" Version="6.3.0" />
<PackageVersion Include="NetTopologySuite" Version="2.5.0" />
<PackageVersion Include="NetTopologySuite.IO.GeoJSON" Version="4.0.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="NodaTime.Serialization.JsonNet" Version="3.1.0" />
<PackageVersion Include="NodaTime.Serialization.SystemTextJson" Version="1.1.2" />
<PackageVersion Include="Npgsql" Version="9.0.4" />
<PackageVersion Include="Npgsql.DependencyInjection" Version="9.0.2" />
<PackageVersion Include="Npgsql.Json.NET" Version="9.0.4" />
<PackageVersion Include="Npgsql.NetTopologySuite" Version="9.0.4" />
<PackageVersion Include="Npgsql.NodaTime" Version="9.0.2" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="Nuke.Common" Version="10.1.0" />
Expand All @@ -60,6 +63,7 @@
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.0" />
<PackageVersion Include="Pgvector" Version="0.3.2" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="Spectre.Console" Version="0.53.0" />
<PackageVersion Include="StronglyTypedId" Version="1.0.0-beta08" />
Expand Down
28 changes: 27 additions & 1 deletion build/build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class Build : NukeBuild

Target TestExtensions => _ => _
.DependsOn(TestNodaTime)
.DependsOn(TestAspnetcore);
.DependsOn(TestAspnetcore)
.DependsOn(TestPostGIS)
.DependsOn(TestPgVector);

Target Init => _ => _
.Executes(() =>
Expand Down Expand Up @@ -136,6 +138,30 @@ class Build : NukeBuild
.SetFramework(Framework));
});

Target TestPostGIS => _ => _
.ProceedAfterFailure()
.Executes(() =>
{
DotNetTest(c => c
.SetProjectFile("src/Marten.PostGIS.Tests")
.SetConfiguration(Configuration)
.EnableNoBuild()
.EnableNoRestore()
.SetFramework(Framework));
});

Target TestPgVector => _ => _
.ProceedAfterFailure()
.Executes(() =>
{
DotNetTest(c => c
.SetProjectFile("src/Marten.PgVector.Tests")
.SetConfiguration(Configuration)
.EnableNoBuild()
.EnableNoRestore()
.SetFramework(Framework));
});

Target TestCore => _ => _
.ProceedAfterFailure()
.Executes(() =>
Expand Down
9 changes: 8 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
version: '3'
services:
postgresql:
image: ${POSTGRES_IMAGE:-ionx/postgres-plv8:12.8}
# Custom build layering PostGIS 3 + pgvector on top of the official
# multi-arch `postgres:17` image (see docker/postgres/Dockerfile).
# The Debian packages `postgresql-17-postgis-3` and
# `postgresql-17-pgvector` are available on both amd64 and arm64, so
# this works on Apple-silicon hosts. PLv8 was dropped — Marten core
# SQL no longer requires it.
build:
context: ./docker/postgres
ports:
- "5432:5432"
environment:
Expand Down
16 changes: 16 additions & 0 deletions docker/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Custom PostgreSQL image for Marten local development.
#
# Layers PostGIS 3 (`postgresql-17-postgis-3`) and pgvector
# (`postgresql-17-pgvector`) on top of the official multi-arch `postgres:17`
# image. Both Debian packages are available for amd64 and arm64, so this
# builds and runs on Apple-silicon hosts without emulation.
#
# Used by `docker-compose.yml` to back the Marten test suite plus the
# Marten.PostGIS / Marten.PgVector extension test projects.
FROM postgres:17

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-17-postgis-3 \
postgresql-17-pgvector \
&& rm -rf /var/lib/apt/lists/*
8 changes: 8 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,14 @@ const config: UserConfig<DefaultTheme.Config> = {
text: 'Read Replicas',
link: '/postgres/read-replicas'
},
{
text: 'PostGIS spatial support',
link: '/postgres/postgis'
},
{
text: 'pgvector support',
link: '/postgres/pgvector'
},
// {
// text: 'Backup and restore',
// link: '/postgres/backup-restore/'
Expand Down
2 changes: 2 additions & 0 deletions docs/cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
"ngram",
"ngrams",
"pgcrypto",
"pgvector",
"Ollama",
"Jeremie",
"Chassaing",
"dedup"
Expand Down
Loading
Loading