4a1ec4d3创建于 2023年2月27日历史提交
# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: Coverage

on:
  # schedule:
  #   - cron: '30 8 * * *' # Daily
  pull_request:
    branches:
      - main
  # repository_dispatch:
  #   types: "coverage"
  
jobs:
  coverage:
    runs-on: ubuntu-latest
    steps:
      - name: Get Cover 
        uses: orgoro/coverage@v3
        with:
            coverageFile: path/to/coverage.xml
            token: ${{ secrets.GITHUB_TOKEN }}
  
  Update_Coverage:
    runs-on: ubuntu-latest
    steps:
    
      # Add coverlet.collector nuget package to test project - 'dotnet add <TestProject.cspoj> package coverlet
      - name: Test
        run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" --logger trx --results-directory coverage

      - name: Copy Coverage to Predictable Location
        run: cp coverage/*/coverage.cobertura.xml coverage/coverage.cobertura.xml

      - name: Code Coverage Summary Report
        uses: irongut/CodeCoverageSummary@v1.3.0
        with:
          filename: coverage/coverage.cobertura.xml
          badge: true
          format: 'markdown'
          output: 'both'

      - name: Add Coverage PR Comment
        uses: marocchino/sticky-pull-request-comment@v2
        if: github.event_name == 'pull_request'
        with:
          recreate: true
          path: code-coverage-results.md

      - name: Write to Job Summary
        run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY