Add CI workflow and unit tests for HubDocs functionality #2
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: CI Build and Test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Restore | |
| run: dotnet restore HubDocs.sln | |
| - name: Build | |
| run: dotnet build HubDocs.sln -c Release --no-restore | |
| - name: Run unit tests | |
| run: dotnet test tests/HubDocs.UnitTests/HubDocs.UnitTests.csproj -c Release --no-build --collect:"XPlat Code Coverage" | |
| - name: Install ReportGenerator | |
| if: always() | |
| run: | | |
| dotnet tool install --global dotnet-reportgenerator-globaltool | |
| echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH" | |
| - name: Generate HTML coverage report | |
| if: always() | |
| run: | | |
| reportgenerator \ | |
| -reports:"tests/HubDocs.UnitTests/TestResults/**/coverage.cobertura.xml" \ | |
| -targetdir:"coverage-report" \ | |
| -reporttypes:"Html;MarkdownSummary" | |
| - name: Upload coverage artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-coverage-cobertura | |
| path: tests/HubDocs.UnitTests/TestResults/**/coverage.cobertura.xml | |
| - name: Upload HTML coverage report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-coverage-html | |
| path: coverage-report |