Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 37 additions & 20 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu

ARG TARGETARCH
ENV TARGETARCH=${TARGETARCH}

ARG ASDF_VERSION
COPY .tool-versions.asdf /tmp/.tool-versions.asdf

# Add amd64 architecture if on arm64
RUN if [ "$TARGETARCH" == "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then dpkg --add-architecture amd64; fi

RUN apt-get update \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y dist-upgrade \
Expand All @@ -12,32 +21,42 @@ RUN apt-get update \
xz-utils tk-dev liblzma-dev netcat-traditional ruby-full build-essential zlib1g-dev \
&& apt remove -y openjdk-8-jdk-headless openjdk-8-jre-headless openjdk-8-jre

# install aws stuff
RUN wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
# Download correct AWS CLI for arch
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \
else \
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"; \
fi && \
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 && \
rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli

# Download correct SAM CLI for arch
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-arm64.zip"; \
else \
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip"; \
fi && \
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
rm /tmp/aws-sam-cli.zip && rm -rf /tmp/aws-sam-cli

# 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; \
RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
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; \
tar -xvzf /tmp/asdf.tar.gz; \
mv asdf /usr/bin

USER vscode

ENV PATH="/home/vscode/.asdf/shims/:$PATH"
RUN \
echo 'PATH="/home/vscode/.asdf/shims/:$PATH"' >> ~/.bashrc; \
echo '. <(asdf completion 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/"


# Install ASDF plugins
RUN asdf plugin add python; \
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \
Expand All @@ -52,7 +71,5 @@ WORKDIR /workspaces/validation-service-fhir-r4
ADD .tool-versions /workspaces/validation-service-fhir-r4/.tool-versions
ADD .tool-versions /home/vscode/.tool-versions

RUN asdf install; \
asdf reshim python; \
asdf reshim poetry; \
asdf reshim java;
RUN asdf install python; \
asdf intstall
1 change: 1 addition & 0 deletions .github/config/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TAG_FORMAT: "v${version}"
77 changes: 20 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,71 +24,34 @@ jobs:
id: commit_id
run: |
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"

tag_release:
needs: quality_checks
get_asdf_version:
runs-on: ubuntu-22.04
outputs:
version_tag: ${{steps.output_version_tag.outputs.VERSION_TAG}}
asdf_version: ${{ steps.asdf-version.outputs.version }}
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
steps:
- name: Checkout code
uses: actions/checkout@v5
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@1902764435ca0dd2f3388eea723a4f92a4eb8302
with:
asdf_branch: v0.11.3

- name: Cache asdf
uses: actions/cache@v4
with:
path: |
~/.asdf
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-asdf-

- name: Install asdf dependencies in .tool-versions
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
with:
asdf_branch: v0.11.3
env:
PYTHON_CONFIGURE_OPTS: --enable-shared

- name: Install node packages
- name: Get asdf version
id: asdf-version
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
- name: Load config value
id: load-config
run: |
make install-node
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"

- 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 }}
tag_release:
needs: [quality_checks, get_commit_id, get_asdf_version]
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@2a3f4ab96e04b7547c4ee5b786745b98809c89be
with:
dry_run: true
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
branch_name: main
publish_package: false
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
secrets: inherit

package_code:
needs: tag_release
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/pr_title_check.yml

This file was deleted.

30 changes: 29 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
install_java: true

pr_title_format_check:
uses: ./.github/workflows/pr_title_check.yml
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/pr_title_check.yml@7abf2a3233d1b08d6566570dbde34b85daa47859

get_issue_number:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -44,6 +44,34 @@ jobs:
).data[0].number;
}
result-encoding: string
get_asdf_version:
runs-on: ubuntu-22.04
outputs:
asdf_version: ${{ steps.asdf-version.outputs.version }}
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Get asdf version
id: asdf-version
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
- name: Load config value
id: load-config
run: |
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"

tag_release:
needs: [get_asdf_version]
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@2a3f4ab96e04b7547c4ee5b786745b98809c89be
with:
dry_run: true
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
branch_name: ${{ github.event.pull_request.head.ref }}
publish_package: false
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
secrets: inherit

get_commit_id:
runs-on: ubuntu-22.04
Expand Down
96 changes: 20 additions & 76 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,90 +24,34 @@ jobs:
run: |
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"

tag_release:
needs: quality_checks
get_asdf_version:
runs-on: ubuntu-22.04
outputs:
version_tag: ${{steps.output_version_tag.outputs.VERSION_TAG}}
asdf_version: ${{ steps.asdf-version.outputs.version }}
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
steps:
- name: Checkout code
uses: actions/checkout@v5
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@1902764435ca0dd2f3388eea723a4f92a4eb8302
with:
asdf_branch: v0.11.3

- name: Cache asdf
uses: actions/cache@v4
with:
path: |
~/.asdf
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-asdf-

- name: Install asdf dependencies in .tool-versions
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
with:
asdf_branch: v0.11.3
env:
PYTHON_CONFIGURE_OPTS: --enable-shared

- name: Install node packages
run: |
make install-node

- name: Set VERSION_TAG to be next tag varsion
id: output_version_tag
run: |
NEXT_VERSION=$(npx semantic-release --dry-run | grep -i 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/')
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
VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
env:
GITHUB_TOKEN: ${{ github.token }}

- name: tag release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get asdf version
id: asdf-version
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
- name: Load config value
id: load-config
run: |
npx semantic-release

- name: Get release for editing
id: get_release
# version 1.2.4
uses: cardinalby/git-get-release-action@5172c3a026600b1d459b117738c605fabc9e4e44
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: ${{ env.VERSION_TAG }}

- name: Edit Release
# version 1.2.0
uses: irongut/EditRelease@ccf529ad26dddf9996e7dd0f24ca5da4ea507cc2
with:
token: ${{ secrets.GITHUB_TOKEN }}
id: ${{ steps.get_release.outputs.id }}
body: |
## Info
[See code diff](${{ github.event.compare }})
[Release workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
tag_release:
needs: [quality_checks, get_commit_id, get_asdf_version]
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@2a3f4ab96e04b7547c4ee5b786745b98809c89be
with:
dry_run: false
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
branch_name: main
publish_package: false
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
secrets: inherit

It was initialized by [${{ github.event.sender.login }}](${{ github.event.sender.html_url }})

package_code:
needs: tag_release
uses: ./.github/workflows/sam_package_code.yml
Expand Down
Loading
Loading