@@ -24,15 +24,21 @@ jobs:
24
24
strategy :
25
25
matrix :
26
26
os : [ubuntu-latest, windows-latest]
27
+
27
28
runs-on : ${{ matrix.os }}
28
29
29
30
env :
31
+ # 🔁 tweak this if your .sln lives elsewhere
32
+ SOLUTION_PATH : ./ApiTests.sln
33
+
34
+ # 🔐 your secrets — already set up in your repo
30
35
API_BASE_URL : ${{ secrets.API_BASE_URL }}
31
36
API_KEY : ${{ secrets.API_KEY }}
32
37
API_KEY_HEADER : ${{ secrets.API_KEY_HEADER }}
33
38
API_LOGIN_PATH : ${{ secrets.API_LOGIN_PATH }}
34
39
API_USERNAME : ${{ secrets.API_USERNAME }}
35
40
API_PASSWORD : ${{ secrets.API_PASSWORD }}
41
+
36
42
DOTNET_NOLOGO : true
37
43
38
44
steps :
@@ -43,54 +49,59 @@ jobs:
43
49
with :
44
50
dotnet-version : ' 8.0.x'
45
51
cache : true
52
+ # If you committed NuGet lock files:
53
+ cache-dependency-path : ' **/packages.lock.json'
46
54
47
55
- name : Restore
48
56
run : dotnet restore
49
57
50
58
- name : Build (Release)
51
59
run : dotnet build --configuration Release --no-restore
52
60
53
- - name : Test + Coverage + Threshold
61
+ # ▶️ Collect coverage (threshold=0 for now) into a single folder per job
62
+ - name : Test + Coverage (MSBuild, threshold=0)
63
+ shell : pwsh
64
+ run : |
65
+ $cov = Join-Path $env:GITHUB_WORKSPACE 'TestResults/coverage'
66
+ New-Item -ItemType Directory -Force -Path $cov | Out-Null
67
+ dotnet test $env:SOLUTION_PATH `
68
+ /p:CollectCoverage=true `
69
+ /p:CoverletOutputFormat=cobertura `
70
+ /p:CoverletOutput="$cov/coverage" `
71
+ /p:Threshold=30 `
72
+ /p:ThresholdType=line `
73
+ /p:ThresholdStat=total `
74
+ --logger "trx;LogFileName=testresults.trx" `
75
+ --results-directory "$($env:GITHUB_WORKSPACE)/TestResults"
76
+
77
+ - name : Install ReportGenerator (global tool)
78
+ shell : pwsh
54
79
run : |
55
- dotnet test ./ApiTests.sln \
56
- /p:CollectCoverage=true \
57
- /p:CoverletOutputFormat=cobertura \
58
- /p:CoverletOutput=TestResults/coverage/ \
59
- /p:Threshold=0 \
60
- /p:ThresholdType=line \
61
- /p:ThresholdStat=total
62
-
63
- - name : Install ReportGenerator
64
- run : dotnet tool install --global dotnet-reportgenerator-globaltool
65
-
66
- - name : Generate Coverage Report
80
+ dotnet tool install --global dotnet-reportgenerator-globaltool
81
+ # Ensure the global tool path is on PATH (works on both OSes)
82
+ $env:PATH += [IO.Path]::PathSeparator + (Join-Path $HOME ".dotnet/tools")
83
+
84
+ - name : Generate Coverage Report (HTML + Cobertura)
85
+ shell : pwsh
67
86
run : |
68
- export PATH="$PATH:~/.dotnet/tools"
69
- reportgenerator \
70
- -reports:"**/TestResults/coverage/coverage .cobertura.xml" \
71
- -targetdir:"CoverageReport" \
87
+ $covFile = Join-Path $env:GITHUB_WORKSPACE 'TestResults/coverage'
88
+ reportgenerator `
89
+ -reports:"$covFile/* .cobertura.xml" `
90
+ -targetdir:"CoverageReport" `
72
91
-reporttypes:"HtmlInline_AzurePipelines;Cobertura"
73
92
74
93
- name : Upload Test Results (.trx)
75
94
if : always()
76
95
uses : actions/upload-artifact@v4
77
96
with :
78
- name : test-results
97
+ name : test-results-${{ matrix.os }}
79
98
path : TestResults/**/*.trx
80
99
if-no-files-found : warn
81
100
82
101
- name : Upload Coverage Report (HTML)
83
102
if : always()
84
103
uses : actions/upload-artifact@v4
85
104
with :
86
- name : coverage-report
105
+ name : coverage-report-${{ matrix.os }}
87
106
path : CoverageReport/**
88
107
if-no-files-found : warn
89
-
90
- - name : Summarize test results
91
- if : always()
92
- run : |
93
- echo "## Test Summary" >> $GITHUB_STEP_SUMMARY
94
- echo "- API: \`dotnet test\` with coverage" >> $GITHUB_STEP_SUMMARY
95
- echo "- Coverage report: see artifacts → coverage-report/index.html" >> $GITHUB_STEP_SUMMARY
96
-
0 commit comments