Illyoung Choi | 5d59ab6 | 2019-06-24 16:15:27 -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 | |
Illyoung Choi | d1e4f5d | 2019-07-22 16:49:20 -0700 | [diff] [blame] | 15 | # Configure shell |
Illyoung Choi | 5d59ab6 | 2019-06-24 16:15:27 -0700 | [diff] [blame] | 16 | SHELL = bash -e -o pipefail |
| 17 | |
| 18 | # Variables |
| 19 | VERSION ?= $(shell cat ./VERSION) |
Illyoung Choi | d1e4f5d | 2019-07-22 16:49:20 -0700 | [diff] [blame] | 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 | |
Illyoung Choi | 5d59ab6 | 2019-06-24 16:15:27 -0700 | [diff] [blame] | 35 | |
Illyoung Choi | 5d59ab6 | 2019-06-24 16:15:27 -0700 | [diff] [blame] | 36 | # Targets |
| 37 | all: test |
| 38 | |
Illyoung Choi | d1e4f5d | 2019-07-22 16:49:20 -0700 | [diff] [blame] | 39 | docker-build: |
Illyoung Choi | 3926274 | 2019-07-23 13:28:00 -0700 | [diff] [blame] | 40 | docker build $(DOCKER_BUILD_ARGS) \ |
Illyoung Choi | d1e4f5d | 2019-07-22 16:49:20 -0700 | [diff] [blame] | 41 | -t ${DOCKER_IMAGENAME} \ |
| 42 | --build-arg org_label_schema_version="${VERSION}" \ |
| 43 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 44 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 45 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 46 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
Illyoung Choi | 3926274 | 2019-07-23 13:28:00 -0700 | [diff] [blame] | 47 | -f ./docker/Dockerfile . |
Illyoung Choi | d1e4f5d | 2019-07-22 16:49:20 -0700 | [diff] [blame] | 48 | |
| 49 | docker-push: |
| 50 | docker push ${DOCKER_IMAGENAME} |
| 51 | |
Illyoung Choi | 5d59ab6 | 2019-06-24 16:15:27 -0700 | [diff] [blame] | 52 | # Create a virtualenv and install all the libraries |
Illyoung Choi | fe121d0 | 2019-07-16 10:47:41 -0700 | [diff] [blame] | 53 | venv-cordworkflowairflow: |
Illyoung Choi | 5d59ab6 | 2019-06-24 16:15:27 -0700 | [diff] [blame] | 54 | virtualenv $@;\ |
| 55 | source ./$@/bin/activate ; set -u ;\ |
| 56 | pip install -r requirements.txt nose2 ;\ |
Illyoung Choi | fe121d0 | 2019-07-16 10:47:41 -0700 | [diff] [blame] | 57 | pip install -e ./ |
Illyoung Choi | 5d59ab6 | 2019-06-24 16:15:27 -0700 | [diff] [blame] | 58 | |
| 59 | # tests |
Illyoung Choi | fe121d0 | 2019-07-16 10:47:41 -0700 | [diff] [blame] | 60 | test: unit-test |
Illyoung Choi | 5d59ab6 | 2019-06-24 16:15:27 -0700 | [diff] [blame] | 61 | |
| 62 | unit-test: |
| 63 | tox |
| 64 | |
| 65 | clean: |
| 66 | find . -name '*.pyc' | xargs rm -f |
| 67 | find . -name '__pycache__' | xargs rm -rf |
| 68 | rm -rf \ |
| 69 | .coverage \ |
| 70 | coverage.xml \ |
| 71 | nose2-results.xml \ |
Illyoung Choi | fe121d0 | 2019-07-16 10:47:41 -0700 | [diff] [blame] | 72 | venv-cordworkflowairflow \ |
| 73 | .tox \ |
| 74 | build \ |
| 75 | dist \ |
| 76 | *.egg-info \ |
| 77 | *results.xml |