-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (97 loc) · 3.29 KB
/
ci.yml
File metadata and controls
113 lines (97 loc) · 3.29 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
name: CI
on:
push:
branches:
- main
pull_request:
# Cancel in-progress runs for the same branch/PR
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-test:
name: Build & Test
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
pull-requests: write
env:
# Dummy connection string for DI validation (tests use in-memory database)
ConnectionStrings__AppDb: "Host=localhost;Database=test;Username=test;Password=test"
# Coverage threshold (line / branch warning)
COVERAGE_THRESHOLD: '80 90'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Build.props') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore DungeonMaster.sln
- name: Build solution
run: dotnet build DungeonMaster.sln --configuration Release --no-restore
- name: Run tests with coverage
run: |
dotnet test DungeonMaster.sln \
--configuration Release \
--no-build \
--filter "Category!=E2E&Category!=ExternalDependency&Category!=Performance" \
--collect:"XPlat Code Coverage" \
--settings coverlet.runsettings \
--logger "trx" \
--results-directory ./TestResults
- name: Merge coverage reports
uses: danielpalme/ReportGenerator-GitHub-Action@5
with:
reports: ./TestResults/**/coverage.cobertura.xml
targetdir: ./CoverageReport
reporttypes: Cobertura;MarkdownSummaryGithub
- name: Publish coverage summary
if: always()
run: cat ./CoverageReport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
- name: Enforce coverage threshold
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: ./CoverageReport/Cobertura.xml
fail_below_min: true
thresholds: ${{ env.COVERAGE_THRESHOLD }}
format: markdown
output: both
- name: Add coverage PR comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: ./TestResults/*.trx
retention-days: 7
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: ./CoverageReport/Cobertura.xml
retention-days: 30
- name: Test Summary
uses: dorny/test-reporter@v1
if: always()
with:
name: Test Results
path: ./TestResults/*.trx
reporter: dotnet-trx