Skip to content

Commit f60f814

Browse files
authored
Merge pull request #1973 from justeattakeaway/fix-codecov-checks
Add codecov config
2 parents 56de3da + 962230c commit f60f814

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
shell: bash
8484
run: find test-results -mindepth 2 -type d -exec rm -rf {} + 2>/dev/null || true
8585

86-
- name: Upload coverage and test results to Codecov
86+
- name: Upload coverage to Codecov
8787
if: ${{ !cancelled() }}
8888
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
8989
env:
@@ -93,6 +93,17 @@ jobs:
9393
directory: test-results
9494
verbose: true
9595

96+
- name: Upload test results to Codecov
97+
if: ${{ !cancelled() }}
98+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
99+
env:
100+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
101+
with:
102+
report_type: test_results
103+
flags: ${{ matrix.os-name }}
104+
files: test-results/**/*-junit.xml
105+
verbose: true
106+
96107
- name: Generate SBOM
97108
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
98109
with:

build.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function DotNetTest {
107107

108108
$additionalArgs = @()
109109

110-
# Generate TRX test results for codecov
110+
# Generate test results for codecov
111111
$testResultsDir = Join-Path $solutionPath "test-results"
112112
if (!(Test-Path $testResultsDir)) {
113113
New-Item -ItemType Directory -Path $testResultsDir -Force | Out-Null
@@ -121,6 +121,10 @@ function DotNetTest {
121121
$additionalArgs += "--results-directory"
122122
$additionalArgs += $projectResultsDir
123123

124+
# Enable TUnit's built-in JUnit reporter for Codecov Test Analytics
125+
$env:TUNIT_ENABLE_JUNIT_REPORTER = "true"
126+
$env:JUNIT_XML_OUTPUT_PATH = (Join-Path $projectResultsDir "${projectName}-junit.xml")
127+
124128
$additionalArgs += "--coverage"
125129
$additionalArgs += "--coverage-output-format"
126130
$additionalArgs += "cobertura"
@@ -129,10 +133,15 @@ function DotNetTest {
129133
$additionalArgs += "--coverage-settings"
130134
$additionalArgs += (Join-Path $solutionPath "codecoverage.runsettings")
131135

132-
& $dotnet test --project $Project --configuration "Release" --no-build $additionalArgs
136+
try {
137+
& $dotnet test --project $Project --configuration "Release" --no-build $additionalArgs
133138

134-
if ($LASTEXITCODE -ne 0) {
135-
throw "dotnet test failed with exit code $LASTEXITCODE"
139+
if ($LASTEXITCODE -ne 0) {
140+
throw "dotnet test failed with exit code $LASTEXITCODE"
141+
}
142+
}
143+
finally {
144+
$env:JUNIT_XML_OUTPUT_PATH = $null
136145
}
137146
}
138147

codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
threshold: 1%
6+
patch:
7+
default:
8+
threshold: 1%
9+
110
ignore:
211
- "samples/**"
12+
- "docs/**"
13+
- "**/*.md"

0 commit comments

Comments
 (0)