-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (105 loc) · 3.67 KB
/
Makefile
File metadata and controls
129 lines (105 loc) · 3.67 KB
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
SHELL=/usr/bin/env bash -euo pipefail
PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS = backend batch_processor_filter delta_backend filenameprocessor mesh_processor recordprocessor lambdas/ack_backend lambdas/redis_sync lambdas/id_sync lambdas/mns_subscription lambdas/shared
PYTHON_PROJECT_DIRS = tests/e2e tests/e2e_batch $(PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS)
#Installs dependencies using poetry.
install-python:
poetry lock --no-update
poetry install
#Installs dependencies using npm.
install-node:
npm install --legacy-peer-deps
#Configures Git Hooks, which are scripts that run given a specified event.
.git/hooks/pre-commit:
cp utilities/scripts/pre-commit .git/hooks/pre-commit
#Condensed Target to run all targets above.
install: install-node install-python .git/hooks/pre-commit
#Run the npm linting script (specified in package.json). Used to check the syntax and formatting of files.
lint:
npm run lint
find . -name '*.py' -not -path '**/.venv/*' -not -path '**/.terraform/*'| xargs poetry run flake8
#Removes build/ + dist/ directories
clean:
rm -rf build
rm -rf dist
#Creates the fully expanded OAS spec in json
publish: clean
mkdir -p build
npm run publish 2> /dev/null
cp build/immunisation-fhir-api.json utilities/sandbox/
cp -r utilities/specification utilities/sandbox/specification
#Runs build proxy script
build-proxy:
utilities/scripts/build_proxy.sh
#Files to loop over in release
# VED-811: remove everything except for proxy related files as we move to Github Actions for backend deployment
_dist_include="pytest.ini poetry.lock poetry.toml pyproject.toml Makefile build/. utilities/specification utilities/sandbox terraform utilities/scripts"
#Create /dist/ sub-directory and copy files into directory
#Ensure full dir structure is preserved for Lambdas
release: clean publish build-proxy
mkdir -p dist
for f in $(_dist_include); do cp -r $$f dist; done
for f in $(PYTHON_PROJECT_DIRS); do cp --parents -r $$f dist; done
cp ecs-proxies-deploy.yml dist/ecs-deploy-sandbox.yml
cp ecs-proxies-deploy.yml dist/ecs-deploy-internal-qa-sandbox.yml
cp ecs-proxies-deploy.yml dist/ecs-deploy-internal-dev-sandbox.yml
#################
# Test commands #
#################
TEST_CMD := @APIGEE_ACCESS_TOKEN=$(APIGEE_ACCESS_TOKEN) \
poetry run pytest -v \
--color=yes \
--api-name=immunisation-fhir-api \
--proxy-name=$(PROXY_NAME) \
-s
PROD_TEST_CMD := $(TEST_CMD) \
--apigee-app-id=$(APIGEE_APP_ID) \
--status-endpoint-api-key=$(STATUS_ENDPOINT_API_KEY)
#Command to run end-to-end smoketests post-deployment to verify the environment is working
smoketest:
$(TEST_CMD) \
--junitxml=smoketest-report.xml \
-m smoketest
test:
$(TEST_CMD) \
--junitxml=test-report.xml \
smoketest-prod:
$(PROD_TEST_CMD) \
--junitxml=smoketest-report.xml \
-m smoketest
test-prod:
$(PROD_CMD) \
--junitxml=test-report.xml \
setup-python-envs:
utilities/scripts/setup-python-envs.sh
initialise-all-python-venvs:
for dir in $(PYTHON_PROJECT_DIRS); do ( \
cd $$dir && \
pwd && \
rm -rf .venv && \
python -m venv .venv && \
source .venv/bin/activate && \
poetry install --no-root && \
deactivate \
); done
update-all-python-dependencies:
for dir in $(PYTHON_PROJECT_DIRS); do ( \
cd $$dir && \
pwd && \
source .venv/bin/activate && \
poetry update && \
deactivate \
); done
run-all-python-unit-tests:
for dir in $(PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS); do ( \
cd $$dir && \
pwd && \
source .venv/bin/activate && \
poetry run make test && \
deactivate \
); done
build-all-docker-images:
for dir in $(PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS); do \
for dockerfile in $$(ls $$dir/*Dockerfile); do \
echo $$dockerfile && docker build --file $$dockerfile $$dir; \
done; \
done