Zack Williams | 7eb36d0 | 2019-03-19 07:16:12 -0700 | [diff] [blame] | 1 | # Copyright 2019-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 | # Configure shell |
| 16 | SHELL = bash -e -o pipefail |
| 17 | |
| 18 | # Variables |
| 19 | VERSION ?= $(shell cat ./VERSION) |
| 20 | CONTAINER_NAME ?= $(notdir $(abspath .)) |
| 21 | |
| 22 | ## Docker related |
| 23 | DOCKER_REGISTRY ?= |
| 24 | DOCKER_REPOSITORY ?= |
| 25 | DOCKER_BUILD_ARGS ?= |
| 26 | DOCKER_TAG ?= ${VERSION} |
| 27 | DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${CONTAINER_NAME}:${DOCKER_TAG} |
| 28 | |
| 29 | ## Docker labels. Only set ref and commit date if committed |
| 30 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 31 | DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown") |
| 32 | DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" ) |
| 33 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 34 | |
| 35 | ## xosgenx related - paths are relative to this directory |
| 36 | XOS_DIR ?= "../xos" |
| 37 | |
| 38 | all: test |
| 39 | |
| 40 | docker-build: |
| 41 | docker build $(DOCKER_BUILD_ARGS) \ |
| 42 | -t ${DOCKER_IMAGENAME} \ |
| 43 | --build-arg org_label_schema_version="${VERSION}" \ |
| 44 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 45 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 46 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 47 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 48 | -f Dockerfile . |
| 49 | |
| 50 | docker-push: |
| 51 | docker push ${DOCKER_IMAGENAME} |
| 52 | |
| 53 | # Test starting the image, loading TOSCA, deleting TOSCA, and cleaning up after |
| 54 | # Not sure if this has been functional recently |
| 55 | test-docker: docker-start test-create test-delete docker-clean |
| 56 | |
| 57 | test: test-unit |
| 58 | |
| 59 | test-unit: generate-protos |
| 60 | tox |
| 61 | |
| 62 | venv-chameleon: |
| 63 | virtualenv $@;\ |
| 64 | source ./$@/bin/activate ; set -u ;\ |
| 65 | pip install -r requirements.txt |
| 66 | |
| 67 | generate-protos: venv-chameleon |
| 68 | source ./venv-chameleon/bin/activate ; set -u ;\ |
| 69 | make -C protos |
| 70 | |
| 71 | clean: |
| 72 | find . -name '*.pyc' | xargs rm -f |
| 73 | rm -rf \ |
| 74 | .tox \ |
| 75 | .coverage \ |
| 76 | coverage \ |
| 77 | coverage.xml \ |
| 78 | nose2-results.xml \ |
| 79 | protos/*_pb2.py \ |
| 80 | protos/*_pb2_grpc.py \ |
| 81 | venv-chameleon |
| 82 | |