diff --git a/.github/workflows/unit-test-on-pull-request.yml b/.github/workflows/unit-test-on-pull-request.yml index 9cc7884..cc0251f 100644 --- a/.github/workflows/unit-test-on-pull-request.yml +++ b/.github/workflows/unit-test-on-pull-request.yml @@ -71,3 +71,55 @@ jobs: - name: Run Benchmarks run: | GOMAXPROCS=100 make bench + + coverage: + name: Coverage + runs-on: ubuntu-latest + strategy: + fail-fast: true + max-parallel: 2 + matrix: + go: ["stable"] + permissions: + contents: write + steps: + - name: Set up Go ${{matrix.go}} + uses: actions/setup-go@v4 + with: + go-version: ${{matrix.go}} + check-latest: true + id: go + - name: Check out + uses: actions/checkout@v4 + - name: Build + run: | + go install + - name: Run Coverage + run: | + go test -v -cover ./... -coverprofile coverage.out -coverpkg ./... + go tool cover -func coverage.out -o coverage.out # Replaces coverage.out with the analysis of coverage.out + + - name: Go Coverage Badge + uses: tj-actions/coverage-badge-go@v1 + # if: ${{ runner.os == 'Linux' && matrix.go == '1.17' }} # Runs this on only one of the ci builds. + with: + green: 80 + filename: coverage.out + +# - name: Pull in remote changes +# run: git pull --rebase + + - uses: stefanzweifel/git-auto-commit-action@v5 + id: auto-commit-action + with: + commit_message: Apply Code Coverage Badge + skip_fetch: true + skip_checkout: true + file_pattern: ./README.md + +# - name: Push Changes +# if: steps.auto-commit-action.outputs.changes_detected == 'true' +# uses: ad-m/github-push-action@master +# with: +# github_token: ${{ github.token }} +# branch: ${{ github.ref }}