-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
118 lines (98 loc) · 2.89 KB
/
Makefile
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
107
108
109
110
111
112
113
114
115
116
117
118
DOCKER_IMAGE_NAME=mass-driver
APP_VERSION=$(shell poetry version --short)
.PHONY: all
all: install lint test docs build install-hooks
.PHONY: install
install:
poetry install
# Enforce the pre-commit hooks
.PHONY: install-hooks
install-hooks:
pre-commit install
.PHONY: lint
lint: # Use all linters on all files (not just staged for commit)
pre-commit run --all --all-files
.PHONY: test
test:
poetry run pytest
ACTION=run --no-pause
FILE=clone.toml
.PHONY: run
run: # Remember to export GITHUB_API_TOKEN beforehand
poetry run mass-driver ${ACTION} ${FILE}
.PHONY: docs
docs: clean-docs
cd docs && make html
poetry run doc2dash \
--force \
--name mass-driver \
docs/build/html \
--destination docs/build/docset \
--icon docs/source/_static/icon_small.png
.PHONY: clean-docs
clean-docs:
-find docs/build/ -delete
.PHONY: docs-serve
docs-serve:
cd docs/build/html && python3 -m http.server
.PHONY: build
build:
poetry build
.PHONY: docker-build-release
docker-build-release:
docker build \
-t "${DOCKER_IMAGE_NAME}:${APP_VERSION}" \
-f release.Dockerfile \
.
.PHONY: docker-build-dev
docker-build-dev:
docker build -t ${DOCKER_IMAGE_NAME}-dev .
# Make a release commit + tag, creating Changelog entry
# Set BUMP variable to any of poetry-supported (major, minor, patch)
# or number (1.2.3 etc), see 'poetry version' docs for details
.PHONY: release
# Default the bump to a patch (v1.2.3 -> v1.2.4)
release: BUMP=patch
release:
# Set the new version Makefile variable after the version bump
$(eval NEW_VERSION := $(shell poetry version --short ${BUMP}))
sed -i \
"s/\(## \[Unreleased\]\)/\1\n\n## v${NEW_VERSION} - $(shell date -I)/" \
CHANGELOG.md
git add CHANGELOG.md pyproject.toml
git commit -m "Bump to version v${NEW_VERSION}"
git tag -a v${NEW_VERSION} \
-m "Release v${NEW_VERSION}"
# Less commonly used commands
# Generate/update the poetry.lock file
.PHONY: lock
lock:
poetry lock --no-update
# Update dependencies (within pyproject.toml specs)
# Update the lock-file at the same time
.PHONY: update
update:
poetry update --lock
# Generate a pip-compatible requirements.txt
# From the poetry.lock. Mostly for CI use.
.PHONY: export-requirements
export-requirements:
poetry run pip freeze > requirements.txt
# Install poetry from pip
# IMPORTANT: Make sure "pip" resolves to a virtualenv
# Or that you are happy with poetry installed system-wide
.PHONY: install-poetry
install-poetry:
pip install poetry
# Ensure Poetry will generate virtualenv inside the git repo /.venv/
# rather than in a centralized location. This makes it possible to
# manipulate venv more simply
.PHONY: poetry-venv-local
poetry-venv-local:
poetry config virtualenvs.in-project true
# Delete the virtualenv to clean dependencies
# Useful when switching to a branch with less dependencies
# Requires the virtualenv to be local (see "poetry-venv-local")
.PHONY: poetry-venv-nuke
poetry-venv-nuke:
find .venv -delete