Girish Gowdra | ab4cd69 | 2020-02-13 17:36:54 +0530 | [diff] [blame] | 1 | #Copyright 2018-present Open Networking Foundation |
| 2 | # |
| 3 | #Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | #you may not use this file except in compliance with the License. |
| 5 | #You may obtain a copy of the License at |
| 6 | # |
| 7 | #http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | #Unless required by applicable law or agreed to in writing, software |
| 10 | #distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | #See the License for the specific language governing permissions and |
| 13 | #limitations under the License. |
| 14 | |
| 15 | ######################################################################## |
| 16 | |
| 17 | # set default shell options |
| 18 | SHELL = bash -e -o pipefail |
| 19 | |
| 20 | ## Variables |
| 21 | VERSION ?= $(shell cat ./VERSION) |
| 22 | GTEST_VER ?= release-1.8.0 |
| 23 | CMOCK_VER ?= 0207b30 |
| 24 | GMOCK_GLOBAL_VER ?= 1.0.2 |
| 25 | GRPC_VER ?= v1.27.1 |
| 26 | |
| 27 | # Docker related |
| 28 | DOCKER_LABEL_VCS_DIRTY = false |
| 29 | ifneq ($(shell git status --porcelain | grep 'docker/Dockerfile.openolt-test' | wc -l | sed -e 's/ //g'),0) |
| 30 | DOCKER_LABEL_VCS_DIRTY = true |
| 31 | VERSION = latest |
| 32 | endif |
| 33 | |
| 34 | DOCKER ?= docker |
| 35 | DOCKER_REGISTRY ?= |
| 36 | DOCKER_REPOSITORY ?= |
| 37 | DOCKER_EXTRA_ARGS ?= |
| 38 | DOCKER_TAG ?= ${VERSION} |
| 39 | |
| 40 | OPENOLT_TEST_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}openolt-test:${DOCKER_TAG} |
| 41 | |
| 42 | VOLTHA_CI_TOOLS_IMAGENAME := voltha/voltha-ci-tools:1.0.3-hadolint |
| 43 | |
| 44 | DOCKER_BUILD_ARGS ?= \ |
| 45 | ${DOCKER_EXTRA_ARGS} \ |
| 46 | --build-arg GTEST_VER=${GTEST_VER} \ |
| 47 | --build-arg CMOCK_VER=${CMOCK_VER} \ |
| 48 | --build-arg GMOCK_GLOBAL_VER=${GMOCK_GLOBAL_VER} \ |
| 49 | --build-arg GRPC_VER=${GRPC_VER} |
| 50 | |
| 51 | .DEFAULT_GOAL := build |
| 52 | |
| 53 | # Builds the docker container with pre-requisite system and test libraries for |
| 54 | # running openolt agent unit test cases. |
| 55 | build: docker-build |
| 56 | |
| 57 | docker-build: openolt-test |
| 58 | |
| 59 | openolt-test: |
| 60 | ${DOCKER} build ${DOCKER_BUILD_ARGS} \ |
| 61 | -t ${OPENOLT_TEST_IMAGENAME} \ |
| 62 | -f docker/Dockerfile.openolt-test . |
| 63 | |
| 64 | docker-push: |
| 65 | ifneq (false,$(DOCKER_LABEL_VCS_DIRTY)) |
| 66 | @echo "Local repo is dirty. Refusing to push." |
| 67 | @exit 1 |
| 68 | endif |
| 69 | ${DOCKER} push ${OPENOLT_TEST_IMAGENAME} |
| 70 | |
| 71 | ## runnable tool containers |
| 72 | HADOLINT = ${DOCKER} run --rm --user $$(id -u):$$(id -g) -v $$PWD:/app ${VOLTHA_CI_TOOLS_IMAGENAME} hadolint --ignore DL3003 --ignore DL3015 |
| 73 | |
| 74 | lint: docker-lint |
| 75 | |
| 76 | docker-lint: |
| 77 | @echo "Linting Dockerfiles..." |
| 78 | @${HADOLINT} $(shell ls docker/Dockerfile.*) |
| 79 | @echo "Dockerfiles linted OK" |