Skip to content

feat: coverage on PRs #6

feat: coverage on PRs

feat: coverage on PRs #6

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: Create comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: 1
body: |
This is a multi-line test comment
- With GitHub **Markdown** :sparkles:
- Created by [create-or-update-comment][1]
[1]: https://github.com/peter-evans/create-or-update-comment
# - 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 }}
# ```