Add Unit and Integration Tests #22
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: Release | |
| on: | |
| push: | |
| tags: | |
| - '*.*.*' | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] | |
| fail-fast: false | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup dotnet | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.x' | |
| - name: Restore | |
| run: dotnet restore src/DispatchR/DispatchR.csproj | |
| - name: Build | |
| run: dotnet build src/DispatchR/DispatchR.csproj --configuration Release --no-restore | |
| - name: Run Unit Tests | |
| run: dotnet test tests/DispatchR.UnitTest/DispatchR.UnitTest.csproj --configuration Release --no-build --collect:"XPlat Code Coverage" | |
| - name: Run Integration Tests | |
| run: dotnet test tests/DispatchR.IntegrationTest/DispatchR.IntegrationTest.csproj --configuration Release --no-build --collect:"XPlat Code Coverage" | |
| - name: Upload Coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| with: | |
| files: './TestResults/**/coverage.cobertura.xml' | |
| - name: Extract version from tag | |
| id: get_version | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT" | |
| - name: Pack project | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: dotnet pack src/DispatchR/DispatchR.csproj --configuration Release --no-build -o ./nupkgs /p:PackageVersion=${{ steps.get_version.outputs.version }} | |
| - name: Push to NuGet | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: dotnet nuget push "./nupkgs/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |