blob: 7404b8e018febebe6cd5f35664ce68e73bbf0a3e [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
Girish Gowdrafddb1752020-09-04 17:59:22 -070025GRPC_VER ?= v1.31.1
Girish Gowdra0b14f6e2020-11-03 23:13:46 -080026PCAPPLUSPLUS_VER ?= v20.08
Girish Gowdraab4cd692020-02-13 17:36:54 +053027
28# Docker related
29DOCKER_LABEL_VCS_DIRTY = false
30ifneq ($(shell git status --porcelain | grep 'docker/Dockerfile.openolt-test' | wc -l | sed -e 's/ //g'),0)
31 DOCKER_LABEL_VCS_DIRTY = true
32 VERSION = latest
33endif
34
35DOCKER ?= docker
36DOCKER_REGISTRY ?=
37DOCKER_REPOSITORY ?=
38DOCKER_EXTRA_ARGS ?=
39DOCKER_TAG ?= ${VERSION}
40
41OPENOLT_TEST_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}openolt-test:${DOCKER_TAG}
42
43VOLTHA_CI_TOOLS_IMAGENAME := voltha/voltha-ci-tools:1.0.3-hadolint
44
45DOCKER_BUILD_ARGS ?= \
46 ${DOCKER_EXTRA_ARGS} \
47 --build-arg GTEST_VER=${GTEST_VER} \
48 --build-arg CMOCK_VER=${CMOCK_VER} \
49 --build-arg GMOCK_GLOBAL_VER=${GMOCK_GLOBAL_VER} \
Girish Gowdra0b14f6e2020-11-03 23:13:46 -080050 --build-arg GRPC_VER=${GRPC_VER} \
51 --build-arg PCAPPLUSPLUS_VER=${PCAPPLUSPLUS_VER}
Girish Gowdraab4cd692020-02-13 17:36:54 +053052
53.DEFAULT_GOAL := build
54
55# Builds the docker container with pre-requisite system and test libraries for
56# running openolt agent unit test cases.
57build: docker-build
58
59docker-build: openolt-test
60
61openolt-test:
62 ${DOCKER} build ${DOCKER_BUILD_ARGS} \
63 -t ${OPENOLT_TEST_IMAGENAME} \
64 -f docker/Dockerfile.openolt-test .
65
66docker-push:
67ifneq (false,$(DOCKER_LABEL_VCS_DIRTY))
68 @echo "Local repo is dirty. Refusing to push."
69 @exit 1
70endif
71 ${DOCKER} push ${OPENOLT_TEST_IMAGENAME}
72
73## runnable tool containers
74HADOLINT = ${DOCKER} run --rm --user $$(id -u):$$(id -g) -v $$PWD:/app ${VOLTHA_CI_TOOLS_IMAGENAME} hadolint --ignore DL3003 --ignore DL3015
75
76lint: docker-lint
77
78docker-lint:
79 @echo "Linting Dockerfiles..."
80 @${HADOLINT} $(shell ls docker/Dockerfile.*)
81 @echo "Dockerfiles linted OK"