-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
106 lines (84 loc) · 2.56 KB
/
Makefile
File metadata and controls
106 lines (84 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
OPEN_CMD := $(shell type xdg-open &> /dev/null && echo 'xdg-open' || echo 'open')
NAME := release-gitter
ENV := venv
.PHONY: default
default: test
# Creates de virtualenv
$(ENV):
python3 -m venv $(ENV)
# Install package and dependencies in virtualenv
$(ENV)/bin/$(NAME): $(ENV)
$(ENV)/bin/pip install -r requirements-dev.txt
# Install hatch into virtualenv for running tests
$(ENV)/bin/hatch: $(ENV)
$(ENV)/bin/pip install hatch
# Installs dev requirements to virtualenv
.PHONY: devenv
devenv: $(ENV)/bin/$(NAME)
# Runs tests for current python
.PHONY: test
test: $(ENV)/bin/hatch
$(ENV)/bin/hatch run +py=3 test:run
# Runs test matrix
.PHONY: test-matrix
test-matrix: $(ENV)/bin/hatch
$(ENV)/bin/hatch run test:run
# Builds wheel for package to upload
.PHONY: build
build: $(ENV)/bin/hatch
$(ENV)/bin/hatch build
# Verify that the python version matches the git tag so we don't push bad shas
.PHONY: verify-tag-version
verify-tag-version: $(ENV)/bin/hatch
$(eval TAG_NAME = $(shell [ -n "$(DRONE_TAG)" ] && echo $(DRONE_TAG) || git describe --tags --exact-match))
test "v$(shell $(ENV)/bin/hatch version)" = "$(TAG_NAME)"
# Upload to pypi
.PHONY: upload
upload: verify-tag-version build
$(ENV)/bin/hatch publish
# Uses twine to upload to test pypi
.PHONY: upload-test
upload-test: build
# Bump version to a post version based on num of commits since last tag to prevent overwriting
$(ENV)/bin/hatch version $(shell git describe --tags | sed 's/-[0-9a-z]*$$//')
$(ENV)/bin/hatch publish --repo test
# Cleans all build, runtime, and test artifacts
.PHONY: clean
clean:
rm -fr ./build *.egg-info ./htmlcov ./.coverage ./.pytest_cache
find . -name '*.pyc' -delete
find . -name '__pycache__' -delete
# Cleans dist and env
.PHONY: dist-clean
dist-clean: clean
-$(ENV)/bin/hatch env prune
rm -fr ./dist $(ENV)
# Run linters
.PHONY: lint
lint: $(ENV)/bin/hatch
$(ENV)/bin/hatch run lint:all
# Install pre-commit hooks
.PHONY: install-hooks
install-hooks: devenv
$(ENV)/bin/hatch run lint:install-hooks
# Generates test coverage
.coverage: test
# Builds coverage html
htmlcov/index.html: .coverage
$(ENV)/bin/hatch 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:
$(ENV)/bin/hatch run docs:build
# Shorthand for building docs
.PHONY: docs
docs: docs/build/html/index.html
.PHONY: clean-all
clean-all: clean dist-clean docs-clean