Skip to content

Commit 7dec95f

Browse files
committed
feat: add nightly integration tests workflow and configure CI to run integration tests with a PostgreSQL service.
1 parent 692cc36 commit 7dec95f

2 files changed

Lines changed: 80 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ jobs:
1616
build-and-test:
1717
runs-on: ubuntu-latest
1818

19+
services:
20+
postgres:
21+
image: postgres:17
22+
env:
23+
POSTGRES_PASSWORD: postgres
24+
POSTGRES_DB: bookstore
25+
ports:
26+
- 5432:5432
27+
options: >-
28+
--health-cmd pg_isready
29+
--health-interval 10s
30+
--health-timeout 5s
31+
--health-retries 5
32+
1933
steps:
2034
- name: Checkout code
2135
uses: actions/checkout@v6
@@ -53,11 +67,9 @@ jobs:
5367
- name: Run web integration tests
5468
run: dotnet test --configuration Release --treenode-filter "/**[Category=Integration]"
5569
working-directory: src/Web/BookStore.Web.Tests
56-
timeout-minutes: 10
57-
continue-on-error: true # Don't fail CI if integration tests timeout
70+
timeout-minutes: 5
5871
# Integration tests run after unit tests pass
59-
# Slower tests that require full application stack (Aspire startup takes time)
60-
# Note: These tests may timeout in CI due to container startup overhead
72+
# PostgreSQL service pre-started to reduce Aspire startup time
6173

6274
code-quality:
6375
runs-on: ubuntu-latest
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Nightly Integration Tests
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *' # Run at 2 AM UTC daily
6+
workflow_dispatch: # Allow manual trigger
7+
8+
env:
9+
DOTNET_VERSION: '10.0.x'
10+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
11+
DOTNET_CLI_TELEMETRY_OPTOUT: true
12+
13+
jobs:
14+
integration-tests:
15+
runs-on: ubuntu-latest
16+
17+
services:
18+
postgres:
19+
image: postgres:17
20+
env:
21+
POSTGRES_PASSWORD: postgres
22+
POSTGRES_DB: bookstore
23+
ports:
24+
- 5432:5432
25+
options: >-
26+
--health-cmd pg_isready
27+
--health-interval 10s
28+
--health-timeout 5s
29+
--health-retries 5
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v6
34+
35+
- name: Setup .NET
36+
uses: actions/setup-dotnet@v5
37+
with:
38+
dotnet-version: ${{ env.DOTNET_VERSION }}
39+
40+
- name: Cache NuGet packages
41+
uses: actions/cache@v4
42+
with:
43+
path: ~/.nuget/packages
44+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
45+
restore-keys: |
46+
${{ runner.os }}-nuget-
47+
48+
- name: Restore dependencies
49+
run: dotnet restore
50+
51+
- name: Build
52+
run: dotnet build --no-restore --configuration Release
53+
54+
- name: Run all integration tests
55+
run: dotnet test --configuration Release --treenode-filter "/**[Category=Integration]"
56+
working-directory: src/Web/BookStore.Web.Tests
57+
timeout-minutes: 10
58+
59+
- name: Upload test results
60+
if: always()
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: integration-test-results
64+
path: '**/TestResults/*.trx'

0 commit comments

Comments
 (0)