diff --git a/.circleci/config.yml b/.circleci/config.yml index 5b7b008e2..41cca7a53 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,10 +20,12 @@ jobs: - run: | case $CIRCLE_NODE_INDEX in 0) sudo -E make -e lint ;; - 1) sudo -E make -e go-tests ;; + 1) sudo -E make -e go-tests ci-go-coverage;; 2) sudo -E make -e deploy-test-checks-root deploy-test-config deploy-test-multi deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy ;; esac - run: shell: /bin/bash command: sudo -E make -e test-ci no_output_timeout: 60m + - store_artifacts: + path: ./coverage.out diff --git a/.codacy.yml b/.codacy.yml new file mode 100644 index 000000000..8f6841491 --- /dev/null +++ b/.codacy.yml @@ -0,0 +1,5 @@ +exclude_paths: +- vendor/**/* +- tests/**/* +- "**_test.go" +- contrib/* diff --git a/.gitignore b/.gitignore index 2794757ee..3027ddb0d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ data/ stack.tgz tmp +coverage.out diff --git a/tests.mk b/tests.mk index 08a9d65ca..2c325f064 100644 --- a/tests.mk +++ b/tests.mk @@ -73,6 +73,16 @@ lint: @echo linting... @$(QUIET) find . -not -path '*/\.*' -not -path './debian/*' -type f | xargs file | grep text | awk -F ':' '{ print $$1 }' | xargs head -n1 | egrep -B1 "bash" | grep "==>" | awk '{ print $$2 }' | xargs shellcheck -e SC2034 +ci-go-coverage: + docker run --rm -ti \ + -e DOKKU_ROOT=/home/dokku \ + -e CODACY_TOKEN=$$CODACY_TOKEN \ + -e CIRCLE_SHA1=$$CIRCLE_SHA1 \ + -v $$PWD:$(GO_REPO_ROOT) \ + -w $(GO_REPO_ROOT) \ + $(BUILD_IMAGE) \ + bash -c "go get github.com/schrej/godacov && godacov -t $$CODACY_TOKEN -r ./coverage.out -c $$CIRCLE_SHA1" || exit $$? + go-tests: @echo running go unit tests... docker run --rm -ti \ @@ -80,8 +90,9 @@ go-tests: -v $$PWD:$(GO_REPO_ROOT) \ -w $(GO_REPO_ROOT) \ $(BUILD_IMAGE) \ - bash -c "go get github.com/onsi/gomega && \ - go list ./... | grep -v /vendor/ | grep -v /tests/apps/ | xargs go test -v -p 1 -race" || exit $$? + bash -c "go get github.com/onsi/gomega github.com/haya14busa/goverage && \ + go list ./... | egrep -v '/vendor/|/tests/apps/' | xargs go test -v -p 1 -race && \ + go list ./... | egrep -v '/vendor/|/tests/apps/' | xargs goverage -v -coverprofile=coverage.out" || exit $$? unit-tests: go-tests @echo running bats unit tests...