diff --git a/.github/workflows/go-ci.yaml b/.github/workflows/go-ci.yaml index 1bfbc53..caab31d 100644 --- a/.github/workflows/go-ci.yaml +++ b/.github/workflows/go-ci.yaml @@ -53,6 +53,7 @@ on: jobs: tests: + name: Tests env: GOPRIVATE: "${{ inputs.go-private }}" GH_USERNAME: ${{ secrets.gh_username || 'gh-netic-robot' }} @@ -87,7 +88,13 @@ jobs: install-mode: "goinstall" - name: Go Compile and Test - run: go test -cover -v ./... + run: go test -cover -coverprofile=coverage.txt -v ./... + + - name: Archive code coverage results + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: code-coverage + path: coverage.txt - name: Run benchmarks if: inputs.run-benchmarks @@ -163,3 +170,18 @@ jobs: - name: Clean up private repository access configuration if: always() && steps.setup_git_creds.outcome == 'success' && inputs.go-private != '' run: git config --global --unset url."https://${{ env.GH_USERNAME }}:${{ env.GH_TOKEN }}@github.com".insteadOf + + code-coverage: + name: Code Coverage + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + needs: tests + permissions: + contents: read + actions: read + pull-requests: write + steps: + - uses: fgrosse/go-coverage-report@8c1d1a09864211d258937b1b1a5b849f7e4f2682 # v1 + with: + coverage-artifact-name: code-coverage + coverage-file-name: "coverage.txt"