Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 3 | # Copyright 2017-2024 Open Networking Foundation Contributors |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [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 | # |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 9 | # http:#www.apache.org/licenses/LICENSE-2.0 |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 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 |
Joey Armstrong | dc04c93 | 2024-04-01 12:14:21 -0400 | [diff] [blame] | 15 | # limitations under the License. |
| 16 | # ----------------------------------------------------------------------- |
| 17 | # SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
| 20 | # Intent: |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 21 | # ----------------------------------------------------------------------- |
| 22 | |
| 23 | $(if $(DEBUG),$(warning ENTER)) |
| 24 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 25 | # Per-repository |
| 26 | include $(ONF_MAKEDIR)/docker/config/$(--repo-name--).mk |
| 27 | |
| 28 | # ------------------- ## |
| 29 | # ---] GLOBALS [--- ## |
| 30 | # ------------------- ## |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 31 | VOLTHA_TOOLS_VERSION ?= 2.4.0 |
| 32 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 33 | # --------------------------------- |
| 34 | # Induce error for misconfiguration |
| 35 | # --------------------------------- |
| 36 | go-cobertura-docker-mount ?= $(error go-cobertura-docker-mount= is required) |
| 37 | protoc-sh-docker-mount ?= $(error protoc-sh-docker-mount= is required) |
| 38 | |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 39 | # --------------------------- |
| 40 | # Macros: command refactoring |
| 41 | # --------------------------- |
| 42 | docker-iam ?= --user $$(id -u):$$(id -g)# # override for local use |
| 43 | docker-run = docker run --rm $(docker-iam)# # Docker command stem |
Joey Armstrong | 7ad5c36 | 2023-07-09 19:10:16 -0400 | [diff] [blame] | 44 | docker-run-is = $(docker-run) $(is-stdin)# # Attach streams when interactive |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 45 | docker-run-app = $(docker-run-is) -v ${CURDIR}:/app# # w/filesystem mount |
Joey Armstrong | 7ad5c36 | 2023-07-09 19:10:16 -0400 | [diff] [blame] | 46 | |
| 47 | # ----------------------------------------------------------------------- |
| 48 | # --interactive: Attach streams when stdout (fh==0) defined |
| 49 | # --tty : Always create a pseudo-tty else jenkins:docker is silent |
| 50 | # ----------------------------------------------------------------------- |
| 51 | is-stdin = $(shell test -t 0 && { echo '--interactive'; }) |
| 52 | is-stdin += --tty |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 53 | |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 54 | # Docker volume mounts: container:/app/release <=> localhost:{pwd}/release |
| 55 | vee-golang = -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg |
| 56 | vee-citools = voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION} |
| 57 | |
| 58 | # --------------- |
| 59 | # Tool Containers |
| 60 | # --------------- |
| 61 | docker-go-stem = $(docker-run-app) -v gocache:/.cache $(vee-golang) $(vee-citools)-golang |
| 62 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 63 | # ----------------------------------------------------------------------- |
| 64 | # Usage: GO := $(call get-cmd-docker-go) |
| 65 | # ----------------------------------------------------------------------- |
| 66 | get-cmd-docker-go = $(docker-go-stem) go |
| 67 | GO ?= $(call get-cmd-docker-go) |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 68 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 69 | # ----------------------------------------------------------------------- |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 70 | # Usage: GO_SH := $(call get-docker-go-sh,./my.env.temp) |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 71 | # - populate my.env.temp with shell content to pass in |
| 72 | # ----------------------------------------------------------------------- |
| 73 | get-cmd-docker-go-sh = $(docker-go-stem) $(if $(1),--env-file $(1)) sh -c |
| 74 | GO_SH ?= $(call get-cmd-docker-go-sh,./my.env.temp) |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 75 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 76 | # ----------------------------------------------------------------------- |
| 77 | # Usage: PROTOC := $(call get-cmd-docker-protoc) |
| 78 | # ----------------------------------------------------------------------- |
| 79 | get-cmd-docker-protoc = $(docker-run-app) $(vee-citools)-protoc protoc |
| 80 | PROTOC ?= $(call get-cmd-docker-protoc) |
| 81 | |
| 82 | # ----------------------------------------------------------------------- |
| 83 | # Usage: PROTOC_SH := $(call get-cmd-docker-protoc-sh) |
| 84 | # ----------------------------------------------------------------------- |
| 85 | get-cmd-docker-protoc-sh =\ |
| 86 | $(strip \ |
| 87 | $(docker-run-is) \ |
| 88 | $(if $(protc-sh-docker-mount), \ |
| 89 | -v ${CURDIR}:$(protoc-sh-docker-mount) \ |
| 90 | --workdir=$(protoc-sh-docker-mount) \ |
| 91 | ) \ |
| 92 | $(vee-citools)-protoc \ |
| 93 | sh -c \ |
| 94 | ) |
| 95 | PROTOC_SH ?= $(call get-cmd-docker-protoc-sh) |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 96 | |
| 97 | # get-docker-protoc-sh = $(strip ) |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 98 | #PROTOC_SH = $(docker-run-is) |
| 99 | #ifdef protc-sh-docker-mount |
| 100 | # PROTOC_SH += -v ${CURDIR}:$(protoc-sh-docker-mount) |
| 101 | # PROTOC_SH += --workdir=$(protoc-sh-docker-mount) |
| 102 | #endif # protoc-sh-docker-mount |
| 103 | #PROTOC_SH += $(vee-citools)-protoc sh -c |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 104 | |
Joey Armstrong | 7ad5c36 | 2023-07-09 19:10:16 -0400 | [diff] [blame] | 105 | # Usage: GO_JUNIT_REPORT := $(call get-docker-go-junit-repo) |
| 106 | # get-docker-go-junit-repo = $(docker-run-app) $(vee-citools)-go-junit-report go-junit-report |
| 107 | # GO_JUNIT_REPORT ?= $(call get-docker-go-junit-repo) |
| 108 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 109 | # ----------------------------------------------------------------------- |
Joey Armstrong | 7ad5c36 | 2023-07-09 19:10:16 -0400 | [diff] [blame] | 110 | # get-docker-gocover-cobertura = $(docker-run-app)/src/github.com/opencord/voltha-openolt-adapter $(vee-citools)-gocover-cobertura gocover-cobertura |
| 111 | # GOCOVER_COBERTURA ?= $(call get-docker-gocover-cobertura) |
| 112 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 113 | ## ----------------------------------------------------------------------- |
| 114 | ## Coverage report: junit |
| 115 | ## ----------------------------------------------------------------------- |
| 116 | ## Usage: GO_JUNIT_REPORT ?= $(call get-go-junit-report-cmd) |
| 117 | ## ----------------------------------------------------------------------- |
| 118 | get-go-junit-report-cmd =\ |
| 119 | $(strip \ |
| 120 | $(docker-run) \ |
| 121 | -v ${CURDIR}:/app \ |
| 122 | -i $(vee-citools)-go-junit-report go-junit-report \ |
| 123 | ) |
| 124 | GO_JUNIT_REPORT ?= $(call get-go-junit-report-cmd) |
Joey Armstrong | 7ad5c36 | 2023-07-09 19:10:16 -0400 | [diff] [blame] | 125 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 126 | ## ----------------------------------------------------------------------- |
| 127 | ## Coverage report: cobertura |
| 128 | ## ----------------------------------------------------------------------- |
| 129 | ## Usage: GOCOVER_COBERTURA ?= $(call get-docker-gocover-cobertura-cmd) |
| 130 | ## ----------------------------------------------------------------------- |
| 131 | get-docker-go-cobertura-cmd =\ |
| 132 | $(strip \ |
| 133 | $(docker-run)\ |
| 134 | -v ${CURDIR}:$(go-cobertura-docker-mount)\ |
| 135 | -i $(vee-citools)-gocover-cobertura gocover-cobertura\ |
| 136 | ) |
| 137 | GOCOVER_COBERTURA ?= $(call get-docker-go-cobertura-cmd) |
Joey Armstrong | 7ad5c36 | 2023-07-09 19:10:16 -0400 | [diff] [blame] | 138 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 139 | ## ----------------------------------------------------------------------- |
| 140 | ## |
| 141 | ## ----------------------------------------------------------------------- |
| 142 | get-cmd-docker-golangci-lint =\ |
| 143 | $(strip \ |
| 144 | $(docker-run-app) \ |
| 145 | -v gocache:/.cache \ |
| 146 | $(vee-golang)\ |
| 147 | $(vee-citools)-golangci-lint\ |
| 148 | golangci-lint\ |
| 149 | ) |
| 150 | GOLANGCI_LINT ?= $(call get-cmd-docker-golangci-lint) |
Joey Armstrong | 7ad5c36 | 2023-07-09 19:10:16 -0400 | [diff] [blame] | 151 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 152 | ## ----------------------------------------------------------------------- |
| 153 | ## |
| 154 | ## ----------------------------------------------------------------------- |
| 155 | get-docker-hadolint =\ |
| 156 | $(strip \ |
| 157 | $(docker-run-app) \ |
| 158 | $(vee-citools)-hadolint \ |
| 159 | hadolint \ |
| 160 | ) |
| 161 | HADOLINT ?= $(call get-docker-hadolint) |
Joey Armstrong | 7ad5c36 | 2023-07-09 19:10:16 -0400 | [diff] [blame] | 162 | |
Joey Armstrong | 8621842 | 2023-05-09 12:24:44 -0400 | [diff] [blame] | 163 | $(if $(DEBUG),$(warning LEAVE)) |
| 164 | |
| 165 | # [EOF] |