forked from uktrade/data-workspace-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
144 lines (112 loc) · 5.44 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
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
142
143
144
SHELL := /bin/bash
APPLICATION_NAME="uktrade / data-workspace"
APPLICATION_VERSION=1.0
# Colour coding for output
COLOUR_NONE=\033[0m
COLOUR_GREEN=\033[1;36m
COLOUR_YELLOW=\033[33;01m
.PHONY: help test
help:
@echo -e "$(COLOUR_GREEN)|--- $(APPLICATION_NAME) [$(APPLICATION_VERSION)] ---|$(COLOUR_NONE)"
@echo -e "$(COLOUR_YELLOW)make up$(COLOUR_NONE) : launches containers for local development"
@echo -e "$(COLOUR_YELLOW)make docker-test-shell-local$(COLOUR_NONE) : bash shell for the unit tests in a container with your local volume mounted"
@echo -e "$(COLOUR_YELLOW)make docker-test-unit-local$(COLOUR_NONE) : runs the unit tests in a container with your local volume mounted"
@echo -e "$(COLOUR_YELLOW)make docker-test-integration$(COLOUR_NONE) : runs the integration tests in a container (10 minutes min)"
@echo -e "$(COLOUR_YELLOW)make logout$(COLOUR_NONE): logs out the current user"
.PHONY: first-use
first-use:
docker network create data-infrastructure-shared-network || true
.PHONY: up
up: first-use
docker compose up
.PHONY: docker-build
docker-build:
docker compose --profile test build
.PHONY: docker-test-unit
docker-test-unit: TESTS ?= /dataworkspace/dataworkspace
docker-test-unit: docker-build
docker compose --profile test -p data-workspace-test run data-workspace-test pytest -vv --junitxml=/test-results/junit.xml $(TESTS)
.PHONY: docker-test-integration
docker-test-integration: TESTS ?= test/
docker-test-integration: docker-build
docker compose --profile test -p data-workspace-test run data-workspace-test pytest --junitxml=/test-results/junit.xml $(TESTS)
.PHONY: docker-test
docker-test: docker-test-integration docker-test-unit
.PHONY: docker-clean
docker-clean:
docker compose --profile test -p data-workspace-test down -v
.PHONY: check-flake8
check-flake8:
flake8 .
.PHONY: docker-check-migrations
docker-check-migrations:
docker compose --profile test -p data-workspace-test run data-workspace-test sh -c "sleep 5 && django-admin makemigrations --check --dry-run --verbosity 3"
.PHONY: check-black
check-black:
@black --version
black --check .
.PHONY: check-pylint
check-pylint:
env PYTHONPATH=app python3 -m pylint.__main__ --rcfile .pylintrc --output-format=colorized dataworkspace/dataworkspace test
.PHONY: check
check: check-flake8 check-black check-pylint
.PHONY: docker-check
docker-check:
docker compose run --rm data-workspace bash -c "cd /app && make check"
.PHONY: docker-format
docker-format: first-use
docker compose run --rm data-workspace bash -c "cd /app && black ."
.PHONY: format
format:
black .
.PHONY: dev-shell
dev-shell:
docker compose run --rm data-workspace bash
.PHONY: save-requirements
save-requirements:
docker compose run --rm data-workspace bash -c "cd /app && pip-compile requirements.in"
docker compose run --rm data-workspace bash -c "cd /app && pip-compile requirements-dev.in"
.PHONY: docker-test-unit-local
docker-test-unit-local:
TEST_DIR="$(TARGET)" ; \
if [ -z "$$TEST_DIR" ]; \
then TEST_DIR="/dataworkspace/dataworkspace"; \
fi; \
docker compose --profile test -p data-workspace-test run data-workspace-test pytest $$TEST_DIR -x -v --disable-warnings --reuse-db
.PHONY: docker-test-shell-local
docker-test-shell-local:
docker compose --profile test -p data-workspace-test run --rm data-workspace-test bash
.PHONY: docker-test-integration-local
docker-test-integration-local:
TEST_DIR="$(TARGET)" ; \
if [ -z "$$TEST_DIR" ]; \
then TEST_DIR="/test"; \
fi; \
docker compose --profile test -p data-workspace-test run --rm data-workspace-test bash -c "DJANGO_SETTINGS_MODULE=dataworkspace.settings.integration_tests pytest -x -v $$TEST_DIR --disable-warnings"
.PHONY: docker-test-local
docker-test-local: docker-test-unit-local docker-test-integration-local
.PHONY: logout
logout:
docker compose exec data-workspace-redis bash -c "redis-cli --scan --pattern data_workspace* | xargs redis-cli unlink"
.PHONY: docker-test-sequential
docker-test-sequential:
docker compose --profile test -p data-workspace-test stop
docker compose --profile test -p data-workspace-test rm -f
docker compose --profile test -p data-workspace-test up -d
docker compose --profile test -p data-workspace-test run --rm data-workspace-test pytest /test/test_application.py -x -v
docker compose --profile test -p data-workspace-test stop
docker compose --profile test -p data-workspace-test up -d
docker compose --profile test -p data-workspace-test run --rm data-workspace-test pytest /test/test_application_1.py -x -v
docker compose --profile test -p data-workspace-test stop
docker compose --profile test -p data-workspace-test up -d
docker compose --profile test -p data-workspace-test run --rm data-workspace-test pytest /test/test_application_2.py -x -v
docker compose --profile test -p data-workspace-test stop
docker compose --profile test -p data-workspace-test up -d
docker compose --profile test -p data-workspace-test run --rm data-workspace-test pytest /test/test_utils.py -x -v
docker compose --profile test -p data-workspace-test stop
docker compose --profile test -p data-workspace-test up -d
docker compose --profile test -p data-workspace-test run --rm data-workspace-test pytest /test/selenium/test_explorer.py -x -v
docker compose --profile test -p data-workspace-test stop
docker compose --profile test -p data-workspace-test up -d
docker compose --profile test -p data-workspace-test run --rm data-workspace-test pytest /test/selenium/test_request_data.py -x -v
docker compose --profile test -p data-workspace-test stop