Skip to content

Commit

Permalink
fix: update coverage upload (#5)
Browse files Browse the repository at this point in the history
* fix: update coverage upload

* fix: update github workflow

* fix: using coverage.out

* fix: using coverage.out in coverage CI workflow

* fix: exclude some folder should not matter to test
  • Loading branch information
samwang0723 authored Jul 2, 2024
1 parent 7fe6e56 commit dbca23d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,3 @@ jobs:
cache: true
- name: Run tests and generate coverage report
run: make test

30 changes: 30 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Coverage
on: [push, pull_request]
jobs:
test:
name: Test with Coverage
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.22'
- name: Check out code
uses: actions/checkout@v2
- name: Install dependencies
run: |
go mod download
- name: Run Unit tests
run: |
make test
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
run: goveralls -coverprofile=coverage.out -service=github
# or use shogo82148/actions-goveralls
# - name: Send coverage
# uses: shogo82148/actions-goveralls@v1
# with:
# path-to-profile: covprofile
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ APP_NAME?=stock-crawler
VERSION?=v2.0.1

SHELL = /bin/bash
SOURCE_LIST = $$(go list ./... | grep -v /third_party/ | grep -v /internal/app/pb)
SOURCE_LIST = $$(go list ./... | grep -v /cmd | grep -v /internal/cronjob | grep -v /internal/kafka)

###########
# install #
Expand All @@ -26,16 +26,19 @@ vendor:
# test #
########

test: test-race test-leak test-coverage-report ## launch all tests
test: test-race test-leak test-coverage-ci ## launch all tests

test-race: ## launch all tests with race detection
go test $(SOURCE_LIST) -cover -race

test-leak: ## launch all tests with leak detection (if possible)
go test $(SOURCE_LIST) -leak

test-coverage-ci:
go test -v $(SOURCE_LIST) -cover -race -covermode=atomic -coverprofile=coverage.out

test-coverage-report:
go test -v $(SOURCE_LIST) -cover -race -covermode=atomic -coverprofile=./coverage.out
go test -v $(SOURCE_LIST) -cover -race -covermode=atomic -coverprofile=coverage.out
go tool cover -html=coverage.out

########
Expand Down

0 comments on commit dbca23d

Please sign in to comment.