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')
|
2019-07-31 04:17:00 +00:00
|
|
|
ENV := env
|
2018-04-15 00:26:58 +00:00
|
|
|
|
2018-04-12 01:16:26 +00:00
|
|
|
.PHONY: default
|
|
|
|
default: test
|
|
|
|
|
2019-07-31 04:17:00 +00:00
|
|
|
# Creates virtualenv
|
|
|
|
$(ENV):
|
|
|
|
python3 -m venv $(ENV)
|
|
|
|
|
|
|
|
# Install minitor and dependencies in virtualenv
|
|
|
|
$(ENV)/bin/minitor: $(ENV)
|
|
|
|
$(ENV)/bin/pip install -r requirements-dev.txt
|
|
|
|
|
|
|
|
# Install tox into virtualenv for running tests
|
|
|
|
$(ENV)/bin/tox: $(ENV)
|
|
|
|
$(ENV)/bin/pip install tox
|
|
|
|
|
|
|
|
# Install wheel for building packages
|
|
|
|
$(ENV)/bin/wheel: $(ENV)
|
|
|
|
$(ENV)/bin/pip install wheel
|
|
|
|
|
|
|
|
# Install twine for uploading packages
|
|
|
|
$(ENV)/bin/twine: $(ENV)
|
|
|
|
$(ENV)/bin/pip install twine
|
|
|
|
|
|
|
|
# Installs dev requirements to virtualenv
|
|
|
|
.PHONY: devenv
|
|
|
|
devenv: $(ENV)/bin/minitor
|
|
|
|
|
|
|
|
# Generates a smaller env for running tox, which builds it's own env
|
|
|
|
.PHONY: test-env
|
|
|
|
test-env: $(ENV)/bin/tox
|
|
|
|
|
|
|
|
# Generates a small build env for building and uploading dists
|
|
|
|
.PHONY: build-env
|
|
|
|
build-env: $(ENV)/bin/twine $(ENV)/bin/wheel
|
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
|
2019-07-31 04:17:00 +00:00
|
|
|
run: $(ENV)/bin/minitor
|
|
|
|
$(ENV)/bin/minitor -vvv
|
2018-02-17 02:09:10 +00:00
|
|
|
|
2018-07-13 06:01:36 +00:00
|
|
|
# Runs Minitor with metrics
|
|
|
|
.PHONY: run-metrics
|
2019-07-31 04:17:00 +00:00
|
|
|
run-metrics: $(ENV)
|
|
|
|
$(ENV)/bin/python -m minitor.main --metrics
|
2018-04-12 01:16:26 +00:00
|
|
|
|
|
|
|
# Runs tests with tox
|
2018-04-09 17:44:30 +00:00
|
|
|
.PHONY: test
|
2019-07-31 04:17:00 +00:00
|
|
|
test: $(ENV)/bin/tox
|
|
|
|
$(ENV)/bin/tox -e py3
|
2018-04-12 01:16:26 +00:00
|
|
|
|
|
|
|
# Builds wheel for package to upload
|
2018-02-17 02:09:10 +00:00
|
|
|
.PHONY: build
|
2019-07-31 04:17:00 +00:00
|
|
|
build: $(ENV)/bin/wheel
|
|
|
|
$(ENV)/bin/python setup.py sdist
|
|
|
|
$(ENV)/bin/python setup.py bdist_wheel
|
2018-02-17 02:09:10 +00:00
|
|
|
|
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
|
2019-07-31 04:17:00 +00:00
|
|
|
upload: verify-tag-version build $(ENV)/bin/twine
|
|
|
|
$(ENV)/bin/twine upload dist/*
|
2018-02-17 02:09:10 +00:00
|
|
|
|
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
|
2019-07-31 04:17:00 +00:00
|
|
|
upload-test: verify-tag-version build $(ENV)/bin/twine
|
|
|
|
$(ENV)/bin/twine upload --repository-url https://test.pypi.org/legacy/ dist/*
|
2018-02-17 02:09:10 +00:00
|
|
|
|
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
|
2019-07-31 04:17:00 +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
|
2019-07-31 04:17:00 +00:00
|
|
|
install-hooks: $(ENV)
|
|
|
|
$(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:
|
2019-07-31 04:17:00 +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
|
2019-07-31 04:17:00 +00:00
|
|
|
$(ENV)/bin/coverage html
|
2018-04-10 18:28:09 +00:00
|
|
|
|
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
|
|
|
|
2019-06-20 19:58:51 +00:00
|
|
|
# Docker targets
|
|
|
|
|
|
|
|
# Targets to download required qemu binaries for running on an amd64 machine
|
|
|
|
build/qemu-x86_64-static:
|
|
|
|
./get_qemu.sh x86_64
|
|
|
|
|
|
|
|
build/qemu-arm-static:
|
|
|
|
./get_qemu.sh arm
|
|
|
|
|
|
|
|
build/qemu-aarch64-static:
|
|
|
|
./get_qemu.sh aarch64
|
|
|
|
|
|
|
|
# Build Docker image for host architechture (amd64)
|
2018-04-18 04:01:58 +00:00
|
|
|
.PHONY: docker-build
|
2019-06-20 19:58:51 +00:00
|
|
|
docker-build: build/qemu-x86_64-static
|
|
|
|
docker build . -t ${DOCKER_TAG}-linux-amd64
|
|
|
|
|
|
|
|
# Cross build for arm architechtures
|
|
|
|
.PHONY: docker-cross-build-arm
|
|
|
|
docker-cross-build-arm: build/qemu-arm-static
|
|
|
|
docker build --build-arg REPO=arm32v6 --build-arg ARCH=arm . -t ${DOCKER_TAG}-linux-arm
|
|
|
|
|
|
|
|
.PHONY: docker-cross-build-arm
|
|
|
|
docker-cross-build-arm64: build/qemu-aarch64-static
|
|
|
|
docker build --build-arg REPO=arm64v8 --build-arg ARCH=aarch64 . -t ${DOCKER_TAG}-linux-arm64
|
|
|
|
|
|
|
|
# Run on host architechture
|
2019-07-31 04:17:00 +00:00
|
|
|
.PHONY: docker-run
|
2019-06-20 19:58:51 +00:00
|
|
|
docker-run: docker-build
|
|
|
|
docker run ${DOCKER_TAG}-linux-amd64
|
|
|
|
|
|
|
|
# Cross run on host architechture
|
|
|
|
.PHONY: docker-cross-run-arm
|
|
|
|
docker-cross-run-arm: docker-cross-build-arm
|
|
|
|
docker run --rm ${DOCKER_TAG}-linux-arm
|
|
|
|
|
|
|
|
.PHONY: docker-cross-run-arm64
|
|
|
|
docker-cross-run-arm64: docker-cross-build-arm64
|
|
|
|
docker run --rm ${DOCKER_TAG}-linux-arm64
|