-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (124 loc) · 4.31 KB
/
Copy pathci.yml
File metadata and controls
147 lines (124 loc) · 4.31 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
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
dotnet:
name: .NET Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage" --settings coverage.runsettings --filter "FullyQualifiedName!~Scaffold.Integration.Tests"
- name: Generate coverage report
if: always()
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:CoverageReport -reporttypes:"Cobertura;TextSummary"
echo "### Code Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat CoverageReport/Summary.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: '**/test-results.trx'
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: CoverageReport/
frontend:
name: Frontend Build & Typecheck
runs-on: ubuntu-latest
defaults:
run:
working-directory: src/Scaffold.Web
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: src/Scaffold.Web/package-lock.json
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Typecheck
run: npx tsc --noEmit
- name: Build
run: npm run build
docker:
name: Docker Build
runs-on: ubuntu-latest
needs: [dotnet, frontend]
steps:
- uses: actions/checkout@v4
- name: Build API image
run: docker build -f src/Scaffold.Api/Dockerfile .
- name: Build Web image
run: docker build -f src/Scaffold.Web/Dockerfile .
integration:
name: Integration Tests
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'pull_request' && github.base_ref == 'main'
continue-on-error: true
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: ScaffoldTest2025!
ports:
- 1433:1433
options: >-
--health-cmd "cat /var/opt/mssql/log/errorlog | grep -q 'SQL Server is now ready for client connections'"
--health-interval 10s
--health-timeout 5s
--health-retries 15
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ScaffoldTest2025!
POSTGRES_DB: scaffold_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Build
run: dotnet build --configuration Release
- name: Run integration tests
env:
SCAFFOLD_TEST_CONNECTION_STRING: "Server=localhost,1433;Database=ScaffoldTestDb;User Id=sa;Password=ScaffoldTest2025!;TrustServerCertificate=true;Encrypt=true"
SCAFFOLD_TEST_PG_CONNECTION_STRING: "Host=localhost;Port=5432;Database=scaffold_test;Username=postgres;Password=ScaffoldTest2025!"
run: dotnet test tests/Scaffold.Integration.Tests --no-build --configuration Release --logger "trx;LogFileName=integration-results.trx"
- name: Upload integration test results
uses: actions/upload-artifact@v4
if: always()
with:
name: integration-test-results
path: '**/integration-results.trx'