-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
173 lines (141 loc) · 5.42 KB
/
Makefile
File metadata and controls
173 lines (141 loc) · 5.42 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
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
165
166
167
168
169
170
171
172
173
SHELL=/bin/bash -euo pipefail
#Installs dependencies using poetry.
install-python:
poetry install --no-root
#Installs dependencies using npm.
install-node:
npm install --legacy-peer-deps
cd sandbox && npm install --legacy-peer-deps
#Configures Git Hooks, which are scripts that run given a specified event.
install-git-hooks:
cp scripts/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
#Condensed Target to run all targets above.
install: install-node install-python install-git-hooks
#Run the npm linting script (specified in package.json). Used to check the syntax and formatting of files.
lint:
find . -name '*.py' -not -path '**/.venv/*' | xargs poetry run flake8
format:
find . -name '*.py' -not -path '**/.venv/*' | xargs poetry run black --check --line-length 120
format-apply:
find . -name '*.py' -not -path '**/.venv/*' | xargs poetry run black --line-length 120
#Removes build/ + dist/ directories
clean:
rm -rf build
rm -rf dist
# Generate Postman Collection
generate-postman-collection:
npx portman --cliOptionsFile scripts/portman/portman-cli.json
# Test Postman Collection
test-postman-collection:
# Optional arguments:
# SANDBOX_BASE_URL: The base URL for the sandbox environment (default is https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4)
npx newman run postman/validated_relationship_service.sandbox.postman_collection.json --env-var baseUrl=$(SANDBOX_BASE_URL)
#Creates the fully expanded OAS spec in json
publish: clean
mkdir -p build
npm run publish 2> /dev/null
#Runs build proxy script
build-proxy:
scripts/build_proxy.sh
#Files to loop over in release
_dist_include="pytest.ini poetry.lock poetry.toml pyproject.toml Makefile build/. tests"
#Create /dist/ sub-directory and copy files into directory
release: clean publish build-proxy
mkdir -p dist
for f in $(_dist_include); do cp -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=validated-relationships-service-api \
--proxy-name=$(PROXY_NAME) \
-s
PROD_TEST_CMD := $(TEST_CMD) \
--apigee-app-id=$(APIGEE_APP_ID) \
--apigee-organization=nhsd-prod \
--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 \
# Run schema validation check
GREEN := \033[32m
RESET := \033[0m
schema-all:
make schema-get-consent \
schema-post-consent \
schema-patch-consent \
schema-related-person \
schema-questionnaire \
schema-errors
schema-get-consent:
@find specification/examples/responses/GET_Consent -name "*.yaml" -type f | while read file; do \
echo "Processing $$file"; \
if echo "$$file" | grep -q "error"; then \
poetry run python scripts/validate_schema.py operationoutcome "$$(realpath $$file)"; \
else \
poetry run python scripts/validate_schema.py consent "$$(realpath $$file)"; \
fi; \
echo -e "$(GREEN)Success!$(RESET)"; \
done
schema-post-consent:
@find specification/examples/responses/POST_Consent -name "*.yaml" -type f | while read file; do \
echo "Processing $$file"; \
poetry run python scripts/validate_schema.py operationoutcome "$$(realpath $$file)"; \
echo -e "$(GREEN)Success!$(RESET)"; \
done
schema-patch-consent:
@find specification/examples/responses/PATCH_Consent -name "*.yaml" -type f | while read file; do \
echo "Processing $$file"; \
poetry run python scripts/validate_schema.py operationoutcome "$$(realpath $$file)"; \
echo -e "$(GREEN)Success!$(RESET)"; \
done
schema-related-person:
@find specification/examples/responses/GET_RelatedPerson -name "*.yaml" -type f | while read file; do \
echo "Processing $$file"; \
if echo "$$file" | grep -q "error"; then \
poetry run python scripts/validate_schema.py operationoutcome "$$(realpath $$file)"; \
else \
poetry run python scripts/validate_schema.py relatedperson "$$(realpath $$file)"; \
fi; \
echo -e "$(GREEN)Success!$(RESET)"; \
done
schema-questionnaire:
@find specification/examples/responses/POST_QuestionnaireResponse -name "*.yaml" -type f | while read file; do \
echo "Processing $$file"; \
poetry run python scripts/validate_schema.py operationoutcome "$$(realpath $$file)"; \
echo -e "$(GREEN)Success!$(RESET)"; \
done
schema-errors:
@find specification/examples/responses/errors -name "*.yaml" -type f | while read file; do \
echo "Processing $$file"; \
poetry run python scripts/validate_schema.py operationoutcome "$$(realpath $$file)"; \
echo -e "$(GREEN)Success!$(RESET)"; \
done
schema-get-questionnaire:
@find specification/examples/responses/GET_QuestionnaireResponse -name "*.yaml" -type f | while read file; do \
echo "Processing $$file"; \
if echo "$$file" | grep -q "error"; then \
poetry run python scripts/validate_schema.py operationoutcome "$$(realpath $$file)"; \
else \
poetry run python scripts/validate_schema.py questionnaireresponse "$$(realpath $$file)"; \
fi; \
echo -e "$(GREEN)Success!$(RESET)"; \
done