-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
164 lines (120 loc) · 4.63 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
UNAME := $(shell uname)
ifeq ($(EXPLICIT_TAG),)
EXPLICIT_TAG := latest
endif
COMMIT_TAG := $$(git log -1 --pretty=%h)
DL_APP_REMOTE_NAME := digital-land-platform
REPO := public.ecr.aws/l6z6v3j6
NAME := $(REPO)/$(DL_APP_REMOTE_NAME)
COMMIT_IMG := $(NAME):$(COMMIT_TAG)
EXPLICIT_IMG := $(NAME):$(EXPLICIT_TAG)
all:: lint
ifeq ($(UNAME), Darwin)
server: export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
endif
init::
python -m pip install pip-tools
python -m piptools sync requirements/requirements.txt requirements/dev-requirements.txt
python -m pre_commit install
npm install
init:: frontend-all
piptool-compile::
python -m piptools compile --output-file=requirements/requirements.txt requirements/requirements.in
python -m piptools compile requirements/dev-requirements.in
piptool-install::
python -m piptools sync requirements/requirements.txt requirements/dev-requirements.txt
postgresql::
sudo service postgresql start
insertBaseData::
python -c 'from tests.utils.database import reset_database; reset_database()'
python -c 'from tests.utils.database import *; add_base_entities_to_database(); add_base_datasets_to_database(); add_base_typology_to_database()'
emptyDatabase::
python -c 'from tests.utils.database import reset_database; reset_database()'
server:
echo $$OBJC_DISABLE_INITIALIZE_FORK_SAFETY
gunicorn -w 2 -k uvicorn.workers.UvicornWorker application.app:app --preload --forwarded-allow-ips="*"
docker-build:
docker build --build-arg RELEASE_TAG=$(COMMIT_TAG) --target production -t $(EXPLICIT_IMG) .
docker tag $(EXPLICIT_IMG) $(COMMIT_IMG)
push: docker-login
docker push $(COMMIT_IMG)
docker push $(EXPLICIT_IMG)
login:
aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin $(REPO)
docker-login:
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
test-acceptance:
python -m playwright install --with-deps chromium firefox webkit
python -m pytest --browser webkit --browser firefox --browser chromium --md-report --md-report-color=never -p no:warnings tests/acceptance
test-acceptance-debug:
python -m playwright install --with-deps chromium firefox webkit
PWDEBUG=1 python3 -m pytest --browser webkit --browser firefox --browser chromium --md-report --md-report-color=never -p no:warnings tests/acceptance
test-accessibility:
python -m playwright install chromium
python -m pytest --browser chromium --md-report --md-report-color=never -p no:warnings tests/accessibility
playwright-codegen:
python -m playwright codegen --viewport-size=800,600 localhost:8000
test: test-unit test-integration test-acceptance test-accessibility
test-js:
npm run test
test-js-unit:
npm run test-unit
test-js-integration:
npm run test-integration
test-unit:
python -m pytest --md-report --md-report-color=never --md-report-output=unit-tests.md tests/unit
npm run test-unit
test-integration:
python -m pytest --md-report --md-report-color=never --md-report-output=integration-tests.md tests/integration
npm run test-integration
test-integration-docker:
docker-compose run web python -m pytest tests/integration --junitxml=.junitxml/integration.xml $(PYTEST_RUNTIME_ARGS)
lint: black flake8
clean::
rm -rf static/
stylesheets::
npx nps build.stylesheets
govukAssets::
npx nps copy.govukAssets
javascripts:
npm run build
rsync -r assets/javascripts static/
robots:
cp assets/robots.txt static/robots.txt
frontend:
npm i
make javascripts
make robots
make stylesheets
make govukAssets
rsync -r assets/images static/
cp node_modules/maplibre-gl/dist/maplibre-gl.css static/stylesheets/maplibre-gl.css
mkdir -p static/govuk/assets
cp node_modules/govuk-frontend/govuk/all.js node_modules/govuk-frontend/govuk/all.js.map static/govuk
cp -r node_modules/govuk-frontend/govuk/assets/* static/govuk/assets
frontend-all: clean frontend
black:
black .
black-check:
black --check .
flake8:
flake8 .
server-dev:
make -j 2 server frontend-watch
load-db: login
docker-compose -f docker-compose.yml -f docker-compose.load-db.yml run load-db-dataset
docker-compose -f docker-compose.yml -f docker-compose.load-db.yml run load-db-entity
deploy: aws-deploy
aws-deploy:
ifeq (, $(ENVIRONMENT))
$(error "No environment specified via $$ENVIRONMENT, please pass as make argument")
endif
aws ecs update-service --force-new-deployment --service $(ENVIRONMENT)-web-service --cluster $(ENVIRONMENT)-web-cluster
.PHONY: docker-security-scan
docker-security-scan:
mkdir -p zap-working-dir
touch zap-working-dir/zap.log
chmod -R a+rw zap-working-dir
docker-compose \
-f docker-compose.security.yml \
run --rm zap