-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (89 loc) · 3.26 KB
/
ci.yml
File metadata and controls
110 lines (89 loc) · 3.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
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
env:
DOTNET_VERSION: '10.0.x'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Run API unit tests (fast feedback)
run: dotnet test --configuration Release ${{ github.event_name == 'pull_request' && '--fail-fast' || '' }} -- --coverage --coverage-output-format cobertura
working-directory: tests/BookStore.ApiService.UnitTests
# TUnit automatically generates GitHub Actions test summary
# Run fast unit tests first for quick feedback
# - name: Run AppHost integration tests
# run: dotnet test --configuration Release -- --coverage --coverage-output-format cobertura
# working-directory: tests/BookStore.AppHost.Tests
# env:
# ASPNETCORE_ENVIRONMENT: Development
# # Tests full application startup and end-to-end scenarios
- name: Run analyzer tests
run: dotnet test --configuration Release
working-directory: tests/BookStore.ApiService.Analyzers.UnitTests
# Verify Roslyn analyzers work correctly
- name: Run Shared unit tests
run: dotnet test --configuration Release -- --coverage --coverage-output-format cobertura
working-directory: tests/BookStore.Shared.UnitTests
# Test shared library components
- name: Code Coverage Summary
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: '**/TestResults/*.cobertura.xml'
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'
- 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 to Job Summary
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
code-quality:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore
- name: Check code formatting
run: dotnet format --verify-no-changes --verbosity diagnostic
- name: Run analyzers
run: dotnet build --no-restore --configuration Release /p:TreatWarningsAsErrors=true