Skip to content

Commit

Permalink
ci(test): add code coverage (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyaneon committed Jan 16, 2023
1 parent 3ae6df5 commit ed861c7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,31 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" --settings ./Xyaneon.Games.Cards.Test/coverlet.runsettings

# Workaround for issue: https://github.com/microsoft/vstest/issues/2378
- name: Relocate test coverage results
run: mv ./Xyaneon.Games.Cards.Test/TestResults/**/coverage.info ./Xyaneon.Games.Cards.Test/TestResults/

- name: Upload coverage file to Coveralls.io
uses: coverallsapp/github-action@1.1.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./Xyaneon.Games.Cards.Test/TestResults/coverage.info
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![NuGet](https://img.shields.io/nuget/v/Xyaneon.Games.Cards.svg?style=flat)][NuGet package]
![Nuget downloads](https://img.shields.io/nuget/dt/Xyaneon.Games.Cards)
[![.NET](https://github.com/Xyaneon/Xyaneon.Games.Cards/actions/workflows/dotnet.yml/badge.svg)](https://github.com/Xyaneon/Xyaneon.Games.Cards/actions/workflows/dotnet.yml)
[![Coverage Status](https://coveralls.io/repos/github/Xyaneon/Xyaneon.Games.Cards/badge.svg?branch=main)](https://coveralls.io/github/Xyaneon/Xyaneon.Games.Cards?branch=main)
[![semantic-release: conventionalcommits](https://img.shields.io/badge/semantic--release-conventionalcommits-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)

![Package Icon][icon]
Expand Down
1 change: 1 addition & 0 deletions Xyaneon.Games.Cards.Test/Xyaneon.Games.Cards.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions Xyaneon.Games.Cards.Test/coverlet.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat Code Coverage">
<Configuration>
<Format>lcov</Format>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>

0 comments on commit ed861c7

Please sign in to comment.