Coverage #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: Coverage | |
| on: | |
| workflow_run: | |
| workflows: | |
| - build-and-test | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: coverage-pages | |
| cancel-in-progress: true | |
| jobs: | |
| coverage: | |
| if: > | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.event == 'push' && | |
| github.event.workflow_run.head_branch == 'main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 10.0.x | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.slnx') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Restore dependencies | |
| run: dotnet restore FixedMathSharp.slnx --property:Configuration=Release | |
| - name: Build solution | |
| run: dotnet build FixedMathSharp.slnx --configuration Release --no-restore | |
| - name: Run tests with coverage | |
| run: dotnet test tests/FixedMathSharp.Tests/FixedMathSharp.Tests.csproj --configuration Release --no-build --collect:"XPlat Code Coverage" --settings tests/FixedMathSharp.Tests/coverlet.runsettings --results-directory artifacts/coverage | |
| - name: Restore local tools | |
| run: dotnet tool restore | |
| - name: Build API documentation | |
| run: | | |
| test -f src/FixedMathSharp/bin/Release/net8.0/FixedMathSharp.dll | |
| test -f src/FixedMathSharp/bin/Release/net8.0/FixedMathSharp.xml | |
| dotnet tool run docfx docs/api/docfx.json | |
| test -f docs/api/obj/_site/index.html | |
| test -f docs/api/obj/_site/api/FixedMathSharp.html | |
| test -f docs/api/obj/_site/assets/icon_128x128.png | |
| grep -q "github.com/mrdav30/FixedMathSharp" docs/api/obj/_site/public/main.js | |
| grep -q "FixedMathSharp-Unity" docs/api/obj/_site/api/FixedMathSharp.html | |
| - name: Install ReportGenerator | |
| run: dotnet tool install --global dotnet-reportgenerator-globaltool | |
| - name: Add ReportGenerator to PATH | |
| run: echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH" | |
| - name: Generate coverage report | |
| run: | | |
| reportgenerator \ | |
| "-reports:artifacts/coverage/**/coverage.cobertura.xml" \ | |
| "-targetdir:artifacts/coverage-report" \ | |
| "-reporttypes:Html;MarkdownSummaryGithub;Badges;JsonSummary" \ | |
| "-filefilters:-**/MemoryPack.Generator/**;-**/*.g.cs;-**/obj/**" | |
| - name: Add coverage summary to job | |
| run: cat artifacts/coverage-report/SummaryGithub.md >> "$GITHUB_STEP_SUMMARY" | |
| - name: Assemble Pages site | |
| run: | | |
| mkdir -p artifacts/pages/coverage | |
| cp -a docs/api/obj/_site/. artifacts/pages/ | |
| cp -a artifacts/coverage-report/. artifacts/pages/coverage/ | |
| test -f artifacts/pages/index.html | |
| test -f artifacts/pages/api/FixedMathSharp.html | |
| test -f artifacts/pages/coverage/Summary.json | |
| - name: Upload coverage artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: coverage-report | |
| path: artifacts/coverage-report | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: artifacts/pages | |
| deploy: | |
| needs: coverage | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Configure Pages | |
| uses: actions/configure-pages@v6 | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |