Merge branch 'main' of https://github.com/qa-dev-hub/api-tests #17
  
    
      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: | |
| 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 | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Build (Release) | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Test + Coverage + Threshold | |
| run: | | |
| dotnet test ./ApiTests.sln \ | |
| /p:CollectCoverage=true \ | |
| /p:CoverletOutputFormat=cobertura \ | |
| /p:CoverletOutput=TestResults/coverage/ \ | |
| /p:Threshold=0 \ | |
| /p:ThresholdType=line \ | |
| /p:ThresholdStat=total | |
| - name: Install ReportGenerator | |
| run: dotnet tool install --global dotnet-reportgenerator-globaltool | |
| - name: Generate Coverage Report | |
| run: | | |
| export PATH="$PATH:~/.dotnet/tools" | |
| reportgenerator \ | |
| -reports:"**/TestResults/coverage/coverage.cobertura.xml" \ | |
| -targetdir:"CoverageReport" \ | |
| -reporttypes:"HtmlInline_AzurePipelines;Cobertura" | |
| - name: Upload Test Results (.trx) | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: TestResults/**/*.trx | |
| if-no-files-found: warn | |
| - name: Upload Coverage Report (HTML) | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: CoverageReport/** | |
| if-no-files-found: warn | |
| - name: Summarize test results | |
| if: always() | |
| run: | | |
| echo "## Test Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "- API: \`dotnet test\` with coverage" >> $GITHUB_STEP_SUMMARY | |
| echo "- Coverage report: see artifacts → coverage-report/index.html" >> $GITHUB_STEP_SUMMARY | |