minitor/Makefile

94 lines
2.2 KiB
Makefile
Raw Permalink Normal View History

DOCKER_TAG := minitor-dev
OPEN_CMD := $(shell type xdg-open &> /dev/null && echo 'xdg-open' || echo 'open')
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
./env/bin/python -m minitor.main -vvv
2018-02-17 02:09:10 +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
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:
$(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:
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-12 01:16:26 +00:00
# Cleans dist and env
.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-12 01:16:26 +00:00
# Generates test coverage
.coverage:
2018-04-11 16:57:22 +00:00
./env/bin/tox
2018-04-12 01:16:26 +00:00
# Builds coverage html
htmlcov/index.html: .coverage
./env/bin/coverage html
# Opens coverage html in browser (on macOS and some Linux systems)
.PHONY: open-coverage
open-coverage: htmlcov/index.html
$(OPEN_CMD) htmlcov/index.html
.PHONY: docker-build
docker-build:
docker build . -t $(DOCKER_TAG)