Skip to content

Commit 1f1ee10

Browse files
authored
Merge branch 'main' into add_temporary_instance
2 parents 51eb28a + 542a5cc commit 1f1ee10

File tree

94 files changed

+6957
-11999
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+6957
-11999
lines changed

.devcontainer/Dockerfile

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
FROM mcr.microsoft.com/devcontainers/base:ubuntu
22

3+
# provide DOCKER_GID via build args if you need to force group id to match host
4+
ARG DOCKER_GID
5+
ARG TARGETARCH
6+
ENV TARGETARCH=${TARGETARCH}
7+
8+
ARG ASDF_VERSION
9+
COPY .tool-versions.asdf /tmp/.tool-versions.asdf
10+
11+
# Anticipate and resolve potential permission issues with apt
12+
RUN mkdir -p /tmp && chmod 1777 /tmp
13+
314
RUN apt-get update \
415
&& export DEBIAN_FRONTEND=noninteractive \
516
&& apt-get -y dist-upgrade \
@@ -11,48 +22,65 @@ RUN apt-get update \
1122
libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \
1223
xz-utils tk-dev liblzma-dev netcat-traditional libyaml-dev
1324

14-
# install aws stuff
15-
RUN wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
25+
# Download correct AWS CLI for arch
26+
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
27+
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \
28+
else \
29+
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"; \
30+
fi && \
1631
unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \
1732
/tmp/aws-cli/aws/install && \
18-
rm tmp/awscliv2.zip && \
19-
rm -rf /tmp/aws-cli
33+
rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli
2034

21-
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 && \
35+
# Download correct SAM CLI for arch
36+
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
37+
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-arm64.zip"; \
38+
else \
39+
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip"; \
40+
fi && \
2241
unzip /tmp/aws-sam-cli.zip -d /tmp/aws-sam-cli && \
2342
/tmp/aws-sam-cli/install && \
24-
rm /tmp/aws-sam-cli.zip && \
25-
rm -rf /tmp/aws-sam-cli
43+
rm /tmp/aws-sam-cli.zip && rm -rf /tmp/aws-sam-cli
44+
45+
# Install ASDF
46+
RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
47+
wget -O /tmp/asdf.tar.gz https://github.com/asdf-vm/asdf/releases/download/v${ASDF_VERSION}/asdf-v${ASDF_VERSION}-linux-amd64.tar.gz; \
48+
tar -xvzf /tmp/asdf.tar.gz; \
49+
mv asdf /usr/bin
50+
51+
# specify DOCKER_GID to force container docker group id to match host
52+
RUN if [ -n "${DOCKER_GID}" ]; then \
53+
if ! getent group docker; then \
54+
groupadd -g ${DOCKER_GID} docker; \
55+
else \
56+
groupmod -g ${DOCKER_GID} docker; \
57+
fi && \
58+
usermod -aG docker vscode; \
59+
fi
2660

2761
USER vscode
2862

29-
# Install ASDF
30-
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3; \
31-
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \
32-
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc; \
63+
ENV PATH="/home/vscode/.asdf/shims/:$PATH"
64+
RUN \
65+
echo 'PATH="/home/vscode/.asdf/shims/:$PATH"' >> ~/.bashrc; \
66+
echo '. <(asdf completion bash)' >> ~/.bashrc; \
3367
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
3468
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
3569
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc;
3670

37-
ENV PATH="$PATH:/home/vscode/.asdf/bin/:/workspaces/eps-prescription-status-update-api/node_modules/.bin"
38-
39-
4071
# Install ASDF plugins
41-
RUN asdf plugin add python; \
42-
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \
43-
asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git; \
44-
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git; \
45-
asdf plugin add direnv; \
46-
asdf plugin add actionlint; \
72+
RUN asdf plugin add python && \
73+
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git && \
74+
asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git && \
75+
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git && \
76+
asdf plugin add direnv && \
77+
asdf plugin add actionlint && \
4778
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
4879

49-
5080
WORKDIR /workspaces/eps-prescription-status-update-api
5181
ADD .tool-versions /workspaces/eps-prescription-status-update-api/.tool-versions
5282
ADD .tool-versions /home/vscode/.tool-versions
5383

54-
RUN asdf install; \
55-
asdf reshim python; \
56-
asdf reshim poetry; \
57-
asdf reshim nodejs; \
58-
asdf direnv setup --shell bash --version 2.32.2;
84+
# install python before poetry to ensure correct python version is used
85+
RUN asdf install python && \
86+
asdf install

.devcontainer/devcontainer.json

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"build": {
77
"dockerfile": "Dockerfile",
88
"context": "..",
9-
"args": {}
9+
"args": {
10+
"DOCKER_GID": "${env:DOCKER_GID:}"
11+
}
1012
},
1113
"mounts": [
1214
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind",
@@ -37,7 +39,7 @@
3739
"github.vscode-github-actions"
3840
],
3941
"settings": {
40-
"python.defaultInterpreterPath": "/workspaces/eps-prescription-status-update/.venv/bin/python",
42+
"python.defaultInterpreterPath": "/workspaces/eps-prescription-status-update-api/.venv/bin/python",
4143
"python.analysis.autoSearchPaths": true,
4244
"python.analysis.extraPaths": [],
4345
"python.testing.unittestEnabled": false,
@@ -55,14 +57,15 @@
5557
}
5658
}
5759
},
58-
"remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" },
59-
"postAttachCommand": "docker build -f https://raw.githubusercontent.com/NHSDigital/eps-workflow-quality-checks/refs/tags/v4.0.4/dockerfiles/nhsd-git-secrets.dockerfile -t git-secrets . && poetry run pre-commit install --install-hooks -f",
60-
"features": {
61-
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
62-
"version": "latest",
63-
"moby": "true",
64-
"installDockerBuildx": "true"
65-
},
66-
"ghcr.io/devcontainers/features/github-cli:1": {}
67-
}
60+
"remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" },
61+
"updateRemoteUserUID": true,
62+
"postAttachCommand": "docker build -f https://raw.githubusercontent.com/NHSDigital/eps-workflow-quality-checks/refs/tags/v4.0.4/dockerfiles/nhsd-git-secrets.dockerfile -t git-secrets . && poetry run pre-commit install --install-hooks -f",
63+
"features": {
64+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
65+
"version": "latest",
66+
"moby": "true",
67+
"installDockerBuildx": "true"
68+
},
69+
"ghcr.io/devcontainers/features/github-cli:1": {}
70+
}
6871
}

.github/cfg/settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TAG_FORMAT: "v${version}-beta"

.github/scripts/release_code.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@ sam deploy \
7171
NotifyRoutingPlanIDValue="$NOTIFY_ROUTING_PLAN_ID" \
7272
NotifyAPIBaseURLValue="$NOTIFY_API_BASE_URL" \
7373
RequireApplicationName="$REQUIRE_APPLICATION_NAME" \
74-
EnableBackup="$ENABLE_BACKUP"
74+
EnableBackup="$ENABLE_BACKUP" \
75+
TestPresciptionsParamValue1="$TEST_PRESCRIPTIONS_1" \
76+
TestPresciptionsParamValue2="$TEST_PRESCRIPTIONS_2" \
77+
TestPresciptionsParamValue3="$TEST_PRESCRIPTIONS_3" \
78+
TestPresciptionsParamValue4="$TEST_PRESCRIPTIONS_4" \
79+
ForwardCsocLogs="$FORWARD_CSOC_LOGS"

.github/workflows/ci.yml

Lines changed: 37 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,29 @@ env:
88
BRANCH_NAME: ${{ github.event.ref.BRANCH_NAME }}
99

1010
jobs:
11+
get_asdf_version:
12+
runs-on: ubuntu-22.04
13+
outputs:
14+
asdf_version: ${{ steps.asdf-version.outputs.version }}
15+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
19+
20+
- name: Get asdf version
21+
id: asdf-version
22+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
23+
- name: Load config value
24+
id: load-config
25+
run: |
26+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/cfg/settings.yml)
27+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
28+
1129
quality_checks:
12-
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/[email protected]
30+
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@4fb41faab9c92d8a1444719bc1ab45a989caf756
31+
needs: [get_asdf_version]
32+
with:
33+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
1334
secrets:
1435
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1536

@@ -24,69 +45,15 @@ jobs:
2445
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
2546
2647
tag_release:
27-
needs: quality_checks
28-
runs-on: ubuntu-22.04
29-
outputs:
30-
version_tag: ${{steps.output_version_tag.outputs.VERSION_TAG}}
31-
steps:
32-
- name: Checkout code
33-
uses: actions/checkout@v5
34-
with:
35-
ref: ${{ env.BRANCH_NAME }}
36-
fetch-depth: 0
37-
38-
# using git commit sha for version of action to ensure we have stable version
39-
- name: Install asdf
40-
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
41-
with:
42-
asdf_branch: v0.11.3
43-
44-
- name: Cache asdf
45-
uses: actions/cache@v4
46-
with:
47-
path: |
48-
~/.asdf
49-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
50-
restore-keys: |
51-
${{ runner.os }}-asdf-
52-
53-
- name: Install asdf dependencies in .tool-versions
54-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
55-
with:
56-
asdf_branch: v0.11.3
57-
env:
58-
PYTHON_CONFIGURE_OPTS: --enable-shared
59-
60-
- name: Install node packages
61-
run: |
62-
make install-node
63-
64-
- name: Set VERSION_TAG env var to be short git SHA and get next tag varsion
65-
id: output_version_tag
66-
run: |
67-
VERSION_TAG=$(git rev-parse --short HEAD)
68-
npx semantic-release --dry-run > semantic-release-output.log
69-
NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/')
70-
if [ -z "${NEXT_VERSION}" ]
71-
then
72-
echo "Could not get next tag. Here is the log from semantic-release"
73-
cat semantic-release-output.log
74-
exit 1
75-
fi
76-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
77-
if [ "${tagFormat}" = "null" ]
78-
then
79-
tagFormat="v\${version}"
80-
fi
81-
# disabling shellcheck as replace does not work
82-
# shellcheck disable=SC2001
83-
NEW_VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
84-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
85-
echo "## NEXT TAG WILL BE : ${NEW_VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
86-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
87-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
88-
env:
89-
GITHUB_TOKEN: ${{ github.token }}
48+
needs: [quality_checks, get_commit_id, get_asdf_version]
49+
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release.yml@3cba6a3733673bafc95526503478674332c26007
50+
with:
51+
dry_run: true
52+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
53+
branch_name: main
54+
publish_package: false
55+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
56+
secrets: inherit
9057

9158
package_code:
9259
needs: tag_release
@@ -117,7 +84,7 @@ jobs:
11784
RUN_REGRESSION_TEST: true
11885
STATE_MACHINE_LOG_LEVEL: ALL
11986
LOG_LEVEL: DEBUG
120-
ENABLE_BACKUP: True
87+
ENABLE_BACKUP: "True"
12188
ENABLE_NOTIFICATIONS_INTERNAL: true
12289
ENABLE_NOTIFICATIONS_EXTERNAL: false
12390
ENABLED_SYSTEMS: "Internal Test System"
@@ -126,6 +93,7 @@ jobs:
12693
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
12794
MTLS_KEY: psu-mtls-1
12895
IS_PULL_REQUEST: false
96+
FORWARD_CSOC_LOGS: false
12997
secrets:
13098
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
13199
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
@@ -156,7 +124,7 @@ jobs:
156124
RUN_REGRESSION_TEST: false
157125
STATE_MACHINE_LOG_LEVEL: ALL
158126
LOG_LEVEL: DEBUG
159-
ENABLE_BACKUP: False
127+
ENABLE_BACKUP: "False"
160128
ENABLE_NOTIFICATIONS_INTERNAL: false
161129
ENABLE_NOTIFICATIONS_EXTERNAL: false
162130
ENABLED_SYSTEMS: "Internal Test System"
@@ -165,6 +133,7 @@ jobs:
165133
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
166134
MTLS_KEY: psu-mtls-1
167135
IS_PULL_REQUEST: false
136+
FORWARD_CSOC_LOGS: false
168137
secrets:
169138
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}
170139
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
@@ -192,7 +161,7 @@ jobs:
192161
RUN_REGRESSION_TEST: true
193162
STATE_MACHINE_LOG_LEVEL: ALL
194163
LOG_LEVEL: DEBUG
195-
ENABLE_BACKUP: False
164+
ENABLE_BACKUP: "False"
196165
ENABLE_NOTIFICATIONS_INTERNAL: false
197166
ENABLE_NOTIFICATIONS_EXTERNAL: false
198167
ENABLED_SYSTEMS: "Internal Test System"
@@ -201,6 +170,7 @@ jobs:
201170
NOTIFY_API_BASE_URL: "https://int.api.service.nhs.uk"
202171
MTLS_KEY: psu-mtls-1
203172
IS_PULL_REQUEST: false
173+
FORWARD_CSOC_LOGS: false
204174
secrets:
205175
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}
206176
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}

0 commit comments

Comments
 (0)