Skip to content

Commit d20878a

Browse files
committed
updated yaml to account for matrix
1 parent 1918631 commit d20878a

File tree

1 file changed

+38
-27
lines changed

1 file changed

+38
-27
lines changed

.github/workflows/api-ci.yml

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,21 @@ jobs:
2424
strategy:
2525
matrix:
2626
os: [ubuntu-latest, windows-latest]
27+
2728
runs-on: ${{ matrix.os }}
2829

2930
env:
31+
# 🔁 tweak this if your .sln lives elsewhere
32+
SOLUTION_PATH: ./ApiTests.sln
33+
34+
# 🔐 your secrets — already set up in your repo
3035
API_BASE_URL: ${{ secrets.API_BASE_URL }}
3136
API_KEY: ${{ secrets.API_KEY }}
3237
API_KEY_HEADER: ${{ secrets.API_KEY_HEADER }}
3338
API_LOGIN_PATH: ${{ secrets.API_LOGIN_PATH }}
3439
API_USERNAME: ${{ secrets.API_USERNAME }}
3540
API_PASSWORD: ${{ secrets.API_PASSWORD }}
41+
3642
DOTNET_NOLOGO: true
3743

3844
steps:
@@ -43,54 +49,59 @@ jobs:
4349
with:
4450
dotnet-version: '8.0.x'
4551
cache: true
52+
# If you committed NuGet lock files:
53+
cache-dependency-path: '**/packages.lock.json'
4654

4755
- name: Restore
4856
run: dotnet restore
4957

5058
- name: Build (Release)
5159
run: dotnet build --configuration Release --no-restore
5260

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
5479
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
6786
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" `
7291
-reporttypes:"HtmlInline_AzurePipelines;Cobertura"
7392
7493
- name: Upload Test Results (.trx)
7594
if: always()
7695
uses: actions/upload-artifact@v4
7796
with:
78-
name: test-results
97+
name: test-results-${{ matrix.os }}
7998
path: TestResults/**/*.trx
8099
if-no-files-found: warn
81100

82101
- name: Upload Coverage Report (HTML)
83102
if: always()
84103
uses: actions/upload-artifact@v4
85104
with:
86-
name: coverage-report
105+
name: coverage-report-${{ matrix.os }}
87106
path: CoverageReport/**
88107
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

Comments
 (0)