From 00e49bbde9604f48e17da61f0d1f498b7b219444 Mon Sep 17 00:00:00 2001 From: Alan Christie Date: Fri, 15 Aug 2025 16:06:21 +0100 Subject: [PATCH 1/5] test: Fix test module name (for consistency) --- tests/{test_test_api_adapter.py => test_test_wapi_adapter.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{test_test_api_adapter.py => test_test_wapi_adapter.py} (100%) diff --git a/tests/test_test_api_adapter.py b/tests/test_test_wapi_adapter.py similarity index 100% rename from tests/test_test_api_adapter.py rename to tests/test_test_wapi_adapter.py From 39bb840888eee2a4305495dda689d72ad5379316 Mon Sep 17 00:00:00 2001 From: "Alan B. Christie" <29806285+alanbchristie@users.noreply.github.com> Date: Fri, 15 Aug 2025 22:25:22 +0100 Subject: [PATCH 2/5] Remove unnecessary logic --- tests/instance_launcher.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/instance_launcher.py b/tests/instance_launcher.py index ab7cab2..3256c0b 100644 --- a/tests/instance_launcher.py +++ b/tests/instance_launcher.py @@ -76,19 +76,15 @@ def launch(self, launch_parameters: LaunchParameters) -> LaunchResult: os.makedirs(EXECUTION_DIRECTORY, exist_ok=True) - # We're passed a RunningWorkflowStep ID but a record is expected to have been - # created bt the caller, we simply create instance records. - response, _ = self._api_adapter.get_running_workflow_step( - running_workflow_step_id=launch_parameters.running_workflow_step_id - ) - # Now simulate the creation of a Task and Instance record + # Create an Instance record (and dummy Task ID) response = self._api_adapter.create_instance( running_workflow_step_id=launch_parameters.running_workflow_step_id ) instance_id = response["id"] task_id = "task-00000000-0000-0000-0000-000000000001" - # Apply variables to the step's Job command. + # Get the job defitnion. + # This is expected to exist in the tests/job-definitions directory. job, _ = self._api_adapter.get_job( collection=launch_parameters.specification["collection"], job=launch_parameters.specification["job"], @@ -96,7 +92,8 @@ def launch(self, launch_parameters: LaunchParameters) -> LaunchResult: ) assert job - # Now apply the variables to the command + # Now apply the provided variables to the command. + # The command may not need any, but we do the decoding anyway. decoded_command, status = job_decoder.decode( job["command"], launch_parameters.specification_variables, From 0da1a595fe46fd9015fb58ebc1e8da108cf06aff Mon Sep 17 00:00:00 2001 From: Alan Christie Date: Thu, 21 Aug 2025 17:02:36 +0000 Subject: [PATCH 3/5] build: Add devcontainer --- .devcontainer/devcontainer.json | 49 +++++++++++++++++++++++++++++++++ .gitignore | 1 + requirements.txt | 2 ++ 3 files changed, 52 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 requirements.txt diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..cc5a44e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,49 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/python +{ + "name": "Python 3", + "image": "mcr.microsoft.com/devcontainers/python:1-3.13-bullseye", + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "moby": true, + "azureDnsAutoDetection": true, + "installDockerBuildx": true, + "installDockerComposeSwitch": true, + "version": "latest", + "dockerDashComposeVersion": "v2" + }, + "ghcr.io/devcontainers/features/git:1": { + "ppa": true, + "version": "os-provided" + } + }, + // We mount bash history in an attempt to preserver history + // between container restarts + // (see https://code.visualstudio.com/remote/advancedcontainers/persist-bash-history) + "mounts": [ + "source=projectname-bashhistory,target=/commandhistory,type=volume" + ], + "customizations": { + "vscode": { + "extensions": [ + "codezombiech.gitignore", + "donjayamanne.githistory", + "donjayamanne.git-extension-pack", + "eamodio.gitlens", + "github.vscode-github-actions", + "ms-kubernetes-tools.vscode-kubernetes-tools", + "ms-python.vscode-pylance", + "sourcery.sourcery", + "streetsidesoftware.code-spell-checker", + "trond-snekvik.simple-rst", + "vivaxy.vscode-conventional-commits", + "yzhang.markdown-all-in-one" + ] + } + }, + "postCreateCommand": { + "Install Python requirements": "pip3 install --user -r requirements.txt", + "Fix Volume Permissions": "sudo chown -R $(whoami): /commandhistory" + }, + "forwardPorts": [] +} diff --git a/.gitignore b/.gitignore index 6e25b42..27fa4a4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ dist/ **/__pycache__/ **/*.pickle tests/project-root/project-*/ +**/.DS_Store # temp files *~ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..801c6a7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +poetry == 1.8.5 +pre-commit == 4.2.0 From 6ddca27390fb816e846b6dc34840e2d10f5a3728 Mon Sep 17 00:00:00 2001 From: Alan Christie Date: Thu, 21 Aug 2025 17:12:14 +0000 Subject: [PATCH 4/5] build: No need for DinD --- .devcontainer/devcontainer.json | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cc5a44e..c15be0a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,17 +1,9 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/python { - "name": "Python 3", + "name": "WorkflowEngine Python 3.13", "image": "mcr.microsoft.com/devcontainers/python:1-3.13-bullseye", "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": { - "moby": true, - "azureDnsAutoDetection": true, - "installDockerBuildx": true, - "installDockerComposeSwitch": true, - "version": "latest", - "dockerDashComposeVersion": "v2" - }, "ghcr.io/devcontainers/features/git:1": { "ppa": true, "version": "os-provided" From bca4f9c6295ca02b58edef5b0870412c062c1907 Mon Sep 17 00:00:00 2001 From: Alan Christie Date: Thu, 21 Aug 2025 17:12:32 +0000 Subject: [PATCH 5/5] docs: Docs on devcontainer --- README.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index c86b422..1f471d3 100644 --- a/README.rst +++ b/README.rst @@ -38,10 +38,9 @@ The project's written in Python and uses `Poetry`_ for dependency and package management. We also use `pre-commit`_ to manage our pre-commit hooks, which rely on `black`_, `mypy`_, `pylint`_, amongst others. -Create your environment:: +From within a VS Code `devcontainer`_] environment (recommended):: - poetry shell - poetry install --with dev + poetry install --with dev --sync pre-commit install -t commit-msg -t pre-commit And then start by running the pre-commit hooks to ensure you're stating with a @@ -51,9 +50,10 @@ _clean_ project:: And then run the tests:: - coverage run -m pytest - coverage report + poetry run coverage run -m pytest + poetry run coverage report +.. _devcontainer: https://code.visualstudio.com/docs/devcontainers/containers .. _Poetry: https://python-poetry.org .. _pre-commit: https://pre-commit.com .. _black: https://github.com/psf/black