Merge pull request #128 from UKGovernmentBEIS/staging #366
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run automated tests | |
on: | |
pull_request: | |
branches: | |
- '**' | |
push: | |
branches: | |
- develop | |
- staging | |
- main | |
jobs: | |
build-and-run-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code onto job runner | |
uses: actions/checkout@v2 | |
- name: Install .Net (6.0) | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 6.0.x | |
- name: Restore .Net dependencies | |
run: dotnet restore --configfile nuget.config | |
- name: Build .Net code | |
run: dotnet build --no-restore | |
- name: Run tests | |
run: dotnet test --no-restore --logger trx --results-directory "TestResults" --collect:"XPlat Code Coverage" --settings HerPortal.UnitTests/coverlet.runsettings | |
- name: Inline code coverage report and minimum coverage check | |
uses: irongut/[email protected] | |
with: | |
filename: TestResults/*/coverage.cobertura.xml | |
badge: false | |
fail_below_min: true | |
format: text | |
hide_branch_rate: false | |
hide_complexity: false | |
indicators: true | |
output: console | |
# Threshold is low as this is a small project and a lot of the code is boilerplate or doesn't make sense to test | |
# Business logic coverage should be kept at/above 80% | |
thresholds: '50 80' | |
# Use always() to always run this step to publish coverage results when there are test failures | |
if: ${{ always() }} | |
- name: Generate detailed code coverage report | |
uses: danielpalme/[email protected] | |
with: | |
reports: TestResults/*/coverage.cobertura.xml | |
targetdir: TestResults/CoverageReport | |
# Use always() to always run this step to publish coverage report when there are test failures | |
if: ${{ always() }} | |
- name: Upload dotnet test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: TestResults | |
# Use always() to always run this step to publish test results when there are test failures | |
if: ${{ always() }} |