From 30e2486b44ddf350d52d0fa13a4d0039db7f1616 Mon Sep 17 00:00:00 2001 From: williamjameswillis <77491334+williamjameswillis@users.noreply.github.com> Date: Fri, 12 Dec 2025 17:04:24 +0000 Subject: [PATCH 1/2] git submodules --- .gitmodules | 3 +++ .vscode/settings.json | 3 +++ gateway-api/src/gateway_api/handler.py | 6 +++++- pytest.ini | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..3a7be07f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "common"] + path = common + url = https://github.com/NHSDigital/clinical-data-common.git diff --git a/.vscode/settings.json b/.vscode/settings.json index 3c5f1eea..423e9213 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -45,6 +45,9 @@ "python.analysis.showOnlyDirectDependenciesInAutoImport": true, "python.analysis.autoImportCompletions": true, "python.analysis.autoIndent": false, + "python.analysis.extraPaths": [ + "${workspaceFolder}/common/src" + ], // Mypy configuration "mypy-type-checker.cwd": "${nearestConfig}", // Enable re-format on type diff --git a/gateway-api/src/gateway_api/handler.py b/gateway-api/src/gateway_api/handler.py index 940e382d..20e32cd7 100644 --- a/gateway-api/src/gateway_api/handler.py +++ b/gateway-api/src/gateway_api/handler.py @@ -1,3 +1,6 @@ +from clinical_data_common import get_hello + + class User: def __init__(self, name: str): self._name = name @@ -10,4 +13,5 @@ def name(self) -> str: def greet(user: User) -> str: if user.name == "nonexistent": raise ValueError("nonexistent user provided.") - return f"Hello, {user.name}!" + greeting = get_hello() + return f"{greeting}{user.name}!" diff --git a/pytest.ini b/pytest.ini index 2feddf4f..6461280d 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,3 @@ [pytest] bdd_features_base_dir = gateway-api/tests/acceptance/features +pythonpath = common/src From 32c998d1638b08947d04a5e758f0e01f8051376b Mon Sep 17 00:00:00 2001 From: williamjameswillis <77491334+williamjameswillis@users.noreply.github.com> Date: Fri, 12 Dec 2025 17:16:34 +0000 Subject: [PATCH 2/2] fix pre commit hooks to ignore common submodule --- common | 1 + gateway-api/pyproject.toml | 1 + scripts/githooks/check-english-usage.sh | 8 ++++---- scripts/githooks/check-file-format.sh | 4 ++-- scripts/githooks/check-markdown-format.sh | 6 ++++-- 5 files changed, 12 insertions(+), 8 deletions(-) create mode 160000 common diff --git a/common b/common new file mode 160000 index 00000000..abef569d --- /dev/null +++ b/common @@ -0,0 +1 @@ +Subproject commit abef569d6c398392f16c65f93b99de0a8f69fc8b diff --git a/gateway-api/pyproject.toml b/gateway-api/pyproject.toml index acf40fcc..9d3077ab 100644 --- a/gateway-api/pyproject.toml +++ b/gateway-api/pyproject.toml @@ -53,3 +53,4 @@ dev = [ [tool.mypy] strict = true +mypy_path = "../common/src" diff --git a/scripts/githooks/check-english-usage.sh b/scripts/githooks/check-english-usage.sh index b3942deb..dced9f30 100755 --- a/scripts/githooks/check-english-usage.sh +++ b/scripts/githooks/check-english-usage.sh @@ -31,16 +31,16 @@ function main() { check=${check:-working-tree-changes} case $check in "all") - filter="git ls-files" + filter="git ls-files | grep -v '^common/'" ;; "staged-changes") - filter="git diff --diff-filter=ACMRT --name-only --cached" + filter="git diff --diff-filter=ACMRT --name-only --cached | grep -v '^common/'" ;; "working-tree-changes") - filter="git diff --diff-filter=ACMRT --name-only" + filter="git diff --diff-filter=ACMRT --name-only | grep -v '^common/'" ;; "branch") - filter="git diff --diff-filter=ACMRT --name-only ${BRANCH_NAME:-origin/main}" + filter="git diff --diff-filter=ACMRT --name-only ${BRANCH_NAME:-origin/main} | grep -v '^common/'" ;; *) echo "Unrecognised check mode: $check" >&2 && exit 1 diff --git a/scripts/githooks/check-file-format.sh b/scripts/githooks/check-file-format.sh index d7c94747..c1936da5 100755 --- a/scripts/githooks/check-file-format.sh +++ b/scripts/githooks/check-file-format.sh @@ -81,7 +81,7 @@ function run-editorconfig-natively() { # shellcheck disable=SC2046,SC2086 editorconfig \ - --exclude '.git/' $dry_run_opt $($filter) + --exclude '.git/' --exclude 'common/' $dry_run_opt $($filter) } # Run editorconfig in a Docker container. @@ -101,7 +101,7 @@ function run-editorconfig-in-docker() { docker run --rm --platform linux/amd64 \ --volume "$PWD":/check \ "$image" \ - sh -c "ec --exclude '.git/' $dry_run_opt \$($filter) /dev/null" + sh -c "ec --exclude '.git/' --exclude 'common/' $dry_run_opt \$($filter) /dev/null" } # ============================================================================== diff --git a/scripts/githooks/check-markdown-format.sh b/scripts/githooks/check-markdown-format.sh index c223381b..448e2703 100755 --- a/scripts/githooks/check-markdown-format.sh +++ b/scripts/githooks/check-markdown-format.sh @@ -72,7 +72,8 @@ function run-markdownlint-natively() { # shellcheck disable=SC2086 markdownlint \ $files \ - --config "$PWD/scripts/config/.markdownlint.yaml" + --config "$PWD/scripts/config/.markdownlint.yaml" \ + --ignore "common/**" } # Run markdownlint in a Docker container. @@ -90,7 +91,8 @@ function run-markdownlint-in-docker() { --volume "$PWD":/workdir \ "$image" \ $files \ - --config /workdir/scripts/config/.markdownlint.yaml + --config /workdir/scripts/config/.markdownlint.yaml \ + --ignore \"common/**\" } # ==============================================================================