blob: 3f9866d5b8580bd61211077c0c7fd01733dd2218 [file] [log] [blame]
Girish Gowdraab4cd692020-02-13 17:36:54 +05301#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
18SHELL = bash -e -o pipefail
19
20## Variables
21VERSION ?= $(shell cat ./VERSION)
22GTEST_VER ?= release-1.8.0
23CMOCK_VER ?= 0207b30
24GMOCK_GLOBAL_VER ?= 1.0.2
25GRPC_VER ?= v1.27.1
26
27# Docker related
28DOCKER_LABEL_VCS_DIRTY = false
29ifneq ($(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
32endif
33
34DOCKER ?= docker
35DOCKER_REGISTRY ?=
36DOCKER_REPOSITORY ?=
37DOCKER_EXTRA_ARGS ?=
38DOCKER_TAG ?= ${VERSION}
39
40OPENOLT_TEST_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}openolt-test:${DOCKER_TAG}
41
42VOLTHA_CI_TOOLS_IMAGENAME := voltha/voltha-ci-tools:1.0.3-hadolint
43
44DOCKER_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.
55build: docker-build
56
57docker-build: openolt-test
58
59openolt-test:
60 ${DOCKER} build ${DOCKER_BUILD_ARGS} \
61 -t ${OPENOLT_TEST_IMAGENAME} \
62 -f docker/Dockerfile.openolt-test .
63
64docker-push:
65ifneq (false,$(DOCKER_LABEL_VCS_DIRTY))
66 @echo "Local repo is dirty. Refusing to push."
67 @exit 1
68endif
69 ${DOCKER} push ${OPENOLT_TEST_IMAGENAME}
70
71## runnable tool containers
72HADOLINT = ${DOCKER} run --rm --user $$(id -u):$$(id -g) -v $$PWD:/app ${VOLTHA_CI_TOOLS_IMAGENAME} hadolint --ignore DL3003 --ignore DL3015
73
74lint: docker-lint
75
76docker-lint:
77 @echo "Linting Dockerfiles..."
78 @${HADOLINT} $(shell ls docker/Dockerfile.*)
79 @echo "Dockerfiles linted OK"