From fa4b9ae95895c665027aa246f5440936f007774a Mon Sep 17 00:00:00 2001 From: Sylvia Moss Date: Thu, 12 Mar 2020 10:36:10 +0100 Subject: [PATCH] Add Codecov configuration (#8862) --- .circleci/config.yml | 24 +++++++++++++++++++++--- .travis.yml | 24 ------------------------ Makefile | 8 +++++++- codecov.yml | 18 ++++++++++++++++++ 4 files changed, 46 insertions(+), 28 deletions(-) delete mode 100644 .travis.yml create mode 100644 codecov.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 7ef977cf2..03500fc3d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,7 @@ orbs: win: circleci/windows@1.0.0 + codecov: codecov/codecov@1.0.5 + version: 2.1 executors: @@ -20,7 +22,7 @@ commands: steps: - checkout - run: curl https://dl.google.com/go/go<< parameters.GOVERSION >>.<< parameters.GOOS >>-amd64.tar.gz | tar -C ~/ -xz - - run: ~/go/bin/go test ./... + - run: ~/go/bin/go test ./... -coverprofile=coverage.txt -covermode=atomic install-go-run-tests-windows: parameters: GOVERSION: @@ -29,7 +31,7 @@ commands: - checkout - run: curl https://dl.google.com/go/go<< parameters.GOVERSION >>.windows-amd64.zip --output ~/go<< parameters.GOVERSION >>.windows-amd64.zip - run: unzip ~/go<< parameters.GOVERSION >>.windows-amd64.zip -d ~/ - - run: ~/go/bin/go test ./... + - run: ~/go/bin/go test ./... -coverprofile=coverage.txt -covermode=atomic build-and-persist-packer-binary: parameters: GOOS: @@ -52,7 +54,9 @@ jobs: working_directory: /go/src/github.com/hashicorp/packer steps: - checkout - - run: make ci + - run: TESTARGS="-coverprofile=coverage.txt -covermode=atomic" make ci + - codecov/upload: + file: coverage.txt test-darwin: executor: darwin working_directory: ~/go/src/github.com/hashicorp/packer @@ -62,6 +66,8 @@ jobs: - install-go-run-tests-unix: GOOS: darwin GOVERSION: "1.13" + - codecov/upload: + file: coverage.txt test-windows: executor: name: win/vs2019 @@ -69,6 +75,17 @@ jobs: steps: - install-go-run-tests-windows: GOVERSION: "1.13" + - codecov/upload: + file: coverage.txt + check-lint: + executor: golang + resource_class: large + working_directory: /go/src/github.com/hashicorp/packer + steps: + - checkout + - run: + command: make ci-lint + no_output_timeout: 30m check-vendor-vs-mod: executor: golang working_directory: /go/src/github.com/hashicorp/packer @@ -150,6 +167,7 @@ workflows: - test-windows check-code: jobs: + - check-lint - check-vendor-vs-mod - check-fmt - check-generate diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 987dcdc71..000000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -env: - - USER=travis GO111MODULE=off - -os: - - osx - -language: go - -branches: - only: - - master - -jobs: - fast_finish: true - include: - - go: "1.13.x" - name: "go test" - script: - - df -h - - travis_wait make ci - - go: "1.13.x" - name: "go lint" - script: travis_wait make ci-lint - diff --git a/Makefile b/Makefile index ddbbef53e..a88399a81 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ install-gen-deps: ## Install dependencies for code generation install-lint-deps: ## Install linter dependencies @echo "==> Updating linter dependencies..." - @curl -sSfL -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.23.1 + @curl -sSfL -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.23.8 dev: ## Build and install a development build @grep 'const VersionPrerelease = ""' version/version.go > /dev/null ; if [ $$? -eq 0 ]; then \ @@ -142,6 +142,12 @@ testacc: install-build-deps generate ## Run acceptance tests testrace: mode-check vet ## Test with race detection enabled @GO111MODULE=off go test -race $(TEST) $(TESTARGS) -timeout=3m -p=8 +# Runs code coverage and open a html page with report +cover: + go test $(TEST) $(TESTARGS) -timeout=3m -coverprofile=coverage.out + go tool cover -html=coverage.out + rm coverage.out + check-vendor-vs-mod: ## Check that go modules and vendored code are on par @GO111MODULE=on go mod vendor @git diff --exit-code --ignore-space-change --ignore-space-at-eol -- vendor ; if [ $$? -eq 1 ]; then \ diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..dc306f95c --- /dev/null +++ b/codecov.yml @@ -0,0 +1,18 @@ +comment: + layout: "diff, flags, files" + behavior: default + require_changes: true # only comment on changes in coverage + require_base: yes # [yes :: must have a base report to post] + require_head: yes # [yes :: must have a head report to post] + branches: # branch names that can post comment + - "master" + +coverage: + status: + project: + default: + target: auto + threshold: "0.5%" + +ignore: # ignore hcl2spec generated code for coverage + - "**/*.hcl2spec.go" \ No newline at end of file