-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (160 loc) · 6.11 KB
/
master-build.yml
File metadata and controls
194 lines (160 loc) · 6.11 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
name: master-build
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
# Cancel in-progress runs on the same branch when a new push arrives
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ── 1. Compile the whole solution ─────────────────────────────────────────────
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Build (Release)
run: dotnet build --no-restore --configuration Release
# ── 2. Core + SQLite tests (no external services required) ───────────────────
test-core:
name: "Tests — Core & SQLite"
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Build (Release)
run: dotnet build --no-restore --configuration Release
- name: "Test: ActiveForge.Tests (core)"
run: >
dotnet test tests/ActiveForge.Tests/ActiveForge.Tests.csproj
--no-build --configuration Release --verbosity normal
--logger "console;verbosity=normal"
- name: "Test: ActiveForge.SQLite.Tests"
run: >
dotnet test tests/ActiveForge.SQLite.Tests/ActiveForge.SQLite.Tests.csproj
--no-build --configuration Release --verbosity normal
--logger "console;verbosity=normal"
# ── 3. SQL Server tests (full suite against SQL Server 2022 in Docker) ─────────
test-sqlserver:
name: "Tests — SQL Server"
needs: build
runs-on: ubuntu-latest
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: "Pa55w0rd!"
ports:
- 1433:1433
options: >-
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'Pa55w0rd!' -No -Q 'SELECT 1'"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Build (Release)
run: dotnet build --no-restore --configuration Release
- name: "Test: ActiveForge.SqlServer.Tests"
env:
SS_ADMIN_CONNSTR: "Server=localhost,1433;Database=master;User Id=sa;Password=Pa55w0rd!;TrustServerCertificate=True"
run: >
dotnet test tests/ActiveForge.SqlServer.Tests/ActiveForge.SqlServer.Tests.csproj
--no-build --configuration Release --verbosity normal
--logger "console;verbosity=normal"
# ── 4. PostgreSQL integration tests ──────────────────────────────────────────
test-postgres:
name: "Tests — PostgreSQL"
needs: build
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: Pa55w0rd
POSTGRES_DB: postgres
ports:
- 5455:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Build (Release)
run: dotnet build --no-restore --configuration Release
- name: "Test: ActiveForge.PostgreSQL.Tests"
env:
PG_ADMIN_CONNSTR: "Host=localhost;Port=5455;Database=postgres;Username=postgres;Password=Pa55w0rd"
run: >
dotnet test tests/ActiveForge.PostgreSQL.Tests/ActiveForge.PostgreSQL.Tests.csproj
--no-build --configuration Release --verbosity normal
--logger "console;verbosity=normal"
# ── 5. MongoDB integration tests ─────────────────────────────────────────────
# Transactions require a replica set; service containers can't be started with
# --replSet, so we start MongoDB manually and initialise the replica set.
test-mongodb:
name: "Tests — MongoDB"
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start MongoDB replica set
run: |
docker run -d --name mongo \
-p 27017:27017 \
mongo:7 --replSet rs0 --bind_ip_all
# Wait for mongod to accept connections
for i in $(seq 1 30); do
docker exec mongo mongosh --quiet --eval "db.adminCommand('ping')" \
&& break || sleep 2
done
# Initialise the single-node replica set
docker exec mongo mongosh --quiet --eval "rs.initiate({_id:'rs0',members:[{_id:0,host:'127.0.0.1:27017'}]})"
# Wait until the node becomes PRIMARY
for i in $(seq 1 20); do
STATUS=$(docker exec mongo mongosh --quiet --eval "rs.status().myState")
[ "$STATUS" = "1" ] && break || sleep 2
done
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Build (Release)
run: dotnet build --no-restore --configuration Release
- name: "Test: ActiveForge.MongoDB.Tests"
run: >
dotnet test tests/ActiveForge.MongoDB.Tests/ActiveForge.MongoDB.Tests.csproj
--no-build --configuration Release --verbosity normal
--logger "console;verbosity=normal"