Skip to content

Commit 8f59e48

Browse files
committed
Merge remote-tracking branch 'origin/main' into cdk_construct
2 parents 1101650 + 06b292b commit 8f59e48

9 files changed

Lines changed: 772 additions & 6631 deletions

File tree

.devcontainer/Dockerfile

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

3+
4+
ARG TARGETARCH
5+
ENV TARGETARCH=${TARGETARCH}
6+
7+
ARG ASDF_VERSION
8+
COPY .tool-versions.asdf /tmp/.tool-versions.asdf
9+
310
RUN apt-get update \
411
&& export DEBIAN_FRONTEND=noninteractive \
512
&& apt-get -y dist-upgrade \
@@ -11,21 +18,41 @@ RUN apt-get update \
1118
libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \
1219
xz-utils tk-dev liblzma-dev netcat libyaml-dev
1320

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

21-
USER vscode
32+
# Download correct SAM CLI for arch
33+
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \
34+
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-arm64.zip"; \
35+
else \
36+
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip"; \
37+
fi && \
38+
unzip /tmp/aws-sam-cli.zip -d /tmp/aws-sam-cli && \
39+
/tmp/aws-sam-cli/install && \
40+
rm /tmp/aws-sam-cli.zip && rm -rf /tmp/aws-sam-cli
2241

2342
# Install ASDF
24-
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.1; \
25-
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \
26-
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc;
43+
RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
44+
if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
45+
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; \
46+
else \
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+
fi && \
49+
tar -xvzf /tmp/asdf.tar.gz && \
50+
mv asdf /usr/bin
51+
52+
53+
USER vscode
2754

28-
ENV PATH="$PATH:/home/vscode/.asdf/bin/:/workspaces/eps-cdk-utils/node_modules/.bin"
55+
ENV PATH="$PATH:/home/vscode/.asdf/shims/:/workspaces/eps-cdk-utils/node_modules/.bin"
2956

3057
# Install ASDF plugins
3158
RUN asdf plugin add python; \
@@ -40,8 +67,5 @@ WORKDIR /workspaces/eps-workflow-quality-checks
4067
ADD .tool-versions /workspaces/eps-cdk-utils/.tool-versions
4168
ADD .tool-versions /home/vscode/.tool-versions
4269

43-
RUN asdf install; \
44-
asdf reshim python; \
45-
asdf reshim poetry; \
46-
asdf reshim nodejs; \
47-
asdf direnv setup --shell bash --version 2.32.2;
70+
RUN asdf install python; \
71+
asdf install

.github/config/settings.yml

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

.github/workflows/ci.yml

Lines changed: 60 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -8,93 +8,59 @@ env:
88
BRANCH_NAME: ${{ github.ref_name }}
99

1010
jobs:
11-
quality_checks:
12-
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/quality-checks.yml@v4.1.3
13-
secrets:
14-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
15-
1611
get_commit_id:
1712
runs-on: ubuntu-22.04
1813
outputs:
1914
commit_id: ${{ steps.commit_id.outputs.commit_id }}
15+
sha_short: ${{ steps.commit_id.outputs.sha_short }}
16+
2017
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v5
20+
with:
21+
ref: ${{ env.BRANCH_NAME }}
22+
2123
- name: Get Commit ID
2224
id: commit_id
2325
run: |
26+
# echo "commit_id=${{ github.sha }}" >> "$GITHUB_ENV"
2427
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
25-
26-
tag_release:
27-
needs: quality_checks
28+
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
29+
get_asdf_version:
2830
runs-on: ubuntu-22.04
2931
outputs:
30-
version_tag: ${{steps.output_version_tag.outputs.VERSION_TAG}}
32+
asdf_version: ${{ steps.asdf-version.outputs.version }}
33+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
3134
steps:
3235
- name: Checkout code
3336
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.14.1
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-
5237

53-
- name: Install asdf dependencies in .tool-versions
54-
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
55-
with:
56-
asdf_branch: v0.14.1
57-
env:
58-
PYTHON_CONFIGURE_OPTS: --enable-shared
59-
60-
- name: Setting up .npmrc
61-
env:
62-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Get asdf version
39+
id: asdf-version
40+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
41+
- name: Load config value
42+
id: load-config
6343
run: |
64-
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
65-
echo "@NHSDigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
66-
67-
- name: Install node packages
68-
run: |
69-
make install-node
44+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
45+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
46+
quality_checks:
47+
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/quality-checks.yml@4a6d03ad51516eddc448daf454805f85fe2025b9
48+
needs: [get_asdf_version, get_commit_id]
49+
with:
50+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
51+
secrets:
52+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
7053

71-
- name: Set VERSION_TAG env var to be short git SHA and get next tag version
72-
id: output_version_tag
73-
run: |
74-
VERSION_TAG=$(git rev-parse --short HEAD)
75-
npx semantic-release --dry-run > semantic-release-output.log
76-
NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/')
77-
if [ -z "${NEXT_VERSION}" ]
78-
then
79-
echo "Could not get next tag. Here is the log from semantic-release"
80-
cat semantic-release-output.log
81-
exit 1
82-
fi
83-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
84-
if [ "${tagFormat}" = "null" ]
85-
then
86-
tagFormat="v\${version}"
87-
fi
88-
# disabling shellcheck as replace does not work
89-
# shellcheck disable=SC2001
90-
NEW_VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
91-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
92-
echo "## NEXT TAG WILL BE : ${NEW_VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
93-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
94-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
95-
env:
96-
GITHUB_TOKEN: ${{ github.token }}
97-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
tag_release:
55+
needs: [quality_checks, get_commit_id, get_asdf_version]
56+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99
57+
with:
58+
dry_run: false
59+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
60+
branch_name: main
61+
publish_package: false
62+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
63+
secrets: inherit
9864

9965
package_code:
10066
needs: [tag_release, quality_checks, get_commit_id]
@@ -141,3 +107,27 @@ jobs:
141107
DOCKER_IMAGE_TAG: ${{needs.tag_release.outputs.version_tag}}
142108
secrets:
143109
CDK_PUSH_IMAGE_ROLE: ${{ secrets.REF_CDK_PUSH_IMAGE_ROLE }}
110+
111+
release_int:
112+
needs: [tag_release, release_qa, package_code, get_commit_id]
113+
uses: ./.github/workflows/docker_image_upload.yml
114+
with:
115+
AWS_ENVIRONMENT: int
116+
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
117+
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
118+
TAG_LATEST: true
119+
DOCKER_IMAGE_TAG: ${{needs.tag_release.outputs.version_tag}}
120+
secrets:
121+
CDK_PUSH_IMAGE_ROLE: ${{ secrets.INT_CDK_PUSH_IMAGE_ROLE }}
122+
123+
release_prod:
124+
needs: [tag_release, release_int, package_code, get_commit_id]
125+
uses: ./.github/workflows/docker_image_upload.yml
126+
with:
127+
AWS_ENVIRONMENT: prod
128+
VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}}
129+
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
130+
TAG_LATEST: true
131+
DOCKER_IMAGE_TAG: ${{needs.tag_release.outputs.version_tag}}
132+
secrets:
133+
CDK_PUSH_IMAGE_ROLE: ${{ secrets.PROD_CDK_PUSH_IMAGE_ROLE }}

.github/workflows/pull_request.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,33 @@ env:
88
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
99

1010
jobs:
11-
pr_title_format_check:
12-
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/pr_title_check.yml@13024fccca97e125d448ca9bc4616cfd413197fe
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@v5
1319

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/config/settings.yml)
27+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
28+
pr_title_format_check:
29+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/pr_title_check.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99
1430
quality_checks:
15-
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/quality-checks.yml@v4.1.3
31+
uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/quality-checks.yml@4a6d03ad51516eddc448daf454805f85fe2025b9
32+
needs: [get_asdf_version, get_commit_id]
33+
with:
34+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
1635
secrets:
1736
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1837

19-
dependabot-auto-approve-and-merge:
20-
needs: quality_checks
21-
uses: NHSDigital/eps-workflow-dependabot/.github/workflows/dependabot-auto-approve-and-merge.yml@5dd998ea44b2e412ea51544b565be3d67f54dc41
22-
secrets:
23-
AUTOMERGE_APP_ID: ${{ secrets.AUTOMERGE_APP_ID }}
24-
AUTOMERGE_PEM: ${{ secrets.AUTOMERGE_PEM }}
25-
2638
get_issue_number:
2739
runs-on: ubuntu-22.04
2840
outputs:

.tool-versions.asdf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# define the .asdf-version to use here
2+
0.18.0

0 commit comments

Comments
 (0)