2018-04-18 04:01:58 +00:00
|
|
|
DOCKER_TAG := minitor-dev
|
2018-04-19 00:05:33 +00:00
|
|
|
OPEN_CMD := $(shell type xdg-open &> /dev/null && echo 'xdg-open' || echo 'open')
|
2018-04-15 00:26:58 +00:00
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
.PHONY: default
|
|
|
|
default: test
|
|
|
|
|
|
|
|
# Builds the python3 venv with all dev requirements
|
2018-02-14 23:37:15 +00:00
|
|
|
env:
|
2018-04-11 16:08:03 +00:00
|
|
|
python3 -m venv env
|
2018-04-09 17:44:30 +00:00
|
|
|
./env/bin/pip install -r requirements-dev.txt
|
2018-02-14 23:37:15 +00:00
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
# Runs Minitor
|
2018-02-17 02:09:10 +00:00
|
|
|
.PHONY: run
|
2018-02-14 23:37:15 +00:00
|
|
|
run: env
|
2019-06-03 18:44:39 +00:00
|
|
|
./env/bin/python -m minitor.main -vvv
|
2018-02-17 02:09:10 +00:00
|
|
|
|
2018-07-13 06:01:36 +00:00
|
|
|
# Runs Minitor with metrics
|
|
|
|
.PHONY: run-metrics
|
|
|
|
run-metrics: env
|
|
|
|
./env/bin/python -m minitor.main --metrics
|
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
# Generates a smaller env for running tox, which builds it's own env
|
|
|
|
.PHONY: test-env
|
|
|
|
test-env:
|
|
|
|
python3 -m venv env
|
|
|
|
./env/bin/pip install tox
|
|
|
|
|
|
|
|
# Runs tests with tox
|
2018-04-09 17:44:30 +00:00
|
|
|
.PHONY: test
|
|
|
|
test: env
|
2018-04-11 16:57:22 +00:00
|
|
|
./env/bin/tox
|
2018-04-09 17:44:30 +00:00
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
# Generates a small build env for building and uploading dists
|
|
|
|
.PHONY: build-env
|
|
|
|
build-env:
|
|
|
|
python3 -m venv env
|
|
|
|
./env/bin/pip install twine wheel
|
|
|
|
|
|
|
|
# Builds wheel for package to upload
|
2018-02-17 02:09:10 +00:00
|
|
|
.PHONY: build
|
2018-04-11 16:04:14 +00:00
|
|
|
build: env
|
2018-02-17 02:09:10 +00:00
|
|
|
./env/bin/python setup.py sdist
|
|
|
|
./env/bin/python setup.py bdist_wheel
|
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
# Verify that the python version matches the git tag so we don't push bad shas
|
|
|
|
.PHONY: verify-tag-version
|
|
|
|
verify-tag-version:
|
2018-04-19 00:36:39 +00:00
|
|
|
$(eval TAG_NAME = $(shell [ -n "$(DRONE_TAG)" ] && echo $(DRONE_TAG) || git describe --tags --exact-match))
|
|
|
|
test "v$(shell python setup.py -V)" = "$(TAG_NAME)"
|
2018-04-12 01:16:26 +00:00
|
|
|
|
|
|
|
# Uses twine to upload to pypi
|
2018-02-17 02:09:10 +00:00
|
|
|
.PHONY: upload
|
2018-04-12 01:16:26 +00:00
|
|
|
upload: verify-tag-version build
|
2018-02-17 02:09:10 +00:00
|
|
|
./env/bin/twine upload dist/*
|
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
# Uses twine to upload to test pypi
|
2018-02-17 02:09:10 +00:00
|
|
|
.PHONY: upload-test
|
2018-04-12 01:16:26 +00:00
|
|
|
upload-test: verify-tag-version build
|
2018-02-17 02:09:10 +00:00
|
|
|
./env/bin/twine upload --repository-url https://test.pypi.org/legacy/ dist/*
|
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
# Cleans all build, runtime, and test artifacts
|
2018-02-17 02:09:10 +00:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2018-04-10 18:28:09 +00:00
|
|
|
rm -fr ./build ./minitor.egg-info ./htmlcov ./.coverage ./.pytest_cache ./.tox
|
2018-04-11 16:57:22 +00:00
|
|
|
find . -name '*.pyc' -delete
|
|
|
|
find . -name '__pycache__' -delete
|
2018-04-10 18:28:09 +00:00
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
# Cleans dist and env
|
2018-04-10 18:28:09 +00:00
|
|
|
.PHONY: dist-clean
|
|
|
|
dist-clean: clean
|
2018-04-11 16:57:22 +00:00
|
|
|
rm -fr ./dist ./env
|
2018-04-09 17:44:30 +00:00
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
# Install pre-commit hooks
|
2018-04-10 00:26:32 +00:00
|
|
|
.PHONY: install-hooks
|
2018-04-12 01:16:26 +00:00
|
|
|
install-hooks: env
|
2018-04-11 16:57:22 +00:00
|
|
|
./env/bin/tox -e pre-commit -- install -f --install-hooks
|
2018-04-10 18:28:09 +00:00
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
# Generates test coverage
|
2018-04-10 18:28:09 +00:00
|
|
|
.coverage:
|
2018-04-11 16:57:22 +00:00
|
|
|
./env/bin/tox
|
2018-04-10 18:28:09 +00:00
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
# Builds coverage html
|
2018-04-10 18:28:09 +00:00
|
|
|
htmlcov/index.html: .coverage
|
|
|
|
./env/bin/coverage html
|
|
|
|
|
2018-04-15 00:26:58 +00:00
|
|
|
# Opens coverage html in browser (on macOS and some Linux systems)
|
2018-04-10 18:28:09 +00:00
|
|
|
.PHONY: open-coverage
|
|
|
|
open-coverage: htmlcov/index.html
|
2018-04-15 00:26:58 +00:00
|
|
|
$(OPEN_CMD) htmlcov/index.html
|
2018-04-18 04:01:58 +00:00
|
|
|
|
|
|
|
.PHONY: docker-build
|
|
|
|
docker-build:
|
|
|
|
docker build . -t $(DOCKER_TAG)
|