11# This file is for you! Edit it to implement your own hooks (make targets) into
22# the project as automated steps to be executed on locally and in the CD pipeline.
3+ # ==============================================================================
4+ SHELL =/bin/bash -euo pipefail
35
4- include scripts/init.mk
6+ # Installs dependencies using poetry.
7+ install-python :
8+ poetry install
59
6- # ==============================================================================
10+ # Installs dependencies using npm.
11+ install-node :
12+ npm install --legacy-peer-deps
13+ cd sandbox && npm install --legacy-peer-deps
14+
15+ # Configures Git Hooks, which are scripts that run given a specified event.
16+ .git/hooks/pre-commit :
17+ cp scripts/pre-commit .git/hooks/pre-commit
18+
19+ # Condensed Target to run all targets above.
20+ install : install-node install-python .git/hooks/pre-commit
21+
22+ # Run the npm linting script (specified in package.json). Used to check the syntax and formatting of files.
23+ lint :
24+ npm run lint
25+ find . -name ' *.py' -not -path ' **/.venv/*' | xargs poetry run flake8
26+
27+ # Removes build/ + dist/ directories
28+ clean :
29+ rm -rf build
30+ rm -rf dist
31+
32+ # Creates the fully expanded OAS spec in json
33+ publish : clean
34+ mkdir -p build
35+ npm run publish 2> /dev/null
36+
37+ # Files to loop over in release
38+ _dist_include ="pytest.ini poetry.lock poetry.toml pyproject.toml Makefile build/. tests"
39+
40+ # Create /dist/ sub-directory and copy files into directory
41+ release : clean publish build-proxy
42+ mkdir -p dist
43+ for f in $( _dist_include) ; do cp -r $$ f dist; done
44+ cp ecs-proxies-deploy.yml dist/ecs-deploy-sandbox.yml
45+ cp ecs-proxies-deploy.yml dist/ecs-deploy-internal-qa-sandbox.yml
46+ cp ecs-proxies-deploy.yml dist/ecs-deploy-internal-dev-sandbox.yml
747
848# Example CI/CD targets are: dependencies, build, publish, deploy, clean, etc.
949
@@ -19,9 +59,6 @@ publish: # Publish the project artefact @Pipeline
1959deploy : # Deploy the project artefact to the target environment @Pipeline
2060 # TODO: Implement the artefact deployment step
2161
22- clean :: # Clean-up project resources (main) @Operations
23- # TODO: Implement project resources clean-up step
24-
2562config :: # Configure development environment (main) @Configuration
2663 # TODO: Use only 'make' targets that are specific to this project, e.g. you may not need to install Node.js
2764 make _install-dependencies
@@ -34,3 +71,37 @@ ${VERBOSE}.SILENT: \
3471 config \
3572 dependencies \
3673 deploy \
74+ # ################
75+ # Test commands #
76+ # ################
77+
78+ TEST_CMD := @APIGEE_ACCESS_TOKEN=$(APIGEE_ACCESS_TOKEN ) \
79+ poetry run pytest -v \
80+ --color=yes \
81+ --api-name=eligibility-signposting-api \
82+ --proxy-name=$(PROXY_NAME ) \
83+ -s
84+
85+ PROD_TEST_CMD := $(TEST_CMD ) \
86+ --apigee-app-id=$(APIGEE_APP_ID ) \
87+ --apigee-organization=nhsd-prod \
88+ --status-endpoint-api-key=$(STATUS_ENDPOINT_API_KEY )
89+
90+ # Command to run end-to-end smoketests post-deployment to verify the environment is working
91+ smoketest :
92+ $(TEST_CMD ) \
93+ --junitxml=smoketest-report.xml \
94+ -m smoketest
95+
96+ test :
97+ $(TEST_CMD ) \
98+ --junitxml=test-report.xml \
99+
100+ smoketest-prod :
101+ $(PROD_TEST_CMD ) \
102+ --junitxml=smoketest-report.xml \
103+ -m smoketest
104+
105+ test-prod :
106+ $(PROD_CMD ) \
107+ --junitxml=test-report.xml \
0 commit comments