Skip to content

Commit c128146

Browse files
committed
adding relevant files from APIM repo
1 parent 5348473 commit c128146

20 files changed

+593
-8
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ root = true
33
[*]
44
charset = utf-8
55
end_of_line = lf
6-
indent_size = 2
6+
indent_size = 4
77
indent_style = space
88
insert_final_newline = true
99
trim_trailing_whitespace = true

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,27 @@
1111
!project.code-workspace
1212

1313
# Please, add your custom content below!
14+
15+
.direnv
16+
node_modules/
17+
bin/
18+
dist/
19+
build/
20+
public/
21+
newman/
22+
.idea
23+
.DS_Store
24+
.#*
25+
26+
__pycache__/
27+
.envrc
28+
.idea/
29+
.venv/
30+
31+
smoketest-report.xml
32+
env
33+
.dir-locals.el
34+
*.pyc
35+
poetry.lock
36+
package-lock.json
37+
test-report.xml

Makefile

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,49 @@
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
1959
deploy: # 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-
2562
config:: # 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 \

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ cd nhs-england-tools/repository-template
4646
The following software packages, or their equivalents, are expected to be installed and configured:
4747

4848
- [Docker](https://www.docker.com/) container runtime or a compatible tool, e.g. [Podman](https://podman.io/),
49-
- [asdf](https://asdf-vm.com/) version manager,
5049
- [GNU make](https://www.gnu.org/software/make/) 3.82 or later,
5150

5251
> [!NOTE]<br>
@@ -72,7 +71,7 @@ The following software packages, or their equivalents, are expected to be instal
7271
Installation and configuration of the toolchain dependencies
7372
7473
```shell
75-
make config
74+
$ make install
7675
```
7776
7877
## Usage

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "eligibility-signposting-api",
3+
"version": "0.0.1",
4+
"description": "OAS (Swagger v3) API Definition for Template API",
5+
"scripts": {
6+
"lint": "node_modules/.bin/openapi-generator-cli validate -i specification/eligibility-signposting-api.yaml",
7+
"publish": "./node_modules/.bin/openapi-generator-cli generate -i specification/eligibility-signposting-api.yaml --generator-key v3.0 -g openapi -o build && rm openapitools.json && mv build/openapi.json build/eligibility-signposting-api.json",
8+
"check-licenses": "node_modules/.bin/license-checker --failOn GPL --failOn LGPL"
9+
},
10+
"author": "NHS Digital",
11+
"license": "MIT",
12+
"homepage": "https://github.com/NHSDigital/eligibility-signposting-api",
13+
"devDependencies": {
14+
"@openapitools/openapi-generator-cli": "^2.5.1",
15+
"apigeetool": "^0.5.4",
16+
"license-checker": "^25.0.1",
17+
"minimist": "^1.2.2"
18+
}
19+
}

poetry.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[virtualenvs]
2+
in-project = true

pyproject.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[project]
2+
python = "^3.8"
3+
4+
[tool.poetry]
5+
name = "eligibility-signposting-api"
6+
version = "0.0.1-alpha"
7+
description = "TODO"
8+
authors = [
9+
#TODO add authors
10+
]
11+
readme = 'README.md'
12+
license = "MIT"
13+
repository = "https://github.com/NHSDigital/eligibility-signposting"
14+
homepage = "https://digital.nhs.uk/developer/api-catalogue"
15+
keywords = ["healthcare", "uk", "nhs"] #TODO add additional keywords
16+
17+
18+
[tool.poetry.dependencies]
19+
python = "^3.8"
20+
pytest-nhsd-apim = "^3.3.2"
21+
22+
[tool.poetry.dev-dependencies]
23+
flake8 = "^3.7.9"
24+
black = "^20.8b1"
25+
pip-licenses = "^2.0.1"
26+
jinja2 = "^2.11.1"
27+
pyyaml = "^5.2"
28+
docopt = "^0.6.2"
29+
jsonpath-rw = "^1.4.0"
30+
semver = "^2.9.0"
31+
gitpython = "^3.0.5"
32+
pytest = "^6.1.2"
33+
coverage = "^5.5"
34+
aiohttp = "^3.7.3"
35+
pytest-asyncio = "^0.14.0"
36+
37+
[tool.poetry.scripts]

pytest.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[pytest]
2+
python_files = *_tests.py test_*.py
3+
norecursedirs = .venv .eggs build dist utils
4+
addopts = --strict-markers
5+
markers =
6+
e2e: end to end tests
7+
smoketest: suitable to run against all environments even production

sandbox/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

sandbox/.eslintrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
"env": {
3+
"commonjs": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": "eslint:recommended",
8+
"globals": {
9+
"Atomics": "readonly",
10+
"SharedArrayBuffer": "readonly"
11+
},
12+
"parserOptions": {
13+
"ecmaVersion": 2018
14+
},
15+
"rules": {
16+
}
17+
};

0 commit comments

Comments
 (0)