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
58 changes: 14 additions & 44 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,14 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu

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

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 \
openjdk-8-jdk 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-traditional libyaml-dev

# Install ASDF
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;

# 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 actionlint;

WORKDIR /workspaces/eps-spine-shared
ADD .tool-versions /workspaces/eps-spine-shared/.tool-versions
ADD .tool-versions /home/vscode/.tool-versions

RUN asdf install python; \
asdf install
ARG IMAGE_NAME=node_24_python_3_10
ARG IMAGE_VERSION=latest
FROM ghcr.io/nhsdigital/eps-devcontainers/${IMAGE_NAME}:${IMAGE_VERSION}

Check warning on line 3 in .devcontainer/Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a specific version tag for the image.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_eps-spine-shared&issues=AZ0FyH3U6R-1wFxZckuD&open=AZ0FyH3U6R-1wFxZckuD&pullRequest=98

USER root
# specify DOCKER_GID to force container docker group id to match host
RUN if [ -n "${DOCKER_GID}" ]; then \
if ! getent group docker; then \
groupadd -g ${DOCKER_GID} docker; \

Check warning on line 9 in .devcontainer/Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Surround this variable with double quotes; otherwise, it can lead to unexpected behavior.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_eps-spine-shared&issues=AZ0FyH3U6R-1wFxZckuF&open=AZ0FyH3U6R-1wFxZckuF&pullRequest=98
else \
Comment on lines +5 to +10
groupmod -g ${DOCKER_GID} docker; \

Check warning on line 11 in .devcontainer/Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Surround this variable with double quotes; otherwise, it can lead to unexpected behavior.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_eps-spine-shared&issues=AZ0FyH3U6R-1wFxZckuG&open=AZ0FyH3U6R-1wFxZckuG&pullRequest=98
fi && \
usermod -aG docker vscode; \
fi
30 changes: 14 additions & 16 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
{
// 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
"name": "eps-spine-shared",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {}
"args": {
"DOCKER_GID": "${env:DOCKER_GID:}",
"IMAGE_NAME": "node_24_python_3_10",
"IMAGE_VERSION": "v1.1.3",
"USER_UID": "${localEnv:USER_ID:}",
"USER_GID": "${localEnv:GROUP_ID:}"
Comment on lines +9 to +11
}
},
"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"
],
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
"version": "latest",
"moby": "true",
"installDockerBuildx": "true"
}
},
},
"customizations": {
"vscode": {
"extensions": [
Expand All @@ -41,11 +39,11 @@
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"flake8.enabled": true,
"python.linting.enabled": true, // required to format on save
"python.linting.enabled": true,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnPaste": false, // required
"editor.formatOnType": false, // required
"editor.formatOnSave": true, // optional
"editor.formatOnPaste": false,
"editor.formatOnType": false,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.tabSize": 2,
"eslint.useFlatConfig": true,
Expand All @@ -54,5 +52,5 @@
}
},
"remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" },
"postCreateCommand": "rm -f ~/.docker/config.json; git config --global --add safe.directory /workspaces/eps-spine-shared; source ~/.bashrc; make reinstall-poetry; make install; docker build -t git-secrets -f https://raw.githubusercontent.com/NHSDigital/eps-common-workflows/3cba6a3733673bafc95526503478674332c26007/dockerfiles/nhsd-git-secrets.dockerfile ."
"postAttachCommand": "git-secrets --register-aws; git-secrets --add-provider -- cat /usr/share/secrets-scanner/nhsd-rules-deny.txt"
}
17 changes: 0 additions & 17 deletions .github/actions/get_asdf_version/action.yaml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/actions/install_dependencies/action.yaml

This file was deleted.

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}"
23 changes: 7 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,16 @@ on:
- main

jobs:
get_asdf_version:
name: Get asdf Version
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get_asdf_version.outputs.version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
name: Checkout source code

- name: Get asdf version
id: get_asdf_version
uses: ./.github/actions/get_asdf_version
get_config_values:
uses: NHSDigital/eps-common-workflows/.github/workflows/get-repo-config.yml@cd3cf9fa582d391ce9c50b10c43155eb48ca65e3
with:
verify_published_from_main_image: true

quality_checks:
name: Quality Checks
needs: get_asdf_version
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
needs: get_config_values
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks-devcontainer.yml@cd3cf9fa582d391ce9c50b10c43155eb48ca65e3
with:
asdfVersion: ${{ needs.get_asdf_version.outputs.version }}
reinstall_poetry: true
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
33 changes: 12 additions & 21 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,14 @@ on:
jobs:
pr_title_format_check:
name: PR Title Format Check
uses: NHSDigital/eps-common-workflows/.github/workflows/pr_title_check.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
uses: NHSDigital/eps-common-workflows/.github/workflows/pr_title_check.yml@cd3cf9fa582d391ce9c50b10c43155eb48ca65e3
permissions:
pull-requests: write
get_config_values:
uses: NHSDigital/eps-common-workflows/.github/workflows/get-repo-config.yml@cd3cf9fa582d391ce9c50b10c43155eb48ca65e3
with:
verify_published_from_main_image: false

get_asdf_version:
name: Get asdf Version
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get_asdf_version.outputs.version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
name: Checkout source code

- name: Get asdf version
id: get_asdf_version
uses: ./.github/actions/get_asdf_version

get_pypi_token:
name: Get PyPI Token for Trusted Publishing
Expand All @@ -43,20 +35,19 @@ jobs:

quality_checks:
name: Quality Checks
needs: get_asdf_version
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
needs: get_config_values
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks-devcontainer.yml@cd3cf9fa582d391ce9c50b10c43155eb48ca65e3
with:
asdfVersion: ${{ needs.get_asdf_version.outputs.version }}
reinstall_poetry: true
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

tag_release:
name: Tag Release (Dry Run)
needs: [get_asdf_version, get_pypi_token]
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
needs: [get_config_values, get_pypi_token]
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release-devcontainer.yml@cd3cf9fa582d391ce9c50b10c43155eb48ca65e3
with:
asdfVersion: ${{ needs.get_asdf_version.outputs.version }}
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
branch_name: ${{ github.event.pull_request.head.ref }}
dry_run: true
pypi_publish: true
Expand All @@ -69,7 +60,7 @@ jobs:
dependabot_auto_approve_and_merge:
name: Dependabot Auto Approve and Merge
needs: quality_checks
uses: NHSDigital/eps-common-workflows/.github/workflows/dependabot-auto-approve-and-merge.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
uses: NHSDigital/eps-common-workflows/.github/workflows/dependabot-auto-approve-and-merge.yml@cd3cf9fa582d391ce9c50b10c43155eb48ca65e3
permissions:
contents: write
pull-requests: write
Expand Down
59 changes: 27 additions & 32 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@ on:
workflow_dispatch:

jobs:
get_asdf_version:
name: Get asdf Version
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get-asdf-version.outputs.version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
name: Checkout source code

- name: Get asdf version
id: get-asdf-version
uses: ./.github/actions/get_asdf_version

get_pypi_token:
name: Get PyPI Token for Trusted Publishing
runs-on: ubuntu-22.04
Expand All @@ -31,41 +18,49 @@ jobs:
- name: Get PyPI token
id: get_pypi_token
uses: ./.github/actions/get_pypi_token

get_config_values:
uses: NHSDigital/eps-common-workflows/.github/workflows/get-repo-config.yml@cd3cf9fa582d391ce9c50b10c43155eb48ca65e3
with:
verify_published_from_main_image: false
quality_checks:
name: Quality Checks
needs: get_asdf_version
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
needs: get_config_values
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks-devcontainer.yml@cd3cf9fa582d391ce9c50b10c43155eb48ca65e3
with:
asdfVersion: ${{ needs.get_asdf_version.outputs.version }}
reinstall_poetry: true
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

get_next_version:
name: Get Next Version Number for Poetry
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
needs: [get_asdf_version, quality_checks]
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release-devcontainer.yml@cd3cf9fa582d391ce9c50b10c43155eb48ca65e3
needs: [get_config_values, quality_checks]
with:
asdfVersion: ${{ needs.get_asdf_version.outputs.version }}
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
branch_name: main
dry_run: true

build:
name: Build Package and Upload as Artifact
runs-on: ubuntu-22.04
needs: [get_asdf_version, get_next_version]
container:
image: ${{ needs.get_config_values.outputs.pinned_image }}
options: --user 1001:1001 --group-add 128
defaults:
run:
shell: bash
needs: [get_config_values, get_next_version]
outputs:
artifact_id: ${{ steps.upload-artifact.outputs.artifact-id }}
steps:
- name: copy .tool-versions
run: |
cp /home/vscode/.tool-versions "$HOME/.tool-versions"
- name: Git checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

- name: Install dependencies
uses: ./.github/actions/install_dependencies
with:
asdf_version: ${{ needs.get_asdf_version.outputs.version }}

uses: actions/checkout@v6
- name: make install
run: |
make install
- name: Build package
run: |
poetry version "$NEXT_VERSION"
Expand All @@ -85,10 +80,10 @@ jobs:

tag_release:
name: Tag Release
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release.yml@3166a790ef94af847ffcafc6b9fbadbf4c56f6d0
needs: [build, get_asdf_version, get_pypi_token]
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release-devcontainer.yml@cd3cf9fa582d391ce9c50b10c43155eb48ca65e3
needs: [build, get_config_values, get_pypi_token]
with:
asdfVersion: ${{ needs.get_asdf_version.outputs.version }}
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
branch_name: main
extra_artifact_name: eps_spine_shared.zip
extra_artifact_id: ${{ needs.build.outputs.artifact_id }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
entry: bash
args:
- -c
- 'docker run -v "$LOCAL_WORKSPACE_FOLDER:/src" git-secrets --pre_commit_hook'
- 'git-secrets --pre_commit_hook'
language: system

- id: python-pre-commit
Expand Down
4 changes: 0 additions & 4 deletions .tool-versions

This file was deleted.

2 changes: 0 additions & 2 deletions .tool-versions.asdf

This file was deleted.

Loading
Loading