khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2016 the original author or authors. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 17 | # set default shell |
| 18 | SHELL = bash -e -o pipefail |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 19 | |
Zack Williams | 27f59a4 | 2019-05-10 09:12:07 -0700 | [diff] [blame] | 20 | # Variables |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 21 | VERSION ?= $(shell cat ./VERSION) |
Zack Williams | 27f59a4 | 2019-05-10 09:12:07 -0700 | [diff] [blame] | 22 | |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 23 | DOCKER_LABEL_VCS_DIRTY = false |
| 24 | ifneq ($(shell git ls-files --others --modified --exclude-standard 2>/dev/null | wc -l | sed -e 's/ //g'),0) |
| 25 | DOCKER_LABEL_VCS_DIRTY = true |
| 26 | endif |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 27 | ## Docker related |
David K. Bainbridge | e14914d | 2019-05-24 13:43:05 -0700 | [diff] [blame] | 28 | DOCKER_EXTRA_ARGS ?= |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 29 | DOCKER_REGISTRY ?= |
| 30 | DOCKER_REPOSITORY ?= |
| 31 | DOCKER_TAG ?= ${VERSION}$(shell [[ ${DOCKER_LABEL_VCS_DIRTY} == "true" ]] && echo "-dirty" || true) |
| 32 | RWCORE_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-rw-core |
| 33 | ROCORE_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-ro-core |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 34 | OFAGENT_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-ofagent |
| 35 | CLI_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-cli |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 36 | |
| 37 | ## Docker labels. Only set ref and commit date if committed |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 38 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 39 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD) |
| 40 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 41 | DOCKER_LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD) |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 42 | |
girishk | 5259f8e | 2019-10-10 18:44:44 +0000 | [diff] [blame] | 43 | # Default is GO111MODULE=auto, which will refuse to use go mod if running |
| 44 | # go less than 1.13.0 and this repository is checked out in GOPATH. For now, |
| 45 | # force module usage. This affects commands executed from this Makefile, but |
| 46 | # not the environment inside the Docker build (which does not build from |
| 47 | # inside a GOPATH). |
| 48 | export GO111MODULE=on |
| 49 | |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 50 | DOCKER_BUILD_ARGS ?= \ |
David K. Bainbridge | e14914d | 2019-05-24 13:43:05 -0700 | [diff] [blame] | 51 | ${DOCKER_EXTRA_ARGS} \ |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 52 | --build-arg org_label_schema_version="${VERSION}" \ |
| 53 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 54 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 55 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 56 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 57 | --build-arg org_opencord_vcs_dirty="${DOCKER_LABEL_VCS_DIRTY}" |
| 58 | |
| 59 | DOCKER_BUILD_ARGS_LOCAL ?= ${DOCKER_BUILD_ARGS} \ |
| 60 | --build-arg LOCAL_PYVOLTHA=${LOCAL_PYVOLTHA} \ |
| 61 | --build-arg LOCAL_PROTOS=${LOCAL_PROTOS} |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 62 | |
Scott Baker | 8461e15 | 2019-10-01 14:44:30 -0700 | [diff] [blame] | 63 | .PHONY: rw_core ro_core local-protos local-pyvoltha |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 64 | |
| 65 | # This should to be the first and default target in this Makefile |
| 66 | help: |
| 67 | @echo "Usage: make [<target>]" |
| 68 | @echo "where available targets are:" |
| 69 | @echo |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 70 | @echo "build : Build the docker images." |
| 71 | @echo " - If this is the first time you are building, choose 'make build' option." |
| 72 | @echo "rw_core : Build the rw_core docker image" |
| 73 | @echo "ro_core : Build the ro_core docker image" |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 74 | @echo "ofagent : Build the openflow agent docker image" |
| 75 | @echo "cli : Build the voltha CLI docker image" |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 76 | @echo "venv : Build local Python virtualenv" |
| 77 | @echo "clean : Remove files created by the build and tests" |
| 78 | @echo "distclean : Remove venv directory" |
| 79 | @echo "docker-push : Push the docker images to an external repository" |
David Bainbridge | 5f3619c | 2019-07-10 22:51:09 +0000 | [diff] [blame] | 80 | @echo "lint-dockerfile : Perform static analysis on Dockerfiles" |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 81 | @echo "lint-style : Verify code is properly gofmt-ed" |
| 82 | @echo "lint-sanity : Verify that 'go vet' doesn't report any issues" |
girishk | 5259f8e | 2019-10-10 18:44:44 +0000 | [diff] [blame] | 83 | @echo "lint-mod : Verify the integrity of the 'mod' files" |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 84 | @echo "lint : Shorthand for lint-style & lint-sanity" |
npujar | 03b018e | 2019-11-13 15:29:36 +0530 | [diff] [blame] | 85 | @echo "sca : Runs various SCA through golangci-lint tool" |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 86 | @echo "test : Generate reports for all go tests" |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 87 | @echo |
| 88 | |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 89 | ## Local Development Helpers |
| 90 | local-protos: |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 91 | @mkdir -p python/local_imports |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 92 | ifdef LOCAL_PROTOS |
William Kurkian | 905834f | 2019-11-13 15:40:46 -0500 | [diff] [blame] | 93 | mkdir -p vendor/github.com/opencord/voltha-protos/v2/go |
| 94 | cp -r ${LOCAL_PROTOS}/go/* vendor/github.com/opencord/voltha-protos/v2/go |
William Kurkian | d4eccbc | 2019-07-30 10:17:21 -0400 | [diff] [blame] | 95 | rm -rf python/local_imports/voltha-protos |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 96 | mkdir -p python/local_imports/voltha-protos/dist |
William Kurkian | 905834f | 2019-11-13 15:40:46 -0500 | [diff] [blame] | 97 | cp ${LOCAL_PROTOS}/dist/*.tar.gz python/local_imports/voltha-protos/dist/ |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 98 | endif |
| 99 | |
Scott Baker | cb7c88a | 2019-10-16 18:32:48 -0700 | [diff] [blame] | 100 | ## Local Development Helpers |
| 101 | local-lib-go: |
| 102 | ifdef LOCAL_LIB_GO |
Scott Baker | 17f1d9d | 2019-10-25 12:51:25 -0700 | [diff] [blame] | 103 | mkdir -p vendor/github.com/opencord/voltha-lib-go/v2/pkg |
| 104 | cp -r ${LOCAL_LIB_GO}/pkg/* vendor/github.com/opencord/voltha-lib-go/v2/pkg/ |
Scott Baker | cb7c88a | 2019-10-16 18:32:48 -0700 | [diff] [blame] | 105 | endif |
| 106 | |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 107 | local-pyvoltha: |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 108 | @mkdir -p python/local_imports |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 109 | ifdef LOCAL_PYVOLTHA |
William Kurkian | d4eccbc | 2019-07-30 10:17:21 -0400 | [diff] [blame] | 110 | rm -rf python/local_imports/pyvoltha |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 111 | mkdir -p python/local_imports/pyvoltha/dist |
Scott Baker | 17f1d9d | 2019-10-25 12:51:25 -0700 | [diff] [blame] | 112 | cp ${LOCAL_PYVOLTHA}/dist/*.tar.gz python/local_imports/pyvoltha/dist/ |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 113 | endif |
| 114 | |
| 115 | ## Python venv dev environment |
| 116 | |
| 117 | VENVDIR := python/venv-volthago |
| 118 | |
| 119 | venv: distclean local-protos local-pyvoltha |
| 120 | virtualenv ${VENVDIR};\ |
| 121 | source ./${VENVDIR}/bin/activate ; set -u ;\ |
| 122 | rm -f ${VENVDIR}/local/bin ${VENVDIR}/local/lib ${VENVDIR}/local/include ;\ |
| 123 | pip install -r python/requirements.txt |
| 124 | ifdef LOCAL_PYVOLTHA |
| 125 | source ./${VENVDIR}/bin/activate ; set -u ;\ |
| 126 | pip install python/local_imports/pyvoltha/dist/*.tar.gz |
| 127 | endif |
| 128 | ifdef LOCAL_PROTOS |
| 129 | source ./${VENVDIR}/bin/activate ; set -u ;\ |
| 130 | pip install python/local_imports/voltha-protos/dist/*.tar.gz |
| 131 | endif |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 132 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 133 | ## Docker targets |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 134 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 135 | build: docker-build |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 136 | |
Scott Baker | 676f0dd | 2019-10-14 17:07:48 -0700 | [diff] [blame] | 137 | docker-build: rw_core ro_core ofagent cli |
sslobodr | a3ea7d4 | 2019-01-16 15:03:16 -0500 | [diff] [blame] | 138 | |
Scott Baker | cb7c88a | 2019-10-16 18:32:48 -0700 | [diff] [blame] | 139 | rw_core: local-protos local-lib-go |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 140 | docker build $(DOCKER_BUILD_ARGS) -t ${RWCORE_IMAGENAME}:${DOCKER_TAG} -t ${RWCORE_IMAGENAME}:latest -f docker/Dockerfile.rw_core . |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 141 | |
Scott Baker | cb7c88a | 2019-10-16 18:32:48 -0700 | [diff] [blame] | 142 | ro_core: local-protos local-lib-go |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 143 | docker build $(DOCKER_BUILD_ARGS) -t ${ROCORE_IMAGENAME}:${DOCKER_TAG} -t ${ROCORE_IMAGENAME}:latest -f docker/Dockerfile.ro_core . |
Stephane Barbarie | a75791c | 2019-01-24 10:58:06 -0500 | [diff] [blame] | 144 | |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 145 | ofagent: local-protos local-pyvoltha |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 146 | docker build $(DOCKER_BUILD_ARGS_LOCAL) -t ${OFAGENT_IMAGENAME}:${DOCKER_TAG} -t ${OFAGENT_IMAGENAME}:latest -f python/docker/Dockerfile.ofagent python |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 147 | |
| 148 | cli: local-protos local-pyvoltha |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 149 | docker build $(DOCKER_BUILD_ARGS_LOCAL) -t ${CLI_IMAGENAME}:${DOCKER_TAG} -t ${CLI_IMAGENAME}:latest -f python/docker/Dockerfile.cli python |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 150 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 151 | docker-push: |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 152 | docker push ${RWCORE_IMAGENAME}:${DOCKER_TAG} |
| 153 | docker push ${ROCORE_IMAGENAME}:${DOCKER_TAG} |
Kent Hagerman | f4a3aab | 2019-05-22 14:42:34 -0400 | [diff] [blame] | 154 | docker push ${OFAGENT_IMAGENAME}:${DOCKER_TAG} |
| 155 | docker push ${CLI_IMAGENAME}:${DOCKER_TAG} |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 156 | |
| 157 | ## lint and unit tests |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 158 | |
David Bainbridge | 5f3619c | 2019-07-10 22:51:09 +0000 | [diff] [blame] | 159 | PATH:=$(GOPATH)/bin:$(PATH) |
| 160 | HADOLINT=$(shell PATH=$(GOPATH):$(PATH) which hadolint) |
| 161 | lint-dockerfile: |
| 162 | ifeq (,$(shell PATH=$(GOPATH):$(PATH) which hadolint)) |
| 163 | mkdir -p $(GOPATH)/bin |
| 164 | curl -o $(GOPATH)/bin/hadolint -sNSL https://github.com/hadolint/hadolint/releases/download/v1.17.1/hadolint-$(shell uname -s)-$(shell uname -m) |
| 165 | chmod 755 $(GOPATH)/bin/hadolint |
| 166 | endif |
| 167 | @echo "Running Dockerfile lint check ..." |
| 168 | @hadolint $$(find . -name "Dockerfile.*") |
| 169 | @echo "Dockerfile lint check OK" |
| 170 | |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 171 | lint-style: |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 172 | ifeq (,$(shell which gofmt)) |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 173 | go get -u github.com/golang/go/src/cmd/gofmt |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 174 | endif |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 175 | @echo "Running style check..." |
| 176 | @gofmt_out="$$(gofmt -l $$(find . -name '*.go' -not -path './vendor/*'))" ;\ |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 177 | if [ ! -z "$$gofmt_out" ]; then \ |
| 178 | echo "$$gofmt_out" ;\ |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 179 | echo "Style check failed on one or more files ^, run 'go fmt' to fix." ;\ |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 180 | exit 1 ;\ |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 181 | fi |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 182 | @echo "Style check OK" |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 183 | |
| 184 | lint-sanity: |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 185 | @echo "Running sanity check..." |
girishk | 5259f8e | 2019-10-10 18:44:44 +0000 | [diff] [blame] | 186 | @go vet -mod=vendor ./... |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 187 | @echo "Sanity check OK" |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 188 | |
girishk | 5259f8e | 2019-10-10 18:44:44 +0000 | [diff] [blame] | 189 | lint-mod: |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 190 | @echo "Running dependency check..." |
girishk | 5259f8e | 2019-10-10 18:44:44 +0000 | [diff] [blame] | 191 | @go mod verify |
Scott Baker | e4c2a98 | 2019-11-21 16:32:03 -0800 | [diff] [blame] | 192 | @echo "Dependency check OK. Running vendor check..." |
| 193 | @git status > /dev/null |
| 194 | @git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Staged or modified files must be committed before running this test" && echo "`git status`" && exit 1) |
| 195 | @[[ `git ls-files --exclude-standard --others go.mod go.sum vendor` == "" ]] || (echo "ERROR: Untracked files must be cleaned up before running this test" && echo "`git status`" && exit 1) |
| 196 | go mod tidy |
| 197 | go mod vendor |
| 198 | @git status > /dev/null |
| 199 | @git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Modified files detected after running go mod tidy / go mod vendor" && echo "`git status`" && exit 1) |
| 200 | @[[ `git ls-files --exclude-standard --others go.mod go.sum vendor` == "" ]] || (echo "ERROR: Untracked files detected after running go mod tidy / go mod vendor" && echo "`git status`" && exit 1) |
| 201 | @echo "Vendor check OK." |
| 202 | |
Kent Hagerman | 0ab4cb2 | 2019-04-24 13:13:35 -0400 | [diff] [blame] | 203 | |
girishk | 5259f8e | 2019-10-10 18:44:44 +0000 | [diff] [blame] | 204 | lint: lint-style lint-sanity lint-mod lint-dockerfile |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 205 | |
Scott Baker | 18ea5a4 | 2019-10-15 16:08:42 -0700 | [diff] [blame] | 206 | # Rules to automatically install golangci-lint |
| 207 | GOLANGCI_LINT_TOOL?=$(shell which golangci-lint) |
| 208 | ifeq (,$(GOLANGCI_LINT_TOOL)) |
| 209 | GOLANGCI_LINT_TOOL=$(GOPATH)/bin/golangci-lint |
| 210 | golangci_lint_tool_install: |
| 211 | # Same version as installed by Jenkins ci-management |
| 212 | # Note that install using `go get` is not recommended as per https://github.com/golangci/golangci-lint |
| 213 | curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOPATH)/bin v1.17.0 |
| 214 | else |
| 215 | golangci_lint_tool_install: |
| 216 | endif |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 217 | |
Scott Baker | 18ea5a4 | 2019-10-15 16:08:42 -0700 | [diff] [blame] | 218 | # Rules to automatically install go-junit-report |
| 219 | GO_JUNIT_REPORT?=$(shell which go-junit-report) |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 220 | ifeq (,$(GO_JUNIT_REPORT)) |
Scott Baker | 18ea5a4 | 2019-10-15 16:08:42 -0700 | [diff] [blame] | 221 | GO_JUNIT_REPORT=$(GOPATH)/bin/go-junit-report |
| 222 | go_junit_install: |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 223 | go get -u github.com/jstemmer/go-junit-report |
Scott Baker | 18ea5a4 | 2019-10-15 16:08:42 -0700 | [diff] [blame] | 224 | else |
| 225 | go_junit_install: |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 226 | endif |
Scott Baker | 18ea5a4 | 2019-10-15 16:08:42 -0700 | [diff] [blame] | 227 | |
| 228 | # Rules to automatically install gocover-covertura |
| 229 | GOCOVER_COBERTURA?=$(shell which gocover-cobertura) |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 230 | ifeq (,$(GOCOVER_COBERTURA)) |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 231 | @GOCOVER_COBERTURA=$(GOPATH)/bin/gocover-cobertura |
Scott Baker | 18ea5a4 | 2019-10-15 16:08:42 -0700 | [diff] [blame] | 232 | gocover_cobertura_install: |
| 233 | go get -u github.com/t-yuki/gocover-cobertura |
| 234 | else |
| 235 | gocover_cobertura_install: |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 236 | endif |
Scott Baker | 18ea5a4 | 2019-10-15 16:08:42 -0700 | [diff] [blame] | 237 | |
| 238 | sca: golangci_lint_tool_install |
| 239 | rm -rf ./sca-report |
| 240 | @mkdir -p ./sca-report |
npujar | 9b959eb | 2019-11-14 16:57:46 +0530 | [diff] [blame^] | 241 | $(GOLANGCI_LINT_TOOL) run -E golint -D structcheck --out-format junit-xml ./cli/... ./rw_core/... ./ro_core/... ./tests/... ./common/... 2>&1 | tee ./sca-report/sca-report.xml |
Scott Baker | 18ea5a4 | 2019-10-15 16:08:42 -0700 | [diff] [blame] | 242 | |
Scott Baker | cb7c88a | 2019-10-16 18:32:48 -0700 | [diff] [blame] | 243 | test: go_junit_install gocover_cobertura_install local-lib-go |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 244 | @mkdir -p ./tests/results |
girishk | 5259f8e | 2019-10-10 18:44:44 +0000 | [diff] [blame] | 245 | @go test -mod=vendor -v -coverprofile ./tests/results/go-test-coverage.out -covermode count ./... 2>&1 | tee ./tests/results/go-test-results.out ;\ |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 246 | RETURN=$$? ;\ |
| 247 | $(GO_JUNIT_REPORT) < ./tests/results/go-test-results.out > ./tests/results/go-test-results.xml ;\ |
| 248 | $(GOCOVER_COBERTURA) < ./tests/results/go-test-coverage.out > ./tests/results/go-test-coverage.xml ;\ |
| 249 | exit $$RETURN |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 250 | |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 251 | clean: |
| 252 | rm -rf python/local_imports |
| 253 | find python -name '*.pyc' | xargs rm -f |
| 254 | |
| 255 | distclean: clean |
David Bainbridge | 81175e4 | 2019-10-16 19:06:37 +0000 | [diff] [blame] | 256 | rm -rf ${VENVDIR} ./sca_report |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 257 | |
Scott Baker | cb7c88a | 2019-10-16 18:32:48 -0700 | [diff] [blame] | 258 | mod-update: |
| 259 | go mod tidy |
| 260 | go mod vendor |
| 261 | |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 262 | # end file |