updated threshold #19
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: API CI | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| paths: | |
| - "**/*.sln" | |
| - "**/*.csproj" | |
| - "**/*.cs" | |
| - ".github/workflows/api-ci.yml" | |
| pull_request: | |
| branches: [ main, develop ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: api-ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| # 🔁 tweak this if your .sln lives elsewhere | |
| SOLUTION_PATH: ./ApiTests.sln | |
| # 🔐 your secrets — already set up in your repo | |
| API_BASE_URL: ${{ secrets.API_BASE_URL }} | |
| API_KEY: ${{ secrets.API_KEY }} | |
| API_KEY_HEADER: ${{ secrets.API_KEY_HEADER }} | |
| API_LOGIN_PATH: ${{ secrets.API_LOGIN_PATH }} | |
| API_USERNAME: ${{ secrets.API_USERNAME }} | |
| API_PASSWORD: ${{ secrets.API_PASSWORD }} | |
| DOTNET_NOLOGO: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET 8 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| cache: true | |
| # If you committed NuGet lock files: | |
| cache-dependency-path: '**/packages.lock.json' | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Build (Release) | |
| run: dotnet build --configuration Release --no-restore | |
| # ▶️ Collect coverage (threshold=0 for now) into a single folder per job | |
| - name: Test + Coverage (MSBuild, threshold=0) | |
| shell: pwsh | |
| run: | | |
| $cov = Join-Path $env:GITHUB_WORKSPACE 'TestResults/coverage' | |
| New-Item -ItemType Directory -Force -Path $cov | Out-Null | |
| dotnet test $env:SOLUTION_PATH ` | |
| /p:CollectCoverage=true ` | |
| /p:CoverletOutputFormat=cobertura ` | |
| /p:CoverletOutput="$cov/coverage" ` | |
| /p:Threshold=0 ` | |
| /p:ThresholdType=line ` | |
| /p:ThresholdStat=total ` | |
| --logger "trx;LogFileName=testresults.trx" ` | |
| --results-directory "$($env:GITHUB_WORKSPACE)/TestResults" | |
| - name: Install ReportGenerator (global tool) | |
| shell: pwsh | |
| run: | | |
| dotnet tool install --global dotnet-reportgenerator-globaltool | |
| # Ensure the global tool path is on PATH (works on both OSes) | |
| $env:PATH += [IO.Path]::PathSeparator + (Join-Path $HOME ".dotnet/tools") | |
| - name: Generate Coverage Report (HTML + Cobertura) | |
| shell: pwsh | |
| run: | | |
| $covFile = Join-Path $env:GITHUB_WORKSPACE 'TestResults/coverage' | |
| reportgenerator ` | |
| -reports:"$covFile/*.cobertura.xml" ` | |
| -targetdir:"CoverageReport" ` | |
| -reporttypes:"HtmlInline_AzurePipelines;Cobertura" | |
| - name: Upload Test Results (.trx) | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-${{ matrix.os }} | |
| path: TestResults/**/*.trx | |
| if-no-files-found: warn | |
| - name: Upload Coverage Report (HTML) | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report-${{ matrix.os }} | |
| path: CoverageReport/** | |
| if-no-files-found: warn |