-
-
Notifications
You must be signed in to change notification settings - Fork 507
462 lines (384 loc) · 18.2 KB
/
Copy pathbuild.yaml
File metadata and controls
462 lines (384 loc) · 18.2 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
name: Build
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
permissions:
contents: read
packages: write
pull-requests: write
env:
DOTNET_NOLOGO: true
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
jobs:
version:
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
version: ${{ steps.version.outputs.version }}
should_publish: ${{ (github.event_name != 'pull_request' || (github.head_ref == vars.DEV_DEPLOY_BRANCH && vars.DEV_DEPLOY_BRANCH != 'main' && vars.DEV_DEPLOY_BRANCH != '')) && secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != '' }}
is_prod_deploy: ${{ startsWith(github.ref, 'refs/tags/v') && github.event_name != 'pull_request' }}
is_dev_deploy: ${{ (github.event_name == 'push' && github.ref == format('refs/heads/{0}', vars.DEV_DEPLOY_BRANCH || 'main')) || (github.event_name == 'pull_request' && github.head_ref == vars.DEV_DEPLOY_BRANCH && vars.DEV_DEPLOY_BRANCH != 'main' && vars.DEV_DEPLOY_BRANCH != '') }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Build Reason
env:
GITHUB_EVENT: ${{ toJson(github) }}
run: |
branch=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}
branch=${branch//\//.}.
if [[ "$branch" = "main." || "$branch" = "master." || "${GITHUB_REF}" = refs/tags* ]]; then
branch=""
fi
echo "GIT_BRANCH_SUFFIX=$branch" >> $GITHUB_ENV
echo "ref: $GITHUB_REF event: $GITHUB_EVENT_NAME branch_suffix: $branch"
- name: Setup .NET Core
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.*
dotnet-quality: ga
- name: Version
id: version
run: |
dotnet tool install --global minver-cli --version 7.0.0
version=$(minver --tag-prefix v --default-pre-release-identifiers "preview.${GIT_BRANCH_SUFFIX}0")
# If on a non-main branch, insert branch name before the height (last numeric segment)
if [ -n "$GIT_BRANCH_SUFFIX" ]; then
branch_name="${GIT_BRANCH_SUFFIX%.}"
if [[ "$version" != *"$branch_name"* ]]; then
version=$(echo "$version" | sed -E "s/\.([0-9]+)$/.${GIT_BRANCH_SUFFIX}\1/")
fi
fi
echo "version=$version" >> $GITHUB_OUTPUT
echo "### $version" >> $GITHUB_STEP_SUMMARY
test-api:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET Core
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.*
dotnet-quality: ga
- uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
nuget-${{ runner.os }}-
- name: Nuget Restore
run: dotnet restore ./Exceptionless.slnx
- name: Build
run: dotnet build ./Exceptionless.slnx --no-restore --configuration Release
- name: Run .NET Tests with Coverage
run: dotnet test --no-restore --no-build --configuration Release --results-directory coverage --max-parallel-test-modules 1 -- --report-github --report-xunit-trx --report-xunit-trx-filename test-results.trx --coverage --coverage-output coverage.cobertura.xml --coverage-output-format cobertura
- name: Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage/coverage.cobertura.xml
badge: true
format: "markdown"
output: "both"
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v3
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
- name: Write Coverage to Job Summary
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
test-client:
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
working-directory: src/Exceptionless.Web/ClientApp
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js environment
uses: actions/setup-node@v6
with:
node-version: 24
- name: Cache node_modules
uses: actions/cache@v5
id: cache-node-modules
with:
path: src/Exceptionless.Web/ClientApp/node_modules
key: node-modules-${{ hashFiles('src/Exceptionless.Web/ClientApp/package-lock.json') }}
- name: Install Npm Packages
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Lint Client
run: npm run lint
- name: Check
run: npm run check
- name: Build
run: npm run build
- name: Run Unit Tests
run: echo "npm run test:unit"
- name: Run Integration Tests
run: echo "npm run test:integration"
test-e2e:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET Core
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.*
dotnet-quality: ga
- name: Install Aspire CLI
run: |
export PATH="$HOME/.dotnet/tools:$PATH"
dotnet tool install --global Aspire.Cli --version 13.3.0
echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
aspire --version
- name: Setup Node.js environment
uses: actions/setup-node@v6
with:
node-version: 24
- uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
nuget-${{ runner.os }}-
- name: Nuget Restore
run: dotnet restore ./Exceptionless.slnx
- name: Build
run: dotnet build ./Exceptionless.slnx --no-restore --configuration Release
- name: Install Client Npm Packages
working-directory: src/Exceptionless.Web/ClientApp
run: npm ci
- name: Install Legacy Client Npm Packages
working-directory: src/Exceptionless.Web/ClientApp.angular
run: npm ci
- name: Install Playwright Chromium
working-directory: src/Exceptionless.Web/ClientApp
run: npx playwright install chromium --with-deps
- name: Start AppHost
run: |
aspire run --detach --format Json --non-interactive --nologo > aspire-run.json
- name: Wait for Aspire Resources
run: |
aspire wait Api --status healthy --timeout 300 --non-interactive
aspire wait Jobs --status healthy --timeout 300 --non-interactive
aspire wait App --status up --timeout 300 --non-interactive
- name: Verify E2E Endpoints
run: |
curl -fksS https://web-ex.dev.localhost:7131/api/v2/about > /dev/null
curl -fksS https://web-ex.dev.localhost:7131/next/login > /dev/null
- name: Run Playwright E2E Tests
working-directory: src/Exceptionless.Web/ClientApp
env:
E2E_URL: https://web-ex.dev.localhost:7131
E2E_RUN_ID: ci-${{ github.run_id }}-${{ github.run_attempt }}
run: npm run test:e2e:ci
- name: Stop AppHost
if: ${{ always() }}
run: |
aspire stop --all --non-interactive || true
- name: Collect Aspire Logs
if: ${{ !cancelled() }}
run: |
mkdir -p aspire-logs
if [ -f aspire-run.json ]; then
cp aspire-run.json aspire-logs/
fi
if [ -d "$HOME/.aspire/cli/logs" ]; then
cp -r "$HOME/.aspire/cli/logs/." aspire-logs/
fi
- name: Upload Playwright Report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v5
with:
name: playwright-report
path: src/Exceptionless.Web/ClientApp/playwright-report/
retention-days: 14
- name: Upload Playwright Test Results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v5
with:
name: playwright-test-results
path: src/Exceptionless.Web/ClientApp/test-results/
retention-days: 14
- name: Upload Aspire Logs
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v5
with:
name: aspire-logs
path: aspire-logs/
retention-days: 14
docker-build:
runs-on: ubuntu-latest
needs: [version]
timeout-minutes: 30
env:
VERSION: ${{ needs.version.outputs.version }}
STAGING_TAG: build-${{ github.run_id }}-${{ github.run_attempt }}
SHOULD_PUBLISH: ${{ needs.version.outputs.should_publish }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
with:
platforms: linux/amd64
- name: Login to GitHub Container Registry
if: ${{ env.SHOULD_PUBLISH == 'true' }}
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build api docker image
run: |
echo "::remove-matcher owner=csc::"
if [ "$SHOULD_PUBLISH" = "true" ]; then
docker buildx build . --build-arg MinVerVersionOverride=$VERSION --target api --platform linux/amd64 --tag ghcr.io/exceptionless/exceptionless/api-ci:$STAGING_TAG --cache-from type=registry,ref=ghcr.io/exceptionless/exceptionless/api-ci:buildcache --cache-to type=registry,ref=ghcr.io/exceptionless/exceptionless/api-ci:buildcache,mode=max --push
else
docker buildx build . --build-arg MinVerVersionOverride=$VERSION --target api --platform linux/amd64 --tag exceptionless/api-ci:latest --cache-from type=gha,scope=api-ci --cache-to type=gha,scope=api-ci,mode=max --load
fi
- name: Build job docker image
run: |
echo "::remove-matcher owner=csc::"
if [ "$SHOULD_PUBLISH" = "true" ]; then
docker buildx build . --build-arg MinVerVersionOverride=$VERSION --target job --platform linux/amd64 --tag ghcr.io/exceptionless/exceptionless/job-ci:$STAGING_TAG --cache-from type=registry,ref=ghcr.io/exceptionless/exceptionless/job-ci:buildcache --cache-to type=registry,ref=ghcr.io/exceptionless/exceptionless/job-ci:buildcache,mode=max --push
else
docker buildx build . --build-arg MinVerVersionOverride=$VERSION --target job --platform linux/amd64 --tag exceptionless/job-ci:latest --cache-from type=gha,scope=job-ci --cache-to type=gha,scope=job-ci,mode=max --load
fi
- name: Build app docker image
run: |
echo "::remove-matcher owner=csc::"
if [ "$SHOULD_PUBLISH" = "true" ]; then
docker buildx build . --build-arg MinVerVersionOverride=$VERSION --target app --platform linux/amd64 --tag ghcr.io/exceptionless/exceptionless/app-ci:$STAGING_TAG --cache-from type=registry,ref=ghcr.io/exceptionless/exceptionless/app-ci:buildcache --cache-to type=registry,ref=ghcr.io/exceptionless/exceptionless/app-ci:buildcache,mode=max --push
else
docker buildx build . --build-arg MinVerVersionOverride=$VERSION --target app --platform linux/amd64 --tag exceptionless/app-ci:latest --cache-from type=gha,scope=app-ci --cache-to type=gha,scope=app-ci,mode=max --load
fi
- name: Build all-in-one docker image
if: ${{ needs.version.outputs.is_prod_deploy == 'true' }}
run: |
echo "::remove-matcher owner=csc::"
if [ "$SHOULD_PUBLISH" = "true" ]; then
docker buildx build . --build-arg MinVerVersionOverride=$VERSION --target exceptionless --platform linux/amd64 --tag ghcr.io/exceptionless/exceptionless/exceptionless-ci:$STAGING_TAG --cache-from type=registry,ref=ghcr.io/exceptionless/exceptionless/exceptionless-ci:buildcache --cache-to type=registry,ref=ghcr.io/exceptionless/exceptionless/exceptionless-ci:buildcache,mode=max --push
else
docker buildx build . --build-arg MinVerVersionOverride=$VERSION --target exceptionless --platform linux/amd64 --tag exceptionless/exceptionless-ci:latest --cache-from type=gha,scope=exceptionless-ci --cache-to type=gha,scope=exceptionless-ci,mode=max --load
fi
docker-publish:
if: ${{ needs.version.outputs.should_publish == 'true' }}
runs-on: ubuntu-latest
needs: [version, docker-build, test-api, test-client, test-e2e]
timeout-minutes: 30
env:
VERSION: ${{ needs.version.outputs.version }}
STAGING_TAG: build-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Pull staged docker images
run: |
images=(api job app)
if [ "${{ needs.version.outputs.is_prod_deploy }}" = "true" ]; then
images+=(exceptionless)
fi
for image in "${images[@]}"; do
docker pull ghcr.io/exceptionless/exceptionless/$image-ci:$STAGING_TAG
done
- name: Publish CI Packages
run: |
echo "::remove-matcher owner=csc::"
# tag and push docker images
images=(api job app)
if [ "${{ needs.version.outputs.is_prod_deploy }}" = "true" ]; then
images+=(exceptionless)
fi
for image in "${images[@]}"; do
docker image tag ghcr.io/exceptionless/exceptionless/$image-ci:$STAGING_TAG exceptionless/$image-ci:$VERSION
docker image tag ghcr.io/exceptionless/exceptionless/$image-ci:$STAGING_TAG exceptionless/$image-ci:latest
docker image tag ghcr.io/exceptionless/exceptionless/$image-ci:$STAGING_TAG ghcr.io/exceptionless/exceptionless/$image-ci:$VERSION
docker image tag ghcr.io/exceptionless/exceptionless/$image-ci:$STAGING_TAG ghcr.io/exceptionless/exceptionless/$image-ci:latest
docker image push --all-tags exceptionless/$image-ci
docker image push --all-tags ghcr.io/exceptionless/exceptionless/$image-ci
done
- name: Publish Release Packages
if: ${{ needs.version.outputs.is_prod_deploy == 'true' }}
run: |
echo "::remove-matcher owner=csc::"
# tag and push docker images
images=(api job app exceptionless)
for image in "${images[@]}"; do
docker image tag ghcr.io/exceptionless/exceptionless/$image-ci:$STAGING_TAG exceptionless/$image:$VERSION
docker image tag ghcr.io/exceptionless/exceptionless/$image-ci:$STAGING_TAG exceptionless/$image:latest
docker image push --all-tags exceptionless/$image
done
- name: Summary
if: ${{ always() }}
run: |
echo "### Build Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: $VERSION" >> $GITHUB_STEP_SUMMARY
echo "- **CI Images**: Published ✅" >> $GITHUB_STEP_SUMMARY
echo "- **Release Images**: ${{ needs.version.outputs.is_prod_deploy == 'true' && 'Published ✅' || 'Skipped' }}" >> $GITHUB_STEP_SUMMARY
echo "- **Deploy**: ${{ needs.version.outputs.is_dev_deploy == 'true' && 'Development queued' || (needs.version.outputs.is_prod_deploy == 'true' && 'Production queued' || 'Skipped') }}" >> $GITHUB_STEP_SUMMARY
deploy:
if: ${{ needs.version.outputs.should_publish == 'true' }}
needs: [version, docker-publish]
runs-on: ubuntu-latest
timeout-minutes: 30
env:
VERSION: ${{ needs.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Helm
uses: azure/setup-helm@v5
- name: Deploy Changes to Development Environment
if: ${{ needs.version.outputs.is_dev_deploy == 'true' }}
run: |
az login --service-principal --username ${{ secrets.AZ_USERNAME }} --password ${{ secrets.AZ_PASSWORD }} --tenant ${{ secrets.AZ_TENANT }} --output none
az aks get-credentials --resource-group exceptionless-v6 --name ex-k8s-v6
sed -i "s/^appVersion:.*$/appVersion: '${VERSION}'/" ./k8s/exceptionless/Chart.yaml
helm upgrade --set "version=${VERSION}" --reuse-values --values ./k8s/ex-dev-values.yaml ex-dev --namespace ex-dev ./k8s/exceptionless
- name: Deploy Changes to Production Environment
if: ${{ needs.version.outputs.is_prod_deploy == 'true' }}
run: |
az login --service-principal --username ${{ secrets.AZ_USERNAME }} --password ${{ secrets.AZ_PASSWORD }} --tenant ${{ secrets.AZ_TENANT }} --output none
az aks get-credentials --resource-group exceptionless-v6 --name ex-k8s-v6
sed -i "s/^appVersion:.*$/appVersion: '${VERSION}'/" ./k8s/exceptionless/Chart.yaml
helm upgrade --set "version=${VERSION}" --reuse-values --values ./k8s/ex-prod-values.yaml ex-prod --namespace ex-prod ./k8s/exceptionless
- name: Summary
if: ${{ always() }}
run: |
echo "### Deployment Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: $VERSION" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.version.outputs.is_dev_deploy }}" = "true" ]; then
echo "- **Environment**: Development" >> $GITHUB_STEP_SUMMARY
echo "- **App**: https://dev-app.exceptionless.io" >> $GITHUB_STEP_SUMMARY
echo "- **Collector**: https://dev-collector.exceptionless.io" >> $GITHUB_STEP_SUMMARY
elif [ "${{ needs.version.outputs.is_prod_deploy }}" = "true" ]; then
echo "- **Environment**: Production" >> $GITHUB_STEP_SUMMARY
echo "- **App**: https://be.exceptionless.io" >> $GITHUB_STEP_SUMMARY
echo "- **Collector**: https://collector.exceptionless.io" >> $GITHUB_STEP_SUMMARY
else
echo "- **Deployment**: Skipped" >> $GITHUB_STEP_SUMMARY
fi