-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (63 loc) · 2.49 KB
/
code-coverage.yml
File metadata and controls
74 lines (63 loc) · 2.49 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
name: Code Coverage
on:
push:
branches: [ main, develop ]
paths:
- "Directory.Build.props"
- ".editorconfig"
- "AIUsageTracker.Core/**"
- "AIUsageTracker.Infrastructure/**"
- "AIUsageTracker.Monitor/**"
- "AIUsageTracker.Tests/**"
- "AIUsageTracker.Monitor.Tests/**"
- "scripts/**"
- ".github/workflows/code-coverage.yml"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
coverage:
name: Collect Code Coverage
runs-on: windows-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Setup .NET with Cache
uses: ./.github/actions/setup-dotnet-cache
with:
dotnet-version: "8.0.x"
cache-key-prefix: "coverage"
- name: Restore dependencies
run: |
dotnet restore AIUsageTracker.Tests\AIUsageTracker.Tests.csproj
dotnet restore AIUsageTracker.Monitor.Tests\AIUsageTracker.Monitor.Tests.csproj
- name: Build projects
run: |
dotnet build AIUsageTracker.Tests\AIUsageTracker.Tests.csproj --configuration Debug --no-restore
dotnet build AIUsageTracker.Monitor.Tests\AIUsageTracker.Monitor.Tests.csproj --configuration Debug --no-restore
- name: Run tests with coverage
run: |
dotnet test AIUsageTracker.Tests\AIUsageTracker.Tests.csproj --configuration Debug --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory TestResults
dotnet test AIUsageTracker.Monitor.Tests\AIUsageTracker.Monitor.Tests.csproj --configuration Debug --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory TestResults
- name: Upload coverage to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6
with:
directory: TestResults
files: "**/coverage.cobertura.xml"
fail_ci_if_error: false
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: code-coverage-results
path: |
TestResults/**/*.trx
TestResults/**/coverage.cobertura.xml
retention-days: 3