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 |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 21 | VERSION ?= $(shell cat ./VERSION) |
Zack Williams | 27f59a4 | 2019-05-10 09:12:07 -0700 | [diff] [blame] | 22 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 23 | ## Docker related |
| 24 | DOCKER_REGISTRY ?= |
| 25 | DOCKER_REPOSITORY ?= |
| 26 | DOCKER_BUILD_ARGS ?= |
| 27 | DOCKER_TAG ?= ${VERSION} |
| 28 | RWCORE_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-rw-core:${DOCKER_TAG} |
| 29 | ROCORE_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-ro-core:${DOCKER_TAG} |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 30 | AFROUTER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-afrouter:${DOCKER_TAG} |
| 31 | AFROUTERTEST_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-afroutertest:${DOCKER_TAG} |
| 32 | AFROUTERD_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-afrouterd:${DOCKER_TAG} |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 33 | SIMULATEDOLT_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-adapter-simulated-olt:${DOCKER_TAG} |
| 34 | SIMULATEDONU_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-adapter-simulated-onu:${DOCKER_TAG} |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 35 | OFAGENT_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-ofagent:${DOCKER_TAG} |
| 36 | CLI_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-cli:${DOCKER_TAG} |
| 37 | PONSIMOLT_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-adapter-ponsim-olt:${DOCKER_TAG} |
| 38 | PONSIMONU_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-adapter-ponsim-onu:${DOCKER_TAG} |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 39 | |
| 40 | ## Docker labels. Only set ref and commit date if committed |
| 41 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 42 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 43 | DOCKER_LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD) |
| 44 | |
| 45 | ifeq ($(shell git ls-files --others --modified --exclude-standard 2>/dev/null | wc -l | sed -e 's/ //g'),0) |
| 46 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD) |
| 47 | else |
| 48 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD)+dirty |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 49 | endif |
| 50 | |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 51 | .PHONY: rw_core ro_core simulated_olt simulated_onu afrouter afrouterd local-protos local-pyvoltha |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 52 | |
| 53 | # This should to be the first and default target in this Makefile |
| 54 | help: |
| 55 | @echo "Usage: make [<target>]" |
| 56 | @echo "where available targets are:" |
| 57 | @echo |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 58 | @echo "build : Build the docker images." |
| 59 | @echo " - If this is the first time you are building, choose 'make build' option." |
| 60 | @echo "rw_core : Build the rw_core docker image" |
| 61 | @echo "ro_core : Build the ro_core docker image" |
| 62 | @echo "afrouter : Build the afrouter docker image" |
| 63 | @echo "afrouterTest : Build the afrouterTest docker image" |
| 64 | @echo "afrouterd : Build the afrouterd docker image" |
| 65 | @echo "simulated_olt : Build the simulated_olt docker image" |
| 66 | @echo "simulated_onu : Build the simulated_onu docker image" |
| 67 | @echo "ofagent : Build the openflow agent docker image" |
| 68 | @echo "cli : Build the voltha CLI docker image" |
| 69 | @echo "adapter_ponsim_olt : Build the ponsim olt adapter docker image" |
| 70 | @echo "adapter_ponsim_onu : Build the ponsim onu adapter docker image" |
| 71 | @echo "venv : Build local Python virtualenv" |
| 72 | @echo "clean : Remove files created by the build and tests" |
| 73 | @echo "distclean : Remove venv directory" |
| 74 | @echo "docker-push : Push the docker images to an external repository" |
| 75 | @echo "lint-style : Verify code is properly gofmt-ed" |
| 76 | @echo "lint-sanity : Verify that 'go vet' doesn't report any issues" |
| 77 | @echo "lint-dep : Verify the integrity of the 'dep' files" |
| 78 | @echo "lint : Shorthand for lint-style & lint-sanity" |
| 79 | @echo "test : Generate reports for all go tests" |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 80 | @echo |
| 81 | |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 82 | ## Local Development Helpers |
| 83 | local-protos: |
| 84 | mkdir -p python/local_imports |
| 85 | ifdef LOCAL_PROTOS |
| 86 | mkdir -p vendor/github.com/opencord/voltha-protos/go |
| 87 | cp -r ${GOPATH}/src/github.com/opencord/voltha-protos/go/* vendor/github.com/opencord/voltha-protos/go |
| 88 | mkdir -p python/local_imports/voltha-protos/dist |
| 89 | cp ../voltha-protos/dist/*.tar.gz python/local_imports/voltha-protos/dist/ |
| 90 | endif |
| 91 | |
| 92 | local-pyvoltha: |
| 93 | mkdir -p python/local_imports |
| 94 | ifdef LOCAL_PYVOLTHA |
| 95 | mkdir -p python/local_imports/pyvoltha/dist |
| 96 | cp ../pyvoltha/dist/*.tar.gz python/local_imports/pyvoltha/dist/ |
| 97 | endif |
| 98 | |
| 99 | ## Python venv dev environment |
| 100 | |
| 101 | VENVDIR := python/venv-volthago |
| 102 | |
| 103 | venv: distclean local-protos local-pyvoltha |
| 104 | virtualenv ${VENVDIR};\ |
| 105 | source ./${VENVDIR}/bin/activate ; set -u ;\ |
| 106 | rm -f ${VENVDIR}/local/bin ${VENVDIR}/local/lib ${VENVDIR}/local/include ;\ |
| 107 | pip install -r python/requirements.txt |
| 108 | ifdef LOCAL_PYVOLTHA |
| 109 | source ./${VENVDIR}/bin/activate ; set -u ;\ |
| 110 | pip install python/local_imports/pyvoltha/dist/*.tar.gz |
| 111 | endif |
| 112 | ifdef LOCAL_PROTOS |
| 113 | source ./${VENVDIR}/bin/activate ; set -u ;\ |
| 114 | pip install python/local_imports/voltha-protos/dist/*.tar.gz |
| 115 | endif |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 116 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 117 | ## Docker targets |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 118 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 119 | build: docker-build |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 120 | |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 121 | docker-build: rw_core ro_core simulated_olt simulated_onu afrouter afrouterd ofagent cli adapter_ponsim_olt adapter_ponsim_onu |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 122 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 123 | afrouter: local-protos |
| 124 | docker build $(DOCKER_BUILD_ARGS) \ |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 125 | -t ${AFROUTER_IMAGENAME} \ |
| 126 | --build-arg org_label_schema_version="${VERSION}" \ |
| 127 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 128 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 129 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 130 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 131 | -f docker/Dockerfile.afrouter . |
sslobodr | a3ea7d4 | 2019-01-16 15:03:16 -0500 | [diff] [blame] | 132 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 133 | afrouterTest: local-protos |
| 134 | docker build $(DOCKER_BUILD_ARGS) \ |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 135 | -t ${AFROUTERTEST_IMAGENAME} \ |
| 136 | --build-arg org_label_schema_version="${VERSION}" \ |
| 137 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 138 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 139 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 140 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 141 | -f docker/Dockerfile.afrouterTest . |
sslobodr | d6e07e7 | 2019-01-31 16:07:20 -0500 | [diff] [blame] | 142 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 143 | afrouterd: local-protos |
| 144 | docker build $(DOCKER_BUILD_ARGS) \ |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 145 | -t ${AFROUTERD_IMAGENAME} \ |
| 146 | --build-arg org_label_schema_version="${VERSION}" \ |
| 147 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 148 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 149 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 150 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 151 | -f docker/Dockerfile.afrouterd . |
sslobodr | a3ea7d4 | 2019-01-16 15:03:16 -0500 | [diff] [blame] | 152 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 153 | rw_core: local-protos |
| 154 | docker build $(DOCKER_BUILD_ARGS) \ |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 155 | -t ${RWCORE_IMAGENAME} \ |
| 156 | --build-arg org_label_schema_version="${VERSION}" \ |
| 157 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 158 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 159 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 160 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 161 | -f docker/Dockerfile.rw_core . |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 162 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 163 | ro_core: local-protos |
| 164 | docker build $(DOCKER_BUILD_ARGS) \ |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 165 | -t ${ROCORE_IMAGENAME} \ |
| 166 | --build-arg org_label_schema_version="${VERSION}" \ |
| 167 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 168 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 169 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 170 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 171 | -f docker/Dockerfile.ro_core . |
Stephane Barbarie | a75791c | 2019-01-24 10:58:06 -0500 | [diff] [blame] | 172 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 173 | simulated_olt: local-protos |
| 174 | docker build $(DOCKER_BUILD_ARGS) \ |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 175 | -t ${SIMULATEDOLT_IMAGENAME} \ |
| 176 | --build-arg org_label_schema_version="${VERSION}" \ |
| 177 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 178 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 179 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 180 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 181 | -f docker/Dockerfile.simulated_olt . |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 182 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 183 | simulated_onu: local-protos |
| 184 | docker build $(DOCKER_BUILD_ARGS) \ |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 185 | -t ${SIMULATEDONU_IMAGENAME} \ |
| 186 | --build-arg org_label_schema_version="${VERSION}" \ |
| 187 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 188 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 189 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 190 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 191 | -f docker/Dockerfile.simulated_onu . |
| 192 | |
| 193 | ofagent: local-protos local-pyvoltha |
| 194 | docker build $(DOCKER_BUILD_ARGS) \ |
| 195 | -t ${OFAGENT_IMAGENAME} \ |
| 196 | --build-arg LOCAL_PYVOLTHA=$(LOCAL_PYVOLTHA) \ |
| 197 | --build-arg LOCAL_PROTOS=$(LOCAL_PROTOS) \ |
| 198 | --build-arg org_label_schema_version="${VERSION}" \ |
| 199 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 200 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 201 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 202 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 203 | -f python/docker/Dockerfile.ofagent python |
| 204 | |
| 205 | cli: local-protos local-pyvoltha |
| 206 | docker build $(DOCKER_BUILD_ARGS) \ |
| 207 | -t ${CLI_IMAGENAME} \ |
| 208 | --build-arg LOCAL_PYVOLTHA=$(LOCAL_PYVOLTHA) \ |
| 209 | --build-arg LOCAL_PROTOS=$(LOCAL_PROTOS) \ |
| 210 | --build-arg org_label_schema_version="${VERSION}" \ |
| 211 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 212 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 213 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 214 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 215 | -f python/docker/Dockerfile.cli python |
| 216 | |
| 217 | adapter_ponsim_olt: local-protos local-pyvoltha |
| 218 | docker build $(DOCKER_BUILD_ARGS) \ |
| 219 | -t ${PONSIMOLT_IMAGENAME} \ |
| 220 | --build-arg LOCAL_PYVOLTHA=$(LOCAL_PYVOLTHA) \ |
| 221 | --build-arg LOCAL_PROTOS=$(LOCAL_PROTOS) \ |
| 222 | --build-arg org_label_schema_version="${VERSION}" \ |
| 223 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 224 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 225 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 226 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 227 | -f python/docker/Dockerfile.adapter_ponsim_olt python |
| 228 | |
| 229 | adapter_ponsim_onu: local-protos local-pyvoltha |
| 230 | docker build $(DOCKER_BUILD_ARGS) \ |
| 231 | -t ${PONSIMONU_IMAGENAME} \ |
| 232 | --build-arg LOCAL_PYVOLTHA=$(LOCAL_PYVOLTHA) \ |
| 233 | --build-arg LOCAL_PROTOS=$(LOCAL_PROTOS) \ |
| 234 | --build-arg org_label_schema_version="${VERSION}" \ |
| 235 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 236 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 237 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 238 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 239 | -f python/docker/Dockerfile.adapter_ponsim_onu python |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 240 | |
| 241 | docker-push: |
| 242 | docker push ${AFROUTER_IMAGENAME} |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 243 | docker push ${AFROUTERD_IMAGENAME} |
| 244 | docker push ${RWCORE_IMAGENAME} |
| 245 | docker push ${ROCORE_IMAGENAME} |
| 246 | docker push ${SIMULATEDOLT_IMAGENAME} |
| 247 | docker push ${SIMULATEDONU_IMAGENAME} |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 248 | docker push ${OFAGENT_IMAGENAME} |
| 249 | docker push ${CLI_IMAGENAME} |
| 250 | docker push ${PONSIMOLT_IMAGENAME} |
| 251 | docker push ${PONSIMONU_IMAGENAME} |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 252 | |
| 253 | ## lint and unit tests |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 254 | |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 255 | lint-style: |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 256 | ifeq (,$(shell which gofmt)) |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 257 | go get -u github.com/golang/go/src/cmd/gofmt |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 258 | endif |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 259 | @echo "Running style check..." |
| 260 | @gofmt_out="$$(gofmt -l $$(find . -name '*.go' -not -path './vendor/*'))" ;\ |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 261 | if [ ! -z "$$gofmt_out" ]; then \ |
| 262 | echo "$$gofmt_out" ;\ |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 263 | 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] | 264 | exit 1 ;\ |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 265 | fi |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 266 | @echo "Style check OK" |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 267 | |
| 268 | lint-sanity: |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 269 | @echo "Running sanity check..." |
| 270 | @go vet ./... |
| 271 | @echo "Sanity check OK" |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 272 | |
Kent Hagerman | 0ab4cb2 | 2019-04-24 13:13:35 -0400 | [diff] [blame] | 273 | lint-dep: |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 274 | @echo "Running dependency check..." |
| 275 | @dep check |
| 276 | @echo "Dependency check OK" |
Kent Hagerman | 0ab4cb2 | 2019-04-24 13:13:35 -0400 | [diff] [blame] | 277 | |
| 278 | lint: lint-style lint-sanity lint-dep |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 279 | |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 280 | GO_JUNIT_REPORT:=$(shell which go-junit-report) |
| 281 | GOCOVER_COBERTURA:=$(shell which gocover-cobertura) |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 282 | |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 283 | test: |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 284 | ifeq (,$(GO_JUNIT_REPORT)) |
| 285 | go get -u github.com/jstemmer/go-junit-report |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 286 | @GO_JUNIT_REPORT=$(GOPATH)/bin/go-junit-report |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 287 | endif |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 288 | ifeq (,$(GOCOVER_COBERTURA)) |
| 289 | go get -u github.com/t-yuki/gocover-cobertura |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 290 | @GOCOVER_COBERTURA=$(GOPATH)/bin/gocover-cobertura |
Zack Williams | 7cf7800 | 2019-04-30 21:45:35 -0700 | [diff] [blame] | 291 | endif |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 292 | @mkdir -p ./tests/results |
Kent Hagerman | ca4c51e | 2019-05-02 12:28:55 -0400 | [diff] [blame] | 293 | @go test -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] | 294 | RETURN=$$? ;\ |
| 295 | $(GO_JUNIT_REPORT) < ./tests/results/go-test-results.out > ./tests/results/go-test-results.xml ;\ |
| 296 | $(GOCOVER_COBERTURA) < ./tests/results/go-test-coverage.out > ./tests/results/go-test-coverage.xml ;\ |
| 297 | exit $$RETURN |
Kent Hagerman | 074d0e0 | 2019-04-24 17:58:16 -0400 | [diff] [blame] | 298 | |
David K. Bainbridge | 1678e19 | 2019-05-17 11:48:29 -0700 | [diff] [blame] | 299 | clean: |
| 300 | rm -rf python/local_imports |
| 301 | find python -name '*.pyc' | xargs rm -f |
| 302 | |
| 303 | distclean: clean |
| 304 | rm -rf ${VENVDIR} |
| 305 | |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 306 | # end file |