Skip to content

Commit

Permalink
[AEA-0000] initial repo setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Orkastrated committed Nov 19, 2024
1 parent 31d67f1 commit cb44579
Show file tree
Hide file tree
Showing 32 changed files with 14,700 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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

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-tracker-ui
ADD .tool-versions /workspaces/eps-prescription-tracker-ui/.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;
75 changes: 75 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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": {
"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",
"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-vpc-resources; 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"
}
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.
135 changes: 135 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: merge to main workflow

on:
push:
branches: [main]

env:
BRANCH_NAME: ${{ github.event.ref.BRANCH_NAME }}

jobs:
quality_checks:
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/[email protected]
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

get_commit_id:
runs-on: ubuntu-latest
outputs:
commit_id: ${{ steps.commit_id.outputs.commit_id }}
steps:
- name: Get Commit ID
id: commit_id
run: |
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
tag_release:
needs: quality_checks
runs-on: ubuntu-latest
outputs:
version_tag: ${{ steps.output_version_tag.outputs.VERSION_TAG }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH_NAME }}
fetch-depth: 0

# using git commit sha for version of action to ensure we have stable version
- name: Install asdf
uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
with:
asdf_branch: v0.14.1

- name: Cache asdf
uses: actions/cache@v4
with:
path: |
~/.asdf
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
- name: Install asdf dependencies in .tool-versions
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
with:
asdf_branch: v0.14.1
env:
PYTHON_CONFIGURE_OPTS: --enable-shared

- name: Install Dependencies
run: make install

- name: Set VERSION_TAG env var to be short git SHA and get next tag varsion
id: output_version_tag
run: |
VERSION_TAG=$(git rev-parse --short HEAD)
npx semantic-release --dry-run > semantic-release-output.log
NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/')
if [ -z "${NEXT_VERSION}" ]
then
echo "Could not get next tag. Here is the log from semantic-release"
cat semantic-release-output.log
exit 1
fi
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
if [ "${tagFormat}" = "null" ]
then
tagFormat="v\${version}"
fi
# disabling shellcheck as replace does not work
# shellcheck disable=SC2001
NEW_VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
echo "## NEXT TAG WILL BE : ${NEW_VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
env:
GITHUB_TOKEN: ${{ github.token }}

# package_code:
# needs: [tag_release, get_commit_id]
# uses: ./.github/workflows/cdk_package_code.yml
# with:
# VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
# COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}

# release_dev:
# needs: [tag_release, package_code, get_commit_id]
# uses: ./.github/workflows/release_all_stacks.yml
# with:
# SERVICE_NAME: cpt-ui
# TARGET_ENVIRONMENT: dev
# VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
# COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
# secrets:
# CDK_PULL_IMAGE_ROLE: ${{ secrets.DEV_CDK_PULL_IMAGE_ROLE }}
# CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}

# create_release_notes:
# needs: [tag_release, package_code, get_commit_id, release_dev]
# uses: ./.github/workflows/create_release_notes.yml
# with:
# VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
# CREATE_INT_RELEASE_NOTES: true
# CREATE_INT_RC_RELEASE_NOTES: false
# CREATE_PROD_RELEASE_NOTES: true
# MARK_JIRA_RELEASED: false
# secrets:
# DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE }}
# DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
# INT_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.INT_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
# PROD_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.PROD_CLOUD_FORMATION_CHECK_VERSION_ROLE }}


# release_qa:
# needs: [tag_release, release_dev, package_code, get_commit_id]
# uses: ./.github/workflows/release_all_stacks.yml
# with:
# SERVICE_NAME: cpt-ui
# TARGET_ENVIRONMENT: qa
# VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
# COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
# secrets:
# CDK_PULL_IMAGE_ROLE: ${{ secrets.QA_CDK_PULL_IMAGE_ROLE }}
# CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
Loading

0 comments on commit cb44579

Please sign in to comment.