Skip to content

Commit

Permalink
ci: add code coverage to unit tests workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
raczu committed Mar 14, 2024
1 parent 1091c5f commit 38f5dee
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,29 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- name: Install coverlet
run: dotnet tool install -g coverlet.console

- name: Install dependencies
run: dotnet restore ${{ env.SOLUTION_FILE }}

- name: Build solution
run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore

- name: Test with dotnet
run: dotnet test ${{ env.SOLUTION_FILE }} --logger trx --logger html --results-directory "TestResults-${{ github.sha }}"
run: |
echo DATE=$(date +"%Y-%m-%d_%H_%M_%S") >> $GITHUB_ENV
dotnet test ${{ env.SOLUTION_FILE }} --logger "trx;logfilename=results-${{ env.DATE }}.trx" --logger "html;logfilename=results-${{ env.DATE }}.html" --no-build --results-directory "TestResults-${{ github.sha }}"
- name: Run coverlet
run: coverlet ${{ env.SOLUTION_FILE}} --target "dotnet" --targetargs "test --no-build"

- name: Upload dotnet test results
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: dotnet-results-${{ github.sha }}
path: TestResults-${{ github.sha }}
retention-days: 14
if: ${{ always() }}

0 comments on commit 38f5dee

Please sign in to comment.