-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (104 loc) · 4.12 KB
/
Makefile
File metadata and controls
141 lines (104 loc) · 4.12 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# To do stuff with make, you type `make` in a directory that has a file called
# "Makefile". You can also type `make -f <makefile>` to use a different filename.
#
# A Makefile is a collection of rules. Each rule is a recipe to do a specific
# thing, sort of like a grunt task or an npm package.json script.
#
# A rule looks like this:
#
# <target>: <prerequisites...>
# <commands>
#
# The "target" is required. The prerequisites are optional, and the commands
# are also optional, but you have to have one or the other.
#
# Type `make` to show the available targets and a description of each.
#
.DEFAULT_GOAL := help
.PHONY: help
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Testing
.PHONY: unit-tests
unit-tests: ## run unit-tests with pytest
@pytest --doctest-modules
.PHONY: unit-tests-cov
unit-tests-cov: ## run unit-tests with pytest and show coverage (terminal + html)
@pytest --doctest-modules --cov=src --cov-report term-missing --cov-report=html
.PHONY: unit-tests-cov-fail
unit-tests-cov-fail: ## run unit tests with pytest and show coverage (terminal + html) & fail if coverage too low & create files for CI
@pytest --doctest-modules --cov=src --cov-report term-missing --cov-report=html --cov-fail-under=80 --junitxml=pytest.xml | tee pytest-coverage.txt
##@ Formatting
.PHONY: format-black
format-black: ## black (code formatter)
@black .
.PHONY: format-isort
format-isort: ## isort (import formatter)
@isort .
.PHONY: format
format: format-black format-isort ## run all formatters
##@ Linting
.PHONY: lint-black
lint-black: ## black in linting mode
@black . --check
.PHONY: lint-isort
lint-isort: ## isort in linting mode
@isort . --check
.PHONY: lint-flake8
lint-flake8: ## flake8 (linter)
@flake8 .
.PHONY: lint-mypy
lint-mypy: ## mypy (static-type checker)
@mypy --config-file pyproject.toml .
.PHONY: lint-mypy-report
lint-mypy-report: ## run mypy & create report
@mypy --config-file pyproject.toml . --html-report ./mypy_html
lint: lint-black lint-isort lint-flake8 lint-mypy ## run all linters
##@ Documentation
docs-build: create_openapi ## build documentation locally
@mkdocs build
docs-deploy: ## build & deploy documentation to "gh-pages" branch
@mkdocs gh-deploy -m "docs: update documentation" -v --force
create_openapi: ## create openapi.json
@python3 scripts/create_openapi_json.py
##@ Clean-up
clean-cov: ## remove output files from pytest & coverage
@rm -rf .coverage
@rm -rf htmlcov
@rm -rf pytest.xml
@rm -rf pytest-coverage.txt
@rm -rf dist
clean-docs: ## remove output files from mkdocs
@rm -rf site
@rm -rf docs/openapi.json
clean: clean-cov clean-docs ## run all clean commands
##@ Releases
current-version: ## returns the current version
@semantic-release print-version --current
next-version: ## returns the next version
@semantic-release print-version --next
current-changelog: ## returns the current changelog
@semantic-release changelog --released
next-changelog: ## returns the next changelog
@semantic-release changelog --unreleased
publish-noop: ## publish command (noop="no operation mode")
@semantic-release publish --noop
##@ Docker
build: ## docker build
@docker build --file Dockerfile --tag project:latest --target production .
run: ## docker run app
@docker run -p 9000:80 -it --rm project:latest
run-bash: ## docker run with bash
@docker run -it --rm project:latest /bin/bash
login: ## login to ghcr.io using a personal access token (PAT)
@if [ -z "$(CR_PAT)" ]; then\
echo "CR_PAT is not set";\
else\
echo $(CR_PAT) | docker login ghcr.io -u johschmidt42 --password-stdin;\
fi
tag: ## tag docker image to ghcr.io/johschmidt42/project:latest
@docker tag project:latest ghcr.io/johschmidt42/project:latest
push: tag ## docker push to container registry (ghcr.io)
@docker push ghcr.io/johschmidt42/project:latest
scan: ## scan the docker image for vulnerabilities
@trivy image project:latest --scanners vuln --format table --severity CRITICAL,HIGH --ignorefile .trivyignore