Skip to content

Commit 7f4084f

Browse files
authored
Update readme (#13)
## Summary - Routine Change ### Details - update readme - update pull request limit for dependabot
1 parent fbe229b commit 7f4084f

3 files changed

Lines changed: 215 additions & 18 deletions

File tree

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ updates:
2929
rebase-strategy: "disabled"
3030
schedule:
3131
interval: "daily"
32+
open-pull-requests-limit: 20
3233

3334
###################################
3435
# Poetry #########################

Makefile

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ guard-%:
44
exit 1; \
55
fi
66

7-
7+
# install targets
88
install: install-python install-hooks
99

1010
install-python:
@@ -13,6 +13,7 @@ install-python:
1313
install-hooks: install-python
1414
poetry run pre-commit install --install-hooks --overwrite
1515

16+
# lint targets
1617
lint: lint-samtemplates lint-python lint-githubactions lint-githubaction-scripts
1718

1819
lint-python:
@@ -27,13 +28,20 @@ lint-githubactions:
2728
lint-githubaction-scripts:
2829
shellcheck .github/scripts/*.sh
2930

31+
# test targets
32+
3033
test: download-dependencies
3134
mvn test
3235

33-
check-licenses:
36+
check-licenses: check-licenses-python check-licenses-java
37+
38+
check-licenses-python:
3439
scripts/check_python_licenses.sh
35-
mvn validate
3640

41+
check-licenses-java:
42+
mvn validate
43+
44+
# clean targets
3745
clean-packages:
3846
rm -f src/main/resources/package/*.tgz
3947

@@ -42,17 +50,21 @@ clean: clean-packages
4250
mvn clean
4351
rm -rf .aws-sam
4452

45-
build: download-dependencies
46-
mvn package
47-
48-
build-latest: clean-packages update-manifest build
53+
deep-clean: clean
54+
rm -rf .venv
55+
rm -rf .idea
56+
rm -rf .mvn
57+
rm -rf src/main/main.iml
58+
rm -rf src/test/test.iml
4959

50-
run:
51-
mvn spring-boot:run
60+
# build targets
61+
compile: download-dependencies
62+
mvn package
5263

5364
download-dependencies:
5465
poetry run scripts/download_dependencies.py
5566

67+
# SAM targets
5668
sam-validate:
5769
sam validate --template-file SAMtemplates/main_template.yaml --region eu-west-2
5870
sam validate --template-file SAMtemplates/lambda_resources.yaml --region eu-west-2

README.md

Lines changed: 193 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1-
# validation-service-fhir-r4
1+
# eps-FHIR-validator-lambda
22

3-
This service can be used to validate FHIR R4 messages against implementation guides on [Simplifier](https://simplifier.net/).
3+
![Build](https://github.com/NHSDigital/eps-FHIR-validator-lambda/workflows/release/badge.svg?branch=main)
4+
5+
This contains a cloud formation stack which contains a lambda which can be used to validate FHIR R4 messages against implementation guides on [Simplifier](https://simplifier.net/).
6+
7+
- `scripts/` Utilities helpful to developers of this specification.
8+
- `SAMtemplates/` Contains the SAM templates used to define the stack.
9+
- `.github` Contains github workflows that are used for building and deploying from pull requests and releases.
10+
- `.devcontainer` Contains a dockerfile and vscode devcontainer definition.
11+
- `src` Contains the java source code for the lambda
12+
13+
## Contributing
14+
15+
Contributions to this project are welcome from anyone, providing that they conform to the [guidelines for contribution](https://github.com/NHSDigital/eps-FHIR-validator-lambda/blob/main/CONTRIBUTING.md) and the [community code of conduct](https://github.com/NHSDigital/eps-FHIR-validator-lambda/blob/main/CODE_OF_CONDUCT.md).
16+
17+
### Licensing
18+
19+
This code is dual licensed under the MIT license and the OGL (Open Government License). Any new work added to this repository must conform to the conditions of these licenses. In particular this means that this project may not depend on GPL-licensed or AGPL-licensed libraries, as these would violate the terms of those libraries' licenses.
20+
21+
The contents of this repository are protected by Crown Copyright (C).
22+
23+
## Updates to implementation guide versions
24+
25+
The implementation guides and versions are defined in `src/resources/manifest.json`. When we need to update to a newer version, just update this file and run `make download-dependencies` to download them locally.
426

5-
## Customising the validator
6-
The Simplifier packages to be used for validation are declared in manifest.json. These are downloaded at build time and included in the jar.
727

828
## Known limitations
929
* Resources must use FHIR version R4
@@ -13,9 +33,173 @@ The Simplifier packages to be used for validation are declared in manifest.json.
1333
* A capability statement in the packages specifies which profile to use for a given resource type
1434
* The validator does not use a terminology server, so some code systems, including SNOMED, cannot be validated
1535

16-
## How to update validator in EPS
17-
From repo root, run:
18-
- `make install`
19-
- `make build-latest`
2036

21-
Commit and push changes to a branch. Get merged into main and reference new commit from EPS repo
37+
## Development
38+
39+
It is recommended that you use visual studio code and a devcontainer as this will install all necessary components and correct versions of tools and languages.
40+
See https://code.visualstudio.com/docs/devcontainers/containers for details on how to set this up on your host machine.
41+
There is also a workspace file in .vscode that should be opened once you have started the devcontainer. The workspace file can also be opened outside of a devcontainer if you wish.
42+
The project uses [SAM](https://aws.amazon.com/serverless/sam/) to develop and deploy the APIs and associated resources.
43+
44+
All commits must be made using [signed commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)
45+
46+
Once the steps at the link above have been completed. Add to your ~/.gnupg/gpg.conf as below:
47+
48+
```
49+
use-agent
50+
pinentry-mode loopback
51+
```
52+
53+
and to your ~/.gnupg/gpg-agent.conf as below:
54+
55+
```
56+
allow-loopback-pinentry
57+
```
58+
59+
As described here:
60+
https://stackoverflow.com/a/59170001
61+
62+
You will need to create the files, if they do not already exist.
63+
This will ensure that your VSCode bash terminal prompts you for your GPG key password.
64+
65+
You can cache the gpg key passphrase by following instructions at https://superuser.com/questions/624343/keep-gnupg-credentials-cached-for-entire-user-session
66+
67+
### SAM setup and usage
68+
69+
[SAM](https://aws.amazon.com/serverless/sam/) allows rapid local development and deployment to AWS for development and testing.
70+
71+
### Setup
72+
73+
Ensure you have the following lines in the file .envrc
74+
75+
```
76+
export AWS_DEFAULT_PROFILE=prescription-dev
77+
export stack_name=<UNIQUE_NAME_FOR_YOU>
78+
```
79+
80+
UNIQUE_NAME_FOR_YOU should be a unique name for you with no underscores in it - eg anthony-brown-1
81+
82+
Once you have saved .envrc, start a new terminal in vscode and run this command to authenticate against AWS
83+
84+
```
85+
make aws-configure
86+
```
87+
88+
Put the following values in:
89+
90+
```
91+
SSO session name (Recommended): sso-session
92+
SSO start URL [None]: <USE VALUE OF SSO START URL FROM AWS LOGIN COMMAND LINE ACCESS INSTRUCTIONS ACCESSED FROM https://myapps.microsoft.com>
93+
SSO region [None]: eu-west-2
94+
SSO registration scopes [sso:account:access]:
95+
```
96+
97+
This will then open a browser window and you should authenticate with your hscic credentials
98+
You should then select the development account and set default region to be eu-west-2.
99+
100+
You will now be able to use AWS and SAM CLI commands to access the dev account. You can also use the AWS extension to view resources.
101+
102+
When the token expires, you may need to reauthorise using `make aws-login`
103+
104+
### CI Setup
105+
106+
The GitHub Actions require a secret to exist on the repo called "SONAR_TOKEN".
107+
This can be obtained from [SonarCloud](https://sonarcloud.io/)
108+
as described [here](https://docs.sonarsource.com/sonarqube/latest/user-guide/user-account/generating-and-using-tokens/).
109+
You will need the "Execute Analysis" permission for the project (NHSDigital_prescriptionsforpatients) in order for the token to work.
110+
111+
112+
### Continuous deployment for testing
113+
114+
You can run the following command to deploy the code to AWS for testing
115+
116+
```
117+
make sam-sync
118+
```
119+
120+
This will take a few minutes to deploy - you will see something like this when deployment finishes
121+
122+
```
123+
......
124+
CloudFormation events from stack operations (refresh every 0.5 seconds)
125+
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
126+
ResourceStatus ResourceType LogicalResourceId ResourceStatusReason
127+
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
128+
.....
129+
CREATE_IN_PROGRESS AWS::ApiGatewayV2::ApiMapping HttpApiGatewayApiMapping -
130+
CREATE_IN_PROGRESS AWS::ApiGatewayV2::ApiMapping HttpApiGatewayApiMapping Resource creation Initiated
131+
CREATE_COMPLETE AWS::ApiGatewayV2::ApiMapping HttpApiGatewayApiMapping -
132+
CREATE_COMPLETE AWS::CloudFormation::Stack ab-1 -
133+
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
134+
135+
136+
Stack creation succeeded. Sync infra completed.
137+
```
138+
139+
Note - the command will keep running and should not be stopped.
140+
141+
142+
### Make commands
143+
144+
There are `make` commands that are run as part of the CI pipeline and help alias some functionality during development.
145+
146+
#### install targets
147+
148+
- `install-python` installs python dependencies
149+
- `install-hooks` installs git pre commit hooks
150+
- `install` runs all install targets
151+
152+
#### SAM targets
153+
154+
These are used to do common commands
155+
156+
- `sam-build` prepares the lambdas and SAM definition file to be used in subsequent steps
157+
- `sam-sync` sync the API and lambda to AWS. This keeps running and automatically uploads any changes to lambda code made locally. Needs AWS_DEFAULT_PROFILE and stack_name environment variables set.
158+
- `sam-validate` validates the main SAM template and the splunk firehose template.
159+
- `sam-deploy-package` deploys a package created by sam-build. Used in CI builds. Needs the following environment variables set
160+
- artifact_bucket - bucket where uploaded packaged files are
161+
- artifact_bucket_prefix - prefix in bucket of where uploaded packaged files ore
162+
- stack_name - name of stack to deploy
163+
- template_file - name of template file created by sam-package
164+
- cloud_formation_execution_role - ARN of role that cloud formation assumes when applying the changeset
165+
166+
167+
#### Clean and deep-clean targets
168+
169+
- `clean` clears up any files that have been generated by building or testing locally.
170+
- `deep-clean` runs clean target and also removes any maven and python libraries installed locally.
171+
172+
#### Linting and testing
173+
174+
- `lint` runs lint for all code
175+
- `lint-python` runs lint for python scripts
176+
- `lint-samtemplates` runs lint for SAM templates
177+
- `lint-githubactions` runs lint for github actions
178+
- `lint-githubactions-scriptns` runs lint for github actions scripts
179+
- `test` runs unit tests for all code
180+
181+
#### Compiling
182+
183+
- `compile` compiles all code
184+
- `download-dependencies` downloads files from simplifier
185+
186+
#### Check licenses
187+
188+
- `check-licenses` checks licenses for all packages used - calls check-licenses-java, check-licenses-python, check-licenses-golang
189+
- `check-licenses-java` checks licenses for all java code
190+
- `check-licenses-python` checks licenses for all python code
191+
192+
#### CLI Login to AWS
193+
194+
- `aws-configure` configures a connection to AWS
195+
- `aws-login` reconnects to AWS from a previously configured connection
196+
197+
198+
### Pre-commit hooks
199+
200+
Some pre-commit hooks are installed as part of the install above, to run basic lint checks and ensure you can't accidentally commit invalid changes.
201+
The pre-commit hook uses python package pre-commit and is configured in the file .pre-commit-config.yaml.
202+
A combination of these checks are also run in CI.
203+
204+
205+

0 commit comments

Comments
 (0)