Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update Makefile and tox.ini from upstream
- Loading branch information
Xav Paice
committed
Aug 5, 2020
1 parent
0b4a4f1
commit c5a5bd2
Showing
3 changed files
with
141 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,41 @@ | ||
*.swp | ||
*~ | ||
.idea | ||
# Juju files | ||
.unit-state.db | ||
.go-cookies | ||
|
||
layers/* | ||
interfaces/* | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# Tests files and dir | ||
.pytest_cache/ | ||
.coverage | ||
.tox | ||
.vscode | ||
/builds/ | ||
/deb_dist | ||
/dist | ||
/repo-info | ||
__pycache__ | ||
report/ | ||
htmlcov/ | ||
|
||
# Log files | ||
*.log | ||
|
||
# pycharm | ||
.idea/ | ||
|
||
# vi | ||
.*.swp | ||
|
||
# version data | ||
repo-info | ||
version | ||
|
||
# Python builds | ||
deb_dist/ | ||
dist/ | ||
|
||
# Snaps | ||
*.snap | ||
|
||
# Builds | ||
.build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,80 @@ | ||
PYTHON := /usr/bin/python3 | ||
|
||
PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST))) | ||
ifndef CHARM_BUILD_DIR | ||
CHARM_BUILD_DIR := /tmp/charm-builds | ||
export CHARM_BUILD_DIR | ||
$(warning Warning CHARM_BUILD_DIR was not set, defaulting to $(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 | ||
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 lint - run flake8" | ||
@echo " make test - run all tests: lint, unit and func tests" | ||
@echo " make unittest - run the tests defined in the unittest subdirectory" | ||
@echo " make functional - run the tests defined in the functional subdirectory" | ||
@echo " make release - build the charm" | ||
@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 "" | ||
|
||
lint: | ||
@echo "Running flake8" | ||
@tox -e lint | ||
|
||
test: lint unittest functional | ||
clean: | ||
@echo "Cleaning files" | ||
@git clean -ffXd -e '!.idea' | ||
@echo "Cleaning existing build" | ||
@rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME} | ||
|
||
unittest: | ||
@tox -e unit | ||
submodules: | ||
@echo "Cloning submodules" | ||
@git submodule update --init --recursive | ||
|
||
functional: build | ||
@PYTEST_KEEP_MODEL=$(PYTEST_KEEP_MODEL) \ | ||
PYTEST_CLOUD_NAME=$(PYTEST_CLOUD_NAME) \ | ||
PYTEST_CLOUD_REGION=$(PYTEST_CLOUD_REGION) \ | ||
tox -e functional | ||
submodules-update: | ||
@echo "Pulling latest updates for submodules" | ||
@git submodule update --init --recursive --remote --merge | ||
|
||
build: | ||
@echo "Building charm to base directory $(CHARM_BUILD_DIR)/advanced-routing" | ||
# @-git describe --tags > ./repo-info | ||
@CHARM_LAYERS_DIR=./layers CHARM_INTERFACES_DIR=./interfaces TERM=linux \ | ||
charm build --build-dir=$(CHARM_BUILD_DIR) . --force | ||
@echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}" | ||
@-git rev-parse --abbrev-ref HEAD > ./src/repo-info | ||
@CHARM_LAYERS_DIR=${CHARM_LAYERS_DIR} CHARM_INTERFACES_DIR=${CHARM_INTERFACES_DIR} \ | ||
TERM=linux CHARM_BUILD_DIR=${CHARM_BUILD_DIR} charm build src/ | ||
|
||
release: clean build | ||
@echo "Charm is built at $(JUJU_REPOSITORY)/builds" | ||
@echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}" | ||
|
||
clean: | ||
@echo "Cleaning files" | ||
@if [ -d .tox ] ; then rm -r .tox ; fi | ||
@if [ -d .pytest_cache ] ; then rm -r .pytest_cache ; fi | ||
@find . -type d -name '__pycache__' -prune -exec rm -rf "{}" | ||
lint: | ||
@echo "Running lint checks" | ||
@cd src && tox -e lint | ||
|
||
black: | ||
@echo "Reformat files with black" | ||
@cd src && tox -e black | ||
|
||
proof: | ||
@echo "Running charm proof" | ||
@charm proof src | ||
|
||
unittests: | ||
@echo "Running unit tests" | ||
@cd src && tox -e unit | ||
|
||
functional: build | ||
@echo "Executing functional tests in ${CHARM_BUILD_DIR}" | ||
@cd src && CHARM_BUILD_DIR=${CHARM_BUILD_DIR} 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: lint test unittest functional build release clean help | ||
.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters