-
Notifications
You must be signed in to change notification settings - Fork 34
219 lines (192 loc) · 7.33 KB
/
Copy pathci.yml
File metadata and controls
219 lines (192 loc) · 7.33 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
218
219
name: CI
on:
push:
branches: ["master", "develop", "feature/**", "release/**", "hotfix/**"]
tags: ["*"]
pull_request:
branches: ["master", "develop"]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Keep the Windows build separate so we still validate the .NET Framework target
# and the packaging prerequisites that only exist on Windows runners.
build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- name: Setup .NET SDKs
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets', '.config/dotnet-tools.json') }}
restore-keys: |
nuget-${{ runner.os }}-
- name: Restore .NET tools
run: dotnet tool restore
- name: Restore solution
run: dotnet restore ./src/NEventStore.Persistence.Sql.Core.sln --verbosity m
- name: Run GitVersion and patch assembly info
id: gitversion
shell: pwsh
working-directory: ${{ github.workspace }}
run: |
$gitVersion = dotnet tool run dotnet-gitversion /targetpath "${{ github.workspace }}" /output json /updateAssemblyInfo | ConvertFrom-Json
dotnet tool run dotnet-gitversion /targetpath "${{ github.workspace }}/dependencies/NEventStore" /updateAssemblyInfo | Out-Null
"semver=$($gitVersion.SemVer)" >> $env:GITHUB_OUTPUT
- name: Build solution
run: dotnet build ./src/NEventStore.Persistence.Sql.Core.sln -c Release --no-restore /p:ContinuousIntegrationBuild=True
# Tests run on Linux with database services (PostgreSQL, MySQL, SQLite).
# Each database provider runs independently to isolate failures and validate
# database-specific persistence logic.
test-sql-databases:
needs: build
name: Test (Linux, ${{ matrix.tfm }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Run each modern TFM independently so failures are isolated and easy to read.
tfm:
- net8.0
- net9.0
- net10.0
services:
sqlexpress:
image: mcr.microsoft.com/mssql/server:2022-RTM-GDR1-ubuntu-20.04
env:
SA_PASSWORD: Password12!
ACCEPT_EULA: Y
MSSQL_PID: Express
options: >-
--health-cmd "/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Password12!' -Q 'SELECT 1'"
--health-interval 20s
--health-timeout 10s
--health-retries 10
--health-start-period 30s
ports:
- 1433:1433
postgresql:
image: postgres:15-alpine
env:
POSTGRES_DB: NEventStore
POSTGRES_USER: postgres
POSTGRES_PASSWORD: Password12!
options: >-
--health-cmd pg_isready
--health-interval 20s
--health-timeout 10s
--health-retries 10
--health-start-period 30s
ports:
- 5432:5432
mysql:
image: mysql:8
env:
MYSQL_DATABASE: NEventStore
MYSQL_ROOT_PASSWORD: Password12!
options: >-
--health-cmd "mysqladmin ping -h localhost"
--health-interval 20s
--health-timeout 10s
--health-retries 10
--health-start-period 30s
ports:
- 3306:3306
oracle:
image: gvenzl/oracle-xe
env:
ORACLE_ALLOW_REMOTE: true
ORACLE_PASSWORD: Password12!
options: >-
--health-cmd "sqlplus -L -S / as sysdba @/dev/null"
--health-interval 25s
--health-timeout 10s
--health-retries 10
--health-start-period 30s
ports:
- 1521:1521
env:
NEventStore.MsSql: Server=localhost;Database=NEventStore;User Id=SA;Password=Password12!;TrustServerCertificate=True;
NEventStore.PostgreSql: Server=localhost;Database=NEventStore;Uid=postgres;Pwd=Password12!;Enlist=false;
NEventStore.MySql: Server=localhost;Database=NEventStore;Uid=root;Pwd=Password12!;AutoEnlist=false;
NEventStore.Sqlite: Data Source=:memory:;Cache=Shared;
NEventStore.Oracle: Data Source=localhost:1521/XE;User Id=system;Password=Password12!;Persist Security Info=True;
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- name: Setup .NET SDKs
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets', '.config/dotnet-tools.json') }}
restore-keys: |
nuget-${{ runner.os }}-
- name: Create NEventStore database once SQL Server is healthy
shell: bash
run: |
set -euo pipefail
# Find the SQL Server service container by ancestor image (more reliable in GH Actions)
container_id="$(/usr/bin/docker ps --filter "ancestor=mcr.microsoft.com/mssql/server:2022-RTM-GDR1-ubuntu-20.04" --format "{{.ID}}" | head -n 1)"
if [ -z "$container_id" ]; then
echo "SQL Server service container not found."
/usr/bin/docker ps --format "{{.ID}} {{.Image}} {{.Names}}" || true
exit 1
fi
# Wait until container reports healthy
for i in $(seq 1 60); do
health_status="$(/usr/bin/docker inspect --format='{{.State.Health.Status}}' "$container_id" 2>/dev/null || echo starting)"
if [ "$health_status" = "healthy" ]; then
echo "SQL Server container healthy"
break
fi
echo "Waiting for SQL Server to be healthy: $health_status ($i/60)"
sleep 2
done
if [ "$health_status" != "healthy" ]; then
echo "SQL Server container is not healthy. Logs follow (last 200 lines):"
/usr/bin/docker logs "$container_id" --tail 200 || true
exit 1
fi
# Create database using sqlcmd inside the container
/usr/bin/docker exec "$container_id" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password12!" -Q "IF DB_ID(N'NEventStore') IS NULL CREATE DATABASE [NEventStore];"
- name: Run tests for ${{ matrix.tfm }}
run: dotnet test ./src/NEventStore.Persistence.Sql.Core.sln -c Release -f ${{ matrix.tfm }} --logger "trx;LogFileName=test-results-${{ matrix.tfm }}.trx"
- name: Upload test results
uses: actions/upload-artifact@v7
with:
name: test-results-${{ matrix.tfm }}
path: "**/test-results-${{ matrix.tfm }}.trx"
if-no-files-found: ignore
retention-days: 14