docs: add nuget badge and dotnet example #45
Workflow file for this run
This file contains hidden or 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: Test .NET | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths-ignore: | |
| - '*.md' | |
| - 'Docs/**' | |
| - 'Examples/**' | |
| - '.gitignore' | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| env: | |
| DOTNET_VERSION: '8.x' | |
| BUILD_CONFIGURATION: 'Release' | |
| TEST_VERBOSITY: minimal | |
| SUMMARIZE_FAILURES: true | |
| jobs: | |
| test-windows: | |
| name: 'Windows' | |
| runs-on: windows-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Restore dependencies | |
| run: dotnet restore IISParser.sln | |
| - name: Build solution | |
| run: dotnet build IISParser.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore | |
| - name: Run tests | |
| run: dotnet test IISParser.Tests/IISParser.Tests.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --framework net8.0 --no-build --verbosity ${{ env.TEST_VERBOSITY }} --logger "console;verbosity=${{ env.TEST_VERBOSITY }}" --logger trx --collect:"XPlat Code Coverage" | |
| - name: Summarize failing tests | |
| if: failure() && env.SUMMARIZE_FAILURES == 'true' | |
| shell: pwsh | |
| run: | | |
| $trxFiles = Get-ChildItem -Recurse -Filter *.trx | |
| if ($trxFiles.Count -eq 0) { | |
| Write-Host "No TRX files found for failure analysis" | |
| exit 0 | |
| } | |
| Write-Host "=== Failed Tests Summary ===" | |
| $failureCount = 0 | |
| $trxFiles | ForEach-Object { | |
| try { | |
| Select-Xml -Path $_.FullName -XPath "//UnitTestResult[@outcome='Failed']" | | |
| ForEach-Object { | |
| $name = $_.Node.testName | |
| $msg = $_.Node.Output.ErrorInfo.Message ?? "No error message available" | |
| Write-Host "❌ $name" | |
| Write-Host " $msg" | |
| $failureCount++ | |
| } | |
| } catch { | |
| Write-Host "Warning: Could not parse TRX file $($_.Name): $($_.Exception.Message)" | |
| } | |
| } | |
| if ($failureCount -eq 0) { | |
| Write-Host "No failed tests found in TRX files" | |
| } else { | |
| Write-Host "=== Total failed tests: $failureCount ===" | |
| } | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-windows | |
| path: '**/*.trx' | |
| - name: Upload coverage reports | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-reports-windows | |
| path: '**/coverage.cobertura.xml' | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: '**/coverage.cobertura.xml' | |
| fail_ci_if_error: false | |
| test-ubuntu: | |
| name: 'Ubuntu' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Restore dependencies | |
| run: dotnet restore IISParser.sln | |
| - name: Build solution | |
| run: dotnet build IISParser.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore | |
| - name: Run tests | |
| run: dotnet test IISParser.Tests/IISParser.Tests.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --framework net8.0 --no-build --verbosity ${{ env.TEST_VERBOSITY }} --logger "console;verbosity=${{ env.TEST_VERBOSITY }}" --logger trx --collect:"XPlat Code Coverage" | |
| - name: Summarize failing tests | |
| if: failure() && env.SUMMARIZE_FAILURES == 'true' | |
| shell: pwsh | |
| run: | | |
| $trxFiles = Get-ChildItem -Recurse -Filter *.trx | |
| if ($trxFiles.Count -eq 0) { | |
| Write-Host "No TRX files found for failure analysis" | |
| exit 0 | |
| } | |
| Write-Host "=== Failed Tests Summary ===" | |
| $failureCount = 0 | |
| $trxFiles | ForEach-Object { | |
| try { | |
| Select-Xml -Path $_.FullName -XPath "//UnitTestResult[@outcome='Failed']" | | |
| ForEach-Object { | |
| $name = $_.Node.testName | |
| $msg = $_.Node.Output.ErrorInfo.Message ?? "No error message available" | |
| Write-Host "❌ $name" | |
| Write-Host " $msg" | |
| $failureCount++ | |
| } | |
| } catch { | |
| Write-Host "Warning: Could not parse TRX file $($_.Name): $($_.Exception.Message)" | |
| } | |
| } | |
| if ($failureCount -eq 0) { | |
| Write-Host "No failed tests found in TRX files" | |
| } else { | |
| Write-Host "=== Total failed tests: $failureCount ===" | |
| } | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-ubuntu | |
| path: '**/*.trx' | |
| - name: Upload coverage reports | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-reports-ubuntu | |
| path: '**/coverage.cobertura.xml' | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: '**/coverage.cobertura.xml' | |
| fail_ci_if_error: false | |
| test-macos: | |
| name: 'macOS' | |
| runs-on: macos-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Restore dependencies | |
| run: dotnet restore IISParser.sln | |
| - name: Build solution | |
| run: dotnet build IISParser.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore | |
| - name: Run tests | |
| run: dotnet test IISParser.Tests/IISParser.Tests.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --framework net8.0 --no-build --verbosity ${{ env.TEST_VERBOSITY }} --logger "console;verbosity=${{ env.TEST_VERBOSITY }}" --logger trx --collect:"XPlat Code Coverage" | |
| - name: Summarize failing tests | |
| if: failure() && env.SUMMARIZE_FAILURES == 'true' | |
| shell: pwsh | |
| run: | | |
| $trxFiles = Get-ChildItem -Recurse -Filter *.trx | |
| if ($trxFiles.Count -eq 0) { | |
| Write-Host "No TRX files found for failure analysis" | |
| exit 0 | |
| } | |
| Write-Host "=== Failed Tests Summary ===" | |
| $failureCount = 0 | |
| $trxFiles | ForEach-Object { | |
| try { | |
| Select-Xml -Path $_.FullName -XPath "//UnitTestResult[@outcome='Failed']" | | |
| ForEach-Object { | |
| $name = $_.Node.testName | |
| $msg = $_.Node.Output.ErrorInfo.Message ?? "No error message available" | |
| Write-Host "❌ $name" | |
| Write-Host " $msg" | |
| $failureCount++ | |
| } | |
| } catch { | |
| Write-Host "Warning: Could not parse TRX file $($_.Name): $($_.Exception.Message)" | |
| } | |
| } | |
| if ($failureCount -eq 0) { | |
| Write-Host "No failed tests found in TRX files" | |
| } else { | |
| Write-Host "=== Total failed tests: $failureCount ===" | |
| } | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-macos | |
| path: '**/*.trx' | |
| - name: Upload coverage reports | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-reports-macos | |
| path: '**/coverage.cobertura.xml' | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: '**/coverage.cobertura.xml' | |
| fail_ci_if_error: false |