github.com/polygon-io/client-go@v1.16.4/.github/workflows/test-coverage.yml (about)

     1  name: code-coverage
     2  on:
     3    push:
     4      tags:
     5        - v*
     6      branches:
     7        - master
     8    pull_request:
     9  permissions:
    10    contents: write
    11  jobs:
    12    test:
    13      name: coverage
    14      runs-on: ubuntu-latest
    15      steps:
    16        - uses: actions/setup-go@v4
    17          with:
    18            go-version: ${{ matrix.go-version }}
    19        - uses: actions/checkout@v4
    20          with:
    21            fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
    22        - name: go-test
    23          run: |
    24            go test -v ./... -covermode=count -coverprofile=coverage.out.temp
    25            grep -Ev '(/example|_deprecated.go)' coverage.out.temp > coverage.out
    26            rm coverage.out.temp
    27            go tool cover -func=coverage.out -o=coverage.out
    28        - name: go-coverage-badge  # Pass the `coverage.out` output to this action
    29          uses: tj-actions/coverage-badge-go@v2
    30          with:
    31            filename: coverage.out
    32        - name: verify-changed
    33          uses: tj-actions/verify-changed-files@v17
    34          id: verify-changed-files
    35          with:
    36            files: README.md
    37        - name: commit-changes
    38          if: steps.verify-changed-files.outputs.files_changed == 'true'
    39          run: |
    40            git config --local user.email "action@github.com"
    41            git config --local user.name "GitHub Action"
    42            git add README.md
    43            git commit -m "chore: Updated coverage badge."
    44            git fetch origin && git rebase origin/master
    45        - name: push-changes
    46          if: steps.verify-changed-files.outputs.files_changed == 'true'
    47          uses: ad-m/github-push-action@master
    48          with:
    49            github_token: ${{ github.token }}
    50            branch: ${{ github.head_ref }}