Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
| 3 | # Copyright 2016-2023 Open Networking Foundation (ONF) and the ONF 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 | # ----------------------------------------------------------------------- |
Phaneendra Manda | 4c62c80 | 2019-03-06 21:37:49 +0530 | [diff] [blame] | 17 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 18 | $(if $(DEBUG),$(warning ENTER)) |
| 19 | |
| 20 | .DEFAULT_GOAL := help |
| 21 | |
| 22 | TOP ?= . |
| 23 | MAKEDIR ?= $(TOP)/makefiles |
| 24 | |
| 25 | $(if $(VERBOSE),$(eval export VERBOSE=$(VERBOSE))) # visible to include(s) |
| 26 | |
| 27 | ##--------------------## |
| 28 | ##---] INCLUDES [---## |
| 29 | ##--------------------## |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 30 | include config.mk# # configure |
| 31 | include makefiles/include.mk # top level include |
| 32 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 33 | ifdef LOCAL_LINT |
| 34 | include $(MAKEDIR)/lint/golang/sca.mk |
| 35 | endif |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 36 | |
| 37 | # Variables |
| 38 | VERSION ?= $(shell cat ./VERSION) |
| 39 | |
Matt Jeanneret | f880eb6 | 2019-07-16 20:08:03 -0400 | [diff] [blame] | 40 | DOCKER_LABEL_VCS_DIRTY = false |
| 41 | ifneq ($(shell git ls-files --others --modified --exclude-standard 2>/dev/null | wc -l | sed -e 's/ //g'),0) |
| 42 | DOCKER_LABEL_VCS_DIRTY = true |
| 43 | endif |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 44 | ## Docker related |
Matt Jeanneret | f880eb6 | 2019-07-16 20:08:03 -0400 | [diff] [blame] | 45 | DOCKER_EXTRA_ARGS ?= |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 46 | DOCKER_REGISTRY ?= |
| 47 | DOCKER_REPOSITORY ?= |
David K. Bainbridge | 96b0651 | 2021-04-01 18:53:51 +0000 | [diff] [blame] | 48 | DOCKER_TAG ?= ${VERSION}$(shell [[ ${DOCKER_LABEL_VCS_DIRTY} == "true" ]] && echo "-dirty" || true) |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 49 | ADAPTER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-openolt-adapter:${DOCKER_TAG} |
David K. Bainbridge | 96b0651 | 2021-04-01 18:53:51 +0000 | [diff] [blame] | 50 | DOCKER_TARGET ?= prod |
Andrea Campanella | cbf583e | 2019-12-17 15:26:00 -0800 | [diff] [blame] | 51 | TYPE ?= minimal |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 52 | |
| 53 | ## Docker labels. Only set ref and commit date if committed |
Matt Jeanneret | f880eb6 | 2019-07-16 20:08:03 -0400 | [diff] [blame] | 54 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 55 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD) |
| 56 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 57 | 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] | 58 | |
Matt Jeanneret | f880eb6 | 2019-07-16 20:08:03 -0400 | [diff] [blame] | 59 | DOCKER_BUILD_ARGS ?= \ |
| 60 | ${DOCKER_EXTRA_ARGS} \ |
| 61 | --build-arg org_label_schema_version="${VERSION}" \ |
| 62 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 63 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 64 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 65 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 66 | --build-arg org_opencord_vcs_dirty="${DOCKER_LABEL_VCS_DIRTY}" |
| 67 | |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 68 | # tool containers |
David K. Bainbridge | 2f2658d | 2021-04-09 16:13:57 +0000 | [diff] [blame] | 69 | VOLTHA_TOOLS_VERSION ?= 2.4.0 |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 70 | |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 71 | # 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 |
| 72 | # 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 |
| 73 | # 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 |
| 74 | # 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 |
| 75 | # 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] | 76 | |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 77 | .PHONY: docker-build local-protos local-lib-go help |
Phaneendra Manda | 4c62c80 | 2019-03-06 21:37:49 +0530 | [diff] [blame] | 78 | |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 79 | ## Local Development Helpers |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 80 | local-protos: ## Copies a local version of the voltha-protos dependency into the vendor directory |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 81 | ifdef LOCAL_PROTOS |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 82 | $(RM) -r vendor/github.com/opencord/voltha-protos/v5/go |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 83 | mkdir -p vendor/github.com/opencord/voltha-protos/v5/go |
| 84 | cp -r ${LOCAL_PROTOS}/go/* vendor/github.com/opencord/voltha-protos/v5/go |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 85 | $(RM) -r vendor/github.com/opencord/voltha-protos/v5/go/vendor |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 86 | endif |
| 87 | |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 88 | local-lib-go: ## Copies a local version of the voltha-lib-go dependency into the vendor directory |
Scott Baker | 355d174 | 2019-10-24 10:57:52 -0700 | [diff] [blame] | 89 | ifdef LOCAL_LIB_GO |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 90 | mkdir -p vendor/github.com/opencord/voltha-lib-go/v7/pkg |
| 91 | cp -r ${LOCAL_LIB_GO}/pkg/* vendor/github.com/opencord/voltha-lib-go/v7/pkg/ |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 92 | endif |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 93 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 94 | ## ----------------------------------------------------------------------- |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 95 | ## Docker targets |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 96 | ## ----------------------------------------------------------------------- |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 97 | build: docker-build ## Alias for 'docker build' |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 98 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 99 | ## ----------------------------------------------------------------------- |
| 100 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | 6ec3c35 | 2020-04-29 15:27:03 -0700 | [diff] [blame] | 101 | 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] | 102 | 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] | 103 | ifdef BUILD_PROFILED |
David K. Bainbridge | e2d9b33 | 2021-04-15 00:11:51 +0000 | [diff] [blame] | 104 | 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 . |
| 105 | endif |
| 106 | ifdef BUILD_RACE |
| 107 | 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] | 108 | endif |
Matteo Scandolo | 8f2b957 | 2020-02-28 15:35:23 -0800 | [diff] [blame] | 109 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 110 | ## ----------------------------------------------------------------------- |
| 111 | ## ----------------------------------------------------------------------- |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 112 | docker-push: ## Push the docker images to an external repository |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 113 | docker push ${ADAPTER_IMAGENAME} |
Matteo Scandolo | 24ed967 | 2020-05-04 10:53:08 -0700 | [diff] [blame] | 114 | ifdef BUILD_PROFILED |
| 115 | docker push ${ADAPTER_IMAGENAME}-profile |
| 116 | endif |
David K. Bainbridge | e2d9b33 | 2021-04-15 00:11:51 +0000 | [diff] [blame] | 117 | ifdef BUILD_RACE |
| 118 | docker push ${ADAPTER_IMAGENAME}-rd |
| 119 | endif |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 120 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 121 | ## ----------------------------------------------------------------------- |
| 122 | ## ----------------------------------------------------------------------- |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 123 | docker-kind-load: ## Load docker images into a KinD cluster |
Andrea Campanella | cbf583e | 2019-12-17 15:26:00 -0800 | [diff] [blame] | 124 | @if [ "`kind get clusters | grep voltha-$(TYPE)`" = '' ]; then echo "no voltha-$(TYPE) cluster found" && exit 1; fi |
| 125 | kind load docker-image ${ADAPTER_IMAGENAME} --name=voltha-$(TYPE) --nodes $(shell kubectl get nodes --template='{{range .items}}{{.metadata.name}},{{end}}' | sed 's/,$$//') |
| 126 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 127 | ## ----------------------------------------------------------------------- |
Matt Jeanneret | 8b823f6 | 2019-05-11 11:01:28 -0400 | [diff] [blame] | 128 | ## lint and unit tests |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 129 | ## ----------------------------------------------------------------------- |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 130 | lint-dockerfile: ## Perform static analysis on Dockerfile |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 131 | @echo "Running Dockerfile lint check ..." |
| 132 | @${HADOLINT} $$(find . -name "Dockerfile.*") |
| 133 | @echo "Dockerfile lint check OK" |
| 134 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 135 | ## ----------------------------------------------------------------------- |
| 136 | ## ----------------------------------------------------------------------- |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 137 | lint-mod: ## Verify the Go dependencies |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 138 | |
Matt Jeanneret | 384d8c9 | 2019-05-06 14:27:31 -0400 | [diff] [blame] | 139 | @echo "Running dependency check..." |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 140 | @${GO} mod verify |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 141 | |
Scott Baker | 22c0e9c | 2019-11-26 08:11:29 -0800 | [diff] [blame] | 142 | @echo "Dependency check OK. Running vendor check..." |
| 143 | @git status > /dev/null |
Kent Hagerman | e71b52d | 2020-02-26 11:13:42 -0500 | [diff] [blame] | 144 | @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) |
| 145 | @[[ `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] | 146 | |
| 147 | $(MAKE) mod-update |
| 148 | # ${GO} mod tidy |
| 149 | # ${GO} mod vendor |
| 150 | |
Scott Baker | 22c0e9c | 2019-11-26 08:11:29 -0800 | [diff] [blame] | 151 | @git status > /dev/null |
Kent Hagerman | e71b52d | 2020-02-26 11:13:42 -0500 | [diff] [blame] | 152 | @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) |
| 153 | @[[ `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] | 154 | @echo "Vendor check OK." |
Matt Jeanneret | 384d8c9 | 2019-05-06 14:27:31 -0400 | [diff] [blame] | 155 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 156 | ## ----------------------------------------------------------------------- |
| 157 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 158 | lint: local-lib-go lint-mod lint-dockerfile |
David Bainbridge | 788e520 | 2019-10-21 18:49:40 +0000 | [diff] [blame] | 159 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 160 | ## ----------------------------------------------------------------------- |
| 161 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 162 | coverage-out := ./tests/results/go-test-coverage.out |
| 163 | coverage-res := ./tests/results/go-test-results.out |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 164 | test: ## Run unit tests |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 165 | |
| 166 | $(call banner-enter,$@) |
| 167 | |
| 168 | $(RM) -r tests/results |
Matt Jeanneret | 384d8c9 | 2019-05-06 14:27:31 -0400 | [diff] [blame] | 169 | @mkdir -p ./tests/results |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 170 | |
| 171 | @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results) |
| 172 | |
| 173 | $(HIDE) $(MAKE) --no-print-directory test-go-coverage |
| 174 | $(HIDE) $(MAKE) --no-print-directory test-junit |
| 175 | $(HIDE) $(MAKE) --no-print-directory test-cobertura |
| 176 | |
| 177 | # ${GOCOVER_COBERTURA} < $(coverage-out) \ |
| 178 | # > ./tests/results/go-test-coverage.xml |
| 179 | |
| 180 | @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results) # yes this may not run |
| 181 | |
| 182 | $(call banner-leave,$@) |
| 183 | |
| 184 | ## ----------------------------------------------------------------------- |
| 185 | ## ----------------------------------------------------------------------- |
| 186 | test-go-coverage: |
| 187 | $(call banner-enter,$@) |
| 188 | @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results) |
| 189 | ( ${GO} test -mod=vendor -v -coverprofile $(coverage-out) -covermode count ./... 2>&1 ) \ |
| 190 | | tee $(coverage-res) |
| 191 | @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results) |
| 192 | $(call banner-leave,$@) |
| 193 | |
| 194 | ## ----------------------------------------------------------------------- |
| 195 | ## ----------------------------------------------------------------------- |
| 196 | test-junit: |
| 197 | $(call banner-enter,$@) |
| 198 | @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results) |
| 199 | ${GO_JUNIT_REPORT} < $(coverage-res) \ |
| 200 | > ./tests/results/go-test-results.xml |
| 201 | @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results) |
| 202 | $(call banner-leave,$@) |
| 203 | |
| 204 | ## ----------------------------------------------------------------------- |
| 205 | ## ----------------------------------------------------------------------- |
| 206 | test-cobertura: |
| 207 | $(call banner-enter,$@) |
| 208 | @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results) |
| 209 | ${GOCOVER_COBERTURA} < $(coverage-out) \ |
| 210 | > ./tests/results/go-test-coverage.xml |
| 211 | @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results) |
| 212 | $(call banner-leave,$@) |
| 213 | |
| 214 | ## ----------------------------------------------------------------------- |
| 215 | ## ----------------------------------------------------------------------- |
| 216 | help :: |
| 217 | @echo '[TEST: Coverage report]' |
| 218 | @echo ' test-go-coverage Generate a coverage report for vendor/' |
| 219 | @echo ' test-junit Digest go coverage, generate junit' |
| 220 | @echo ' test-cobertura Digest coverage and junit reports' |
Matt Jeanneret | 384d8c9 | 2019-05-06 14:27:31 -0400 | [diff] [blame] | 221 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 222 | ## ----------------------------------------------------------------------- |
| 223 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 224 | sca: |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 225 | $(call banner-enter,$@) |
| 226 | |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 227 | @$(RM) -r ./sca-report |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 228 | @mkdir -p ./sca-report |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 229 | @echo "Running static code analysis..." |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 230 | @${GOLANGCI_LINT} run --deadline=6m --out-format junit-xml ./... \ |
| 231 | | tee ./sca-report/sca-report.xml |
Kent Hagerman | e71b52d | 2020-02-26 11:13:42 -0500 | [diff] [blame] | 232 | @echo "" |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 233 | @echo "Static code analysis OK" |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 234 | |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 235 | $(call banner-leave,$@) |
| 236 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 237 | ## ----------------------------------------------------------------------- |
| 238 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 239 | clean :: distclean |
| 240 | sterile :: clean distclean |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 241 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 242 | ## ----------------------------------------------------------------------- |
| 243 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a6af152 | 2023-01-17 16:06:16 -0500 | [diff] [blame] | 244 | distclean: |
| 245 | $(RM) -r ./sca-report |
Matt Jeanneret | b5bf10e | 2019-05-18 15:02:51 -0400 | [diff] [blame] | 246 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 247 | ## ----------------------------------------------------------------------- |
| 248 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 249 | .PHONY: mod-update |
| 250 | mod-update: mod-tidy mod-vendor |
| 251 | |
| 252 | ## ----------------------------------------------------------------------- |
| 253 | ## ----------------------------------------------------------------------- |
| 254 | .PHONY: mod-tidy |
| 255 | mod-tidy: |
| 256 | $(call banner-enter,$@) |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 257 | ${GO} mod tidy |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 258 | $(call banner-leave,$@) |
| 259 | |
| 260 | ## ----------------------------------------------------------------------- |
| 261 | ## ----------------------------------------------------------------------- |
| 262 | .PHONY: mod-vendor |
| 263 | mod-vendor: |
| 264 | $(call banner-enter,$@) |
| 265 | @$(if $(LOCAL_FIX_PERMS),chmod 777 .) |
Kent Hagerman | 2cd4b7b | 2020-02-04 15:15:14 -0500 | [diff] [blame] | 266 | ${GO} mod vendor |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 267 | @$(if $(LOCAL_FIX_PERMS),chmod 755 .) |
| 268 | $(call banner-leave,$@) |
| 269 | |
| 270 | ## ----------------------------------------------------------------------- |
| 271 | ## ----------------------------------------------------------------------- |
| 272 | help :: |
| 273 | @echo '[MOD UPDATE]' |
| 274 | @echo ' mod-update' |
| 275 | @echo ' LOCAL_FIX_PERMS=1 Hack to fix docker access problems' |
| 276 | @echo ' mod-tidy' |
| 277 | @echo ' mod-vendor' |
Zack Williams | 7566225 | 2020-04-06 18:16:54 -0700 | [diff] [blame] | 278 | |
Joey Armstrong | f9bffdf | 2022-12-27 07:05:28 -0500 | [diff] [blame] | 279 | # [EOF] |