From 8604c0bccacb15759fab161fd50a0c32a4c784ae Mon Sep 17 00:00:00 2001 From: Alexander Linne Date: Fri, 24 May 2024 12:03:30 +0200 Subject: [PATCH] ci: add code coverage check Signed-off-by: Alexander Linne --- .config/dotnet-tools.json | 6 +- .github/workflows/build.yaml | 20 ++++++- ArchUnitNETTests/ArchUnitNETTests.csproj | 70 +++++++++++++----------- coverlet.runsettings | 13 +++++ 4 files changed, 70 insertions(+), 39 deletions(-) create mode 100644 coverlet.runsettings diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a13daa35..149a9897 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -4,9 +4,7 @@ "tools": { "csharpier": { "version": "0.28.0", - "commands": [ - "dotnet-csharpier" - ] + "commands": ["dotnet-csharpier"] } } -} \ No newline at end of file +} diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 12553b13..6ccf1fa3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -18,10 +18,26 @@ jobs: uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0 with: dotnet-version: 8.0.204 - - name: Install tools + - name: Install .NET tools run: dotnet tool restore - name: Check formatting run: dotnet csharpier --check . + coverage: + name: Check code coverage + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Setup .NET + uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0 + with: + dotnet-version: 8.0.204 + - name: Run tests + run: dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings ArchUnitNETTests/ + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} run-tests: name: Run tests strategy: @@ -36,4 +52,4 @@ jobs: with: dotnet-version: 8.0.204 - name: Run tests - run: dotnet test -c Debug + run: dotnet test -c Release diff --git a/ArchUnitNETTests/ArchUnitNETTests.csproj b/ArchUnitNETTests/ArchUnitNETTests.csproj index 7acad077..953ec859 100644 --- a/ArchUnitNETTests/ArchUnitNETTests.csproj +++ b/ArchUnitNETTests/ArchUnitNETTests.csproj @@ -1,40 +1,44 @@ - + - - net8.0 - latest - TNG Technology Consulting GmbH - true - + + net8.0 + latest + TNG Technology Consulting GmbH + true + - - - - + + + + - - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + - - - Never - - - PreserveNewest - - + + + Never + + + PreserveNewest + + - - - + + + - - - Dependencies\cpplib\CppDllTest.dll - - + + + Dependencies\cpplib\CppDllTest.dll + + - + \ No newline at end of file diff --git a/coverlet.runsettings b/coverlet.runsettings new file mode 100644 index 00000000..327c2a64 --- /dev/null +++ b/coverlet.runsettings @@ -0,0 +1,13 @@ + + + + + + + cobertura + [ArchUnitNET]* + + + + + \ No newline at end of file