-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (55 loc) · 2.27 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
SOURCE_DIR = ./named_enum
.PHONY: clean help
help:
clear;
@echo "================= Usage =================";
@echo "clean : Remove autogenerated folders";
@echo "clean-pyc : Remove python artifacts."
@echo "clean-build : Remove build artifacts."
@echo "install : Install all dependencies and the package itself."
@echo "bandit : Run bandit security analysis.";
@echo "mypy : Run mypy type checking.";
@echo "flake8 : Run flake8 linting.";
@echo "test : Run tests and generate coverage report.";
@echo "build : Build a python wheel package.";
@echo "publish : Publish a python wheel package to package index.";
# Clean the folder from build/test related folders
clean: clean-build clean-pyc
rm -rf .mypy_cache/ .pytest_cache/
rm -f .coverage
clean-pyc:
find . \( -name '*.pyc' -o -name '*.pyo' \) -exec rm -rf {} +
clean-build:
rm -rf build/ dist/ *.egg-info
# Install development dependencies
install:
poetry install --with dev,test,docs
# Install and run bandit security analysis
bandit:
poetry run bandit -r $(SOURCE_DIR)
# Install and run mypy type checking
mypy:
poetry run mypy $(SOURCE_DIR)
# Install and run flake8 linting
flake8:
poetry run flake8 $(SOURCE_DIR)
# Install requirements for testing and run tests
test:
poetry run pytest
# build wheel package
build:
poetry build -f wheel
# publish the built package
publish:
@if [ -n "${POETRY_PYPI_TOKEN_PYPI}" ]; then\
echo "Uploading package to PyPi.";\
poetry publish --build --skip-existing;\
elif [ -n "${PACKAGE_INDEX_REPOSITORY_URL}" ] && [ -n "${PACKAGE_INDEX_USERNAME}" ] && [ -n "${PACKAGE_INDEX_PASSWORD}" ]; then\
echo "Uploading package to private package index ${PACKAGE_INDEX_REPOSITORY_URL}.";\
poetry config repositories.packagidx ${PACKAGE_INDEX_REPOSITORY_URL};\
poetry config http-basic.packagidx "${PACKAGE_INDEX_USERNAME}" "${PACKAGE_INDEX_PASSWORD}";\
poetry publish --build --skip-existing -r packagidx;\
else\
echo "To upload package to a private package index, you need to set environment variables \033[1mPACKAGE_INDEX_REPOSITORY_URL\033[0m \033[1mPACKAGE_INDEX_USERNAME\033[0m and \033[1mPACKAGE_INDEX_PASSWORD\033[0m.";\
exit 1;\
fi