test: achieve 100% line and branch coverage #14
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: Build and Test | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| DOTNET_NOLOGO: true | |
| jobs: | |
| build-and-test: | |
| name: Build and Test on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| dotnet-version: ['8.0.x', '9.0.x', '10.0.x'] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET ${{ matrix.dotnet-version }} | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ matrix.dotnet-version }} | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build solution | |
| run: dotnet build --configuration Release --no-restore --warnaserror | |
| - name: Run tests | |
| run: dotnet test --configuration Release --no-build --verbosity normal | |
| - name: Run ValidationKit tests with coverage | |
| if: matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '8.0.x' | |
| run: dotnet test tests/Fox.ValidationKit.Tests/Fox.ValidationKit.Tests.csproj --configuration Release --framework net8.0 --collect:"XPlat Code Coverage" --settings coverlet.runsettings --results-directory ./coverage-report | |
| - name: Upload coverage to Codecov | |
| if: matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '8.0.x' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: './coverage-report/**/coverage.cobertura.xml' | |
| flags: unittests | |
| fail_ci_if_error: false | |
| pack-validation: | |
| name: Pack Validation | |
| runs-on: ubuntu-latest | |
| needs: build-and-test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET 8 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Pack Fox.ValidationKit | |
| run: dotnet pack src/Fox.ValidationKit/Fox.ValidationKit.csproj --configuration Release --no-restore | |
| - name: Pack Fox.ValidationKit.ResultKit | |
| run: dotnet pack src/Fox.ValidationKit.ResultKit/Fox.ValidationKit.ResultKit.csproj --configuration Release --no-restore | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: ./artifacts/*.nupkg | |
| retention-days: 7 |