Update dotnet-desktop.yml #5
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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: .NET Build & Test | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build-and-test: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: 7.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore | |
- name: Run NUnit Tests | |
run: | | |
docker run --rm \ | |
--workdir /app \ | |
-v $(pwd)/Tests:/app \ | |
-v $(pwd)/TestResults:/results \ | |
nunit/nunit3-reporting \ | |
nunit3-console YourTestProject.dll --result=/results/test-results.xml | |
- name: Upload Test Results | |
uses: actions/upload-artifact@v2 | |
with: | |
name: test-results | |
path: TestResults | |
- name: Check Test Results | |
run: | | |
$xml = [xml](Get-Content ./TestResults/test-results.xml) | |
$totalTests = [int]$xml.SelectSingleNode('//test-run').GetAttribute('total') | |
$passedTests = [int]$xml.SelectSingleNode('//test-run').GetAttribute('passed') | |
$failedTests = $totalTests - $passedTests | |
if ($failedTests -gt 0) { | |
Write-Host "Some tests failed." | |
exit 1 | |
} else { | |
Write-Host "All tests passed." | |
} | |
- name: Set Workflow Status | |
if: failure() | |
run: echo "Tests failed" |