Skip to content

Commit

Permalink
feat: enable codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Aug 11, 2019
1 parent 267306b commit d8cd184
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
11 changes: 7 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ orbs:
dl: moul/[email protected] # https://github.com/moul/dl/blob/master/.circleci/config.yml
retry: moul/[email protected] # https://github.com/moul/retry/blob/master/.circleci/config.yml
tools: gotest/[email protected]
docker: circleci/[email protected]
codecov: codecov/[email protected]

executors:
golang:
Expand Down Expand Up @@ -36,11 +38,10 @@ jobs:
# FIXME: save cache

# build and unit test the project
test:
go_test:
executor: golang
steps:
- checkout
# FIXME: restore cache
- run: go clean -modcache
- retry/install
- tools/mod-download
Expand All @@ -50,7 +51,9 @@ jobs:
# FIXME: setup coverage
- moul/install_golangci-lint
- run: . ~/.profile && retry -m 3 make lint
# FIXME: save cache
- codecov/upload:
file: coverage.txt
flags: go_test
# FIXME: store_test_results

docker_integration:
Expand All @@ -69,6 +72,6 @@ jobs:
workflows:
main:
jobs:
- test
- go_test
- docker_build
- docker_integration
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
coverage.txt

.env

node_modules
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,15 @@ $(PWCTL_OUT_FILES): $(PWCTL_SOURCES)

.PHONY: test
test: .proto.generated
go test -mod=readonly -v ./...
echo "" > /tmp/coverage.txt
set -e; for dir in `find . -type f -name "go.mod" | sed -r 's@/[^/]+$$@@' | sort | uniq`; do (set -xe; \
cd $$dir; \
go test -v -mod=readonly -cover -coverprofile=/tmp/profile.out -covermode=atomic -race ./...; \
if [ -f /tmp/profile.out ]; then \
cat /tmp/profile.out >> /tmp/coverage.txt; \
rm -f /tmp/profile.out; \
fi); done
mv /tmp/coverage.txt .

%.pb.go: %.proto
protoc \
Expand Down
15 changes: 15 additions & 0 deletions pkg/randstring/randstring_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package randstring

import (
"fmt"
"math/rand"
)

func ExampleRandString() {
rand.Seed(42)
fmt.Println(RandString(10))
fmt.Println(RandString(42))
// output:
// CBzlgwF4Xt
// dzFemEMgBqNznwB199sND0jQ6KJ402CKj1s8Oquw5O
}

0 comments on commit d8cd184

Please sign in to comment.