Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 3 | # Copyright 2016-2024 Open Networking Foundation Contributors |
Phaneendra Manda | 4c62c80 | 2019-03-06 21:37:49 +0530 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 16 | # ----------------------------------------------------------------------- |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 17 | # SPDX-FileCopyrightText: 2016-2024 Open Networking Foundation Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
Phaneendra Manda | 4c62c80 | 2019-03-06 21:37:49 +0530 | [diff] [blame] | 20 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 21 | $(if $(DEBUG),$(warning ENTER)) |
| 22 | |
| 23 | .DEFAULT_GOAL := help |
| 24 | |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 25 | ##-------------------## |
| 26 | ##---] GLOBALS [---## |
| 27 | ##-------------------## |
| 28 | |
| 29 | RSYNC ?= rsync |
| 30 | RSYNC-CMD := $(RSYNC) -rv --checksum --archive |
| 31 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 32 | TOP ?= . |
| 33 | MAKEDIR ?= $(TOP)/makefiles |
| 34 | |
| 35 | $(if $(VERBOSE),$(eval export VERBOSE=$(VERBOSE))) # visible to include(s) |
| 36 | |
| 37 | ##--------------------## |
| 38 | ##---] INCLUDES [---## |
| 39 | ##--------------------## |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 40 | include config.mk# # configure |
| 41 | include makefiles/include.mk # top level include |
| 42 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 43 | ifdef LOCAL_LINT |
| 44 | include $(MAKEDIR)/lint/golang/sca.mk |
| 45 | endif |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 46 | |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 47 | ##------------------## |
| 48 | ##---] MACROS [---## |
| 49 | ##------------------## |
| 50 | |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 51 | # Variables |
| 52 | VERSION ?= $(shell cat ./VERSION) |
| 53 | |
Matt Jeanneret | f880eb6 | 2019-07-16 20:08:03 -0400 | [diff] [blame] | 54 | DOCKER_LABEL_VCS_DIRTY = false |
| 55 | ifneq ($(shell git ls-files --others --modified --exclude-standard 2>/dev/null | wc -l | sed -e 's/ //g'),0) |
| 56 | DOCKER_LABEL_VCS_DIRTY = true |
| 57 | endif |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 58 | ## Docker related |
Matt Jeanneret | f880eb6 | 2019-07-16 20:08:03 -0400 | [diff] [blame] | 59 | DOCKER_EXTRA_ARGS ?= |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 60 | DOCKER_REGISTRY ?= |
| 61 | DOCKER_REPOSITORY ?= |
David K. Bainbridge | 96b0651 | 2021-04-01 18:53:51 +0000 | [diff] [blame] | 62 | DOCKER_TAG ?= ${VERSION}$(shell [[ ${DOCKER_LABEL_VCS_DIRTY} == "true" ]] && echo "-dirty" || true) |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 63 | ADAPTER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-openolt-adapter:${DOCKER_TAG} |
David K. Bainbridge | 96b0651 | 2021-04-01 18:53:51 +0000 | [diff] [blame] | 64 | DOCKER_TARGET ?= prod |
Andrea Campanella | cbf583e | 2019-12-17 15:26:00 -0800 | [diff] [blame] | 65 | TYPE ?= minimal |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 66 | |
| 67 | ## Docker labels. Only set ref and commit date if committed |
Matt Jeanneret | f880eb6 | 2019-07-16 20:08:03 -0400 | [diff] [blame] | 68 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 69 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD) |
| 70 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 71 | DOCKER_LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD) |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 72 | |
Matt Jeanneret | f880eb6 | 2019-07-16 20:08:03 -0400 | [diff] [blame] | 73 | DOCKER_BUILD_ARGS ?= \ |
| 74 | ${DOCKER_EXTRA_ARGS} \ |
| 75 | --build-arg org_label_schema_version="${VERSION}" \ |
| 76 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 77 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 78 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 79 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 80 | --build-arg org_opencord_vcs_dirty="${DOCKER_LABEL_VCS_DIRTY}" |
| 81 | |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 82 | # tool containers |
David K. Bainbridge | 2f2658d | 2021-04-09 16:13:57 +0000 | [diff] [blame] | 83 | VOLTHA_TOOLS_VERSION ?= 2.4.0 |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 84 | |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 85 | ## TODO: Verify / migrate to repo:onf-make |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 86 | # GO = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golang go |
| 87 | # GO_JUNIT_REPORT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-go-junit-report go-junit-report |
| 88 | # GOCOVER_COBERTURA = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app/src/github.com/opencord/voltha-openolt-adapter -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-gocover-cobertura gocover-cobertura |
| 89 | # GOLANGCI_LINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golangci-lint golangci-lint |
| 90 | # HADOLINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-hadolint hadolint |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 91 | |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 92 | .PHONY: docker-build help |
Phaneendra Manda | 4c62c80 | 2019-03-06 21:37:49 +0530 | [diff] [blame] | 93 | |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 94 | ## ----------------------------------------------------------------------- |
| 95 | ## Intent: Local Development Helpers. When LOCAL_PROTOS= is defined |
| 96 | ## copy in locally modified repo:voltha-protos for a building. |
| 97 | ## ----------------------------------------------------------------------- |
| 98 | ## Usage : make build LOCAL_LIB_GO=/path/to/my/voltha-protos |
| 99 | ## ----------------------------------------------------------------------- |
| 100 | .PHONY: local-protos |
| 101 | protos-v5 := vendor/github.com/opencord/voltha-protos/v5/go |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 102 | |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 103 | local-protos: |
| 104 | |
| 105 | ifdef LOCAL_PROTOS |
| 106 | $(call banner-enter,$@) |
| 107 | |
| 108 | $(RM) -r "$(protos-v5)" |
| 109 | mkdir -p "$(protos-v5)" |
| 110 | $(RSYNC-CMD) "${LOCAL_PROTOS}/go/." "$(protos-v5)/." |
| 111 | $(RM) -r "$(protos-v5)/vendor" |
| 112 | |
| 113 | $(call banner-leave,$@) |
| 114 | endif # LOCAL_PROTOS= |
| 115 | |
| 116 | ## ----------------------------------------------------------------------- |
| 117 | ## Intent: Local Development Helpers. When LOCAL_LIB_GO= is defined |
| 118 | ## copy in locally modified repo:voltha-protos for a building. |
| 119 | ## ----------------------------------------------------------------------- |
| 120 | ## Usage : make build LOCAL_LIB_GO=/path/to/my/voltha-lib-go |
| 121 | ## ----------------------------------------------------------------------- |
| 122 | .PHONY: local-lib-go |
| 123 | lib-go-v7 := vendor/github.com/opencord/voltha-lib-go/v7 |
| 124 | |
| 125 | local-lib-go: |
| 126 | |
| 127 | ifdef LOCAL_LIB_GO |
| 128 | $(call banner-enter,$@) |
| 129 | |
| 130 | mkdir -p "$(lib-go-v7)/pkg" |
| 131 | $(RSYNC-CMD) "${LOCAL_LIB_GO}/pkg/." "$(lib-go-v7)/pkg/." |
| 132 | |
| 133 | $(call banner-leave,$@) |
| 134 | endif # LOCAL_LIB_GO= |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 135 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 136 | ## ----------------------------------------------------------------------- |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 137 | ## Docker targets |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 138 | ## ----------------------------------------------------------------------- |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 139 | build: docker-build ## Alias for 'docker build' |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 140 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 141 | ## ----------------------------------------------------------------------- |
| 142 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | 6ec3c35 | 2020-04-29 15:27:03 -0700 | [diff] [blame] | 143 | docker-build: local-protos local-lib-go ## Build openolt adapter docker image (set BUILD_PROFILED=true to also build the profiled image) |
David K. Bainbridge | e2d9b33 | 2021-04-15 00:11:51 +0000 | [diff] [blame] | 144 | docker build $(DOCKER_BUILD_ARGS) --target=${DOCKER_TARGET} --build-arg CGO_PARAMETER=0 -t ${ADAPTER_IMAGENAME} -f docker/Dockerfile.openolt . |
Matteo Scandolo | 6ec3c35 | 2020-04-29 15:27:03 -0700 | [diff] [blame] | 145 | ifdef BUILD_PROFILED |
David K. Bainbridge | e2d9b33 | 2021-04-15 00:11:51 +0000 | [diff] [blame] | 146 | docker build $(DOCKER_BUILD_ARGS) --target=dev --build-arg CGO_PARAMETER=1 --build-arg EXTRA_GO_BUILD_TAGS="-tags profile" -t ${ADAPTER_IMAGENAME}-profile -f docker/Dockerfile.openolt . |
| 147 | endif |
| 148 | ifdef BUILD_RACE |
| 149 | docker build $(DOCKER_BUILD_ARGS) --target=dev --build-arg CGO_PARAMETER=1 --build-arg EXTRA_GO_BUILD_TAGS="-race" -t ${ADAPTER_IMAGENAME}-rd -f docker/Dockerfile.openolt . |
Matteo Scandolo | 6ec3c35 | 2020-04-29 15:27:03 -0700 | [diff] [blame] | 150 | endif |
Matteo Scandolo | 8f2b957 | 2020-02-28 15:35:23 -0800 | [diff] [blame] | 151 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 152 | ## ----------------------------------------------------------------------- |
| 153 | ## ----------------------------------------------------------------------- |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 154 | docker-push: ## Push the docker images to an external repository |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 155 | docker push ${ADAPTER_IMAGENAME} |
Matteo Scandolo | 24ed967 | 2020-05-04 10:53:08 -0700 | [diff] [blame] | 156 | ifdef BUILD_PROFILED |
| 157 | docker push ${ADAPTER_IMAGENAME}-profile |
| 158 | endif |
David K. Bainbridge | e2d9b33 | 2021-04-15 00:11:51 +0000 | [diff] [blame] | 159 | ifdef BUILD_RACE |
| 160 | docker push ${ADAPTER_IMAGENAME}-rd |
| 161 | endif |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 162 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 163 | ## ----------------------------------------------------------------------- |
| 164 | ## ----------------------------------------------------------------------- |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 165 | docker-kind-load: ## Load docker images into a KinD cluster |
Andrea Campanella | cbf583e | 2019-12-17 15:26:00 -0800 | [diff] [blame] | 166 | @if [ "`kind get clusters | grep voltha-$(TYPE)`" = '' ]; then echo "no voltha-$(TYPE) cluster found" && exit 1; fi |
| 167 | kind load docker-image ${ADAPTER_IMAGENAME} --name=voltha-$(TYPE) --nodes $(shell kubectl get nodes --template='{{range .items}}{{.metadata.name}},{{end}}' | sed 's/,$$//') |
| 168 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 169 | ## ----------------------------------------------------------------------- |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 170 | ## lint and unit tests |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 171 | ## ----------------------------------------------------------------------- |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 172 | lint-dockerfile: ## Perform static analysis on Dockerfile |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 173 | @echo "Running Dockerfile lint check ..." |
| 174 | @${HADOLINT} $$(find . -name "Dockerfile.*") |
| 175 | @echo "Dockerfile lint check OK" |
| 176 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 177 | ## ----------------------------------------------------------------------- |
| 178 | ## ----------------------------------------------------------------------- |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 179 | lint-mod: ## Verify the Go dependencies |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 180 | |
Matt Jeanneret | 384d8c9 | 2019-05-06 14:27:31 -0400 | [diff] [blame] | 181 | @echo "Running dependency check..." |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 182 | @${GO} mod verify |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 183 | |
Scott Baker | 22c0e9c | 2019-11-26 08:11:29 -0800 | [diff] [blame] | 184 | @echo "Dependency check OK. Running vendor check..." |
| 185 | @git status > /dev/null |
Kent Hagerman | e71b52d | 2020-02-26 11:13:42 -0500 | [diff] [blame] | 186 | @git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Staged or modified files must be committed before running this test" && git status -- go.mod go.sum vendor && exit 1) |
| 187 | @[[ `git ls-files --exclude-standard --others go.mod go.sum vendor` == "" ]] || (echo "ERROR: Untracked files must be cleaned up before running this test" && git status -- go.mod go.sum vendor && exit 1) |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 188 | |
| 189 | $(MAKE) mod-update |
| 190 | # ${GO} mod tidy |
| 191 | # ${GO} mod vendor |
| 192 | |
Scott Baker | 22c0e9c | 2019-11-26 08:11:29 -0800 | [diff] [blame] | 193 | @git status > /dev/null |
Kent Hagerman | e71b52d | 2020-02-26 11:13:42 -0500 | [diff] [blame] | 194 | @git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Modified files detected after running go mod tidy / go mod vendor" && git status -- go.mod go.sum vendor && git checkout -- go.mod go.sum vendor && exit 1) |
| 195 | @[[ `git ls-files --exclude-standard --others go.mod go.sum vendor` == "" ]] || (echo "ERROR: Untracked files detected after running go mod tidy / go mod vendor" && git status -- go.mod go.sum vendor && git checkout -- go.mod go.sum vendor && exit 1) |
Scott Baker | 22c0e9c | 2019-11-26 08:11:29 -0800 | [diff] [blame] | 196 | @echo "Vendor check OK." |
Matt Jeanneret | 384d8c9 | 2019-05-06 14:27:31 -0400 | [diff] [blame] | 197 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 198 | ## ----------------------------------------------------------------------- |
| 199 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 200 | lint: local-lib-go lint-mod lint-dockerfile |
David Bainbridge | 788e520 | 2019-10-21 18:49:40 +0000 | [diff] [blame] | 201 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 202 | ## ----------------------------------------------------------------------- |
| 203 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 204 | coverage-out := ./tests/results/go-test-coverage.out |
| 205 | coverage-res := ./tests/results/go-test-results.out |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 206 | test: ## Run unit tests |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 207 | |
| 208 | $(call banner-enter,$@) |
| 209 | |
| 210 | $(RM) -r tests/results |
Matt Jeanneret | 384d8c9 | 2019-05-06 14:27:31 -0400 | [diff] [blame] | 211 | @mkdir -p ./tests/results |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 212 | |
| 213 | @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results) |
| 214 | |
| 215 | $(HIDE) $(MAKE) --no-print-directory test-go-coverage |
| 216 | $(HIDE) $(MAKE) --no-print-directory test-junit |
| 217 | $(HIDE) $(MAKE) --no-print-directory test-cobertura |
| 218 | |
| 219 | # ${GOCOVER_COBERTURA} < $(coverage-out) \ |
| 220 | # > ./tests/results/go-test-coverage.xml |
| 221 | |
| 222 | @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results) # yes this may not run |
| 223 | |
| 224 | $(call banner-leave,$@) |
| 225 | |
| 226 | ## ----------------------------------------------------------------------- |
| 227 | ## ----------------------------------------------------------------------- |
| 228 | test-go-coverage: |
| 229 | $(call banner-enter,$@) |
| 230 | @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results) |
| 231 | ( ${GO} test -mod=vendor -v -coverprofile $(coverage-out) -covermode count ./... 2>&1 ) \ |
| 232 | | tee $(coverage-res) |
| 233 | @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results) |
| 234 | $(call banner-leave,$@) |
| 235 | |
| 236 | ## ----------------------------------------------------------------------- |
| 237 | ## ----------------------------------------------------------------------- |
| 238 | test-junit: |
| 239 | $(call banner-enter,$@) |
| 240 | @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results) |
| 241 | ${GO_JUNIT_REPORT} < $(coverage-res) \ |
| 242 | > ./tests/results/go-test-results.xml |
| 243 | @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results) |
| 244 | $(call banner-leave,$@) |
| 245 | |
| 246 | ## ----------------------------------------------------------------------- |
| 247 | ## ----------------------------------------------------------------------- |
| 248 | test-cobertura: |
| 249 | $(call banner-enter,$@) |
| 250 | @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results) |
| 251 | ${GOCOVER_COBERTURA} < $(coverage-out) \ |
| 252 | > ./tests/results/go-test-coverage.xml |
| 253 | @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results) |
| 254 | $(call banner-leave,$@) |
| 255 | |
| 256 | ## ----------------------------------------------------------------------- |
| 257 | ## ----------------------------------------------------------------------- |
| 258 | help :: |
| 259 | @echo '[TEST: Coverage report]' |
| 260 | @echo ' test-go-coverage Generate a coverage report for vendor/' |
| 261 | @echo ' test-junit Digest go coverage, generate junit' |
| 262 | @echo ' test-cobertura Digest coverage and junit reports' |
Matt Jeanneret | 384d8c9 | 2019-05-06 14:27:31 -0400 | [diff] [blame] | 263 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 264 | ## ----------------------------------------------------------------------- |
| 265 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 266 | sca: |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 267 | $(call banner-enter,$@) |
| 268 | |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 269 | @$(RM) -r ./sca-report |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 270 | @mkdir -p ./sca-report |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 271 | @echo "Running static code analysis..." |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 272 | @${GOLANGCI_LINT} run --deadline=6m --out-format junit-xml ./... \ |
| 273 | | tee ./sca-report/sca-report.xml |
Kent Hagerman | e71b52d | 2020-02-26 11:13:42 -0500 | [diff] [blame] | 274 | @echo "" |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 275 | @echo "Static code analysis OK" |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 276 | |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 277 | $(call banner-leave,$@) |
| 278 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 279 | ## ----------------------------------------------------------------------- |
| 280 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 281 | clean :: distclean |
| 282 | sterile :: clean distclean |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 283 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 284 | ## ----------------------------------------------------------------------- |
| 285 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 286 | distclean: |
| 287 | $(RM) -r ./sca-report |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 288 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 289 | ## ----------------------------------------------------------------------- |
| 290 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 291 | .PHONY: mod-update |
| 292 | mod-update: mod-tidy mod-vendor |
| 293 | |
| 294 | ## ----------------------------------------------------------------------- |
| 295 | ## ----------------------------------------------------------------------- |
| 296 | .PHONY: mod-tidy |
| 297 | mod-tidy: |
| 298 | $(call banner-enter,$@) |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 299 | ${GO} mod tidy |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 300 | $(call banner-leave,$@) |
| 301 | |
| 302 | ## ----------------------------------------------------------------------- |
| 303 | ## ----------------------------------------------------------------------- |
| 304 | .PHONY: mod-vendor |
| 305 | mod-vendor: |
| 306 | $(call banner-enter,$@) |
| 307 | @$(if $(LOCAL_FIX_PERMS),chmod 777 .) |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 308 | ${GO} mod vendor |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 309 | @$(if $(LOCAL_FIX_PERMS),chmod 755 .) |
| 310 | $(call banner-leave,$@) |
| 311 | |
| 312 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 313 | ## Intent: Render README.md for interactive viewing. |
| 314 | ## ----------------------------------------------------------------------- |
| 315 | view : |
| 316 | pandoc README.md | lynx -stdin |
| 317 | |
| 318 | ## ----------------------------------------------------------------------- |
| 319 | ## Intent: Display supported makefile targets |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 320 | ## ----------------------------------------------------------------------- |
| 321 | help :: |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 322 | @printf ' %-33.33s %s\n' 'local-help' \ |
| 323 | 'Show extended help for local build targets' |
Joey Armstrong | a3b7c59 | 2023-12-11 17:56:05 -0500 | [diff] [blame] | 324 | @printf ' %-33.33s %s\n' 'sca' 'golang: static code analysis' |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 325 | @printf ' %-33.33s %s\n' 'view' \ |
| 326 | 'Render markdown (.md) for interactive viewing' |
| 327 | |
| 328 | help :: |
| 329 | @echo |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 330 | @echo '[MOD UPDATE]' |
| 331 | @echo ' mod-update' |
| 332 | @echo ' LOCAL_FIX_PERMS=1 Hack to fix docker access problems' |
| 333 | @echo ' mod-tidy' |
| 334 | @echo ' mod-vendor' |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 335 | |
Joey Armstrong | 098137b | 2024-03-02 09:04:39 -0500 | [diff] [blame] | 336 | local-help : |
| 337 | @echo |
| 338 | @echo '[LOCAL: dev]' |
| 339 | |
| 340 | @printf ' %-33.33s %s\n' 'local-protos' \ |
| 341 | 'Copy a local dev version of voltha-protos into vendor/' |
| 342 | @printf ' %s\n' '% $(MAKE) local-protos LOCAL_PROTOS={path}' |
| 343 | |
| 344 | @echo |
| 345 | @printf ' %-33.33s %s\n' 'local-lib-go' \ |
| 346 | 'Copy a local dev version of voltha-lib-go into vendor/' |
| 347 | @printf ' %s\n' '% $(MAKE) local-lib-go LOCAL_LIB_GO={path}' |
| 348 | |
| 349 | # Thought: Use "$(MAKE) LOCAL=1" to wrap |
| 350 | # "make local-protos local-lib-go build" |
| 351 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 352 | # [EOF] |