-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
96 lines (84 loc) · 2.64 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
APP_UID := $(shell id -u)
setup_mounts:
@mkdir -p mounts/db
@mkdir -p mounts/mysql_db
@mkdir -p mounts/logs
@mkdir -p mounts/modules_web
@mkdir -p mounts/modules_celery
@mkdir -p Access/access_modules
@chown $(APP_UID) mounts/db
@chown $(APP_UID) mounts/mysql_db
@chown $(APP_UID) mounts/logs
@chown $(APP_UID) mounts/modules_web
@chown $(APP_UID) mounts/modules_celery
@chown $(APP_UID) Access/access_modules
## make all : Run service, test and linter
.PHONY: all
all: build test lint
## make dev : Build and start docker containers - (web/test/db)
.PHONY: dev
dev: export APPUID = $(APP_UID)
dev: setup_mounts
@docker-compose up --build -d web celery
## make build : Build and start docker containers - (web and db)
.PHONY: build
build: export APPUID = $(APP_UID)
build:
@docker-compose up --build -d web
## make build_only : Only build the web container
.PHONY: build_only
build_only: export APPUID = $(APP_UID)
build_only:
@docker-compose build web
.PHONY: down
down: export APPUID = $(APP_UID)
down:
@docker-compose -f docker-compose.yml down
## View docker logs for containers started in `make dev`
.PHONY: logs
logs:
@docker-compose logs -ft
ensure_web_container_for_test:
@if [ $$(docker ps -a -f name=dev | wc -l) -eq 2 ]; then \
docker exec dev python -m pytest --version; \
else \
echo "No containers running.. Starting Django runserver:"; \
make build; \
fi
## Run tests with coverage
.PHONY: test
test: export APPUID = $(APP_UID)
test: setup_mounts ensure_web_container_for_test
@if [ "$(TESTS)" = "" ]; then \
echo "No arguments passed to make test. Running all tests.."; \
docker exec dev python -m pytest -v --cov --disable-warnings; \
echo "Tests finished."; \
else \
echo "Running tests with filter $(TESTS)"; \
docker exec dev python -m pytest -v --cov --disable-warnings -k '$(TESTS)'; \
fi
## Lint code using pylama skipping files in env (if pyenv created)
.PHONY: lint
lint: export APPUID = $(APP_UID)
lint: setup_mounts ensure_web_container_for_test
@docker exec dev python -m pylama --version
@docker exec dev python -m pylama Access/accessrequest_helper.py scripts bootprocess
@if [ "$$?" -ne 0 ]; then \
echo "Linter checks failed"; \
exit 1; \
else \
echo "Linter checks passed"; \
fi
.PHONY: schema_validate
schema_validate: export APPUID = $(APP_UID)
schema_validate: setup_mounts ensure_web_container_for_test
@echo "Validating Schema"
@docker exec dev python scripts/validator.py
@if [ "$$?" -ne 0 ]; then \
echo "Schema validation failed"; \
exit 1; \
else \
echo "Schema validation passed"; \
fi
run_semgrep:
$(shell semgrep --error --config "p/cwe-top-25" --config "p/r2c-security-audit")