This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
57 lines (48 loc) · 2.06 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
DEFAULT_GOAL: help
OPEN=$(word 1, $(wildcard /usr/bin/xdg-open /usr/bin/open))
.PHONY: format
format: ## Run the formatter
@docker build -t securedrop-sdk/black:latest -f Dockerfile.black . && \
docker run --rm -v $(PWD):/home/kdas/workplace securedrop-sdk/black:latest black .
TESTS ?= tests
.PHONY: test
test: ## Run the test suite
@python -m pytest -v --cov sdclientapi --cov-report html --cov-report term-missing $(TESTS)
.PHONY: lint
lint: ## Run the flake8 lints
@flake8 sdclientapi tests
.PHONY: mypy
mypy: ## Run the mypy typechecker
@mypy sdclientapi
.PHONY: check
check: lint mypy test safety ## Run all checks and tests
.PHONY: safety
safety: ## Runs `safety check` to check python dependencies for vulnerabilities
pip install --upgrade safety && \
for req_file in `find . -type f -name '*requirements.txt'`; do \
echo "Checking file $$req_file" \
&& safety check --full-report -r $$req_file \
&& echo -e '\n' \
|| exit 1; \
done
.PHONY: update-pip-requirements
update-pip-requirements: ## Updates all Python requirements files via pip-compile.
pip-compile --generate-hashes --output-file dev-requirements.txt requirements.in dev-requirements.in
pip-compile --generate-hashes --output-file requirements.txt requirements.in
.PHONY: open-coverage-report
open-coverage-report: ## Open the coverage report in your browser
@$(OPEN) htmlcov/index.html
# Explaination of the below shell command should it ever break.
# 1. Set the field separator to ": ##" and any make targets that might appear between : and ##
# 2. Use sed-like syntax to remove the make targets
# 3. Format the split fields into $$1) the target name (in blue) and $$2) the target descrption
# 4. Pass this file as an arg to awk
# 5. Sort it alphabetically
# 6. Format columns with colon as delimiter.
.PHONY: help
help: ## Print this message and exit.
@printf "Makefile for developing and testing the SecureDrop SDK.\n"
@printf "Subcommands:\n\n"
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z_-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) \
| sort \
| column -s ':' -t