-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description :pencil: Summary: This pull request proposes the creation of a new repository named "electronic-prescription-service-clinical-prescription-tracker" to establish the foundation for the **Clinical Prescription Tracker API**. The repository structure and initial content will mirror that of the existing "prescriptionsforpatients" repository. It will include a basic stack for CI and release builds of the Clinical Prescription Tracker API. :ticket: Jira References: - [AEA-3604](https://nhsd-jira.digital.nhs.uk/browse/AEA-3604) create the Clinical Prescription Tracker API AWS repo - [AEA-3677](https://nhsd-jira.digital.nhs.uk/browse/AEA-3677) deploy basic stack for CI and release builds of the Clinical Prescription Tracker API
- Loading branch information
1 parent
ef49aeb
commit 82d9abc
Showing
83 changed files
with
14,922 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore_checks: | ||
- W3002 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
FROM mcr.microsoft.com/devcontainers/base:ubuntu | ||
|
||
RUN apt-get update \ | ||
&& export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get -y dist-upgrade \ | ||
&& apt-get -y install --no-install-recommends htop vim curl git build-essential \ | ||
libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev libbz2-dev \ | ||
zlib1g-dev unixodbc unixodbc-dev libsecret-1-0 libsecret-1-dev libsqlite3-dev \ | ||
openjdk-8-jdk jq apt-transport-https ca-certificates gnupg-agent \ | ||
software-properties-common bash-completion python3-pip make libbz2-dev \ | ||
libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \ | ||
xz-utils tk-dev liblzma-dev netcat | ||
|
||
# install aws stuff | ||
RUN wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \ | ||
unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \ | ||
/tmp/aws-cli/aws/install && \ | ||
rm tmp/awscliv2.zip && \ | ||
rm -rf /tmp/aws-cli | ||
|
||
RUN wget -O /tmp/aws-sam-cli.zip https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip && \ | ||
unzip /tmp/aws-sam-cli.zip -d /tmp/aws-sam-cli && \ | ||
/tmp/aws-sam-cli/install && \ | ||
rm /tmp/aws-sam-cli.zip && \ | ||
rm -rf /tmp/aws-sam-cli | ||
|
||
USER vscode | ||
|
||
# Install ASDF | ||
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3; \ | ||
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \ | ||
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc; | ||
|
||
ENV PATH="$PATH:/home/vscode/.asdf/bin/:/workspaces/electronic-prescription-service-clinical-prescription-tracker/node_modules/.bin" | ||
|
||
|
||
# Install ASDF plugins | ||
RUN asdf plugin add python; \ | ||
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \ | ||
asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git; \ | ||
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git; \ | ||
asdf plugin add java; \ | ||
asdf plugin add direnv; \ | ||
asdf plugin add golang https://github.com/kennyp/asdf-golang.git; \ | ||
asdf plugin add golangci-lint https://github.com/hypnoglow/asdf-golangci-lint.git; \ | ||
asdf plugin add actionlint; | ||
|
||
|
||
WORKDIR /workspaces/electronic-prescription-service-clinical-prescription-tracker | ||
ADD .tool-versions /workspaces/electronic-prescription-service-clinical-prescription-tracker/.tool-versions | ||
ADD .tool-versions /home/vscode/.tool-versions | ||
|
||
RUN asdf install; \ | ||
asdf reshim python; \ | ||
asdf reshim poetry; \ | ||
asdf reshim nodejs; \ | ||
asdf reshim java; \ | ||
asdf direnv setup --shell bash --version 2.32.2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu | ||
{ | ||
"name": "Ubuntu", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": "..", | ||
"args": {} | ||
}, | ||
"mounts": [ | ||
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind", | ||
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind", | ||
"source=${env:HOME}${env:USERPROFILE}/.gnupg,target=/home/vscode/.gnupg,type=bind", | ||
"source=${env:HOME}${env:USERPROFILE}/.npmrc,target=/home/vscode/.npmrc,type=bind" | ||
], | ||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": { | ||
"version": "latest", | ||
"moby": "true", | ||
"installDockerBuildx": "true" | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"AmazonWebServices.aws-toolkit-vscode", | ||
"redhat.vscode-yaml", | ||
"ms-python.python", | ||
"ms-python.flake8", | ||
"eamodio.gitlens", | ||
"github.vscode-pull-request-github", | ||
"orta.vscode-jest", | ||
"42crunch.vscode-openapi", | ||
"mermade.openapi-lint", | ||
"rvest.vs-code-prettier-eslint", | ||
"christian-kohler.npm-intellisense", | ||
"dbaeumer.vscode-eslint", | ||
"lfm.vscode-makefile-term", | ||
"GrapeCity.gc-excelviewer", | ||
"redhat.vscode-xml", | ||
"streetsidesoftware.code-spell-checker", | ||
"timonwong.shellcheck", | ||
"mkhl.direnv", | ||
"github.vscode-github-actions" | ||
], | ||
"settings": { | ||
"python.defaultInterpreterPath": "/workspaces/electronic-prescription-service-clinical-prescription-tracker/.venv/bin/python", | ||
"python.analysis.autoSearchPaths": true, | ||
"python.analysis.extraPaths": [], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true, | ||
"python.linting.pylintEnabled": false, | ||
"python.linting.flake8Enabled": true, | ||
"python.linting.enabled": true, // required to format on save | ||
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint", | ||
"editor.formatOnPaste": false, // required | ||
"editor.formatOnType": false, // required | ||
"editor.formatOnSave": true, // optional | ||
"editor.formatOnSaveMode": "file", | ||
"cSpell.words": ["fhir", "Formik", "pino", "serialisation"] | ||
} | ||
} | ||
}, | ||
"postCreateCommand": "rm -f ~/.docker/config.json; git config --global --add safe.directory /workspaces/electronic-prescription-service-clinical-prescription-tracker; make install; direnv allow ." | ||
// "features": {}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "" | ||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length=120 | ||
exclude = .git,__pycache__,dist,.venv/*,node_modules/*,utils/*,tests/.venv/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: "Create confluence release notes" | ||
description: "Do release note actions in confluence and jira" | ||
inputs: | ||
RELEASE_TAG: | ||
required: false | ||
description: "The tag we are marking as released in jira" | ||
DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE: | ||
required: true | ||
description: "The role to assume to execute the release notes lambda" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: connect to dev account | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-region: eu-west-2 | ||
role-to-assume: ${{ inputs.DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE }} | ||
role-session-name: account-resources-release-notes-run-lambda | ||
|
||
- name: call markJiraReleased lambda | ||
shell: bash | ||
working-directory: .github/scripts | ||
env: | ||
RELEASE_TAG: ${{ inputs.RELEASE_TAG }} | ||
run: ./call_mark_jira_released.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: "Create confluence release notes" | ||
description: "Do release note actions in confluence and jira" | ||
inputs: | ||
TARGET_ENVIRONMENT: | ||
required: true | ||
description: "Target Environment" | ||
RELEASE_TAG: | ||
required: false | ||
description: "The tag we are releasing - only used for create_rc_release_notes" | ||
CONFLUENCE_PAGE_ID: | ||
required: true | ||
description: "The id of confluence page to update or create under" | ||
CREATE_RC_RELEASE_NOTES: | ||
required: true | ||
description: "whether to create rc release notes page instead of normal release notes" | ||
default: "false" | ||
DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE: | ||
required: true | ||
description: "The role to assume to execute the release notes lambda" | ||
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: | ||
required: true | ||
description: "The dev cloud formation deploy role" | ||
TARGET_CLOUD_FORMATION_CHECK_VERSION_ROLE: | ||
required: true | ||
description: "The target cloud formation deploy role" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: connect to target account | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-region: eu-west-2 | ||
role-to-assume: ${{ inputs.TARGET_CLOUD_FORMATION_CHECK_VERSION_ROLE }} | ||
role-session-name: account-resources-release-notes-target | ||
|
||
- name: Get deployed tag on target | ||
shell: bash | ||
working-directory: .github/scripts | ||
env: | ||
TARGET_ENVIRONMENT: ${{ inputs.TARGET_ENVIRONMENT }} | ||
run: ./get_target_deployed_tag.sh | ||
|
||
- name: connect to dev account | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-region: eu-west-2 | ||
role-to-assume: ${{ inputs.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }} | ||
role-session-name: account-resources-release-notes-dev | ||
|
||
- name: get current dev tag | ||
shell: bash | ||
working-directory: .github/scripts | ||
run: ./get_current_dev_tag.sh | ||
|
||
- name: connect to dev account to run release notes lambda | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-region: eu-west-2 | ||
role-to-assume: ${{ inputs.DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE }} | ||
role-session-name: account-resources-release-notes-run-lambda | ||
unset-current-credentials: true | ||
|
||
- name: create int release notes | ||
shell: bash | ||
working-directory: .github/scripts | ||
if: inputs.TARGET_ENVIRONMENT == 'int' && inputs.CREATE_RC_RELEASE_NOTES == 'false' | ||
env: | ||
ENV: INT | ||
PAGE_ID: ${{ inputs.CONFLUENCE_PAGE_ID }} | ||
run: ./create_env_release_notes.sh | ||
|
||
- name: create int rc release notes | ||
shell: bash | ||
working-directory: .github/scripts | ||
if: inputs.TARGET_ENVIRONMENT == 'int' && inputs.CREATE_RC_RELEASE_NOTES == 'true' | ||
env: | ||
RELEASE_TAG: ${{ inputs.RELEASE_TAG }} | ||
PAGE_ID: ${{ inputs.CONFLUENCE_PAGE_ID }} | ||
run: ./create_int_rc_release_notes.sh | ||
|
||
- name: create prod release notes | ||
shell: bash | ||
working-directory: .github/scripts | ||
if: inputs.TARGET_ENVIRONMENT == 'prod' | ||
env: | ||
ENV: PROD | ||
PAGE_ID: ${{ inputs.CONFLUENCE_PAGE_ID }} | ||
run: ./create_env_release_notes.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
######################################################################### | ||
# Dependabot configuration file | ||
######################################################################### | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
# Workflow files stored in the | ||
# default location of `.github/workflows` | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
||
################################### | ||
# NPM workspace ################## | ||
################################### | ||
- package-ecosystem: "npm" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
versioning-strategy: increase | ||
|
||
################################### | ||
# Poetry ######################### | ||
################################### | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
versioning-strategy: increase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Summary | ||
|
||
**Remove items from this list if they are not relevant. Remove this line once this has been done** | ||
|
||
- Routine Change | ||
- :exclamation: Breaking Change | ||
- :robot: Operational or Infrastructure Change | ||
- :sparkles: New Feature | ||
- :warning: Potential issues that might be caused by this change | ||
|
||
### Details | ||
|
||
Add any summary information of what is in the change. **Remove this line if you have nothing to add.** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "calling mark jira released" | ||
|
||
cat <<EOF > payload.json | ||
{ | ||
"releaseVersion": "Clinical-Tracker-$RELEASE_TAG" | ||
} | ||
EOF | ||
cat payload.json | ||
|
||
function_arn=$(aws cloudformation list-exports --query "Exports[?Name=='release-notes:MarkJiraReleasedLambdaArn'].Value" --output text) | ||
aws lambda invoke --function-name "${function_arn}" --cli-binary-format raw-in-base64-out --payload file://payload.json out.txt | ||
cat out.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
cat <<EOF > payload.json | ||
{ | ||
"currentTag": "$CURRENT_DEPLOYED_TAG", | ||
"targetTag": "$DEV_TAG", | ||
"repoName": "electronic-prescription-service-clinical-prescription-tracker", | ||
"targetEnvironment": "$ENV", | ||
"productName": "Clinical Tracker", | ||
"releaseNotesPageId": "$PAGE_ID", | ||
"releaseNotesPageTitle": "Current Clinical Tracker release notes - $ENV" | ||
} | ||
EOF | ||
cat payload.json | ||
|
||
function_arn=$(aws cloudformation list-exports --query "Exports[?Name=='release-notes:CreateReleaseNotesLambdaArn'].Value" --output text) | ||
aws lambda invoke --function-name "${function_arn}" --cli-binary-format raw-in-base64-out --payload file://payload.json out.txt | ||
cat out.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
cat <<EOF > payload.json | ||
{ | ||
"currentTag": "$CURRENT_DEPLOYED_TAG", | ||
"targetTag": "$RELEASE_TAG", | ||
"repoName": "electronic-prescription-service-clinical-prescription-tracker", | ||
"targetEnvironment": "INT", | ||
"productName": "Clinical Tracker", | ||
"releaseNotesPageId": "$PAGE_ID", | ||
"releaseNotesPageTitle": "Clinical-Tracker-$RELEASE_TAG - Deployed to [INT] on $(date +'%d-%m-%y')", | ||
"createReleaseCandidate": "true", | ||
"releasePrefix": "Clinical-Tracker-" | ||
} | ||
EOF | ||
cat payload.json | ||
|
||
function_arn=$(aws cloudformation list-exports --query "Exports[?Name=='release-notes:CreateReleaseNotesLambdaArn'].Value" --output text) | ||
aws lambda invoke --function-name "${function_arn}" --cli-binary-format raw-in-base64-out --payload file://payload.json out.txt | ||
cat out.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
ACTIVE_STACKS=$(aws cloudformation list-stacks | jq -r '.StackSummaries[] | select ( .StackStatus != "DELETE_COMPLETE" ) | select( .StackName | capture("^clinical-tracker-pr-(sandbox-)?(\\d+)$") ) | .StackName ') | ||
|
||
mapfile -t ACTIVE_STACKS_ARRAY <<< "$ACTIVE_STACKS" | ||
|
||
for i in "${ACTIVE_STACKS_ARRAY[@]}" | ||
do | ||
echo "Checking if stack $i has open pull request" | ||
PULL_REQUEST=${i//pr-/} | ||
PULL_REQUEST=${PULL_REQUEST//sandbox-/} | ||
echo "Checking pull request id ${PULL_REQUEST}" | ||
URL="https://api.github.com/repos/NHSDigital/electronic-prescription-service-clinical-prescription-tracker/pulls/${PULL_REQUEST}" | ||
RESPONSE=$(curl "${URL}" 2>/dev/null) | ||
STATE=$(echo "${RESPONSE}" | jq -r .state) | ||
if [ "$STATE" == "closed" ]; then | ||
echo "** going to delete stack $i as state is ${STATE} **" | ||
aws cloudformation delete-stack --stack-name "${i}" | ||
else | ||
echo "not going to delete stack $i as state is ${STATE}" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
dev_tag=$(aws cloudformation describe-stacks --stack-name clinical-tracker --query "Stacks[0].Tags[?Key=='version'].Value" --output text) | ||
|
||
echo "DEV_TAG=${dev_tag}" >> "$GITHUB_ENV" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
current_deployed_tag=$(aws cloudformation describe-stacks --stack-name clinical-tracker --query "Stacks[0].Tags[?Key=='version'].Value" --output text) | ||
|
||
echo "CURRENT_DEPLOYED_TAG=${current_deployed_tag}" >> "$GITHUB_ENV" |
Oops, something went wrong.