Skip to content

Commit d22b3a3

Browse files
kris-szlapaanthony-nhsbencegadanyi1-nhststephen-nhs
authored
Update: [AEA-5871] - modify eps-assist-me deployment pipeline to run regression tests (#97)
## Summary 🎫 [AEA-5871](https://nhsd-jira.digital.nhs.uk/browse/AEA-5871) modify eps-assist-me deployment pipeline to run regression tests - Routine Change - 🤖 Operational or Infrastructure Change ### Details This pull request updates the eps-assist-me deployment pipeline to run regression tests. some refactors: - makes devcontainer arm macos happy 🥳 - L1 to L2 infra change of OpenSearch - makes asdf versioning a repo level change - use common release tagging workflow --------- Co-authored-by: Anthony Brown <[email protected]> Co-authored-by: Bence Gadanyi <[email protected]> Co-authored-by: tstephen-nhs <[email protected]>
1 parent 3385876 commit d22b3a3

18 files changed

+288
-211
lines changed

.devcontainer/Dockerfile

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
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+
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then dpkg --add-architecture arm64; fi
12+
13+
# Anticipate and resolve potential permission issues with apt
14+
RUN mkdir -p /tmp && chmod 1777 /tmp
315
# Install system dependencies
416
RUN apt-get update \
517
&& export DEBIAN_FRONTEND=noninteractive \
@@ -8,49 +20,76 @@ RUN apt-get update \
820
libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev libbz2-dev \
921
zlib1g-dev unixodbc unixodbc-dev libsecret-1-0 libsecret-1-dev libsqlite3-dev \
1022
jq apt-transport-https ca-certificates gnupg-agent \
11-
software-properties-common bash-completion python3-pip make libbz2-dev \
23+
software-properties-common bash-completion python3-pip make \
1224
libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \
13-
xz-utils tk-dev liblzma-dev netcat-openbsd libyaml-dev
25+
xz-utils tk-dev liblzma-dev netcat-traditional libyaml-dev
1426

1527
# Install aws stuff
16-
RUN wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
28+
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
29+
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \
30+
else \
31+
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"; \
32+
fi && \
1733
unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \
1834
/tmp/aws-cli/aws/install && \
19-
rm tmp/awscliv2.zip && \
20-
rm -rf /tmp/aws-cli
35+
rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli
2136

22-
# Set user to vscode
23-
USER vscode
37+
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
38+
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-arm64.zip"; \
39+
else \
40+
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip"; \
41+
fi && \
42+
unzip /tmp/aws-sam-cli.zip -d /tmp/aws-sam-cli && \
43+
/tmp/aws-sam-cli/install && \
44+
rm /tmp/aws-sam-cli.zip && rm -rf /tmp/aws-sam-cli
2445

2546
# Install ASDF
26-
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3; \
27-
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \
28-
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc; \
47+
RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
48+
if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \
49+
wget -O /tmp/asdf.tar.gz "https://github.com/asdf-vm/asdf/releases/download/v${ASDF_VERSION}/asdf-v${ASDF_VERSION}-linux-arm64.tar.gz"; \
50+
else \
51+
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"; \
52+
fi && \
53+
tar -xzf /tmp/asdf.tar.gz -C /tmp && \
54+
mkdir -p /usr/bin && \
55+
mv /tmp/asdf /usr/bin/asdf && \
56+
chmod +x /usr/bin/asdf && \
57+
rm -rf /tmp/asdf.tar.gz
58+
59+
# specify DOCKER_GID to force container docker group id to match host
60+
RUN if [ -n "${DOCKER_GID}" ]; then \
61+
if ! getent group docker; then \
62+
groupadd -g ${DOCKER_GID} docker; \
63+
else \
64+
groupmod -g ${DOCKER_GID} docker; \
65+
fi && \
66+
usermod -aG docker vscode; \
67+
fi
68+
69+
USER vscode
70+
71+
ENV PATH="/home/vscode/.asdf/shims/:$PATH"
72+
RUN \
73+
echo 'PATH="/home/vscode/.asdf/shims/:$PATH"' >> ~/.bashrc; \
2974
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
3075
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
3176
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc;
3277

33-
ENV PATH="$PATH:/home/vscode/.asdf/bin/:/workspaces/eps-assist-me/node_modules/.bin"
78+
ENV PATH="$PATH:/workspaces/eps-assist-me/node_modules/.bin"
3479

3580
# Install ASDF plugins
36-
RUN asdf plugin add python; \
37-
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \
38-
asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git; \
39-
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git; \
40-
asdf plugin add direnv; \
41-
asdf plugin add actionlint; \
81+
RUN asdf plugin add python && \
82+
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git && \
83+
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git && \
84+
asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git && \
85+
asdf plugin add direnv && \
86+
asdf plugin add actionlint && \
4287
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
4388

44-
# Set working directory
4589
WORKDIR /workspaces/eps-assist-me
46-
47-
# Copy .tool-versions
4890
ADD .tool-versions /workspaces/eps-assist-me/.tool-versions
4991
ADD .tool-versions /home/vscode/.tool-versions
5092

51-
# Install tools
52-
RUN asdf install; \
53-
asdf reshim python; \
54-
asdf reshim poetry; \
55-
asdf reshim nodejs; \
56-
asdf direnv setup --shell bash --version 2.32.2;
93+
# install python before poetry to ensure correct python version is used
94+
RUN asdf install python && \
95+
asdf install

.devcontainer/devcontainer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
33
{
44
"name": "Ubuntu",
5-
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
65
"build": {
76
"dockerfile": "Dockerfile",
87
"context": "..",
9-
"args": {}
8+
"args": {
9+
"DOCKER_GID": "${env:DOCKER_GID:}"
10+
}
1011
},
1112
"mounts": [
1213
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind",
1314
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind",
1415
"source=${env:HOME}${env:USERPROFILE}/.gnupg,target=/home/vscode/.gnupg,type=bind",
15-
"source=${env:HOME}${env:USERPROFILE}/.npmrc,target=/home/vscode/.npmrc,type=bind"
16+
"source=${env:HOME}${env:USERPROFILE}/.npmrc,target=/home/vscode/.npmrc,type=bind",
17+
"source=${env:HOME}${env:USERPROFILE}/.gitconfig,target=/home/vscode/.gitconfig,type=bind"
1618
],
1719
"features": {
1820
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
@@ -46,7 +48,7 @@
4648
"github.vscode-github-actions"
4749
],
4850
"settings": {
49-
"python.defaultInterpreterPath": "/workspaces/eps-assist-me/.venv/bin/python",
51+
"python.defaultInterpreterPath": "/home/vscode/.asdf/shims/python",
5052
"python.analysis.autoSearchPaths": true,
5153
"python.analysis.extraPaths": [],
5254
"python.testing.unittestEnabled": false,

.github/workflows/cdk_package_code.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
with:
2727
ref: ${{ env.BRANCH_NAME }}
2828

29-
# using git commit sha for version of action to ensure we have stable version
3029
- name: Get asdf version
3130
id: asdf-version
32-
run: echo "version=0.18.0" >> "$GITHUB_OUTPUT"
31+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
32+
3333

3434
# using git commit sha for version of action to ensure we have stable version
3535
- name: Install asdf

.github/workflows/ci.yml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,8 @@ jobs:
3232
secrets:
3333
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3434

35-
get_commit_id:
36-
runs-on: ubuntu-22.04
37-
outputs:
38-
commit_id: ${{ steps.commit_id.outputs.commit_id }}
39-
steps:
40-
- name: Get Commit ID
41-
id: commit_id
42-
run: |
43-
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
44-
4535
tag_release:
46-
needs: [quality_checks, get_commit_id, get_asdf_version]
36+
needs: [quality_checks, get_asdf_version]
4737
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@361957c147279f5f0f68b64fde9927833363d5f7
4838
with:
4939
dry_run: true
@@ -54,21 +44,21 @@ jobs:
5444
secrets: inherit
5545

5646
package_code:
57-
needs: [get_commit_id, tag_release]
47+
needs: [tag_release]
5848
uses: ./.github/workflows/cdk_package_code.yml
5949
with:
6050
STACK_NAME: epsam
6151
VERSION_NUMBER: ${{ needs.tag_release.outputs.version_tag }}
62-
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
52+
COMMIT_ID: ${{ github.sha }}
6353

6454
release_dev:
65-
needs: [get_commit_id, tag_release, package_code]
55+
needs: [tag_release, package_code]
6656
uses: ./.github/workflows/release_all_stacks.yml
6757
with:
6858
STACK_NAME: epsam
6959
TARGET_ENVIRONMENT: dev
7060
VERSION_NUMBER: ${{ needs.tag_release.outputs.version_tag }}
71-
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
61+
COMMIT_ID: ${{ github.sha }}
7262
CDK_APP_NAME: EpsAssistMeApp
7363
DEPLOY_CODE: true
7464
LOG_RETENTION_IN_DAYS: 30
@@ -78,6 +68,7 @@ jobs:
7868
MARK_JIRA_RELEASED: false
7969
CREATE_INT_RC_RELEASE_NOTES: false
8070
IS_PULL_REQUEST: false
71+
RUN_REGRESSION_TESTS: true
8172
secrets:
8273
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
8374
CDK_PULL_IMAGE_ROLE: ${{ secrets.DEV_CDK_PULL_IMAGE_ROLE }}
@@ -90,22 +81,23 @@ jobs:
9081
SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }}
9182

9283
release_qa:
93-
needs: [get_commit_id, tag_release, package_code, release_dev]
84+
needs: [tag_release, package_code, release_dev]
9485
uses: ./.github/workflows/release_all_stacks.yml
9586
with:
9687
STACK_NAME: epsam
9788
TARGET_ENVIRONMENT: qa
9889
VERSION_NUMBER: ${{ needs.tag_release.outputs.version_tag }}
99-
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
90+
COMMIT_ID: ${{ github.sha }}
10091
CDK_APP_NAME: EpsAssistMeApp
10192
DEPLOY_CODE: true
10293
LOG_RETENTION_IN_DAYS: 30
10394
LOG_LEVEL: "DEBUG"
104-
CREATE_INT_RELEASE_NOTES: true
105-
CREATE_PROD_RELEASE_NOTES: true
95+
CREATE_INT_RELEASE_NOTES: false
96+
CREATE_PROD_RELEASE_NOTES: false
10697
MARK_JIRA_RELEASED: false
10798
CREATE_INT_RC_RELEASE_NOTES: false
10899
IS_PULL_REQUEST: false
100+
RUN_REGRESSION_TESTS: true
109101
secrets:
110102
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
111103
CDK_PULL_IMAGE_ROLE: ${{ secrets.QA_CDK_PULL_IMAGE_ROLE }}

.github/workflows/pull_request.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ jobs:
1919

2020
- name: Get asdf version
2121
id: asdf-version
22-
run: echo "version=0.18.0" >> "$GITHUB_OUTPUT"
23-
22+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
2423
- name: Load config value
2524
id: load-config
2625
run: |
@@ -62,31 +61,22 @@ jobs:
6261
}
6362
result-encoding: string
6463

65-
get_commit_id:
66-
runs-on: ubuntu-22.04
67-
outputs:
68-
commit_id: ${{ steps.commit_id.outputs.commit_id }}
69-
steps:
70-
- name: Get Commit ID
71-
id: commit_id
72-
run: |
73-
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
7464
package_code:
75-
needs: [get_issue_number, get_commit_id]
65+
needs: [get_issue_number]
7666
uses: ./.github/workflows/cdk_package_code.yml
7767
with:
7868
STACK_NAME: epsam-pr-${{needs.get_issue_number.outputs.issue_number}}
7969
VERSION_NUMBER: PR-${{ needs.get_issue_number.outputs.issue_number }}
80-
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
70+
COMMIT_ID: ${{ github.sha }}
8171

8272
release_code:
83-
needs: [get_issue_number, package_code, get_commit_id]
73+
needs: [get_issue_number, package_code]
8474
uses: ./.github/workflows/release_all_stacks.yml
8575
with:
8676
STACK_NAME: epsam-pr-${{needs.get_issue_number.outputs.issue_number}}
8777
TARGET_ENVIRONMENT: dev-pr
8878
VERSION_NUMBER: PR-${{ needs.get_issue_number.outputs.issue_number }}
89-
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
79+
COMMIT_ID: ${{ github.sha }}
9080
CDK_APP_NAME: EpsAssistMeApp
9181
DEPLOY_CODE: true
9282
LOG_RETENTION_IN_DAYS: 30
@@ -96,6 +86,7 @@ jobs:
9686
MARK_JIRA_RELEASED: false
9787
CREATE_INT_RC_RELEASE_NOTES: false
9888
IS_PULL_REQUEST: true
89+
RUN_REGRESSION_TESTS: true
9990
secrets:
10091
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
10192
CDK_PULL_IMAGE_ROLE: ${{ secrets.DEV_CDK_PULL_IMAGE_ROLE }}

0 commit comments

Comments
 (0)