Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into add_gsul
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-nhs committed Apr 8, 2024
2 parents 1f90595 + 2ae539d commit 1014799
Show file tree
Hide file tree
Showing 38 changed files with 1,819 additions and 859 deletions.
File renamed without changes.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ jobs:
STACK_NAME: psu
TARGET_ENVIRONMENT: dev
ENABLE_MUTUAL_TLS: false
DEPLOY_SANDBOX: false
BUILD_ARTIFACT: packaged_code
TRUSTSTORE_FILE: psu-truststore.pem
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
LOG_LEVEL: DEBUG
LOG_RETENTION_DAYS: 30
CREATE_INT_RELEASE_NOTES: true
CREATE_PROD_RELEASE_NOTES: true
Expand All @@ -117,12 +115,10 @@ jobs:
STACK_NAME: psu
TARGET_ENVIRONMENT: qa
ENABLE_MUTUAL_TLS: false
DEPLOY_SANDBOX: false
BUILD_ARTIFACT: packaged_code
TRUSTSTORE_FILE: psu-truststore.pem
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
LOG_LEVEL: DEBUG
LOG_RETENTION_DAYS: 30
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
18 changes: 16 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,26 @@ jobs:
ARTIFACT_BUCKET_PREFIX: PR-${{needs.get_issue_number.outputs.issue_number}}
TARGET_ENVIRONMENT: dev-pr
ENABLE_MUTUAL_TLS: false
DEPLOY_SANDBOX: false
BUILD_ARTIFACT: packaged_code
TRUSTSTORE_FILE: psu-truststore.pem
VERSION_NUMBER: PR-${{ needs.get_issue_number.outputs.issue_number }}
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
LOG_LEVEL: DEBUG
LOG_RETENTION_DAYS: 30
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}

release_sandbox_code:
needs: [get_issue_number, package_code, get_commit_id]
uses: ./.github/workflows/sam_release_code.yml
with:
STACK_NAME: psu-pr-${{needs.get_issue_number.outputs.issue_number}}-sandbox
ARTIFACT_BUCKET_PREFIX: PR-${{needs.get_issue_number.outputs.issue_number}}-sandbox
TARGET_ENVIRONMENT: dev-pr
ENABLE_MUTUAL_TLS: false
BUILD_ARTIFACT: packaged_sandbox_code
TRUSTSTORE_FILE: psu-sandbox-truststore.pem
VERSION_NUMBER: PR-${{ needs.get_issue_number.outputs.issue_number }}
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
LOG_RETENTION_DAYS: 30
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
10 changes: 0 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,10 @@ jobs:
STACK_NAME: psu
TARGET_ENVIRONMENT: dev
ENABLE_MUTUAL_TLS: false
DEPLOY_SANDBOX: false
BUILD_ARTIFACT: packaged_code
TRUSTSTORE_FILE: psu-truststore.pem
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
LOG_LEVEL: DEBUG
LOG_RETENTION_DAYS: 30
CREATE_INT_RELEASE_NOTES: true
CREATE_PROD_RELEASE_NOTES: true
Expand All @@ -142,12 +140,10 @@ jobs:
STACK_NAME: psu
TARGET_ENVIRONMENT: ref
ENABLE_MUTUAL_TLS: false
DEPLOY_SANDBOX: false
BUILD_ARTIFACT: packaged_code
TRUSTSTORE_FILE: psu-truststore.pem
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
LOG_LEVEL: DEBUG
LOG_RETENTION_DAYS: 30
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.REF_CLOUD_FORMATION_DEPLOY_ROLE }}
Expand All @@ -160,12 +156,10 @@ jobs:
STACK_NAME: psu
TARGET_ENVIRONMENT: qa
ENABLE_MUTUAL_TLS: false
DEPLOY_SANDBOX: false
BUILD_ARTIFACT: packaged_code
TRUSTSTORE_FILE: psu-truststore.pem
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
LOG_LEVEL: DEBUG
LOG_RETENTION_DAYS: 30
secrets:
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
Expand All @@ -178,12 +172,10 @@ jobs:
STACK_NAME: psu
TARGET_ENVIRONMENT: int
ENABLE_MUTUAL_TLS: false
DEPLOY_SANDBOX: false
BUILD_ARTIFACT: packaged_code
TRUSTSTORE_FILE: psu-truststore.pem
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
LOG_LEVEL: DEBUG
LOG_RETENTION_DAYS: 30
CREATE_INT_RELEASE_NOTES: true
CREATE_INT_RC_RELEASE_NOTES: true
Expand All @@ -202,12 +194,10 @@ jobs:
# STACK_NAME: psu
# TARGET_ENVIRONMENT: prod
# ENABLE_MUTUAL_TLS: true
# DEPLOY_SANDBOX: false
# BUILD_ARTIFACT: packaged_code
# TRUSTSTORE_FILE: psu-truststore.pem
# VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
# COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
# LOG_LEVEL: INFO
# LOG_RETENTION_DAYS: 731
# MARK_JIRA_RELEASED: true
# CREATE_PROD_RELEASE_NOTES: true
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/sam_package_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,23 @@ jobs:
name: packaged_code
path: |
.aws-sam/build
packages/updatePrescriptionStatus/lib/get-secrets-layer.zip
SAMtemplates/state_machines/UpdatePrescriptionStatusStateMachine.asl.json
- shell: bash
name: package sandbox
run: |
cp .tool-versions ~/
rm -rf .aws-sam
export PATH=$PATH:$PWD/node_modules/.bin
make sam-build-sandbox
cp Makefile .aws-sam/build/
cp samconfig_package_and_deploy.toml .aws-sam/build/
# Readme is included to stop the action flattening the folder structure of aws-sam/build when it is the only item to upload
- uses: actions/upload-artifact@v4
name: upload sandbox build artifact
with:
name: packaged_sandbox_code
path: |
.aws-sam/build
README.md
7 changes: 2 additions & 5 deletions .github/workflows/sam_release_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ on:
BUILD_ARTIFACT:
required: true
type: string
DEPLOY_SANDBOX:
required: true
type: boolean
TRUSTSTORE_FILE:
required: true
type: string
Expand All @@ -31,8 +28,9 @@ on:
required: true
type: string
LOG_LEVEL:
required: true
required: false
type: string
default: INFO
LOG_RETENTION_DAYS:
required: true
type: string
Expand Down Expand Up @@ -108,7 +106,6 @@ jobs:
env:
artifact_bucket_prefix: prescription_status_update/${{ inputs.ARTIFACT_BUCKET_PREFIX }}
COMMIT_ID: ${{ inputs.COMMIT_ID }}
deploy_sandbox: ${{ inputs.DEPLOY_SANDBOX }}
enable_mutual_tls: ${{ inputs.ENABLE_MUTUAL_TLS }}
LOG_LEVEL: ${{ inputs.LOG_LEVEL }}
LOG_RETENTION_DAYS: ${{ inputs.LOG_RETENTION_DAYS }}
Expand Down
51 changes: 34 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ repos:
types_or: [ts, tsx, javascript, jsx, json]
pass_filenames: false

- id: lint-sandbox
name: Lint sandbox
entry: npm
args: ["run", "--prefix=packages/sandbox", "lint"]
language: system
files: ^packages\/sandbox
types_or: [ts, tsx, javascript, jsx, json]
pass_filenames: false

- id: oas-build-checks
name: Build OAS
entry: make
Expand All @@ -40,23 +49,31 @@ repos:
files: ^(examples|packages\/specification)
types_or: [json, yaml]

# - id: lint-githubactions
# name: Lint github actions
# entry: make
# args: ["lint-githubactions"]
# language: system
# files: ^.github
# types_or: [yaml]
# pass_filenames: false

# - id: lint-githubaction-scripts
# name: Lint github action scripts
# entry: make
# args: ["lint-githubaction-scripts"]
# language: system
# files: ^.github/scripts
# types_or: [sh, shell]
# pass_filenames: false
- id: lint-samtemplates
name: Lint sam templates
entry: make
args: ["lint-samtemplates"]
language: system
files: ^SAMtemplates
pass_filenames: false

- id: lint-githubactions
name: Lint github actions
entry: make
args: ["lint-githubactions"]
language: system
files: ^.github
types_or: [yaml]
pass_filenames: false

- id: lint-githubaction-scripts
name: Lint github action scripts
entry: make
args: ["lint-githubaction-scripts"]
language: system
files: ^.github/scripts
types_or: [sh, shell]
pass_filenames: false

fail_fast: true
default_stages: [commit]
10 changes: 5 additions & 5 deletions .vscode/eps-prescription-status-update-api.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
{
"name": "packages/gsul",
"path": "../packages/gsul"
},
{
"name": "packages/sandbox",
"path": "../packages/sandbox"
}
],
"settings": {
Expand Down Expand Up @@ -85,11 +89,7 @@
"package-lock.json",
"node_modules",
".vscode"
],
"jest.jestCommandLine": "NODE_OPTIONS=--experimental-vm-modules node_modules/.bin/jest --no-cache",
"jest.nodeEnv": {
"POWERTOOLS_DEV": true
}
]
},
"extensions": {
"recommendations": [
Expand Down
26 changes: 22 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ build-specification:
sam-build: sam-validate compile
sam build --template-file SAMtemplates/main_template.yaml --region eu-west-2

sam-build-sandbox: sam-validate-sandbox compile
sam build --template-file SAMtemplates/sandbox_template.yaml --region eu-west-2

sam-run-local: sam-build
sam local start-api

Expand Down Expand Up @@ -56,9 +59,20 @@ sam-list-outputs: guard-AWS_DEFAULT_PROFILE guard-stack_name

sam-validate:
sam validate --template-file SAMtemplates/main_template.yaml --region eu-west-2
sam validate --template-file SAMtemplates/lambda_resources.yaml --region eu-west-2
sam validate --template-file SAMtemplates/apis/main.yaml --region eu-west-2
sam validate --template-file SAMtemplates/apis/api_resources.yaml --region eu-west-2
sam validate --template-file SAMtemplates/functions/main.yaml --region eu-west-2
sam validate --template-file SAMtemplates/functions/lambda_resources.yaml --region eu-west-2
sam validate --template-file SAMtemplates/tables/main.yaml --region eu-west-2
sam validate --template-file SAMtemplates/tables/dynamodb_resources.yaml --region eu-west-2
sam validate --template-file SAMtemplates/state_machines/main.yaml --region eu-west-2
sam validate --template-file SAMtemplates/state_machines/state_machine_resources.yaml --region eu-west-2


sam-validate-sandbox:
sam validate --template-file SAMtemplates/sandbox_template.yaml --region eu-west-2

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-VERSION_NUMBER guard-COMMIT_ID guard-LOG_LEVEL guard-LOG_RETENTION_DAYS guard-TARGET_ENVIRONMENT
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-VERSION_NUMBER guard-LOG_RETENTION_DAYS guard-TARGET_ENVIRONMENT
sam deploy \
--template-file $$template_file \
--stack-name $$stack_name \
Expand All @@ -79,7 +93,7 @@ sam-deploy-package: guard-artifact_bucket guard-artifact_bucket_prefix guard-sta
VersionNumber=$$VERSION_NUMBER \
CommitId=$$COMMIT_ID \
LogLevel=$$LOG_LEVEL \
LogRetentionDays=$$LOG_RETENTION_DAYS \
LogRetentionInDays=$$LOG_RETENTION_DAYS \
Env=$$TARGET_ENVIRONMENT

compile-node:
Expand All @@ -91,9 +105,10 @@ lint-node: compile-node
npm run lint --workspace packages/specification
npm run lint --workspace packages/updatePrescriptionStatus
npm run lint --workspace packages/gsul
npm run lint --workspace packages/sandbox

lint-samtemplates:
poetry run cfn-lint -t SAMtemplates/*.yaml
poetry run cfn-lint -t SAMtemplates/**/*.yaml

lint-python:
poetry run flake8 scripts/*.py --config .flake8
Expand All @@ -109,11 +124,14 @@ lint: lint-node lint-samtemplates lint-python lint-githubactions lint-githubacti
test: compile
npm run test --workspace packages/updatePrescriptionStatus
npm run test --workspace packages/gsul
npm run test --workspace packages/sandbox

#Removes build/ + dist/ directories
clean:
rm -rf packages/updatePrescriptionStatus/coverage
rm -rf packages/updatePrescriptionStatus/lib
rm -rf packages/sandbox/coverage
rm -rf packages/sandbox/lib
rm -rf .aws-sam

deep-clean: clean
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Deployment history can be found at https://nhsdigital.github.io/eps-prescription
This is the AWS layer that provides an API for EPS Prescription Status Update.

- `packages/updatePrescriptionStatus/` Handles updating prescription status for the root endpoint.
- `packages/sandbox` A sandbox endpoint returning an example response.
- `packages/specification/` This [Open API Specification](https://swagger.io/docs/specification/about/) describes the endpoints, methods and messages.
- `scripts/` Utilities helpful to developers of this specification.
- `SAMtemplates/` Contains the SAM templates used to define the stacks.
Expand Down
Loading

0 comments on commit 1014799

Please sign in to comment.