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
31 changes: 21 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"request": "launch",
"justMyCode": false,
"program": "/venv/bin/deploy-tools",
"args": "validate ${input:from-scratch} ${input:test-build} ${input:deploy-folder} ${input:config-folder}",
"args": "validate ${input:allow-all} ${input:from-scratch} ${input:test-build} ${input:deploy-folder} ${input:config-folder}",
"console": "integratedTerminal",
"env": {
// Enable break on exception when debugging tests (see: tests/conftest.py)
Expand All @@ -51,7 +51,7 @@
"request": "launch",
"justMyCode": false,
"program": "/venv/bin/deploy-tools",
"args": "compare ${input:use-previous} ${input:deploy-folder}",
"args": "compare ${input:compare-mode} ${input:deploy-folder}",
"console": "integratedTerminal",
"env": {
// Enable break on exception when debugging tests (see: tests/conftest.py)
Expand All @@ -64,7 +64,7 @@
"request": "launch",
"justMyCode": false,
"program": "/venv/bin/deploy-tools",
"args": "sync ${input:from-scratch} ${input:deploy-folder} ${input:config-folder}",
"args": "sync ${input:allow-all} ${input:from-scratch} ${input:deploy-folder} ${input:config-folder}",
"console": "integratedTerminal",
"env": {
// Enable break on exception when debugging tests (see: tests/conftest.py)
Expand All @@ -91,32 +91,43 @@
"default": "${workspaceFolder}/src/deploy_tools/demo_configuration/",
"type": "promptString"
},
{
"id": "allow-all",
"description": "Allow all lifecycle transitions",
"options": [
"",
"--allow-all"
],
"default": "",
"type": "pickString"
},
{
"id": "from-scratch",
"description": "Allow a complete redeployment to an empty directory",
"options": [
"--not-from-scratch",
"",
"--from-scratch"
],
"default": "--no-from-scratch",
"default": "",
"type": "pickString"
},
{
"id": "use-previous",
"description": "Compare against previous Deployment snapshot",
"id": "compare-mode",
"description": "Compare against previous Deployment snapshot or from scratch",
"options": [
"--use-current",
"--use-previous"
"--use-previous",
"--from-scratch"
],
"default": "--no-use-previous",
"default": "--use-current",
"type": "pickString"
},
{
"id": "test-build",
"description": "Include test build of the deployment changes",
"options": [
"--test-build",
"--no-test-build"
""
],
"default": "--test-build",
"type": "pickString"
Expand Down
31 changes: 21 additions & 10 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{
"label": "Sync modules",
"type": "shell",
"command": "deploy-tools sync ${input:from-scratch} ${input:deploy-folder} ${input:config-folder}",
"command": "deploy-tools sync ${input:allow-all} ${input:from-scratch} ${input:deploy-folder} ${input:config-folder}",
"problemMatcher": []
},
{
Expand All @@ -33,13 +33,13 @@
{
"label": "Validate deployment",
"type": "shell",
"command": "deploy-tools validate ${input:from-scratch} ${input:test-build} ${input:deploy-folder} ${input:config-folder}",
"command": "deploy-tools validate ${input:allow-all} ${input:from-scratch} ${input:test-build} ${input:deploy-folder} ${input:config-folder}",
"problemMatcher": []
},
{
"label": "Compare deployment to snapshot",
"type": "shell",
"command": "deploy-tools compare ${input:use-previous} ${input:deploy-folder}",
"command": "deploy-tools compare ${input:compare-mode} ${input:deploy-folder}",
"problemMatcher": []
},
],
Expand All @@ -62,32 +62,43 @@
"default": "${workspaceFolder}/src/deploy_tools/demo_configuration/",
"type": "promptString"
},
{
"id": "allow-all",
"description": "Allow all lifecycle transitions",
"options": [
"",
"--allow-all"
],
"default": "",
"type": "pickString"
},
{
"id": "from-scratch",
"description": "Allow a complete redeployment to an empty directory",
"options": [
"--not-from-scratch",
"",
"--from-scratch"
],
"default": "--no-from-scratch",
"default": "",
"type": "pickString"
},
{
"id": "use-previous",
"description": "Compare against previous Deployment snapshot",
"id": "compare-mode",
"description": "Compare against previous Deployment snapshot or from scratch",
"options": [
"--use-current",
"--use-previous"
"--use-previous",
"--from-scratch"
],
"default": "--no-use-previous",
"default": "--use-current",
"type": "pickString"
},
{
"id": "test-build",
"description": "Include test build of the deployment changes",
"options": [
"--test-build",
"--no-test-build"
""
],
"default": "--test-build",
"type": "pickString"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ bit different to the CLI commands; see `deploy-tools --help` for more informatio

|**Step**|**Description** |
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|Compare |Compare the snapshot taken of the previous deployment with the modulefiles and built modules that already exist. This ensures that the Deployment Area is in a healthy state |
|Validate|Process the updated configuration. By comparing the new configuration files with a snapshot from the previous deployment, we determine the set of actions that need to be taken |
|Check |With the set of expected changes, perform some basic checks of the deployment area to ensure there are no major issues preventing the Deploy step from running |
|Build |Generate entrypoint scripts, configuration files and environment variables for a given Module. These are output to the Build Area |
|Deploy |Move all built Modules from the Build Area into the Modules Area. A link to the built modulefile is moved to either the Modulefiles Folder or Deprecated Folder, depending on its deprecation status. Update default versions for the modulefiles|

Expand Down Expand Up @@ -85,7 +85,7 @@ in greater detail.
|Generate Schema |`deploy-tools schema` |Generate the yaml schema (in .json format) for the top-level configuration files |
|Clean deployment |`rm -rf <Deployment Root>`|Wipe the deployment area local to your own checkout of deploy-tools, enabling you to test a deployment from scratch |
|Sync Modules |`deploy-tools sync` |Synchronise the Deployment configuration with the Deployment Area |
|Validate deployment |`deploy-tools validate` |Compare the new configuration with that previously used when deploying modules, and check that all expected Deploy operations are unlikely to fail. This will also test the build process if requested. |
|Validate deployment |`deploy-tools validate` |Compare the new configuration with that previously used when deploying modules, and test the build process if requested |
|Compare deployment to snapshot|`deploy-tools compare` |Compare the configuration stored from the last `deploy-tools sync` run, with the state of any deployed Modules. This should always be run by CI/CD before attempting to Deploy, and any differences will be reported|

## Glossary
Expand Down
40 changes: 32 additions & 8 deletions src/deploy_tools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .compare import compare_to_snapshot
from .models.schema import generate_schema
from .sync import synchronise
from .validate import validate_and_check_configuration
from .validate import validate_and_test_configuration

__all__ = ["main"]

Expand All @@ -35,6 +35,7 @@
dir_okay=True,
writable=True,
show_default=False,
resolve_path=True,
help="Root of the deployment area to use.",
),
]
Expand All @@ -45,6 +46,7 @@
file_okay=False,
dir_okay=True,
show_default=False,
resolve_path=True,
help="Folder containing configuration for deployment.",
),
]
Expand All @@ -56,20 +58,33 @@
dir_okay=True,
writable=True,
show_default=False,
resolve_path=True,
help="Output path to write all .json schema files to.",
),
]
ALLOW_ALL_OPTION = Annotated[
bool,
typer.Option(
"--allow-all",
show_default="False", # Shows default as 'False'
help="Allow all lifecycle transitions. This still requires the deployment area "
"to be in a healthy state.",
),
]
FROM_SCRATCH_OPTION = Annotated[
bool,
typer.Option(
"--from-scratch/--not-from-scratch",
"--from-scratch",
show_default="False", # Shows default as 'False'
help="Deploy into an empty deployment area.",
),
]
TEST_BUILD_OPTION = Annotated[
bool,
typer.Option(
"--test-build/--no-test-build", help="Test the build in a temporary directory."
"--test-build",
show_default="False", # Shows default as 'False'
help="Test the build in a temporary directory.",
),
]
USE_PREVIOUS_OPTION = Annotated[
Expand Down Expand Up @@ -100,6 +115,7 @@
def sync(
deployment_root: DEPLOYMENT_ROOT_ARGUMENT,
config_folder: CONFIG_FOLDER_ARGUMENT,
allow_all: ALLOW_ALL_OPTION = False,
from_scratch: FROM_SCRATCH_OPTION = False,
verbose: VERBOSE_OPTION = 0,
) -> None:
Expand All @@ -108,31 +124,39 @@
This will also run the validate command beforehand, but without printing the
expected changes.
"""
synchronise(deployment_root, config_folder, from_scratch)
if from_scratch:
allow_all = True

Check warning on line 128 in src/deploy_tools/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/deploy_tools/__main__.py#L127-L128

Added lines #L127 - L128 were not covered by tests

synchronise(deployment_root, config_folder, allow_all, from_scratch)

Check warning on line 130 in src/deploy_tools/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/deploy_tools/__main__.py#L130

Added line #L130 was not covered by tests


@app.command(no_args_is_help=True)
def validate(
deployment_root: DEPLOYMENT_ROOT_ARGUMENT,
config_folder: CONFIG_FOLDER_ARGUMENT,
from_scratch: FROM_SCRATCH_OPTION = False,
test_build: TEST_BUILD_OPTION = True,
allow_all: ALLOW_ALL_OPTION = False,
test_build: TEST_BUILD_OPTION = False,
verbose: VERBOSE_OPTION = 0,
) -> None:
"""Validate deployment configuration and print a list of expected module changes.

If specified, this includes a test build of the provided configuration. The
configuration validation is the same as used by the deploy-tools sync command.
"""
validate_and_check_configuration(
deployment_root, config_folder, from_scratch, test_build
if from_scratch:
allow_all = True

Check warning on line 148 in src/deploy_tools/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/deploy_tools/__main__.py#L147-L148

Added lines #L147 - L148 were not covered by tests

validate_and_test_configuration(

Check warning on line 150 in src/deploy_tools/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/deploy_tools/__main__.py#L150

Added line #L150 was not covered by tests
deployment_root, config_folder, allow_all, from_scratch, test_build
)


@app.command(no_args_is_help=True)
def compare(
deployment_root: DEPLOYMENT_ROOT_ARGUMENT,
use_previous: USE_PREVIOUS_OPTION = False,
from_scratch: FROM_SCRATCH_OPTION = False,
verbose: VERBOSE_OPTION = 0,
) -> None:
"""Compare the deployment snapshot to deployed modules in the deployment root.
Expand All @@ -141,7 +165,7 @@
deploy step, we can use this function to determine any required steps for fixing
files in the deployment root.
"""
compare_to_snapshot(deployment_root, use_previous)
compare_to_snapshot(deployment_root, use_previous, from_scratch)

Check warning on line 168 in src/deploy_tools/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/deploy_tools/__main__.py#L168

Added line #L168 was not covered by tests


@app.command(no_args_is_help=True)
Expand Down
104 changes: 0 additions & 104 deletions src/deploy_tools/check_deploy.py

This file was deleted.

Loading
Loading