Skip to content

Commit

Permalink
chore: Update Go build workflow and Makefile, improve CI
Browse files Browse the repository at this point in the history
  • Loading branch information
edmarfelipe committed Aug 25, 2024
1 parent c9ee6de commit 877ac2d
Showing 1 changed file with 44 additions and 18 deletions.
62 changes: 44 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,59 @@ jobs:
- name: Test
run: make test

- name: Set up gotestfmt
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
- name: Set up tools
run: |
go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
go install github.com/boumenot/gocover-cobertura
- name: Tests
run: |
set -euo pipefail
go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: coverage.txt
# - name: Archive code coverage results
# uses: actions/upload-artifact@v4
# with:
# name: code-coverage
# path: coverage.txt

- name: Show coverage details
id: coverage-details
run: |
go tool cover -func=coverage.txt
coverage:
name: "Code coverage report"
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: test
permissions:
contents: read
actions: read # to download code coverage results from "test" job
pull-requests: write # write permission needed to comment on PR
steps:
- uses: fgrosse/go-coverage-report@v1.0.2
- name: Convert go coverage to corbetura format
run: gocover-cobertura < coverage.txt > coverage.xml

- name: Generate code coverage report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage.xml
badge: false
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'

- name: Add Coverage PR Comment
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
path: code-coverage-results.md

# coverage:
# name: "Code coverage report"
# if: github.event_name == 'pull_request'
# runs-on: ubuntu-latest
# needs: test
# permissions:
# contents: read
# actions: read # to download code coverage results from "test" job
# pull-requests: write # write permission needed to comment on PR
# steps:
# - uses: fgrosse/go-coverage-report@v1.0.2

0 comments on commit 877ac2d

Please sign in to comment.