-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
104 lines (81 loc) · 3.43 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
# SPDX-FileCopyrightText: 2019 Free Software Foundation Europe e.V.
#
# SPDX-License-Identifier: GPL-3.0-or-later
SOURCE_DIR = reuse_api
# Files/dirs to be checked by pylama/black/isort
QUALITY_TARGETS = $(SOURCE_DIR) tests/* *.py
export FLASK_SKIP_DOTENV = 1
export FLASK_APP = ${SOURCE_DIR}
export FLASK_ENV = development
export FLASK_RUN_HOST = localhost
export FLASK_RUN_PORT = 8000
.DEFAULT_GOAL := help
COMPOSE := docker compose
GREEN = $(shell tput -Txterm setaf 2)
WHITE = $(shell tput -Txterm setaf 7)
YELLOW = $(shell tput -Txterm setaf 3)
RESET = $(shell tput -Txterm sgr0)
HELPME = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-\.]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (20 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; }
help:
@perl -e '$(HELPME)' $(MAKEFILE_LIST)
.PHONY: help
virtualenv: ##@development Set up the virtual environment with the Python dependencies.
@pipenv install --dev
.PHONY: virtualenv
applyisort: ##@development Apply a correct Python import sort inline.
@pipenv run isort $(QUALITY_TARGETS)
.PHONY: applyisort
applyblack: ##@development Apply source code formatting with black.
@pipenv run black $(QUALITY_TARGETS)
.PHONY: applyblack
flask: ##@development Run the Flask built-in web server.
@pipenv run flask run
.PHONY: flask
gunicorn: ##@development Run the Gunicorn based web server.
@pipenv run gunicorn --bind $$FLASK_RUN_HOST:$$FLASK_RUN_PORT "$$FLASK_APP:create_app()"
.PHONY: gunicorn
isort: ##@quality Check the Python source code for import sorting.
@pipenv run isort --check --diff $(QUALITY_TARGETS)
.PHONY: isort
black: ##@quality Check the Python source code formatting with black.
@pipenv run black --check --diff $(QUALITY_TARGETS)
.PHONY: black
pylama: ##@quality Check the Python source code for coding standards compliance.
@pipenv run pylama $(QUALITY_TARGETS)
.PHONY: pylama
pytest: ##@quality Run the functional tests.
@pipenv run pytest --cov=$(SOURCE_DIR) tests
.PHONY: pytest
dev.prep: ##@development Initially build the docker image that the API worker executes
@chmod 600 ./api-worker/worker-setup/files/test_ed25519
@mkdir -p ./forms/store/reuse-api
@if ! [ -e ./forms/store/reuse-api/repos.json ]; then echo [] > ./forms/store/reuse-api/repos.json; fi
@docker build -f api-worker/docker-image/Dockerfile -t reuse-api-worker-runner api-worker/docker-image
.PHONY: dev.prep
dev.up: dev.prep ##@development Bring up entire environment with docker compose and detach
@docker network create forms_default || echo "Network already present."
@$(COMPOSE) -f forms/docker-compose.dev.yml up --build -d
@$(COMPOSE) -f docker-compose.dev.yml up --build -d
.PHONY: dev.up
dev.down: ##@development Bring down entire environment with docker compose
@$(COMPOSE) -f docker-compose.dev.yml down
@$(COMPOSE) -f forms/docker-compose.dev.yml down
.PHONY: dev.down
dev.logs: ##@development Get logs of running docker containers
@$(COMPOSE) -f docker-compose.dev.yml -f forms/docker-compose.dev.yml logs -f
.PHONY: dev.logs
dev.reset: ##@development Prune some configs to test the API from scratch
@echo [] > ./forms/store/reuse-api/repos.json
@rm -f ./api-worker/worker-setup/files/known_hosts
.PHONY: dev.reset
quality: isort black pylama pytest ##@quality Run all quality checks.
.PHONY: quality