@@ -15,11 +15,7 @@ concurrency:
1515 cancel-in-progress : true
1616
1717env :
18- postgis_version : 3
1918 DOTNET_SKIP_FIRST_TIME_EXPERIENCE : true
20- # Windows comes with PG pre-installed, and defines the PGPASSWORD environment variable. Remove it as it interferes
21- # with some of our tests
22- PGPASSWORD : " "
2319
2420jobs :
2521 build :
2824 strategy :
2925 fail-fast : false
3026 matrix :
31- os : [ubuntu-24.04]
32- pg_major : [17, 16, 15, 14, 13]
27+ os : [ubuntu-latest, windows-latest, macos-latest]
3328 config : [Release]
34- test_tfm : [net9.0]
35- include :
36- - os : ubuntu-24.04
37- pg_major : 17
38- config : Debug
39- test_tfm : net9.0
40- - os : macos-15
41- pg_major : 16
42- config : Release
43- test_tfm : net9.0
44- - os : windows-2022
45- pg_major : 17
46- config : Release
47- test_tfm : net9.0
48- - os : ubuntu-24.04
49- pg_major : 17
50- config : Release
51- test_tfm : net8.0
52- # - os: ubuntu-24.04
53- # pg_major: 17
54- # config: Release
55- # test_tfm: net8.0
56- # pg_prerelease: 'PG Prerelease'
57-
58- outputs :
59- is_release : ${{ steps.analyze_tag.outputs.is_release }}
60- is_prerelease : ${{ steps.analyze_tag.outputs.is_prerelease }}
29+ test_tfm : [net8.0, net9.0]
6130
6231 steps :
6332 - name : Checkout
@@ -77,328 +46,3 @@ jobs:
7746 - name : Build
7847 run : dotnet build -c ${{ matrix.config }}
7948 shell : bash
80-
81- - name : Start PostgreSQL ${{ matrix.pg_major }} (Linux)
82- if : startsWith(matrix.os, 'ubuntu')
83- run : |
84- # First uninstall any PostgreSQL installed on the image
85- dpkg-query -W --showformat='${Package}\n' 'postgresql-*' | xargs sudo dpkg -P postgresql
86-
87- # Automated repository configuration
88- sudo apt install -y postgresql-common
89- sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
90- sudo apt-get update -qq
91- sudo apt-get install -qq postgresql-${{ matrix.pg_major }}
92- export PGDATA=/etc/postgresql/${{ matrix.pg_major }}/main
93-
94- sudo cp $GITHUB_WORKSPACE/.build/{server.crt,server.key,ca.crt} $PGDATA
95- sudo chmod 600 $PGDATA/{server.crt,server.key,ca.crt}
96- sudo chown postgres $PGDATA/{server.crt,server.key,ca.crt}
97-
98- # Create npgsql_tests user with md5 password 'npgsql_tests'
99- sudo -u postgres psql -c "CREATE USER npgsql_tests SUPERUSER PASSWORD 'md5adf74603a5772843f53e812f03dacb02'"
100-
101- sudo -u postgres psql -c "CREATE USER npgsql_tests_ssl SUPERUSER PASSWORD 'npgsql_tests_ssl'"
102- sudo -u postgres psql -c "CREATE USER npgsql_tests_nossl SUPERUSER PASSWORD 'npgsql_tests_nossl'"
103-
104- # To disable PostGIS for prereleases (because it usually isn't available until late), surround with the following:
105- if [ -z "${{ matrix.pg_prerelease }}" ]; then
106- sudo apt-get install -qq postgresql-${{ matrix.pg_major }}-postgis-${{ env.postgis_version }}
107- fi
108-
109- if [ ${{ matrix.pg_major }} -ge 14 ]; then
110- sudo sed -i "s|unix_socket_directories = '/var/run/postgresql'|unix_socket_directories = '/var/run/postgresql, @/npgsql_unix'|" $PGDATA/postgresql.conf
111- fi
112-
113- sudo sed -i 's/max_connections = 100/max_connections = 500/' $PGDATA/postgresql.conf
114- sudo sed -i 's/#ssl = off/ssl = on/' $PGDATA/postgresql.conf
115- sudo sed -i "s|ssl_ca_file =|ssl_ca_file = '$PGDATA/ca.crt' #|" $PGDATA/postgresql.conf
116- sudo sed -i "s|ssl_cert_file =|ssl_cert_file = '$PGDATA/server.crt' #|" $PGDATA/postgresql.conf
117- sudo sed -i "s|ssl_key_file =|ssl_key_file = '$PGDATA/server.key' #|" $PGDATA/postgresql.conf
118- sudo sed -i 's/#password_encryption = md5/password_encryption = scram-sha-256/' $PGDATA/postgresql.conf
119- sudo sed -i 's/#wal_level =/wal_level = logical #/' $PGDATA/postgresql.conf
120- sudo sed -i 's/#max_wal_senders =/max_wal_senders = 50 #/' $PGDATA/postgresql.conf
121- sudo sed -i 's/#logical_decoding_work_mem =/logical_decoding_work_mem = 64kB #/' $PGDATA/postgresql.conf
122- sudo sed -i 's/#wal_sender_timeout =/wal_sender_timeout = 3s #/' $PGDATA/postgresql.conf
123- sudo sed -i "s/#synchronous_standby_names =/synchronous_standby_names = 'npgsql_test_sync_standby' #/" $PGDATA/postgresql.conf
124- sudo sed -i "s/#synchronous_commit =/synchronous_commit = local #/" $PGDATA/postgresql.conf
125- sudo sed -i "s/#max_prepared_transactions = 0/max_prepared_transactions = 100/" $PGDATA/postgresql.conf
126-
127- # Disable trust authentication, requiring MD5 passwords - some tests must fail if a password isn't provided.
128- sudo sh -c "echo 'local all all trust' > $PGDATA/pg_hba.conf"
129- sudo sh -c "echo 'host all npgsql_tests_scram all scram-sha-256' >> $PGDATA/pg_hba.conf"
130- sudo sh -c "echo 'hostssl all npgsql_tests_ssl all md5' >> $PGDATA/pg_hba.conf"
131- sudo sh -c "echo 'hostnossl all npgsql_tests_ssl all reject' >> $PGDATA/pg_hba.conf"
132- sudo sh -c "echo 'hostnossl all npgsql_tests_nossl all md5' >> $PGDATA/pg_hba.conf"
133- sudo sh -c "echo 'hostssl all npgsql_tests_nossl all reject' >> $PGDATA/pg_hba.conf"
134- sudo sh -c "echo 'host all all all md5' >> $PGDATA/pg_hba.conf"
135- sudo sh -c "echo 'host replication all all md5' >> $PGDATA/pg_hba.conf"
136-
137- sudo pg_ctlcluster ${{ matrix.pg_major }} main restart
138-
139- # user 'npgsql_tests_scram' must be created with password encrypted as scram-sha-256 (which only applies after restart)
140- sudo -u postgres psql -c "CREATE USER npgsql_tests_scram SUPERUSER PASSWORD 'npgsql_tests_scram'"
141-
142- # Uncomment the following to SSH into the agent running the build (https://github.com/mxschmitt/action-tmate)
143- # - uses: actions/checkout@v4
144- # - name: Setup tmate session
145- # uses: mxschmitt/action-tmate@v3
146-
147- - name : Start PostgreSQL ${{ matrix.pg_major }} (Windows)
148- if : startsWith(matrix.os, 'windows')
149- shell : bash
150- run : |
151- # Find EnterpriseDB version number
152- EDB_VERSION=$(pwsh -c "
153- \$global:progressPreference='silentlyContinue';
154- Invoke-WebRequest -URI https://www.postgresql.org/applications-v2.xml |
155- Select-Object -ExpandProperty Content |
156- Select-Xml -XPath '/applications/application[id=\"postgresql_${{ matrix.pg_major }}\" and platform=\"windows-x64\"]/version/text()' |
157- Select-Object -First 1 -ExpandProperty Node |
158- Select-Object -ExpandProperty Value")
159-
160- # Install PostgreSQL
161- echo "Installing PostgreSQL (version: ${EDB_VERSION})"
162- curl -o pgsql.zip -L https://get.enterprisedb.com/postgresql/postgresql-${EDB_VERSION}-windows-x64-binaries.zip
163- unzip pgsql.zip -x 'pgsql/include/**' 'pgsql/doc/**' 'pgsql/pgAdmin 4/**' 'pgsql/StackBuilder/**'
164-
165- # Match Npgsql CI Docker image and stash one level up
166- cp $GITHUB_WORKSPACE/.build/{server.crt,server.key,ca.crt} pgsql
167-
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-
190- # Start PostgreSQL
191- pgsql/bin/initdb -D pgsql/PGDATA -E UTF8 -U postgres
192- SOCKET_DIR=$(echo "$LOCALAPPDATA\Temp" | sed 's|\\|/|g')
193- sed -i "s|max_connections = 100|max_connections = 500|" pgsql/PGDATA/postgresql.conf
194- sed -i "s|#unix_socket_directories = ''|unix_socket_directories = '$SOCKET_DIR'|" pgsql/PGDATA/postgresql.conf
195- sed -i "s|#wal_level =|wal_level = logical #|" pgsql/PGDATA/postgresql.conf
196- sed -i "s|#max_wal_senders =|max_wal_senders = 50 #|" pgsql/PGDATA/postgresql.conf
197- sed -i "s|#logical_decoding_work_mem =|logical_decoding_work_mem = 64kB #|" pgsql/PGDATA/postgresql.conf
198- sed -i "s|#wal_sender_timeout =|wal_sender_timeout = 3s #|" pgsql/PGDATA/postgresql.conf
199- sed -i "s|#synchronous_standby_names =|synchronous_standby_names = 'npgsql_test_sync_standby' #|" pgsql/PGDATA/postgresql.conf
200- sed -i "s|#synchronous_commit =|synchronous_commit = local #|" pgsql/PGDATA/postgresql.conf
201- sed -i "s|#max_prepared_transactions = 0|max_prepared_transactions = 100|" pgsql/PGDATA/postgresql.conf
202- pgsql/bin/pg_ctl -D pgsql/PGDATA -l logfile -o '-c ssl=true -c ssl_cert_file=../server.crt -c ssl_key_file=../server.key -c ssl_ca_file=../ca.crt' start
203-
204- # Create npgsql_tests user with md5 password 'npgsql_tests'
205- pgsql/bin/psql -U postgres -c "CREATE ROLE npgsql_tests SUPERUSER LOGIN PASSWORD 'md5adf74603a5772843f53e812f03dacb02'"
206-
207- pgsql/bin/psql -U postgres -c "CREATE ROLE npgsql_tests_ssl SUPERUSER LOGIN PASSWORD 'npgsql_tests_ssl'"
208- pgsql/bin/psql -U postgres -c "CREATE ROLE npgsql_tests_nossl SUPERUSER LOGIN PASSWORD 'npgsql_tests_nossl'"
209-
210- # user 'npgsql_tests_scram' must be created with password encrypted as scram-sha-256 (which only applies after restart)
211- if [ ${{ matrix.pg_major }} -ge 14 ]; then
212- sed -i "s|password_encryption = md5|password_encryption = scram-sha-256|" pgsql/PGDATA/postgresql.conf
213- else
214- sed -i "s|#password_encryption = md5|password_encryption = scram-sha-256|" pgsql/PGDATA/postgresql.conf
215- fi
216-
217- pgsql/bin/pg_ctl -D pgsql/PGDATA -l logfile -o '-c ssl=true -c ssl_cert_file=../server.crt -c ssl_key_file=../server.key -c ssl_ca_file=../ca.crt' restart
218-
219- pgsql/bin/psql -U postgres -c "CREATE ROLE npgsql_tests_scram SUPERUSER LOGIN PASSWORD 'npgsql_tests_scram'"
220-
221- # Disable trust authentication except for unix domain sockets, requiring MD5
222- # passwords - some tests must fail if a password isn't provided.
223- if [ ${{ matrix.pg_major }} -ge 13 ]; then
224- echo "local all all trust" > pgsql/PGDATA/pg_hba.conf
225- echo "host all npgsql_tests_scram all scram-sha-256" >> pgsql/PGDATA/pg_hba.conf
226- else
227- echo "host all npgsql_tests_scram all scram-sha-256" > pgsql/PGDATA/pg_hba.conf
228- fi
229- echo "hostssl all npgsql_tests_ssl all md5" >> pgsql/PGDATA/pg_hba.conf
230- echo "hostnossl all npgsql_tests_ssl all reject" >> pgsql/PGDATA/pg_hba.conf
231- echo "hostnossl all npgsql_tests_nossl all md5" >> pgsql/PGDATA/pg_hba.conf
232- echo "hostssl all npgsql_tests_nossl all reject" >> pgsql/PGDATA/pg_hba.conf
233- echo "host all all all md5" >> pgsql/PGDATA/pg_hba.conf
234- echo "host replication all all md5" >> pgsql/PGDATA/pg_hba.conf
235-
236- - name : Start PostgreSQL ${{ matrix.pg_major }} (MacOS)
237- if : startsWith(matrix.os, 'macos')
238- run : |
239- brew update
240- brew install postgresql@${{ matrix.pg_major }}
241-
242- PGDATA=/opt/homebrew/var/postgresql@${{ matrix.pg_major }}
243-
244- sudo sed -i '' 's/#ssl = off/ssl = on/' $PGDATA/postgresql.conf
245- sudo sed -i '' "s/#ssl_ca_file =/ssl_ca_file = 'ca.crt' #/" $PGDATA/postgresql.conf
246- cp $GITHUB_WORKSPACE/.build/{server.crt,server.key,ca.crt} $PGDATA
247- chmod 600 $PGDATA/{server.crt,server.key,ca.crt}
248-
249- postgreService=$(brew services list | grep -oe "postgresql@${{ matrix.pg_major }}\S*")
250-
251- brew services start $postgreService
252- export PATH="/opt/homebrew/opt/postgresql@${{ matrix.pg_major }}/bin:$PATH"
253- echo "Check PostgreSQL service is running"
254- i=5
255- COMMAND='pg_isready'
256- while [ $i -gt 0 ]; do
257- echo "Check PostgreSQL service status"
258- eval $COMMAND && break
259- ((i--))
260- if [ $i == 0 ]; then
261- echo "PostgreSQL service not ready, all attempts exhausted"
262- exit 1
263- fi
264- echo "PostgreSQL service not ready, wait 5 more sec, attempts left: $i"
265- sleep 5
266- done
267-
268- # Create npgsql_tests user with md5 password 'npgsql_tests'
269- psql -c "CREATE USER npgsql_tests SUPERUSER PASSWORD 'md5adf74603a5772843f53e812f03dacb02'" postgres
270-
271- psql -c "CREATE USER npgsql_tests_ssl SUPERUSER PASSWORD 'npgsql_tests_ssl'" postgres
272- psql -c "CREATE USER npgsql_tests_nossl SUPERUSER PASSWORD 'npgsql_tests_nossl'" postgres
273-
274- sudo sed -i '' 's/max_connections = 100/max_connections = 500/' $PGDATA/postgresql.conf
275- sudo sed -i '' 's/#password_encryption = md5/password_encryption = scram-sha-256/' $PGDATA/postgresql.conf
276- sudo sed -i '' 's/#wal_level =/wal_level = logical #/' $PGDATA/postgresql.conf
277- sudo sed -i '' 's/#max_wal_senders =/max_wal_senders = 50 #/' $PGDATA/postgresql.conf
278- sudo sed -i '' 's/#logical_decoding_work_mem =/logical_decoding_work_mem = 64kB #/' $PGDATA/postgresql.conf
279- sudo sed -i '' 's/#wal_sender_timeout =/wal_sender_timeout = 3s #/' $PGDATA/postgresql.conf
280- sudo sed -i '' "s/#synchronous_standby_names =/synchronous_standby_names = 'npgsql_test_sync_standby' #/" $PGDATA/postgresql.conf
281- sudo sed -i '' "s/#synchronous_commit =/synchronous_commit = local #/" $PGDATA/postgresql.conf
282- sudo sed -i '' "s/#max_prepared_transactions = 0/max_prepared_transactions = 100/" $PGDATA/postgresql.conf
283- # Disable trust authentication, requiring MD5 passwords - some tests must fail if a password isn't provided.
284- sudo sh -c "echo 'local all all trust' > $PGDATA/pg_hba.conf"
285- sudo sh -c "echo 'hostssl all npgsql_tests_ssl all md5' >> $PGDATA/pg_hba.conf"
286- sudo sh -c "echo 'hostnossl all npgsql_tests_ssl all reject' >> $PGDATA/pg_hba.conf"
287- sudo sh -c "echo 'hostnossl all npgsql_tests_nossl all md5' >> $PGDATA/pg_hba.conf"
288- sudo sh -c "echo 'hostssl all npgsql_tests_nossl all reject' >> $PGDATA/pg_hba.conf"
289- sudo sh -c "echo 'host all npgsql_tests_scram all scram-sha-256' >> $PGDATA/pg_hba.conf"
290- sudo sh -c "echo 'host all all all md5' >> $PGDATA/pg_hba.conf"
291- sudo sh -c "echo 'host replication all all md5' >> $PGDATA/pg_hba.conf"
292-
293- brew services restart $postgreService
294- echo "Check PostgreSQL service is running"
295- i=5
296- COMMAND='pg_isready'
297- while [ $i -gt 0 ]; do
298- echo "Check PostgreSQL service status"
299- eval $COMMAND && break
300- ((i--))
301- if [ $i == 0 ]; then
302- echo "PostgreSQL service not ready, all attempts exhausted"
303- exit 1
304- fi
305- echo "PostgreSQL service not ready, wait 5 more sec, attempts left: $i"
306- sleep 5
307- done
308- psql -c "CREATE USER npgsql_tests_scram SUPERUSER PASSWORD 'npgsql_tests_scram'" postgres
309-
310- # TODO: Once test/Npgsql.Specification.Tests work, switch to just testing on the solution
311- - name : Test
312- run : |
313- dotnet test -c ${{ matrix.config }} -f ${{ matrix.test_tfm }} test/Npgsql.Tests --logger "GitHubActions;report-warnings=false"
314- dotnet test -c ${{ matrix.config }} -f ${{ matrix.test_tfm }} test/Npgsql.DependencyInjection.Tests --logger "GitHubActions;report-warnings=false"
315- shell : bash
316-
317- - name : Test Plugins
318- if : " !startsWith(matrix.os, 'macos')"
319- run : |
320- if [ -z "${{ matrix.pg_prerelease }}" ]; then
321- dotnet test -c ${{ matrix.config }} -f ${{ matrix.test_tfm }} test/Npgsql.PluginTests --logger "GitHubActions;report-warnings=false"
322- fi
323- shell : bash
324-
325- - id : analyze_tag
326- name : Analyze tag
327- shell : bash
328- run : |
329- if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
330- echo "Release tag detected"
331- echo "::set-output name=is_release::true"
332- if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+.*- ]]; then
333- echo "Prerelease tag detected"
334- echo "::set-output name=is_prerelease::true"
335- fi
336- fi
337-
338- publish-ci :
339- needs : build
340- runs-on : ubuntu-24.04
341- if : github.event_name == 'push' && github.repository == 'npgsql/npgsql'
342- environment : myget
343-
344- steps :
345- - name : Checkout
346- uses : actions/checkout@v4
347-
348- - name : NuGet Cache
349- uses : actions/cache@v4
350- with :
351- path : ~/.nuget/packages
352- key : ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Build.targets') }}
353- restore-keys : |
354- ${{ runner.os }}-nuget-
355-
356- - name : Setup .NET Core SDK
357- 358-
359- - name : Pack
360- run : dotnet pack --configuration Release --property:PackageOutputPath="$PWD/nupkgs" --version-suffix "ci.$(date -u +%Y%m%dT%H%M%S)+sha.${GITHUB_SHA:0:9}" -p:ContinuousIntegrationBuild=true
361-
362- - name : Upload artifacts (nupkg)
363- uses : actions/upload-artifact@v4
364- with :
365- name : Npgsql.CI
366- path : nupkgs
367-
368- - name : Publish packages to MyGet (vnext)
369- if : startsWith(github.ref, 'refs/heads/') && startsWith(github.ref, 'refs/heads/hotfix/') == false
370- run : dotnet nuget push "*.nupkg" --api-key ${{ secrets.MYGET_FEED_TOKEN }} --source https://www.myget.org/F/npgsql-vnext/api/v3/index.json
371- working-directory : nupkgs
372-
373- - name : Publish packages to MyGet (patch)
374- if : startsWith(github.ref, 'refs/heads/hotfix/')
375- run : dotnet nuget push "*.nupkg" --api-key ${{ secrets.MYGET_FEED_TOKEN }} --source https://www.myget.org/F/npgsql/api/v3/index.json
376- working-directory : nupkgs
377-
378- release :
379- needs : build
380- runs-on : ubuntu-24.04
381- if : github.event_name == 'push' && startsWith(github.repository, 'npgsql/') && needs.build.outputs.is_release == 'true'
382- environment : nuget.org
383-
384- steps :
385- - name : Checkout
386- uses : actions/checkout@v4
387-
388- - name : Setup .NET Core SDK
389- 390-
391- - name : Pack
392- run : dotnet pack --configuration Release --property:PackageOutputPath="$PWD/nupkgs" -p:ContinuousIntegrationBuild=true
393-
394- - name : Upload artifacts
395- uses : actions/upload-artifact@v4
396- with :
397- name : Npgsql.Release
398- path : nupkgs
399-
400- # TODO: Create a release
401-
402- - name : Publish to nuget.org
403- run : dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_ORG_API_KEY }} --source https://api.nuget.org/v3/index.json
404- working-directory : nupkgs
0 commit comments