Repository navigation
217 lines (183 loc) · 7.52 KB
/
Copy pathbuild.yml
File metadata and controls
217 lines (183 loc) · 7.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Build
on:
push:
branches:
- main
- 'hotfix/**'
- 'release/**'
tags:
- v*
pull_request:
permissions:
contents: read
id-token: write # required for GitHub OIDC
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-26.04]
pg_major: [18, 17, 16, 15, 14]
config: [Release]
include:
- os: windows-2022
pg_major: 17
config: Release
- os: ubuntu-26.04
pg_major: 18
config: Debug
- os: ubuntu-26.04
pg_major: 19
config: Debug
pg_prerelease: rc1
outputs:
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') && !matrix.pg_prerelease }}
services:
postgres:
image: ${{ startsWith(matrix.os, 'ubuntu') && (matrix.pg_prerelease && format('postgres:{0}{1}', matrix.pg_major, matrix.pg_prerelease) || format('postgis/postgis:{0}-3.6', matrix.pg_major)) || '' }}
command: postgres -c max_connections=200
env:
POSTGRES_USER: npgsql_tests
POSTGRES_PASSWORD: npgsql_tests
ports:
- 5432/tcp
options: >-
--health-cmd "pg_isready --host localhost --username npgsql_tests"
--health-interval 1s
--health-timeout 5s
--health-retries 60
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Start PostgreSQL ${{ matrix.pg_major }} (Windows)
id: setup-postgresql-windows
if: startsWith(matrix.os, 'windows')
background: true
run: |
# Find EnterpriseDB version number
EDB_VERSION=$(pwsh -c "
\$global:progressPreference='silentlyContinue';
Invoke-WebRequest -URI https://www.postgresql.org/applications-v2.xml |
Select-Object -ExpandProperty Content |
Select-Xml -XPath '/applications/application[id=\"postgresql_${{ matrix.pg_major }}\" and platform=\"windows-x64\"]/version/text()' |
Select-Object -First 1 -ExpandProperty Node |
Select-Object -ExpandProperty Value")
# Install PostgreSQL
echo "Installing PostgreSQL (version: ${EDB_VERSION})"
curl --fail --retry 5 --retry-all-errors -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/**'
# Start PostgreSQL
pgsql/bin/initdb -D pgsql/PGDATA -E UTF8 -U postgres
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'"
pgsql/bin/psql -U postgres -c "CREATE DATABASE npgsql_tests OWNER npgsql_tests"
shell: bash
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
- name: Build
run: dotnet build --configuration ${{ matrix.config }}
shell: bash
- name: Wait for PostgreSQL setup
wait-all: true
- name: Test
run: dotnet test -c ${{ matrix.config }} --no-build --filter-not-trait category=failing
shell: bash
env:
# Disable SSL to avoid unnecessary handshake pressure in the Windows functional tests.
Test__Npgsql__DefaultConnection: Server=localhost;Port=${{ job.services.postgres.ports[5432] || 5432 }};Username=npgsql_tests;Password=npgsql_tests;SSL Mode=Disable
- id: analyze_tag
name: Analyze tag
shell: bash
run: |
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Release tag detected"
echo "is_release=true" >> "$GITHUB_OUTPUT"
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+.*- ]]; then
echo "Prerelease tag detected"
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
fi
fi
publish-ci:
needs: build
runs-on: ubuntu-26.04
if: github.event_name == 'push' && startsWith(github.repository, 'npgsql/')
environment: myget
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
- name: Pack
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
- name: Upload artifacts
uses: actions/upload-artifact@v7.0.2
with:
name: EFCore.PG.CI
path: nupkgs
- name: Publish packages to MyGet (vnext)
if: startsWith(github.ref, 'refs/heads/') && startsWith(github.ref, 'refs/heads/hotfix/') == false
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.MYGET_FEED_TOKEN }} --source https://www.myget.org/F/npgsql-vnext/api/v3/index.json
working-directory: nupkgs
- name: Publish packages to MyGet (patch)
if: startsWith(github.ref, 'refs/heads/hotfix/')
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.MYGET_FEED_TOKEN }} --source https://www.myget.org/F/npgsql/api/v3/index.json
working-directory: nupkgs
release:
needs: build
runs-on: ubuntu-26.04
if: github.event_name == 'push' && startsWith(github.repository, 'npgsql/') && needs.build.outputs.is_release == 'true'
permissions:
id-token: write # enable GitHub OIDC token issuance for this job
environment: nuget.org
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
- name: Verify release dependencies
shell: bash
run: |
# Do not let daily feeds or the build's package cache hide unpublished dependencies.
packages_dir=$(mktemp -d)
for project in src/*/*.csproj; do
dotnet restore "$project" \
--source https://api.nuget.org/v3/index.json \
--packages "$packages_dir" \
--no-http-cache
done
- name: Pack
run: dotnet pack --configuration Release --property:PackageOutputPath="$PWD/nupkgs" -p:ContinuousIntegrationBuild=true
- name: Upload artifacts
uses: actions/upload-artifact@v7.0.2
with:
name: EFCore.PG.Release
path: nupkgs
# TODO: Create a release
# Get a short-lived NuGet API key
- name: NuGet login (OIDC)
uses: NuGet/login@v1
id: login
with:
user: roji
- name: Publish to nuget.org
run: dotnet nuget push "*.nupkg" --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
working-directory: nupkgs