Skip to content

Commit bf01420

Browse files
Add test analytics (#1398)
Use Codecov's test analytics feature.
1 parent 8efaec4 commit bf01420

File tree

4 files changed

+27
-22
lines changed

4 files changed

+27
-22
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,20 @@ jobs:
6565
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
6666
NUGET_XMLDOC_MODE: skip
6767

68-
- uses: codecov/codecov-action@v5
69-
name: Upload coverage to Codecov
68+
- name: Upload coverage to Codecov
69+
uses: codecov/codecov-action@v5
7070
with:
7171
files: ./artifacts/coverage.cobertura.xml,./src/TodoApp/coverage/lcov.info
7272
flags: ${{ matrix.os-name }}
7373
token: ${{ secrets.CODECOV_TOKEN }}
7474

75+
- name: Upload test results to Codecov
76+
uses: codecov/test-results-action@v1
77+
if: ${{ !cancelled() }}
78+
with:
79+
flags: ${{ matrix.os-name }}
80+
token: ${{ secrets.CODECOV_TOKEN }}
81+
7582
- name: Publish screenshots
7683
uses: actions/upload-artifact@v4
7784
if: ${{ !cancelled() }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ bin
1313
Bin
1414
coverage
1515
coverage.*
16+
junit.xml
1617
node_modules
1718
obj
1819
packages

build.ps1

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ param(
88
[Parameter(Mandatory = $false)][switch] $SkipTests
99
)
1010

11-
# These make CI builds faster
12-
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = "true"
13-
$env:NUGET_XMLDOC_MODE = "skip"
14-
1511
$Configuration = "Release"
1612
$ErrorActionPreference = "Stop"
1713
$ProgressPreference = "SilentlyContinue"
@@ -21,8 +17,8 @@ $sdkFile = Join-Path $solutionPath "global.json"
2117

2218
$dotnetVersion = (Get-Content $sdkFile | Out-String | ConvertFrom-Json).sdk.version
2319

24-
if ($OutputPath -eq "") {
25-
$OutputPath = Join-Path $PSScriptRoot "artifacts"
20+
if ([string]::IsNullOrEmpty($OutputPath)) {
21+
$OutputPath = Join-Path $solutionPath "artifacts"
2622
}
2723

2824
$installDotNetSdk = $false;
@@ -47,45 +43,45 @@ else {
4743

4844
if ($installDotNetSdk -eq $true) {
4945

50-
$env:DOTNET_INSTALL_DIR = Join-Path $PSScriptRoot ".dotnet"
51-
$sdkPath = Join-Path $env:DOTNET_INSTALL_DIR "sdk" "$dotnetVersion"
46+
${env:DOTNET_INSTALL_DIR} = Join-Path $solutionPath ".dotnet"
47+
$sdkPath = Join-Path ${env:DOTNET_INSTALL_DIR} "sdk" $dotnetVersion
5248

5349
if (!(Test-Path $sdkPath)) {
54-
if (!(Test-Path $env:DOTNET_INSTALL_DIR)) {
55-
mkdir $env:DOTNET_INSTALL_DIR | Out-Null
50+
if (-Not (Test-Path ${env:DOTNET_INSTALL_DIR})) {
51+
mkdir ${env:DOTNET_INSTALL_DIR} | Out-Null
5652
}
5753
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12"
5854
if (($PSVersionTable.PSVersion.Major -ge 6) -And !$IsWindows) {
59-
$installScript = Join-Path $env:DOTNET_INSTALL_DIR "install.sh"
55+
$installScript = Join-Path ${env:DOTNET_INSTALL_DIR} "install.sh"
6056
Invoke-WebRequest "https://dot.net/v1/dotnet-install.sh" -OutFile $installScript -UseBasicParsing
6157
chmod +x $installScript
62-
& $installScript --version "$dotnetVersion" --install-dir "$env:DOTNET_INSTALL_DIR" --no-path --skip-non-versioned-files
58+
& $installScript --jsonfile $sdkFile --install-dir ${env:DOTNET_INSTALL_DIR} --no-path --skip-non-versioned-files
6359
}
6460
else {
65-
$installScript = Join-Path $env:DOTNET_INSTALL_DIR "install.ps1"
61+
$installScript = Join-Path ${env:DOTNET_INSTALL_DIR} "install.ps1"
6662
Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile $installScript -UseBasicParsing
67-
& $installScript -Version "$dotnetVersion" -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -SkipNonVersionedFiles
63+
& $installScript -JsonFile $sdkFile -InstallDir ${env:DOTNET_INSTALL_DIR} -NoPath -SkipNonVersionedFiles
6864
}
6965
}
7066
}
7167
else {
72-
$env:DOTNET_INSTALL_DIR = Split-Path -Path (Get-Command dotnet).Path
68+
${env:DOTNET_INSTALL_DIR} = Split-Path -Path (Get-Command dotnet).Path
7369
}
7470

75-
$dotnet = Join-Path "$env:DOTNET_INSTALL_DIR" "dotnet"
71+
$dotnet = Join-Path ${env:DOTNET_INSTALL_DIR} "dotnet"
7672

7773
if ($installDotNetSdk -eq $true) {
78-
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
74+
${env:PATH} = "${env:DOTNET_INSTALL_DIR};${env:PATH}"
7975
}
8076

8177
function DotNetTest {
8278
param([string]$Project)
8379

8480
$additionalArgs = @()
8581

86-
if (![string]::IsNullOrEmpty($env:GITHUB_SHA)) {
87-
$additionalArgs += "--logger"
88-
$additionalArgs += "GitHubActions;report-warnings=false"
82+
if (-Not [string]::IsNullOrEmpty(${env:GITHUB_SHA})) {
83+
$additionalArgs += "--logger:GitHubActions;report-warnings=false"
84+
$additionalArgs += "--logger:junit;LogFilePath=junit.xml"
8985
}
9086

9187
& $dotnet test $Project --output $OutputPath --configuration $Configuration $additionalArgs

tests/TodoApp.Tests/TodoApp.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1111
<PackageReference Include="coverlet.msbuild" Version="6.0.4" PrivateAssets="All" />
1212
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
13+
<PackageReference Include="JunitXml.TestLogger" Version="6.1.0" />
1314
<PackageReference Include="JustEat.HttpClientInterception" Version="5.1.1" />
1415
<PackageReference Include="MartinCostello.Logging.XUnit.v3" Version="0.5.1" />
1516
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.4" />

0 commit comments

Comments
 (0)