Repository navigation
123 lines (106 loc) · 4.87 KB
/
Copy pathci.yml
File metadata and controls
123 lines (106 loc) · 4.87 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
name: CI
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
# Read-only at workflow level. The one job below asks for the write it needs,
# so a job added later starts from nothing rather than inheriting it.
permissions:
contents: read
jobs:
# ════════════════════════════════════════════════════════════════════
# Build, test, pack
#
# This workflow never publishes. It builds, runs every test, and leaves
# the packages as an artifact you can download and inspect. Releasing is
# a separate, manually triggered workflow — see publish.yml.
# ════════════════════════════════════════════════════════════════════
build-and-test:
name: Build & Test
runs-on: ubuntu-latest
permissions:
contents: read
# Only for the sticky coverage comment on pull requests.
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
# .NET 8 is needed by the sample projects
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore
run: dotnet restore DSoftStudio.Mediator.slnx
- name: Build
run: dotnet build DSoftStudio.Mediator.slnx -c Release --no-restore
# Run EVERY test project in the solution in one shot. `dotnet test` on the
# solution discovers all test projects (and skips non-test ones), so a newly
# added test project is covered automatically — no need to edit this workflow
# (the old hand-listed steps silently skipped ModularMonolith.Tests). Coverage
# is collected per project and MERGED below into a single accurate report.
- name: Test
run: >
dotnet test DSoftStudio.Mediator.slnx
-c Release
--no-build
--logger "trx"
--collect:"XPlat Code Coverage"
# ── Artifacts (always uploaded, even on failure) ──
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: tests/**/TestResults/**/*.trx
- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage
path: tests/**/TestResults/**/coverage.cobertura.xml
# MERGE all per-project coverage files into ONE report before summarizing.
# Each test project emits its own coverage.cobertura.xml covering the SAME
# assemblies only in the slice it exercises; feeding the raw glob to a summary
# lists each assembly N times with different numbers (the misleading "34%").
# ReportGenerator unions them, so every assembly shows its real combined
# coverage exactly once.
- name: Merge coverage reports
if: github.event_name == 'pull_request'
uses: danielpalme/ReportGenerator-GitHub-Action@049f7ec958c672fd31d5cc1cb01622dc8d2e23ab # v5.5.10
with:
reports: 'tests/**/TestResults/**/coverage.cobertura.xml'
targetdir: 'coverage'
reporttypes: 'Cobertura;MarkdownSummaryGithub'
- name: Add coverage to PR
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
with:
path: coverage/SummaryGithub.md
# ── Pack (only on main/tag, and only if all tests passed) ──
#
# Packing is NOT publishing. These .nupkg files are uploaded as a build
# artifact so you can download and inspect exactly what a release would
# contain, and nothing pushes them anywhere. Publication lives in
# publish.yml and runs only when someone presses "Run workflow".
- name: Pack NuGet packages
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
run: |
mkdir -p nupkgs
dotnet pack src/DSoftStudio.Mediator.Abstractions -c Release --no-build -o nupkgs
dotnet pack src/DSoftStudio.Mediator -c Release --no-build -o nupkgs
dotnet pack src/DSoftStudio.Mediator.FluentValidation -c Release --no-build -o nupkgs
dotnet pack src/DSoftStudio.Mediator.HybridCache -c Release --no-build -o nupkgs
dotnet pack src/DSoftStudio.Mediator.OpenTelemetry -c Release --no-build -o nupkgs
- name: Upload NuGet packages
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: nupkgs
path: nupkgs/*