-
Notifications
You must be signed in to change notification settings - Fork 0
224 lines (181 loc) · 6.26 KB
/
ci.yml
File metadata and controls
224 lines (181 loc) · 6.26 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
220
221
222
223
224
name: CI
on:
pull_request:
push:
branches:
- main
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
code-review:
name: Code Review
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore ./Acmp.sln
- name: Verify formatting
run: dotnet format ./Acmp.sln --verify-no-changes --severity warn
- name: Build
run: dotnet build ./Acmp.sln --configuration Release --no-restore -warnaserror
tests:
name: Tests
runs-on: ubuntu-latest
needs: code-review
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore ./Acmp.sln
- name: Build
run: dotnet build ./Acmp.sln --configuration Release --no-restore
- name: Test
run: dotnet test ./Acmp.sln --configuration Release --no-build --logger "trx;LogFileName=test-results.trx" --results-directory ./artifacts/test-results
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: artifacts/test-results
if-no-files-found: error
integration-tests-sqlserver:
name: Integration Tests (SQL Server)
runs-on: ubuntu-latest
needs: tests
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: Y
SA_PASSWORD: Your_strong_Passw0rd!
ports:
- 1433:1433
options: >-
--health-cmd "bash -c '</dev/tcp/127.0.0.1/1433'"
--health-interval 10s
--health-timeout 5s
--health-retries 10
env:
RUN_DATABASE_INTEGRATION_TESTS: true
SQLSERVER_TEST_CONNECTION_STRING: Server=127.0.0.1,1433;Database=master;User Id=sa;Password=Your_strong_Passw0rd!;TrustServerCertificate=True;Encrypt=False
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Wait for SQL Server
shell: bash
run: |
for i in {1..60}; do
if (echo > /dev/tcp/127.0.0.1/1433) >/dev/null 2>&1; then
exit 0
fi
sleep 2
done
echo "SQL Server service did not become ready in time."
exit 1
- name: Restore
run: dotnet restore ./Acmp.sln
- name: Run SQL Server integration tests
run: dotnet test ./tests/MyCompany.AuthPlatform.Api.IntegrationTests/MyCompany.AuthPlatform.Api.IntegrationTests.csproj --configuration Release --filter "Category=SqlServer" --logger "trx;LogFileName=sqlserver-integration.trx" --results-directory ./artifacts/sqlserver-integration
- name: Upload SQL Server integration results
if: always()
uses: actions/upload-artifact@v4
with:
name: sqlserver-integration-results
path: artifacts/sqlserver-integration
if-no-files-found: error
integration-tests-postgres:
name: Integration Tests (PostgreSQL)
runs-on: ubuntu-latest
needs: tests
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
RUN_DATABASE_INTEGRATION_TESTS: true
POSTGRES_ADMIN_CONNECTION_STRING: Host=127.0.0.1;Port=5432;Database=postgres;Username=postgres;Password=postgres
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Wait for PostgreSQL
shell: bash
run: |
for i in {1..60}; do
if pg_isready -h 127.0.0.1 -p 5432 -U postgres >/dev/null 2>&1; then
exit 0
fi
sleep 2
done
echo "PostgreSQL service did not become ready in time."
exit 1
- name: Restore
run: dotnet restore ./Acmp.sln
- name: Run PostgreSQL integration tests
run: dotnet test ./tests/MyCompany.AuthPlatform.Api.IntegrationTests/MyCompany.AuthPlatform.Api.IntegrationTests.csproj --configuration Release --filter "Category=Postgres" --logger "trx;LogFileName=postgres-integration.trx" --results-directory ./artifacts/postgres-integration
- name: Upload PostgreSQL integration results
if: always()
uses: actions/upload-artifact@v4
with:
name: postgres-integration-results
path: artifacts/postgres-integration
if-no-files-found: error
ui-tests:
name: UI Tests
runs-on: ubuntu-latest
needs: tests
env:
RUN_UI_TESTS: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore ./Acmp.sln
- name: Build
run: dotnet build ./Acmp.sln --configuration Release --no-restore
- name: Install Playwright Chromium
shell: pwsh
run: ./tests/MyCompany.AuthPlatform.Api.IntegrationTests/bin/Release/net8.0/playwright.ps1 install --with-deps chromium
- name: Run UI tests
run: dotnet test ./tests/MyCompany.AuthPlatform.Api.IntegrationTests/MyCompany.AuthPlatform.Api.IntegrationTests.csproj --configuration Release --no-build --filter "Category=UI" --logger "trx;LogFileName=ui-tests.trx" --results-directory ./artifacts/ui-tests
- name: Upload UI test results
if: always()
uses: actions/upload-artifact@v4
with:
name: ui-test-results
path: artifacts/ui-tests
if-no-files-found: error