-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
114 lines (88 loc) · 4.53 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# SPDX-FileCopyrightText: 2023-present Intel Corporation
# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
# set default shell
SHELL = bash -e -o pipefail
# Variables
VERSION ?= $(shell cat ./VERSION)
## Docker related
DOCKER_USER ?=
DOCKER_PASSWORD ?=
DOCKER_REGISTRY ?=
DOCKER_REPOSITORY ?= onosproject/
DOCKER_BUILD_ARGS ?=
DOCKER_TAG ?= latest
DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}aether-roc-gui:${DOCKER_TAG}
## Docker labels. Only set ref and commit date if committed
DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote | head -n 1))
DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
DOCKER_LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD)
PLATFORM ?= linux/amd64
NODE = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") weboaks/node-karma-protractor-chrome:debian-node14
ifeq ($(shell git ls-files --others --modified --exclude-standard 2>/dev/null | wc -l | sed -e 's/ //g'),0)
DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD)
else
DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD)+dirty
endif
.PHONY: build
build-tools:=$(shell if [ ! -d "./build/build-tools" ]; then cd build && git clone https://github.com/onosproject/build-tools.git; fi)
include ./build/build-tools/make/onf-common.mk
build: # @HELP build the Web GUI and run all validations (on the host machine)
build:
npm run build:prod
test: # @HELP run the unit tests and source code validation
test: npmdeps build lint license
npm test
jenkins-test: license # @HELP target used in Jenkins to run validation (these tests run in a docker container, only use on VM executors)
${NODE} bash -c "cd /app && NG_CLI_ANALYTICS=false npm install --cache /tmp/empty-cache && npm run lint && npm test && npm run build:prod"
jenkins-publish: docker-build docker-push # @HELP target used in Jenkins to publish docker images
./build/build-tools/release-merge-commit
npmdeps: # @HELP ensure that the required dependencies are in place
NG_CLI_ANALYTICS=false npm install
lint: npmdeps
npm run lint
# For running make openapi-gen in Mac run the below command and change sed to gsed\
brew install gsed
openapi-gen: # @HELP compile the OpenAPI files in to Typescript
node_modules/.bin/ng-openapi-gen --input ../aether-roc-api/api/aether-2.1.0-openapi3.yaml --output src/openapi3/aether/2.1.0
node_modules/.bin/ng-openapi-gen --input ../aether-roc-api/api/aether-top-level-openapi3.yaml --output src/openapi3/top/level
for f in src/openapi3/*/*/*.ts src/openapi3/*/*/*/*.ts; do \
{ echo "// Code generated by openapi-gen. DO NOT EDIT."; cat $$f; } > $$f.new; mv $$f.new $$f; \
done
aether-roc-gui-docker: # @HELP build aether-roc-gui Docker image
docker build --progress=plain --no-cache --platform ${PLATFORM} . -f build/aether-roc-gui/Dockerfile \
--build-arg LOCAL_ONOSAPPS=$(LOCAL_ONOSAPPS) \
--build-arg org_label_schema_version="${VERSION}" \
--build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
--build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
--build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
--build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
--build-arg http_proxy=${http_proxy} \
--build-arg https_proxy=${https_proxy} \
--build-arg no_proxy=${no_proxy} \
-t ${DOCKER_IMAGENAME}
images: # @HELP build all Docker images (the build happens inside a docker container)
images: aether-roc-gui-docker
docker-build: aether-roc-gui-docker
docker-push: # push to docker registy: use DOCKER_REGISTRY, DOCKER_REPOSITORY and DOCKER_TAG to customize
ifdef DOCKER_USER
ifdef DOCKER_PASSWORD
echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USER} --password-stdin
else
@echo "DOCKER_USER is specified but DOCKER_PASSWORD is missing"
@exit 1
endif
endif
docker push ${DOCKER_IMAGENAME}
kind-only:
$(eval CLUSTER_NAME := $(shell kind get clusters))
@if [ "$(CLUSTER_NAME)" = '' ]; then echo "no kind cluster found" && exit 1; fi
kind load --name=$(CLUSTER_NAME) docker-image ${DOCKER_IMAGENAME}
kind: # @HELP build Docker images and add them to the currently configured kind cluster
kind: images kind-only
all: images
publish:
./build/build-tools/publish-version ${VERSION} onosproject/aether-roc-gui
clean:: # @HELP remove all the build artifacts
rm -rf ./dist ./node-modules