Skip to content

Commit a91a4e0

Browse files
AEA-3248 _status Endpoint (#87)
1 parent 03d7f39 commit a91a4e0

22 files changed

+515
-169
lines changed

.github/workflows/pull_request.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,22 @@ jobs:
3838
}
3939
result-encoding: string
4040

41+
get_commit_id:
42+
runs-on: ubuntu-latest
43+
outputs:
44+
commit_id: ${{ steps.commit_id.outputs.commit_id }}
45+
steps:
46+
- name: Get Commit ID
47+
id: commit_id
48+
run: |
49+
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
50+
4151
package_code:
4252
needs: get_issue_number
4353
uses: ./.github/workflows/sam_package_code.yml
4454

4555
release_code:
46-
needs: [get_issue_number, package_code]
56+
needs: [get_issue_number, package_code, get_commit_id]
4757
uses: ./.github/workflows/sam_release_code.yml
4858
with:
4959
STACK_NAME: PR-${{needs.get_issue_number.outputs.issue_number}}
@@ -53,13 +63,15 @@ jobs:
5363
DEPLOY_SANDBOX: false
5464
BUILD_ARTIFACT: packaged_code
5565
TRUSTSTORE_FILE: truststore.pem
66+
VERSION_NUMBER: PR-${{ needs.get_issue_number.outputs.issue_number }}
67+
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
5668
secrets:
5769
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
5870
SPLUNK_HEC_TOKEN: ${{ secrets.DEV_SPLUNK_HEC_TOKEN }}
5971
TARGET_SPINE_SERVER: ${{ secrets.DEV_TARGET_SPINE_SERVER }}
6072

6173
release_sandbox_code:
62-
needs: [get_issue_number, package_code]
74+
needs: [get_issue_number, package_code, get_commit_id]
6375
uses: ./.github/workflows/sam_release_code.yml
6476
with:
6577
STACK_NAME: PR-sandbox-${{needs.get_issue_number.outputs.issue_number}}
@@ -69,6 +81,8 @@ jobs:
6981
DEPLOY_SANDBOX: true
7082
BUILD_ARTIFACT: packaged_sandbox_code
7183
TRUSTSTORE_FILE: sandbox-truststore.pem
84+
VERSION_NUMBER: PR-${{ needs.get_issue_number.outputs.issue_number }}
85+
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
7286
secrets:
7387
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
7488
SPLUNK_HEC_TOKEN: ${{ secrets.DEV_SPLUNK_HEC_TOKEN }}

.github/workflows/release.yml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ jobs:
1212
quality_checks:
1313
uses: ./.github/workflows/quality_checks.yml
1414

15+
get_commit_id:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
commit_id: ${{ steps.commit_id.outputs.commit_id }}
19+
steps:
20+
- name: Get Commit ID
21+
id: commit_id
22+
run: |
23+
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
24+
1525
tag_release:
1626
needs: quality_checks
1727
runs-on: ubuntu-latest
@@ -68,7 +78,7 @@ jobs:
6878
uses: ./.github/workflows/sam_package_code.yml
6979

7080
release_dev:
71-
needs: [tag_release, package_code]
81+
needs: [tag_release, package_code, get_commit_id]
7282
uses: ./.github/workflows/sam_release_code.yml
7383
with:
7484
ARTIFACT_BUCKET_PREFIX: ${{needs.tag_release.outputs.spec_version}}
@@ -78,13 +88,15 @@ jobs:
7888
DEPLOY_SANDBOX: false
7989
BUILD_ARTIFACT: packaged_code
8090
TRUSTSTORE_FILE: truststore.pem
91+
VERSION_NUMBER: ${{needs.tag_release.outputs.spec_version}}
92+
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
8193
secrets:
8294
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
8395
SPLUNK_HEC_TOKEN: ${{ secrets.DEV_SPLUNK_HEC_TOKEN }}
8496
TARGET_SPINE_SERVER: ${{ secrets.DEV_TARGET_SPINE_SERVER }}
8597

8698
release_dev_sandbox:
87-
needs: [tag_release, package_code]
99+
needs: [tag_release, package_code, get_commit_id]
88100
uses: ./.github/workflows/sam_release_code.yml
89101
with:
90102
ARTIFACT_BUCKET_PREFIX: ${{needs.tag_release.outputs.spec_version}}
@@ -94,13 +106,15 @@ jobs:
94106
DEPLOY_SANDBOX: true
95107
BUILD_ARTIFACT: packaged_sandbox_code
96108
TRUSTSTORE_FILE: sandbox-truststore.pem
109+
VERSION_NUMBER: ${{needs.tag_release.outputs.spec_version}}
110+
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
97111
secrets:
98112
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
99113
SPLUNK_HEC_TOKEN: ${{ secrets.DEV_SPLUNK_HEC_TOKEN }}
100114
TARGET_SPINE_SERVER: sandbox
101115

102116
release_ref:
103-
needs: [tag_release, release_dev, release_dev_sandbox, package_code]
117+
needs: [tag_release, release_dev, release_dev_sandbox, package_code, get_commit_id]
104118
uses: ./.github/workflows/sam_release_code.yml
105119
with:
106120
ARTIFACT_BUCKET_PREFIX: ${{needs.tag_release.outputs.spec_version}}
@@ -110,13 +124,15 @@ jobs:
110124
DEPLOY_SANDBOX: false
111125
BUILD_ARTIFACT: packaged_code
112126
TRUSTSTORE_FILE: truststore.pem
127+
VERSION_NUMBER: ${{needs.tag_release.outputs.spec_version}}
128+
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
113129
secrets:
114130
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.REF_CLOUD_FORMATION_DEPLOY_ROLE }}
115131
SPLUNK_HEC_TOKEN: ${{ secrets.REF_SPLUNK_HEC_TOKEN }}
116132
TARGET_SPINE_SERVER: ${{ secrets.REF_TARGET_SPINE_SERVER }}
117133

118134
release_qa:
119-
needs: [tag_release, release_dev, release_dev_sandbox, package_code]
135+
needs: [tag_release, release_dev, release_dev_sandbox, package_code, get_commit_id]
120136
uses: ./.github/workflows/sam_release_code.yml
121137
with:
122138
ARTIFACT_BUCKET_PREFIX: ${{needs.tag_release.outputs.spec_version}}
@@ -126,13 +142,15 @@ jobs:
126142
DEPLOY_SANDBOX: false
127143
BUILD_ARTIFACT: packaged_code
128144
TRUSTSTORE_FILE: truststore.pem
145+
VERSION_NUMBER: ${{needs.tag_release.outputs.spec_version}}
146+
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
129147
secrets:
130148
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
131149
SPLUNK_HEC_TOKEN: ${{ secrets.QA_SPLUNK_HEC_TOKEN }}
132150
TARGET_SPINE_SERVER: ${{ secrets.QA_TARGET_SPINE_SERVER }}
133151

134152
release_int:
135-
needs: [tag_release, release_qa, package_code]
153+
needs: [tag_release, release_qa, package_code, get_commit_id]
136154
uses: ./.github/workflows/sam_release_code.yml
137155
with:
138156
ARTIFACT_BUCKET_PREFIX: ${{needs.tag_release.outputs.spec_version}}
@@ -142,13 +160,15 @@ jobs:
142160
DEPLOY_SANDBOX: false
143161
BUILD_ARTIFACT: packaged_code
144162
TRUSTSTORE_FILE: truststore.pem
163+
VERSION_NUMBER: ${{needs.tag_release.outputs.spec_version}}
164+
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
145165
secrets:
146166
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.INT_CLOUD_FORMATION_DEPLOY_ROLE }}
147167
SPLUNK_HEC_TOKEN: ${{ secrets.INT_SPLUNK_HEC_TOKEN }}
148168
TARGET_SPINE_SERVER: ${{ secrets.INT_TARGET_SPINE_SERVER }}
149169

150170
release_sandbox:
151-
needs: [tag_release, release_qa, package_code]
171+
needs: [tag_release, release_qa, package_code, get_commit_id]
152172
uses: ./.github/workflows/sam_release_code.yml
153173
with:
154174
ARTIFACT_BUCKET_PREFIX: ${{needs.tag_release.outputs.spec_version}}
@@ -158,13 +178,15 @@ jobs:
158178
DEPLOY_SANDBOX: true
159179
BUILD_ARTIFACT: packaged_sandbox_code
160180
TRUSTSTORE_FILE: sandbox-truststore.pem
181+
VERSION_NUMBER: ${{needs.tag_release.outputs.spec_version}}
182+
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
161183
secrets:
162184
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.INT_CLOUD_FORMATION_DEPLOY_ROLE }}
163185
SPLUNK_HEC_TOKEN: ${{ secrets.INT_SPLUNK_HEC_TOKEN }}
164186
TARGET_SPINE_SERVER: sandbox
165187

166188
release_prod:
167-
needs: [tag_release, release_int, release_sandbox, package_code]
189+
needs: [tag_release, release_int, release_sandbox, package_code, get_commit_id]
168190
uses: ./.github/workflows/sam_release_code.yml
169191
with:
170192
ARTIFACT_BUCKET_PREFIX: ${{needs.tag_release.outputs.spec_version}}
@@ -174,6 +196,8 @@ jobs:
174196
DEPLOY_SANDBOX: false
175197
BUILD_ARTIFACT: packaged_code
176198
TRUSTSTORE_FILE: truststore.pem
199+
VERSION_NUMBER: ${{needs.tag_release.outputs.spec_version}}
200+
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
177201
secrets:
178202
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.PROD_CLOUD_FORMATION_DEPLOY_ROLE }}
179203
SPLUNK_HEC_TOKEN: ${{ secrets.PROD_SPLUNK_HEC_TOKEN }}

.github/workflows/sam_release_code.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ on:
2424
TRUSTSTORE_FILE:
2525
required: true
2626
type: string
27+
VERSION_NUMBER:
28+
required: true
29+
type: string
30+
COMMIT_ID:
31+
required: true
32+
type: string
2733
secrets:
2834
CLOUD_FORMATION_DEPLOY_ROLE:
2935
required: true
@@ -56,6 +62,7 @@ jobs:
5662
- shell: bash
5763
name: release code
5864
run: |
65+
echo ${{ inputs.COMMIT_ID }}
5966
export artifact_bucket=$(aws cloudformation list-exports --output json | \
6067
jq -r '.Exports[] | select(.Name == "ci-resources:ArtifactsBucket") | .Value' |grep -o '[^:]*$')
6168
export artifact_bucket_prefix=${{ inputs.ARTIFACT_BUCKET_PREFIX }}
@@ -64,6 +71,8 @@ jobs:
6471
export SPLUNK_HEC_ENDPOINT=${{ vars.SPLUNK_STRUCTURED_ENDPOINT }}
6572
export SPLUNK_HEC_TOKEN=${{ secrets.SPLUNK_HEC_TOKEN }}
6673
export target_spine_server=${{ secrets.TARGET_SPINE_SERVER }}
74+
export VERSION_NUMBER=${{ inputs.VERSION_NUMBER }}
75+
export COMMIT_ID=${{ inputs.COMMIT_ID }}
6776
export cloud_formation_execution_role=$(aws cloudformation list-exports --output json | \
6877
jq -r '.Exports[] | select(.Name == "ci-resources:CloudFormationExecutionRole") | .Value' )
6978
TRUSTSTORE_BUCKET_ARN=$(aws cloudformation describe-stacks \

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,14 @@ repos:
4545
types_or: [ts, tsx, javascript, jsx, json]
4646
pass_filenames: false
4747

48+
- id: lint-statusLambda
49+
name: Lint statusLambda
50+
entry: npm
51+
args: ["run", "--prefix=packages/statusLambda", "lint"]
52+
language: system
53+
files: ^packages\/statusLambda
54+
types_or: [ts, tsx, javascript, jsx, json]
55+
pass_filenames: false
56+
4857
fail_fast: true
4958
default_stages: [commit]

.vscode/prescriptionsforpatients.code-workspace

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
{
2828
"name": "packages/splunkProcessor",
2929
"path": "../packages/splunkProcessor"
30+
},
31+
{
32+
"name": "packages/statusLambda",
33+
"path": "../packages/statusLambda"
3034
}
3135
],
3236
"settings": {
@@ -113,7 +117,7 @@
113117
"streetsidesoftware.code-spell-checker",
114118
"timonwong.shellcheck",
115119
"mkhl.direnv",
116-
"bungcip.better-toml"
120+
"tamasfe.even-better-toml"
117121
]
118122
}
119123
}

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ sam-validate:
6565
sam-validate-sandbox:
6666
sam validate --template-file sandbox_template.yaml
6767

68-
sam-deploy-package: guard-artifact_bucket guard-artifact_bucket_prefix guard-stack_name guard-template_file guard-cloud_formation_execution_role guard-LATEST_TRUSTSTORE_VERSION guard-enable_mutual_tls guard-SPLUNK_HEC_TOKEN guard-SPLUNK_HEC_ENDPOINT
68+
sam-deploy-package: guard-artifact_bucket guard-artifact_bucket_prefix guard-stack_name guard-template_file guard-cloud_formation_execution_role guard-LATEST_TRUSTSTORE_VERSION guard-enable_mutual_tls guard-SPLUNK_HEC_TOKEN guard-SPLUNK_HEC_ENDPOINT guard-VERSION_NUMBER guard-COMMIT_ID
6969
sam deploy \
7070
--template-file $$template_file \
7171
--stack-name $$stack_name \
@@ -84,20 +84,24 @@ sam-deploy-package: guard-artifact_bucket guard-artifact_bucket_prefix guard-sta
8484
TruststoreVersion=$$LATEST_TRUSTSTORE_VERSION \
8585
EnableMutualTLS=$$enable_mutual_tls \
8686
TargetSpineServer=$$target_spine_server \
87-
EnableSplunk=true
87+
EnableSplunk=true \
88+
VersionNumber=$$VERSION_NUMBER \
89+
CommitId=$$COMMIT_ID
8890

8991
lint:
9092
npm run lint --workspace packages/capabilityStatement
9193
npm run lint --workspace packages/getMyPrescriptions
9294
npm run lint --workspace packages/middleware
9395
npm run lint --workspace packages/sandbox
9496
npm run lint --workspace packages/splunkProcessor
97+
npm run lint --workspace packages/statusLambda
9598

9699
test:
97100
npm run test --workspace packages/capabilityStatement
98101
npm run test --workspace packages/getMyPrescriptions
99102
npm run test --workspace packages/middleware
100103
npm run test --workspace packages/sandbox
104+
npm run test --workspace packages/statusLambda
101105

102106
clean:
103107
rm -rf packages/capabilityStatement/coverage

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Prescriptions API
22

3-
![Build](https://github.com/NHSDigital/prescriptionsforpatients/workflows/Build/badge.svg?branch=main)
3+
![Build](https://github.com/NHSDigital/prescriptionsforpatients/workflows/release/badge.svg?branch=main)
44

55
This is an API for accessing prescription information.
66

77
- `packages/getMyPrescriptions/` Get prescription details.
88
- `packages/splunkProcessor/` Processes CloudWatch logs for Splunk.
99
- `packages/sandbox/` Returns [static data](./packages/specification/examples/GetMyPrescriptions/Bundle/success.json) from the Sandbox
1010
- `packages/middleware/` A modified [middy-error-handler](https://github.com/schibsted/middy-error-handler) to return FHIR responses
11+
- `packages/statusLambda/` Returns the status of the getMyPrescriptions endpoint
1112
- `scripts/` Utilities helpful to developers of this specification.
1213
- `cloudformation/` Contains cloudformation files used to create resources for CI builds and deployments
1314
- `privateCA/` Contains script to create self signed CA certificate and a client certificate used for mutual TLS

package-lock.json

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"packages/middleware",
2323
"packages/sandbox",
2424
"packages/specification",
25-
"packages/splunkProcessor"
25+
"packages/splunkProcessor",
26+
"packages/statusLambda"
2627
],
2728
"private": true,
2829
"dependencies": {

packages/getMyPrescriptions/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"@aws-lambda-powertools/logger": "^1.10.0",
1818
"@middy/core": "^4.5.2",
1919
"@middy/input-output-logger": "^4.5.2",
20-
"@schibsted/middy-error-handler": "^4.2.2",
2120
"module-alias": "^2.2.3"
2221
},
2322
"_moduleAliases": {

0 commit comments

Comments
 (0)