NUnit Only #1172
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: NUnit Only | |
| on: | |
| schedule: | |
| - cron: "0 1,7,13,19 * * *" | |
| push: | |
| paths: | |
| - '.github/workflows/nunit-pipeline.yml' | |
| # - '.github/actions/**' | |
| - 'Saucery/**' | |
| - 'Merlin.NUnit/**' | |
| - 'Merlin.NUnit.RealDevices/**' | |
| branches: [master, 'releases/**', 'feat/**', 'feature/**', 'fix/**', 'test/**'] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| CONFIG: Release | |
| NUGET_SOURCE: https://api.nuget.org/v3/index.json | |
| NUGET_USER: fullcircle | |
| COVERLET_DIR: ./TestResults | |
| UT_PROJECT: Saucery.Core.Tests.XUnitv3/Saucery.Core.Tests.XUnitv3.csproj | |
| TT_PROJECT: Template.Tests/Template.Tests.csproj | |
| M_NUNIT_PROJECT: Merlin.NUnit/Merlin.NUnit.csproj | |
| M_RD_NUNIT_PROJECT: Merlin.NUnit.RealDevices/Merlin.NUnit.RealDevices.csproj | |
| COVERAGE_FORMAT: cobertura | |
| UNIT_COVERAGE_FILENAME: opencover.unit.xml | |
| NUNIT_INTEGRATION_COVERAGE_FILENAME: opencover.nunit.integration.xml | |
| NUNIT_RD_INTEGRATION_COVERAGE_FILENAME: opencover.nunit.realdevice.integration.xml | |
| WATCHED_GLOBS: | | |
| .github/workflows/nunit-pipeline.yml | |
| .github/actions/** | |
| Saucery/** | |
| Merlin.NUnit/** | |
| Merlin.NUnit.RealDevices/** | |
| jobs: | |
| detect-changes: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| contents: read | |
| outputs: | |
| changed: ${{ steps.detect.outputs.changed }} | |
| paths_changed: ${{ steps.detect.outputs.paths_changed }} | |
| previous_sha: ${{ steps.detect.outputs.previous_sha }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - id: detect | |
| uses: ./.github/actions/detect-watched-paths | |
| with: | |
| workflow-id: .github/workflows/nunit-pipeline.yml | |
| watched-globs: ${{ env.WATCHED_GLOBS }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| SAUCE_USER_NAME: ${{ secrets.SAUCE_USER_NAME }} | |
| SAUCE_API_KEY: ${{ secrets.SAUCE_API_KEY }} | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.paths_changed == 'true' | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ./.github/actions/setup-dotnet | |
| - name: Compile solution | |
| run: dotnet build -c ${{ env.CONFIG }} | |
| - uses: ./.github/actions/run-xunit3-coverage | |
| with: | |
| project: ${{ env.UT_PROJECT }} | |
| configuration: ${{ env.CONFIG }} | |
| coverage-format: ${{ env.COVERAGE_FORMAT }} | |
| coverage-output: ${{ env.UNIT_COVERAGE_FILENAME }} | |
| - uses: ./.github/actions/enable-test-report-upload | |
| - name: Run Template Tests | |
| run: dotnet run --project ${{ env.TT_PROJECT }} -- --treenode-filter '/*/*/*/*[Category=NUnit]' | |
| - name: Publish Unit Test Results | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: unit-test-results | |
| path: Saucery.Core.Tests.XUnitv3/bin/${{ env.CONFIG }}/net10.0/TestResults/${{ env.UNIT_COVERAGE_FILENAME }} | |
| nunit-integration-tests: | |
| runs-on: ubuntu-latest | |
| env: | |
| SAUCE_USER_NAME: ${{ secrets.SAUCE_USER_NAME }} | |
| SAUCE_API_KEY: ${{ secrets.SAUCE_API_KEY }} | |
| SAUCERY_TEST_FRAMEWORK: NUnit | |
| needs: build | |
| if: needs.build.result == 'success' | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ./.github/actions/setup-dotnet | |
| - name: Restore dependencies | |
| run: dotnet restore --force | |
| - name: Build project | |
| run: dotnet build -c ${{ env.CONFIG }} | |
| - uses: ./.github/actions/run-coverlet-project | |
| with: | |
| test-project: ${{ env.M_NUNIT_PROJECT }} | |
| output: ${{ env.NUNIT_INTEGRATION_COVERAGE_FILENAME }} | |
| output-format: ${{ env.COVERAGE_FORMAT }} | |
| excludes: '[Merlin.NUnit]Tests.*' | |
| - name: Publish NUnit Integration Results | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: xunit-integration-test-results | |
| path: ${{ env.COVERLET_DIR }}/${{ env.NUNIT_INTEGRATION_COVERAGE_FILENAME }} | |
| nunit-real-integration-tests: | |
| runs-on: ubuntu-latest | |
| env: | |
| SAUCE_USER_NAME: ${{ secrets.SAUCE_USER_NAME }} | |
| SAUCE_API_KEY: ${{ secrets.SAUCE_API_KEY }} | |
| SAUCERY_TEST_FRAMEWORK: NUnit | |
| needs: build | |
| if: needs.build.result == 'success' | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ./.github/actions/setup-dotnet | |
| - name: Restore dependencies | |
| run: dotnet restore --force | |
| - name: Build project | |
| run: dotnet build -c ${{ env.CONFIG }} | |
| - uses: ./.github/actions/run-coverlet-project | |
| with: | |
| test-project: ${{ env.M_RD_NUNIT_PROJECT }} | |
| output: ${{ env.NUNIT_RD_INTEGRATION_COVERAGE_FILENAME }} | |
| output-format: ${{ env.COVERAGE_FORMAT }} | |
| excludes: '[Merlin.NUnit.RealDevices]Tests.*' | |
| - name: Publish NUnit Real Integration Results | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: xunit-real-integration-test-results | |
| path: ${{ env.COVERLET_DIR }}/${{ env.NUNIT_RD_INTEGRATION_COVERAGE_FILENAME }} | |
| publish-saucery: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| environment: nuget-publish | |
| needs: [nunit-integration-tests, nunit-real-integration-tests] | |
| if: github.ref == 'refs/heads/master' && needs.nunit-integration-tests.result == 'success' && needs.nunit-real-integration-tests.result == 'success' | |
| outputs: | |
| local_version: ${{ steps.publish.outputs.version }} | |
| publish: ${{ steps.publish.outputs.published }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ./.github/actions/setup-dotnet | |
| - id: publish | |
| uses: ./.github/actions/publish-saucery-package | |
| with: | |
| project-path: Saucery/Saucery.csproj | |
| package-id: Saucery | |
| configuration: ${{ env.CONFIG }} | |
| nupkg-dir: artifacts | |
| nuget-source: ${{ env.NUGET_SOURCE }} | |
| nuget-user: ${{ env.NUGET_USER }} | |
| publish-mode: local-version-newer | |
| tag: | |
| needs: publish-saucery | |
| if: ${{ needs.publish-saucery.outputs.publish == 'true' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master') }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: nunit-${{ needs.publish-saucery.outputs.local_version }} | |
| cancel-in-progress: false | |
| steps: | |
| - name: Bump version and push tag | |
| uses: mathieudutour/github-tag-action@v6.2 | |
| with: | |
| github_token: ${{ github.token }} | |
| tag_prefix: "" | |
| custom_tag: nunit-${{ needs.publish-saucery.outputs.local_version }} | |
| generate-report: | |
| runs-on: ubuntu-latest | |
| needs: [nunit-integration-tests, nunit-real-integration-tests] | |
| if: needs.nunit-integration-tests.result == 'success' && needs.nunit-real-integration-tests.result == 'success' | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ./.github/actions/setup-dotnet | |
| - uses: actions/download-artifact@v8 | |
| with: { name: unit-test-results } | |
| - uses: actions/download-artifact@v8 | |
| with: { name: xunit-integration-test-results } | |
| - uses: actions/download-artifact@v8 | |
| with: { name: xunit-real-integration-test-results } | |
| - name: ReportGenerator | |
| uses: danielpalme/ReportGenerator-GitHub-Action@5.5.11 | |
| with: | |
| reports: ${{ env.UNIT_COVERAGE_FILENAME }};${{ env.NUNIT_INTEGRATION_COVERAGE_FILENAME }};${{ env.NUNIT_RD_INTEGRATION_COVERAGE_FILENAME }} | |
| targetdir: coveragereport | |
| reporttypes: HtmlInline;Cobertura | |
| - name: Upload coverage report artifact | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: CoverageReport | |
| path: coveragereport |