Skip to content

Commit 88d8005

Browse files
committed
- fix tests by adding test container setup
1 parent 23567e1 commit 88d8005

3 files changed

Lines changed: 160 additions & 17 deletions

File tree

.github/workflows/master-build.yml

Lines changed: 158 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,169 @@
1-
# This workflow will build a .NET project
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3-
4-
name: .NET
1+
name: master-build
52

63
on:
74
push:
8-
branches: [ "master" ]
5+
branches: ["master"]
96
pull_request:
10-
branches: [ "master" ]
7+
branches: ["master"]
8+
9+
# Cancel in-progress runs on the same branch when a new push arrives
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
1113

1214
jobs:
15+
16+
# ── 1. Compile the whole solution ─────────────────────────────────────────────
1317
build:
18+
name: Build
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
1422

23+
- name: Setup .NET 8
24+
uses: actions/setup-dotnet@v4
25+
with:
26+
dotnet-version: 8.0.x
27+
28+
- name: Restore
29+
run: dotnet restore
30+
31+
- name: Build (Release)
32+
run: dotnet build --no-restore --configuration Release
33+
34+
# ── 2. Core + SQLite tests (no external services required) ───────────────────
35+
test-core:
36+
name: "Tests — Core & SQLite"
37+
needs: build
1538
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Setup .NET 8
43+
uses: actions/setup-dotnet@v4
44+
with:
45+
dotnet-version: 8.0.x
1646

47+
- name: Restore
48+
run: dotnet restore
49+
50+
- name: Build (Release)
51+
run: dotnet build --no-restore --configuration Release
52+
53+
- name: "Test: ActiveForge.Tests (core)"
54+
run: >
55+
dotnet test tests/ActiveForge.Tests/ActiveForge.Tests.csproj
56+
--no-build --configuration Release --verbosity normal
57+
--logger "console;verbosity=normal"
58+
59+
- name: "Test: ActiveForge.SQLite.Tests"
60+
run: >
61+
dotnet test tests/ActiveForge.SQLite.Tests/ActiveForge.SQLite.Tests.csproj
62+
--no-build --configuration Release --verbosity normal
63+
--logger "console;verbosity=normal"
64+
65+
# ── 3. SQL Server unit tests (no live DB — integration tests filtered out) ────
66+
test-sqlserver-unit:
67+
name: "Tests — SQL Server (unit only)"
68+
needs: build
69+
runs-on: ubuntu-latest
1770
steps:
18-
- uses: actions/checkout@v4
19-
- name: Setup .NET
20-
uses: actions/setup-dotnet@v4
21-
with:
22-
dotnet-version: 8.0.x
23-
- name: Restore dependencies
24-
run: dotnet restore
25-
- name: Build
26-
run: dotnet build --no-restore
27-
- name: Test
28-
run: dotnet test --no-build --verbosity normal
71+
- uses: actions/checkout@v4
72+
73+
- name: Setup .NET 8
74+
uses: actions/setup-dotnet@v4
75+
with:
76+
dotnet-version: 8.0.x
77+
78+
- name: Restore
79+
run: dotnet restore
80+
81+
- name: Build (Release)
82+
run: dotnet build --no-restore --configuration Release
83+
84+
- name: "Test: ActiveForge.SqlServer.Tests (unit only)"
85+
run: >
86+
dotnet test tests/ActiveForge.SqlServer.Tests/ActiveForge.SqlServer.Tests.csproj
87+
--no-build --configuration Release --verbosity normal
88+
--filter "Category!=Integration"
89+
--logger "console;verbosity=normal"
90+
91+
# ── 4. PostgreSQL integration tests ──────────────────────────────────────────
92+
test-postgres:
93+
name: "Tests — PostgreSQL"
94+
needs: build
95+
runs-on: ubuntu-latest
96+
97+
services:
98+
postgres:
99+
image: postgres:16-alpine
100+
env:
101+
POSTGRES_USER: postgres
102+
POSTGRES_PASSWORD: Pa55w0rd
103+
POSTGRES_DB: postgres
104+
ports:
105+
- 5455:5432
106+
options: >-
107+
--health-cmd pg_isready
108+
--health-interval 10s
109+
--health-timeout 5s
110+
--health-retries 5
111+
112+
steps:
113+
- uses: actions/checkout@v4
114+
115+
- name: Setup .NET 8
116+
uses: actions/setup-dotnet@v4
117+
with:
118+
dotnet-version: 8.0.x
119+
120+
- name: Restore
121+
run: dotnet restore
122+
123+
- name: Build (Release)
124+
run: dotnet build --no-restore --configuration Release
125+
126+
- name: "Test: ActiveForge.PostgreSQL.Tests"
127+
env:
128+
PG_ADMIN_CONNSTR: "Host=localhost;Port=5455;Database=postgres;Username=postgres;Password=Pa55w0rd"
129+
run: >
130+
dotnet test tests/ActiveForge.PostgreSQL.Tests/ActiveForge.PostgreSQL.Tests.csproj
131+
--no-build --configuration Release --verbosity normal
132+
--logger "console;verbosity=normal"
133+
134+
# ── 5. MongoDB integration tests ─────────────────────────────────────────────
135+
test-mongodb:
136+
name: "Tests — MongoDB"
137+
needs: build
138+
runs-on: ubuntu-latest
139+
140+
services:
141+
mongodb:
142+
image: mongo:7
143+
ports:
144+
- 27017:27017
145+
options: >-
146+
--health-cmd "mongosh --eval 'db.adminCommand(\"ping\")' --quiet"
147+
--health-interval 10s
148+
--health-timeout 10s
149+
--health-retries 5
150+
151+
steps:
152+
- uses: actions/checkout@v4
153+
154+
- name: Setup .NET 8
155+
uses: actions/setup-dotnet@v4
156+
with:
157+
dotnet-version: 8.0.x
158+
159+
- name: Restore
160+
run: dotnet restore
161+
162+
- name: Build (Release)
163+
run: dotnet build --no-restore --configuration Release
164+
165+
- name: "Test: ActiveForge.MongoDB.Tests"
166+
run: >
167+
dotnet test tests/ActiveForge.MongoDB.Tests/ActiveForge.MongoDB.Tests.csproj
168+
--no-build --configuration Release --verbosity normal
169+
--logger "console;verbosity=normal"

tests/ActiveForge.SqlServer.Tests/SqlServerConnectionCrudTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public SsProduct(DataConnection conn) : base(conn) { }
3030
/// Each test class instance gets its own uniquely named database so test
3131
/// runs are fully isolated even when executed in parallel.
3232
/// </summary>
33+
[Trait("Category", "Integration")]
3334
public sealed class SqlServerConnectionCrudTests : IDisposable
3435
{
3536
private static int _counter;

tests/ActiveForge.SqlServer.Tests/SqlServerJoinIntegrationTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public sealed class SsJoinProdOuter : IdentityRecord
5656
/// Mirrors the SQLite join test suite to verify the shared DBDataConnection
5757
/// join infrastructure works correctly with the SQL Server dialect.
5858
/// </summary>
59+
[Trait("Category", "Integration")]
5960
public sealed class SqlServerJoinIntegrationTests : IDisposable
6061
{
6162
private static int _counter;

0 commit comments

Comments
 (0)