Skip to content

Commit

Permalink
upload test coverage artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
sfowl committed Dec 13, 2024
1 parent b841851 commit 1f89948
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CI Build and Test

on:
workflow_call:
push:
branches: ['main']
pull_request:
branches: ['main']

Expand All @@ -27,3 +29,28 @@ jobs:
run: go build -tags release -v ./...
- name: Test
run: make test
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: coverage.out


# XXX this will fail if main does not already have a coverage.out report uploaded by the previous job
# TODO uncomment this after upload-artifact has run on main branch
# code-coverage:
# name: Code coverage report
# runs-on: ubuntu-latest
# needs: build-and-test
# steps:
# - name: coverage report
# id: coverage-report
# uses: fgrosse/[email protected]
# with:
# coverage-file-name: coverage.out
# skip-comment: true # requires write permissin on pull requests
# # below options help track coverage across forks
# trim: github.com/project-kessel/inventory-api
# root-package: ""
# - name: coverage summary
# run: echo "${{ steps.coverage-report.outputs.coverage_report }}" >> "$GITHUB_STEP_SUMMARY"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# HTML test coverage report produce with `go tool cover`
coverage.html

# Dependency directories (remove the comment below to include it)
vendor/
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ test:
@$(GO) test ./... -count=1 -coverprofile=coverage.out -skip 'TestInventoryAPIGRPC_*|TestInventoryAPIHTTP_*|Test_ACMKafkaConsumer'
@echo "Overall test coverage:"
@$(GO) tool cover -func=coverage.out | grep total: | awk '{print $$3}'
@rm coverage.out

test-coverage: test
@$(GO) tool cover -html=coverage.out -o coverage.html
@echo "coverage report written to coverage.html"


.PHONY: generate
Expand Down

0 comments on commit 1f89948

Please sign in to comment.