-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (74 loc) · 2.73 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
PYTHON := /usr/bin/python3
PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))
ifndef CHARM_BUILD_DIR
CHARM_BUILD_DIR=${PROJECTPATH}.build
endif
ifndef CHARM_LAYERS_DIR
CHARM_LAYERS_DIR=${PROJECTPATH}/layers
endif
ifndef CHARM_INTERFACES_DIR
CHARM_INTERFACES_DIR=${PROJECTPATH}/interfaces
endif
ifdef CONTAINER
BUILD_ARGS="--destructive-mode"
endif
METADATA_FILE="src/metadata.yaml"
CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E "^name:" | awk '{print $$2}')
help:
@echo "This project supports the following targets"
@echo ""
@echo " make help - show this text"
@echo " make clean - remove unneeded files"
@echo " make submodules - make sure that the submodules are up-to-date"
@echo " make submodules-update - update submodules to latest changes on remote branch"
@echo " make build - build the charm"
@echo " make release - run clean, submodules, and build targets"
@echo " make lint - run flake8 and black --check"
@echo " make black - run black and reformat files"
@echo " make proof - run charm proof"
@echo " make unittests - run the tests defined in the unittest subdirectory"
@echo " make functional - run the tests defined in the functional subdirectory"
@echo " make test - run lint, proof, unittests and functional targets"
@echo ""
clean:
@echo "Cleaning files"
@git clean -ffXd -e '!.idea'
@echo "Cleaning existing build"
@rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME}
@charmcraft clean
@rm -rf ${PROJECTPATH}/${CHARM_NAME}.charm
submodules:
# @git submodule update --init --recursive
@echo "No submodules. Skipping."
submodules-update:
# @git submodule update --init --recursive --remote --merge
@echo "No submodules. Skipping."
build: clean submodules-update
@echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}"
@-git rev-parse --abbrev-ref HEAD > ./src/repo-info
#@charmcraft -v pack ${BUILD_ARGS}
@charmcraft pack --destructive-mode
@bash -c ./rename.sh
@mkdir -p ${CHARM_BUILD_DIR}/${CHARM_NAME}
@unzip ${PROJECTPATH}/${CHARM_NAME}.charm -d ${CHARM_BUILD_DIR}/${CHARM_NAME}
release: clean build
@echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}"
lint:
@echo "Running lint checks"
@cd src && tox -e lint
black:
@echo "Reformat files with black"
@cd src && tox -e black
proof: build
@echo "Running charm proof"
@charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME}
unittests:
@echo "Running unit tests"
@cd src && tox -e unit
functional: build
@echo "Executing functional tests in ${CHARM_BUILD_DIR}"
@cd src && CHARM_LOCATION=${PROJECTPATH} tox -e func
test: lint proof unittests functional
@echo "Tests completed for charm ${CHARM_NAME}."
# The targets below don't depend on a file
.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test