unhacs/Makefile

95 lines
2.0 KiB
Makefile
Raw Normal View History

2024-06-04 22:20:13 +00:00
OPEN_CMD := $(shell type xdg-open &> /dev/null && echo 'xdg-open' || echo 'open')
NAME := unhacs
ENV := env
.PHONY: default
default: test
2024-06-07 23:31:02 +00:00
# Runs package
.PHONY: run
run:
poetry run $(NAME) list
2024-06-04 22:20:13 +00:00
2024-06-07 23:31:02 +00:00
.PHONY: install
install:
poetry install
2024-06-04 22:20:13 +00:00
.PHONY: devenv
2024-06-07 23:31:02 +00:00
devenv: install
2024-06-04 22:20:13 +00:00
2024-06-07 23:46:09 +00:00
.PHONY: lint
lint: devenv
2024-06-07 23:46:09 +00:00
poetry run pre-commit run --all-files
2024-06-07 23:31:02 +00:00
# Runs tests
2024-06-04 22:20:13 +00:00
.PHONY: test
test: devenv
2024-09-18 18:33:27 +00:00
poetry run python -m unittest discover tests
2024-06-04 22:20:13 +00:00
# Builds wheel for package to upload
.PHONY: build
2024-06-07 23:31:02 +00:00
build:
poetry build
2024-06-04 22:20:13 +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))
2024-06-07 23:31:02 +00:00
test "v$(shell poetry version | awk '{print $$2}')" = "$(TAG_NAME)"
2024-06-04 22:20:13 +00:00
2024-06-07 23:31:02 +00:00
# Upload to pypi
2024-06-04 22:20:13 +00:00
.PHONY: upload
2024-06-07 23:31:02 +00:00
upload: verify-tag-version build
poetry publish
2024-06-04 22:20:13 +00:00
# Uses twine to upload to test pypi
.PHONY: upload-test
2024-06-07 23:31:02 +00:00
upload-test: verify-tag-version build
poetry publish --repository testpypi
2024-06-04 22:20:13 +00:00
# Cleans all build, runtime, and test artifacts
.PHONY: clean
clean:
rm -fr ./build *.egg-info ./htmlcov ./.coverage ./.pytest_cache ./.tox
find . -name '*.pyc' -delete
find . -name '__pycache__' -delete
# Cleans dist and env
.PHONY: dist-clean
dist-clean: clean
2024-06-07 23:31:02 +00:00
rm -fr ./dist
2024-06-04 22:20:13 +00:00
# Install pre-commit hooks
.PHONY: install-hooks
install-hooks: devenv
2024-06-07 23:46:09 +00:00
poetry run pre-commit install -f --install-hooks
2024-06-04 22:20:13 +00:00
# Generates test coverage
.coverage: devenv
2024-06-07 23:31:02 +00:00
poetry run pytest
2024-06-04 22:20:13 +00:00
# Builds coverage html
htmlcov/index.html: .coverage
2024-06-07 23:31:02 +00:00
poetry run coverage html
2024-06-04 22:20:13 +00:00
# Opens coverage html in browser (on macOS and some Linux systems)
.PHONY: open-coverage
open-coverage: htmlcov/index.html
$(OPEN_CMD) htmlcov/index.html
# Cleans out docs
.PHONY: docs-clean
docs-clean:
rm -fr docs/build/* docs/source/code/*
# Builds docs
docs/build/html/index.html:
2024-06-07 23:31:02 +00:00
@echo TODO: Make docs
2024-06-04 22:20:13 +00:00
# Shorthand for building docs
.PHONY: docs
docs: docs/build/html/index.html
.PHONY: clean-all
clean-all: clean dist-clean docs-clean