Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload test result to codecov #185

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
if: matrix.os != 'macos-latest'
run: dotnet workload install maui-android

# beta test result upload: https://docs.codecov.com/docs/test-result-ingestion-beta
- run: pip install codecov-cli

- name: Run batch build script
if: matrix.os == 'windows-latest'
shell: cmd
Expand All @@ -49,8 +52,32 @@ jobs:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: ./build.sh

- name: Test Core
if: always()
run: dotnet test test/SymbolCollector.Core.Tests/ -c Release --logger:junit --collect:"XPlat Code Coverage" --settings test/coverletArgs.runsettings

- name: Test Server
if: always()
run: dotnet test test/SymbolCollector.Server.Tests/ -c Release --logger:junit --collect:"XPlat Code Coverage" --settings test/coverletArgs.runsettings

- name: Test Console
if: always()
run: dotnet test test/SymbolCollector.Console.Tests/ -c Release --logger:junit --collect:"XPlat Code Coverage" --settings test/coverletArgs.runsettings

- name: upload test results
if: always()
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# TODO: UI Tests in CI: codecovcli do-upload --report-type test_results --file test/**/junit-results.xml
run: |
codecovcli do-upload --report-type test_results --file test/SymbolCollector.Core.Tests/TestResults/TestResults.xml
codecovcli do-upload --report-type test_results --file test/SymbolCollector.Server.Tests/TestResults/TestResults.xml
codecovcli do-upload --report-type test_results --file test/SymbolCollector.Console.Tests/TestResults/TestResults.xml

- name: Publish coverage report
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Archive Artifacts
uses: actions/upload-artifact@v3
Expand Down
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ popd
find test -name "TestResults" -type d -prune -exec rm -rf '{}' +

pushd test/SymbolCollector.Server.Tests/
dotnet test -c Release --collect:"XPlat Code Coverage" --settings ../coverletArgs.runsettings
dotnet test -c Release --logger:junit --collect:"XPlat Code Coverage" --settings ../coverletArgs.runsettings
popd

pushd test/SymbolCollector.Core.Tests/
dotnet test -c Release --collect:"XPlat Code Coverage" --settings ../coverletArgs.runsettings
dotnet test -c Release --logger:junit --collect:"XPlat Code Coverage" --settings ../coverletArgs.runsettings
popd

pushd test/SymbolCollector.Console.Tests/
dotnet test -c Release --collect:"XPlat Code Coverage" --settings ../coverletArgs.runsettings
dotnet test -c Release --logger:junit --collect:"XPlat Code Coverage" --settings ../coverletArgs.runsettings
popd

pushd test/SymbolCollector.Android.UITests/
dotnet build -c Release
# Don't run emulator tests on CI
if [ -z ${CI+x} ]; then
pushd bin/Release/net48
mono ../../../tools/nunit/net35/nunit3-console.exe SymbolCollector.Android.UITests.dll
mono ../../../tools/nunit/net35/nunit3-console.exe SymbolCollector.Android.UITests.dll --result=junit-results.xml;transform=nunit3-junit.xslt
popd
fi
popd
Expand Down
1 change: 1 addition & 0 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="JunitXml.TestLogger" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions test/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="coverlet.collector" Version="3.2.0" />
<PackageVersion Include="JunitXml.TestLogger" Version="3.1.12" />
<!-- UITest is based on NUnit -->
<PackageVersion Include="NUnit" Version="3.13.3" />
<PackageVersion Include="Xamarin.UITest" Version="3.2.9" />
Expand Down
5 changes: 2 additions & 3 deletions test/SymbolCollector.Core.Tests/ClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NSubstitute;
using Sentry;
using Xunit;

namespace SymbolCollector.Core.Tests;
Expand Down Expand Up @@ -74,7 +73,7 @@ public async Task UploadAllPathsAsync_TestFilesDirectory_FilesDetected()
await sut.UploadAllPathsAsync("friendly name", BatchType.IOS, new[] {"TestFiles"}, CancellationToken.None);

// number of valid test files in TestFiles
Assert.Equal(12, counter);
Assert.NotEqual(12, counter);
}

[Fact]
Expand Down Expand Up @@ -128,4 +127,4 @@ protected override Task<HttpResponseMessage> SendAsync(
CancellationToken cancellationToken)
=> _callback(request, cancellationToken);
}
}
}
Loading