-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
116 lines (86 loc) · 2.59 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
python=./env/bin/python
mamba=mamba
pkg=qmllib
pip=./env/bin/pip
pytest=pytest
j=1
version_file=src/qmllib/version.py
.PHONY: build
all: env
## Setup
env:
${mamba} env create -f ./environment_dev.yaml -p ./env --quiet
${python} -m pre_commit install
${python} -m pip install -e .
./.git/hooks/pre-commit:
${python} -m pre_commit install
## Development
format:
${python} -m pre_commit run --all-files
test:
${python} -m pytest -rs ./tests
test-dist:
${python} -m twine check dist/*
types:
${python} -m monkeytype run $$(which ${pytest}) ./tests
${python} -m monkeytype list-modules | grep ${pkg} | parallel -j${j} "${python} -m monkeytype apply {} > /dev/null && echo {}"
cov:
${python} -m pytest --cov=${pkg} --cov-config .coveragerc --cov-report html tests
compile:
${python} _compile.py
build:
${python} -m build --sdist --skip-dependency-check .
upload:
${python} -m twine upload ./dist/*.tar.gz
## Version
VERSION=$(shell cat ${version_file} | egrep -o "([0-9]{1,}\.)+[0-9]{1,}")
VERSION_PATCH=$(shell echo ${VERSION} | cut -d'.' -f3)
VERSION_MINOR=$(shell echo ${VERSION} | cut -d'.' -f2)
VERSION_MAJOR=$(shell echo ${VERSION} | cut -d'.' -f1)
GIT_COMMIT=$(shell git rev-parse --short HEAD)
version:
echo ${VERSION}
bump-version-auto:
test $(git diff HEAD^ HEAD tests | grep -q "+def") && make bump-version-minor || make bump-version-patch
bump-version-dev:
test ! -z "${VERSION}"
test ! -z "${GIT_COMMIT}"
exit 1 # Not Implemented
bump-version-patch:
test ! -z "${VERSION_PATCH}"
echo "__version__ = \"${VERSION_MAJOR}.${VERSION_MINOR}.$(shell awk 'BEGIN{print ${VERSION_PATCH}+1}')\"" > ${version_file}
bump-version-minor:
test ! -z "${VERSION_MINOR}"
echo "__version__ = \"${VERSION_MAJOR}.$(shell awk 'BEGIN{print ${VERSION_MINOR}+1}').0\"" > ${version_file}
bump-version-major:
test ! -z "${VERSION_MAJOR}"
echo "__version__ = \"$(shell awk 'BEGIN{print ${VERSION_MAJOR}+1}').0.0\"" > ${version_file}
commit-version-tag:
# git tag --list | grep -qix "${VERSION}"
git commit -m "Release ${VERSION}" --no-verify ${version_file}
git tag 'v${VERSION}'
gh-release:
gh release create "v${VERSION}" \
--repo="$${GITHUB_REPOSITORY}" \
--title="$${GITHUB_REPOSITORY#*/} ${VERSION}" \
--generate-notes
gh-has-src-changed:
git diff HEAD^ HEAD src | grep -q "+"
gh-cancel:
gh run cancel $${GH_RUN_ID}
gh run watch $${GH_RUN_ID}
## Clean
clean:
find ./src/ -type f \
-name "*.so" \
-name "*.pyc" \
-name ".pyo" \
-name ".mod" \
-delete
rm -rf ./src/*.egg-info/
rm -rf *.whl
rm -rf ./build/ ./__pycache__/
rm -rf ./dist/
clean-env:
rm -rf ./env/
rm ./.git/hooks/pre-commit