This repository has been archived by the owner on Oct 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
70 lines (57 loc) · 2.2 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
PYTHON := /usr/bin/python3
PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))
ifdef CONTAINER
BUILD_ARGS="--destructive-mode"
endif
METADATA_FILE="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 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 ${PROJECTPATH}/${CHARM_NAME}*.charm files"
@rm -rf ${PROJECTPATH}/${CHARM_NAME}*.charm
@echo "Cleaning charmcraft"
@charmcraft clean
submodules:
@echo "Cloning submodules"
@git submodule update --init --recursive
submodules-update:
@echo "Pulling latest updates for submodules"
@git submodule update --init --recursive --remote --merge
build: clean submodules-update
@echo "Building charm to base directory ${PROJECTPATH}/${CHARM_NAME}.charm"
@-git rev-parse --abbrev-ref HEAD > ./repo-info
@-git describe --always > ./version
@charmcraft -v pack ${BUILD_ARGS}
@bash -c ./rename.sh
release: clean build
@echo "Charm is built at ${PROJECTPATH}/${CHARM_NAME}.charm"
lint:
@echo "Running lint checks"
@tox -e lint
black:
@echo "Reformat files with black"
@tox -e black
unittests:
@echo "Running unit tests"
@tox -e unit
functional: build
@echo "Executing functional tests with ${PROJECTPATH}/${CHARM_NAME}.charm"
@CHARM_LOCATION=${PROJECTPATH} tox -e func
test: lint 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 unittests functional test