ci: collect + upload coverage to Codecov (#32) #48
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
| # CI: build, format-check, and run unit tests for the F# SDK. | |
| # | |
| # Action pinning policy: | |
| # - First-party actions (actions/*) are pinned to a major tag (e.g. @v4). | |
| # - Third-party actions are pinned to a full commit SHA with a version comment. | |
| # | |
| # .NET version is governed by global.json (sdk 10.0.203, rollForward latestFeature). | |
| # TargetFramework (net10.0) comes from Directory.Build.props and is the sole matrix entry. | |
| name: test | |
| on: | |
| push: | |
| branches: [main] | |
| paths-ignore: | |
| - "**.md" | |
| - "docs/**" | |
| - "LICENSE" | |
| - ".gitignore" | |
| - ".editorconfig" | |
| pull_request: | |
| branches: [main] | |
| paths-ignore: | |
| - "**.md" | |
| - "docs/**" | |
| - "LICENSE" | |
| - ".gitignore" | |
| - ".editorconfig" | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| name: test (${{ matrix.tfm }} on ${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| tfm: [net10.0] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 1 | |
| - name: Setup .NET (from global.json) | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: global.json | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props', '**/*.fsproj', 'global.json', 'nuget.config') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Restore .NET tools (fantomas) | |
| run: dotnet tool restore | |
| - name: Restore dependencies | |
| run: dotnet restore ARCP.slnx | |
| - name: Format check (fantomas) | |
| run: dotnet fantomas --check src tests samples | |
| - name: Build | |
| run: dotnet build ARCP.slnx --configuration Release --no-restore | |
| - name: Test (unit, with coverage) | |
| run: > | |
| dotnet test tests/Arcp.UnitTests/Arcp.UnitTests.fsproj | |
| --configuration Release | |
| --no-build | |
| --verbosity normal | |
| --collect:"XPlat Code Coverage" | |
| --logger "trx;LogFileName=unit-tests.trx" | |
| --logger "console;verbosity=normal" | |
| --results-directory ${{ github.workspace }}/TestResults | |
| # coverlet.collector writes one coverage.cobertura.xml per test | |
| # project under TestResults/<guid>/. Non-blocking so a Codecov | |
| # outage cannot break CI. | |
| - name: Upload coverage to Codecov | |
| # codecov/codecov-action v6.0.1 | |
| uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1 | |
| with: | |
| fail_ci_if_error: false | |
| flags: unittests | |
| directory: ${{ github.workspace }}/TestResults | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload test results | |
| if: failure() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: test-results-${{ matrix.os }}-${{ matrix.tfm }} | |
| path: ${{ github.workspace }}/TestResults | |
| if-no-files-found: ignore | |
| retention-days: 7 |