bandcamp-search/Makefile
Ian Fijolek 69306c551b
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Disable tests
2024-10-15 09:16:30 -07:00

116 lines
2.6 KiB
Makefile

OPEN_CMD := $(shell type xdg-open &> /dev/null && echo 'xdg-open' || echo 'open')
NAME := bandcamp_search
ENV := env
.PHONY: default
default: test
# Runs package
.PHONY: run
run:
poetry run python -m $(NAME) "Kooky Spooky"
.PHONY: install
install:
poetry install
.PHONY: devenv
devenv: install
.PHONY: lint
lint: devenv
poetry run pre-commit run --all-files
# Runs tests
.PHONY: test
test: devenv
@echo poetry run python -m unittest discover tests --pattern "*_test.py"
# Builds wheel for package to upload
.PHONY: build
build:
poetry build
# 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 poetry version | awk '{print $$2}')" = "$(TAG_NAME)"
.PHONY: bump-patch
bump-patch:
$(eval NEW_VERSION = $(shell poetry version patch | awk '{print $$6}'))
git add pyproject.toml
git commit -m "Bump version to $(NEW_VERSION)"
git tag "v$(NEW_VERSION)"
.PHONY: bump-minor
bump-minor:
$(eval NEW_VERSION = $(shell poetry version minor | awk '{print $$6}'))
git add pyproject.toml
git commit -m "Bump version to $(NEW_VERSION)"
git tag "v$(NEW_VERSION)"
.PHONY: bump-major
bump-major:
$(eval NEW_VERSION = $(shell poetry version major | awk '{print $$6}'))
git add pyproject.toml
git commit -m "Bump version to $(NEW_VERSION)"
git tag "v$(NEW_VERSION)"
# Upload to pypi
.PHONY: upload
upload: verify-tag-version build
poetry publish
# Uses twine to upload to test pypi
.PHONY: upload-test
upload-test: verify-tag-version build
poetry publish --repository testpypi
# 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
rm -fr ./dist
# Install pre-commit hooks
.PHONY: install-hooks
install-hooks: devenv
poetry run pre-commit install -f --install-hooks
# Generates test coverage
.coverage: devenv
poetry run pytest
# Builds coverage html
htmlcov/index.html: .coverage
poetry run 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
# Cleans out docs
.PHONY: docs-clean
docs-clean:
rm -fr docs/build/* docs/source/code/*
# Builds docs
docs/build/html/index.html:
@echo TODO: Make docs
# Shorthand for building docs
.PHONY: docs
docs: docs/build/html/index.html
.PHONY: clean-all
clean-all: clean dist-clean docs-clean