-
Notifications
You must be signed in to change notification settings - Fork 6
162 lines (131 loc) · 4.89 KB
/
Copy pathCI.yml
File metadata and controls
162 lines (131 loc) · 4.89 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
name: CI
on:
push:
branches: [main]
paths:
- 'src/**'
- 'tests/**'
- 'samples/**'
- 'gen/**'
- 'servicebus/**'
- 'Directory.Packages.props'
- 'docker-compose.yml'
- '*.slnf'
- '*.sln'
- '.config/dotnet-tools.json'
- '.github/workflows/CI.yml'
pull_request:
paths:
- 'src/**'
- 'tests/**'
- 'samples/**'
- 'gen/**'
- 'servicebus/**'
- 'Directory.Packages.props'
- 'docker-compose.yml'
- '*.slnf'
- '*.sln'
- '.config/dotnet-tools.json'
- '.github/workflows/CI.yml'
workflow_dispatch:
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Start containers
run: docker compose up -d
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x
9.x
10.x
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }}
restore-keys: nuget-${{ runner.os }}-
- name: Restore .NET tools
run: dotnet tool restore
- name: Restore (all)
run: dotnet restore CoreEx.sln --verbosity minimal
# --- Core ---
- name: Build core
run: dotnet build CoreEx.Core.slnf --no-restore --configuration Release
- name: Test core (parallel)
run: dotnet test CoreEx.Core.Test.Parallel.slnf --no-build --configuration Release --logger trx --collect "XPlat Code Coverage" --results-directory coverage/core
- name: Test core (sequential)
run: dotnet test CoreEx.Core.Test.Sequential.slnf --no-build --configuration Release --logger trx --collect "XPlat Code Coverage" --results-directory coverage/core -m:1 -p:TestTfmsInParallel=false -p:BuildInParallel=false
- name: Upload core test results
if: always()
uses: actions/upload-artifact@v4
with:
name: core-test-results
path: "coverage/core/**/*.trx"
retention-days: 30
# --- Samples ---
- name: Build samples
run: dotnet build CoreEx.Samples.Build.slnf --no-restore --configuration Release
- name: CodeGen tool (samples/src/Contoso.Products.CodeGen)
working-directory: samples/src/Contoso.Products.CodeGen
run: dotnet run refdata --no-build --configuration Release -f net10.0 --expect-no-changes
- name: CodeGen tool (samples/src/Contoso.Shopping.CodeGen)
working-directory: samples/src/Contoso.Shopping.CodeGen
run: dotnet run refdata --no-build --configuration Release -f net10.0 --expect-no-changes
- name: Database tool (samples/src/Contoso.Products.Database)
working-directory: samples/src/Contoso.Products.Database
run: dotnet run all --no-build --configuration Release -f net10.0 --expect-no-changes
- name: Database tool (samples/src/Contoso.Shopping.Database)
working-directory: samples/src/Contoso.Shopping.Database
run: dotnet run all --no-build --configuration Release -f net10.0 --expect-no-changes
- name: Database tool (samples/src/Contoso.Orders.Database)
working-directory: samples/src/Contoso.Orders.Database
run: dotnet run all --no-build --configuration Release -f net10.0 --expect-no-changes
- name: Test samples
run: dotnet test CoreEx.Samples.Test.slnf --no-build --configuration Release --logger trx --collect "XPlat Code Coverage" --results-directory coverage/samples -m:1 -p:TestTfmsInParallel=false -p:BuildInParallel=false
- name: Upload samples test results
if: always()
uses: actions/upload-artifact@v4
with:
name: samples-test-results
path: "coverage/samples/**/*.trx"
retention-days: 30
# --- Coverage ---
- name: Merge and generate coverage report
if: always()
run: |
dotnet tool run reportgenerator \
-reports:"coverage/**/coverage.cobertura.xml" \
-targetdir:"coverage/report" \
-reporttypes:"HtmlInline_AzurePipelines;Cobertura;Badges" \
-assemblyfilters:"-*Test*;-*E2E*"
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/report
retention-days: 30
# --- Cleanup ---
- name: Capture container logs on failure
if: failure()
run: docker compose logs --no-color > container-logs.txt 2>&1
- name: Upload container logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: container-logs
path: container-logs.txt
retention-days: 30
- name: Stop containers
if: always()
run: docker compose down