Skip to content

Commit

Permalink
Fix: [AEA-0000] - initial pull request (#1)
Browse files Browse the repository at this point in the history
* first commit

* remove TARGET_SPINE_SERVER

* add tests

* do not do sonar scan yet

* fix template name

* remove sandbox

* update readme

* add pre commit hooks
  • Loading branch information
anthony-nhs authored Sep 9, 2024
1 parent 0bf3789 commit 787d40e
Show file tree
Hide file tree
Showing 59 changed files with 14,885 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .cfnlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore_checks:
- W3002
58 changes: 58 additions & 0 deletions .devcontainer/Dockerfile
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 \
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 libyaml-dev

# 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; \
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc;

ENV PATH="$PATH:/home/vscode/.asdf/bin/:/workspaces/eps-prescription-tracker-ui/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 direnv; \
asdf plugin add actionlint; \
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git


WORKDIR /workspaces/eps-prescription-status-update-api
ADD .tool-versions /workspaces/eps-prescription-status-update-api/.tool-versions
ADD .tool-versions /home/vscode/.tool-versions

RUN asdf install; \
asdf reshim python; \
asdf reshim poetry; \
asdf reshim nodejs; \
asdf direnv setup --shell bash --version 2.32.2;
69 changes: 69 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// 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"
],
"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",
"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/eps-prescription-tracker-ui/.venv/bin/python",
"python.analysis.autoSearchPaths": true,
"python.analysis.extraPaths": [],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"pylint.enabled": false,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true, // required to format on save
"editor.formatOnPaste": false, // required
"editor.formatOnType": false, // required
"editor.formatOnSave": true, // optional
"editor.formatOnSaveMode": "file",
"cSpell.words": ["fhir", "Formik", "pino", "serialisation"],
"editor.defaultFormatter": "dbaeumer.vscode-eslint"

}
}
},
"postCreateCommand": "rm -f ~/.docker/config.json; git config --global --add safe.directory /workspaces/eps-prescription-tracker-ui; 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"
}

26 changes: 26 additions & 0 deletions .github/actions/mark_jira_released/action.yml
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
89 changes: 89 additions & 0 deletions .github/actions/update_confluence_jira/action.yml
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
37 changes: 37 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#########################################################################
# Dependabot configuration file
#########################################################################

version: 2

updates:
- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "Upgrade: [dependabot] - "

###################################
# NPM workspace ##################
###################################
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
versioning-strategy: increase
commit-message:
prefix: "Upgrade: [dependabot] - "

###################################
# Poetry #########################
###################################
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
versioning-strategy: increase
commit-message:
prefix: "Upgrade: [dependabot] - "
59 changes: 59 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## 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.**

## Pull Request Naming

Pull requests should be named using the following format:

```text
Tag: [AEA-NNNN] - Short description
```

Tag can be one of:

- `Fix` - for a bug fix. (Patch release)
- `Update` - either for a backwards-compatible enhancement or for a rule change that adds reported problems. (Patch release)
- `New` - implemented a new feature. (Minor release)
- `Breaking` - for a backwards-incompatible enhancement or feature. (Major release)
- `Docs` - changes to documentation only. (Patch release)
- `Build` - changes to build process only. (No release)
- `Upgrade` - for a dependency upgrade. (Patch release)
- `Chore` - for refactoring, adding tests, etc. (anything that isn't user-facing). (Patch release)

If the current release is x.y.z then
- a patch release increases z by 1
- a minor release increases y by 1
- a major release increases x by 1

Correct tagging is necessary for our automated versioning and release process.

The description of your pull request will be used as the commit message for the merge, and also be included in the changelog. Please ensure that your title is sufficiently descriptive.

### Rerunning Checks

If you need to rename your pull request, you can restart the checks by either:

- Closing and reopening the pull request
- pushing an empty commit
```bash
git commit --allow-empty -m 'trigger build'
git push
```
- Amend your last commit and force push to the branch
```bash
git commit --amend --no-edit
git push --force
```

Rerunning the checks from within the pull request will not use the updated title.
14 changes: 14 additions & 0 deletions .github/scripts/call_mark_jira_released.sh
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
18 changes: 18 additions & 0 deletions .github/scripts/create_env_release_notes.sh
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": "eps-prescription-tracker-ui",
"targetEnvironment": "$ENV",
"productName": "Clinical Tracker UI",
"releaseNotesPageId": "$PAGE_ID",
"releaseNotesPageTitle": "Current Clinical Tracker UI 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
Loading

0 comments on commit 787d40e

Please sign in to comment.