Skip to content

feat: coverage on PRs #5

feat: coverage on PRs

feat: coverage on PRs #5

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go CI build and test
on:
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
- name: Install dependencies
run: go mod tidy
- name: Build
run: go build -v ./...
- name: Run tests with coverage
id: test
run: |
go test ./... -coverprofile=coverage.out
go tool cover -func=coverage.out > coverage.txt
echo "::set-output name=coverage::$(tail -n 10 coverage.txt | head -n 1 | awk '{print $3}')"
echo "::set-output name=coverage_details::$(cat coverage.txt)"
- name: Post coverage report as a comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
## Test Coverage Report
The overall test coverage is **${{ steps.test.outputs.coverage }}**.
### Coverage Details
```
${{ steps.test.outputs.coverage_details }}
```