shipit-cli 0.19.0__tar.gz → 0.19.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/PKG-INFO +1 -1
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/pyproject.toml +1 -1
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/assets/wordpress/install.sh +3 -1
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/cli.py +6 -3
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/runners/base.py +6 -2
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/runners/local.py +6 -27
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/runners/wasmer.py +10 -21
- shipit_cli-0.19.1/src/shipit/version.py +5 -0
- shipit_cli-0.19.1/src/shipit/volumes.py +90 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/tests/test_cli_after_deploy.py +33 -1
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/tests/test_volumes.py +10 -6
- shipit_cli-0.19.0/src/shipit/version.py +0 -5
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/.gitignore +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/README.md +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/__init__.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/assets/php/php.ini +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/assets/wordpress/.htaccess +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/assets/wordpress/start.php +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/assets/wordpress/wp-config.php +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/builders/__init__.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/builders/base.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/builders/docker.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/builders/local.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/generator.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/procfile.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/base.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/go.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/hugo.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/jekyll.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/laravel.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/mkdocs.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/node_static.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/php.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/python.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/registry.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/staticfile.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/providers/wordpress.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/runners/__init__.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/shipit_types.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/ui.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/src/shipit/utils.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/tests/test_e2e.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/tests/test_generate_shipit_examples.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/tests/test_php_provider.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/tests/test_staticfile_provider.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/tests/test_version.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/tests/test_wasmer_annotations.py +0 -0
- {shipit_cli-0.19.0 → shipit_cli-0.19.1}/tests/test_wordpress_phpix.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: shipit-cli
|
|
3
|
-
Version: 0.19.
|
|
3
|
+
Version: 0.19.1
|
|
4
4
|
Summary: Shipit CLI is the best way to build, serve and deploy your projects anywhere.
|
|
5
5
|
Project-URL: homepage, https://wasmer.io
|
|
6
6
|
Project-URL: repository, https://github.com/wasmerio/shipit
|
|
@@ -19,7 +19,9 @@ mkdir -p wp-content/plugins
|
|
|
19
19
|
mkdir -p wp-content/upgrade
|
|
20
20
|
|
|
21
21
|
if [ -n "${WPCONTENT_BASE_PATH:-}" ] && [ -d "${WPCONTENT_BASE_PATH}" ]; then
|
|
22
|
-
|
|
22
|
+
shopt -s dotglob nullglob
|
|
23
|
+
cp -R "${WPCONTENT_BASE_PATH}"/* /app/wp-content
|
|
24
|
+
shopt -u dotglob nullglob
|
|
23
25
|
fi
|
|
24
26
|
|
|
25
27
|
echo "Installing WordPress core"
|
|
@@ -36,6 +36,7 @@ from shipit.shipit_types import (
|
|
|
36
36
|
)
|
|
37
37
|
from shipit.ui import console
|
|
38
38
|
from shipit.version import version as shipit_version
|
|
39
|
+
from shipit.volumes import build_volumes, load_volume_mappings
|
|
39
40
|
|
|
40
41
|
app = typer.Typer(invoke_without_command=True)
|
|
41
42
|
|
|
@@ -720,7 +721,7 @@ def serve(
|
|
|
720
721
|
raise RuntimeError("--wasmer-deploy requires the Wasmer runner")
|
|
721
722
|
runner.deploy(app_owner=wasmer_app_owner, app_name=wasmer_app_name)
|
|
722
723
|
elif commands_to_run:
|
|
723
|
-
run_serve_commands(runner, commands_to_run)
|
|
724
|
+
run_serve_commands(path, runner, commands_to_run)
|
|
724
725
|
|
|
725
726
|
|
|
726
727
|
@app.command(name="plan")
|
|
@@ -1073,6 +1074,7 @@ def build(
|
|
|
1073
1074
|
|
|
1074
1075
|
# Build and serve
|
|
1075
1076
|
build_backend.build(serve.name, env, serve.mounts or [], build_steps)
|
|
1077
|
+
build_volumes(path, serve)
|
|
1076
1078
|
runner.build(serve)
|
|
1077
1079
|
if serve.prepare and not skip_prepare:
|
|
1078
1080
|
runner.prepare(env, serve.prepare)
|
|
@@ -1105,11 +1107,12 @@ def resolve_run_commands(
|
|
|
1105
1107
|
return commands
|
|
1106
1108
|
|
|
1107
1109
|
|
|
1108
|
-
def run_serve_commands(runner: Runner, commands: List[str]) -> None:
|
|
1110
|
+
def run_serve_commands(path: Path, runner: Runner, commands: List[str]) -> None:
|
|
1111
|
+
volume_mappings = load_volume_mappings(path)
|
|
1109
1112
|
for command in commands:
|
|
1110
1113
|
if command in OPTIONAL_RUN_COMMANDS and not runner.has_serve_command(command):
|
|
1111
1114
|
continue
|
|
1112
|
-
runner.run_serve_command(command)
|
|
1115
|
+
runner.run_serve_command(command, volume_mappings=volume_mappings)
|
|
1113
1116
|
|
|
1114
1117
|
|
|
1115
1118
|
def main() -> None:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from typing import Dict, List, Protocol, TYPE_CHECKING
|
|
2
|
+
from typing import Dict, List, Optional, Protocol, TYPE_CHECKING
|
|
3
3
|
|
|
4
4
|
from shipit.builders.base import BuildBackend
|
|
5
5
|
|
|
@@ -15,5 +15,9 @@ class Runner(Protocol):
|
|
|
15
15
|
def build(self, serve: "Serve") -> None: ...
|
|
16
16
|
def prepare(self, env: Dict[str, str], prepare: List["PrepareStep"]) -> None: ...
|
|
17
17
|
def has_serve_command(self, command: str) -> bool: ...
|
|
18
|
-
def run_serve_command(
|
|
18
|
+
def run_serve_command(
|
|
19
|
+
self,
|
|
20
|
+
command: str,
|
|
21
|
+
volume_mappings: Optional[Dict[str, str]] = None,
|
|
22
|
+
) -> None: ...
|
|
19
23
|
def get_serve_mount_path(self, name: str) -> Path: ...
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import shutil
|
|
2
2
|
from pathlib import Path
|
|
3
|
-
from typing import Dict, List, TYPE_CHECKING
|
|
3
|
+
from typing import Dict, List, Optional, TYPE_CHECKING
|
|
4
4
|
|
|
5
5
|
import sh
|
|
6
6
|
from rich import box
|
|
@@ -37,30 +37,6 @@ class LocalRunner:
|
|
|
37
37
|
self.build_prepare(serve)
|
|
38
38
|
self.build_serve(serve)
|
|
39
39
|
|
|
40
|
-
def _prepare_volumes(self, serve: Serve) -> None:
|
|
41
|
-
for volume in serve.volumes or []:
|
|
42
|
-
source = volume.path.absolute()
|
|
43
|
-
target = volume.serve_path
|
|
44
|
-
|
|
45
|
-
source.mkdir(parents=True, exist_ok=True)
|
|
46
|
-
|
|
47
|
-
if target.is_symlink():
|
|
48
|
-
if target.resolve(strict=False) == source.resolve():
|
|
49
|
-
continue
|
|
50
|
-
target.unlink()
|
|
51
|
-
elif target.exists():
|
|
52
|
-
if target.is_dir():
|
|
53
|
-
if not any(source.iterdir()):
|
|
54
|
-
shutil.copytree(target, source, dirs_exist_ok=True)
|
|
55
|
-
shutil.rmtree(target)
|
|
56
|
-
else:
|
|
57
|
-
if not any(source.iterdir()):
|
|
58
|
-
shutil.copy2(target, source / target.name)
|
|
59
|
-
target.unlink()
|
|
60
|
-
|
|
61
|
-
target.parent.mkdir(parents=True, exist_ok=True)
|
|
62
|
-
target.symlink_to(source, target_is_directory=True)
|
|
63
|
-
|
|
64
40
|
def build_prepare(self, serve: Serve) -> None:
|
|
65
41
|
if not serve.prepare:
|
|
66
42
|
return
|
|
@@ -93,7 +69,6 @@ class LocalRunner:
|
|
|
93
69
|
|
|
94
70
|
def build_serve(self, serve: Serve) -> None:
|
|
95
71
|
console.print("\n[bold]Building serve[/bold]")
|
|
96
|
-
self._prepare_volumes(serve)
|
|
97
72
|
shutil.rmtree(self.serve_bin_path.parent, ignore_errors=True)
|
|
98
73
|
self.serve_bin_path.mkdir(parents=True, exist_ok=True)
|
|
99
74
|
runtime_path = self.build_backend.get_runtime_path() or ""
|
|
@@ -133,7 +108,11 @@ class LocalRunner:
|
|
|
133
108
|
def has_serve_command(self, command: str) -> bool:
|
|
134
109
|
return (self.serve_bin_path / command).is_file()
|
|
135
110
|
|
|
136
|
-
def run_serve_command(
|
|
111
|
+
def run_serve_command(
|
|
112
|
+
self,
|
|
113
|
+
command: str,
|
|
114
|
+
volume_mappings: Optional[Dict[str, str]] = None,
|
|
115
|
+
) -> None:
|
|
137
116
|
console.print(f"\n[bold]Running {command} command[/bold]")
|
|
138
117
|
command_path = self.serve_bin_path / command
|
|
139
118
|
sh.Command(str(command_path))(_out=write_stdout, _err=write_stderr)
|
|
@@ -20,6 +20,7 @@ from shipit.runners.base import Runner
|
|
|
20
20
|
from shipit.shipit_types import EnvStep, Package, PrepareStep, Serve, UseStep
|
|
21
21
|
from shipit.ui import console
|
|
22
22
|
from shipit.version import version as shipit_version
|
|
23
|
+
from shipit.volumes import load_volume_mappings, volume_mapdir_args
|
|
23
24
|
|
|
24
25
|
if TYPE_CHECKING:
|
|
25
26
|
from shipit.shipit_types import Step
|
|
@@ -213,7 +214,6 @@ class WasmerRunner:
|
|
|
213
214
|
self.wasmer_token = token
|
|
214
215
|
self.bin = bin or "wasmer"
|
|
215
216
|
self.provider_config: Any = None
|
|
216
|
-
self.current_serve: Optional[Serve] = None
|
|
217
217
|
|
|
218
218
|
def get_serve_mount_path(self, name: str) -> Path:
|
|
219
219
|
if name == "app":
|
|
@@ -262,25 +262,9 @@ class WasmerRunner:
|
|
|
262
262
|
return new_build_steps
|
|
263
263
|
|
|
264
264
|
def build(self, serve: Serve) -> None:
|
|
265
|
-
self.current_serve = serve
|
|
266
|
-
self._ensure_volume_directories(serve)
|
|
267
265
|
self.build_prepare(serve)
|
|
268
266
|
self.build_serve(serve)
|
|
269
267
|
|
|
270
|
-
def _ensure_volume_directories(self, serve: Serve) -> None:
|
|
271
|
-
for volume in serve.volumes or []:
|
|
272
|
-
volume.path.mkdir(parents=True, exist_ok=True)
|
|
273
|
-
|
|
274
|
-
def _volume_mapdir_args(self) -> List[str]:
|
|
275
|
-
if not self.current_serve:
|
|
276
|
-
return []
|
|
277
|
-
|
|
278
|
-
self._ensure_volume_directories(self.current_serve)
|
|
279
|
-
return [
|
|
280
|
-
f"--mapdir={volume.serve_path}:{volume.path.absolute()}"
|
|
281
|
-
for volume in self.current_serve.volumes or []
|
|
282
|
-
]
|
|
283
|
-
|
|
284
268
|
def build_prepare(self, serve: Serve) -> None:
|
|
285
269
|
if not serve.prepare:
|
|
286
270
|
return
|
|
@@ -332,6 +316,7 @@ class WasmerRunner:
|
|
|
332
316
|
prepare_dir = self.wasmer_dir_path / "prepare"
|
|
333
317
|
self.run_serve_command(
|
|
334
318
|
"bash",
|
|
319
|
+
volume_mappings=load_volume_mappings(self.src_dir),
|
|
335
320
|
extra_args=[
|
|
336
321
|
f"--mapdir=/prepare:{prepare_dir}",
|
|
337
322
|
"--",
|
|
@@ -351,8 +336,6 @@ class WasmerRunner:
|
|
|
351
336
|
return None
|
|
352
337
|
|
|
353
338
|
def build_serve(self, serve: Serve) -> None:
|
|
354
|
-
self.current_serve = serve
|
|
355
|
-
self._ensure_volume_directories(serve)
|
|
356
339
|
doc = document()
|
|
357
340
|
doc.add(comment(f"Wasmer manifest generated with Shipit v{shipit_version}"))
|
|
358
341
|
package = table()
|
|
@@ -620,7 +603,10 @@ class WasmerRunner:
|
|
|
620
603
|
(self.wasmer_dir_path / "app.yaml").write_text(app_yaml)
|
|
621
604
|
|
|
622
605
|
def run_serve_command(
|
|
623
|
-
self,
|
|
606
|
+
self,
|
|
607
|
+
command: str,
|
|
608
|
+
volume_mappings: Optional[Dict[str, str]] = None,
|
|
609
|
+
extra_args: Optional[List[str]] = None,
|
|
624
610
|
) -> None:
|
|
625
611
|
console.print(f"\n[bold]Serving site[/bold]: running {command} command")
|
|
626
612
|
extra_args = extra_args or []
|
|
@@ -635,7 +621,10 @@ class WasmerRunner:
|
|
|
635
621
|
"--net",
|
|
636
622
|
"--forward-host-env",
|
|
637
623
|
f"--command={command}",
|
|
638
|
-
*
|
|
624
|
+
*volume_mapdir_args(
|
|
625
|
+
self.build_backend,
|
|
626
|
+
volume_mappings or {},
|
|
627
|
+
),
|
|
639
628
|
*extra_args,
|
|
640
629
|
],
|
|
641
630
|
env=os.environ,
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import shutil
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Dict
|
|
5
|
+
|
|
6
|
+
from shipit.builders.base import BuildBackend
|
|
7
|
+
from shipit.shipit_types import Serve, Volume
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_volumes_dir(src_dir: Path) -> Path:
|
|
11
|
+
return src_dir / ".shipit" / "volumes"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def get_volume_mappings_path(src_dir: Path) -> Path:
|
|
15
|
+
return get_volumes_dir(src_dir) / "mappings.json"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def build_volumes(src_dir: Path, serve: Serve) -> Dict[str, str]:
|
|
19
|
+
volumes_dir = get_volumes_dir(src_dir)
|
|
20
|
+
volumes_dir.mkdir(parents=True, exist_ok=True)
|
|
21
|
+
|
|
22
|
+
mappings = {
|
|
23
|
+
volume.name: str(volume.serve_path)
|
|
24
|
+
for volume in serve.volumes or []
|
|
25
|
+
}
|
|
26
|
+
for volume in serve.volumes or []:
|
|
27
|
+
volume.path.mkdir(parents=True, exist_ok=True)
|
|
28
|
+
if _should_link_local_volume(src_dir, volume):
|
|
29
|
+
_link_local_volume(volume)
|
|
30
|
+
|
|
31
|
+
get_volume_mappings_path(src_dir).write_text(
|
|
32
|
+
json.dumps(mappings, indent=2, sort_keys=True) + "\n"
|
|
33
|
+
)
|
|
34
|
+
return mappings
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def load_volume_mappings(src_dir: Path) -> Dict[str, str]:
|
|
38
|
+
mappings_path = get_volume_mappings_path(src_dir)
|
|
39
|
+
if not mappings_path.is_file():
|
|
40
|
+
return {}
|
|
41
|
+
|
|
42
|
+
mappings = json.loads(mappings_path.read_text())
|
|
43
|
+
if not isinstance(mappings, dict):
|
|
44
|
+
raise ValueError("Volume mappings must be a dictionary")
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
str(name): str(guest_path)
|
|
48
|
+
for name, guest_path in mappings.items()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def volume_mapdir_args(
|
|
53
|
+
build_backend: BuildBackend,
|
|
54
|
+
volume_mappings: Dict[str, str],
|
|
55
|
+
) -> list[str]:
|
|
56
|
+
args: list[str] = []
|
|
57
|
+
for name, guest_path in volume_mappings.items():
|
|
58
|
+
host_path = build_backend.get_volume_path(name).absolute()
|
|
59
|
+
host_path.mkdir(parents=True, exist_ok=True)
|
|
60
|
+
args.append(f"--mapdir={guest_path}:{host_path}")
|
|
61
|
+
return args
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _should_link_local_volume(src_dir: Path, volume: Volume) -> bool:
|
|
65
|
+
shipit_dir = (src_dir / ".shipit").absolute()
|
|
66
|
+
return volume.serve_path.is_absolute() and volume.serve_path.is_relative_to(
|
|
67
|
+
shipit_dir
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _link_local_volume(volume: Volume) -> None:
|
|
72
|
+
source = volume.path.absolute()
|
|
73
|
+
target = volume.serve_path
|
|
74
|
+
|
|
75
|
+
if target.is_symlink():
|
|
76
|
+
if target.resolve(strict=False) == source.resolve():
|
|
77
|
+
return
|
|
78
|
+
target.unlink()
|
|
79
|
+
elif target.exists():
|
|
80
|
+
if target.is_dir():
|
|
81
|
+
if not any(source.iterdir()):
|
|
82
|
+
shutil.copytree(target, source, dirs_exist_ok=True)
|
|
83
|
+
shutil.rmtree(target)
|
|
84
|
+
else:
|
|
85
|
+
if not any(source.iterdir()):
|
|
86
|
+
shutil.copy2(target, source / target.name)
|
|
87
|
+
target.unlink()
|
|
88
|
+
|
|
89
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
90
|
+
target.symlink_to(source, target_is_directory=True)
|
|
@@ -16,6 +16,7 @@ class FakeRunner:
|
|
|
16
16
|
def __init__(self, *args, **kwargs) -> None:
|
|
17
17
|
self.calls: list[str] = []
|
|
18
18
|
self.checked: list[str] = []
|
|
19
|
+
self.volume_mappings: list[dict[str, str] | None] = []
|
|
19
20
|
self.available_commands = set(type(self).available_commands)
|
|
20
21
|
type(self).instances.append(self)
|
|
21
22
|
|
|
@@ -23,8 +24,13 @@ class FakeRunner:
|
|
|
23
24
|
self.checked.append(command)
|
|
24
25
|
return command in self.available_commands
|
|
25
26
|
|
|
26
|
-
def run_serve_command(
|
|
27
|
+
def run_serve_command(
|
|
28
|
+
self,
|
|
29
|
+
command: str,
|
|
30
|
+
volume_mappings: dict[str, str] | None = None,
|
|
31
|
+
) -> None:
|
|
27
32
|
self.calls.append(command)
|
|
33
|
+
self.volume_mappings.append(volume_mappings)
|
|
28
34
|
|
|
29
35
|
|
|
30
36
|
runner = CliRunner()
|
|
@@ -44,6 +50,7 @@ def test_serve_runs_after_deploy_before_start(
|
|
|
44
50
|
assert result.exit_code == 0, result.output
|
|
45
51
|
assert FakeRunner.instances[-1].calls == ["after_deploy", "start"]
|
|
46
52
|
assert FakeRunner.instances[-1].checked == ["after_deploy", "start"]
|
|
53
|
+
assert FakeRunner.instances[-1].volume_mappings == [{}, {}]
|
|
47
54
|
|
|
48
55
|
|
|
49
56
|
def test_serve_skips_after_deploy_when_missing(
|
|
@@ -60,6 +67,7 @@ def test_serve_skips_after_deploy_when_missing(
|
|
|
60
67
|
assert result.exit_code == 0, result.output
|
|
61
68
|
assert FakeRunner.instances[-1].calls == ["start"]
|
|
62
69
|
assert FakeRunner.instances[-1].checked == ["after_deploy", "start"]
|
|
70
|
+
assert FakeRunner.instances[-1].volume_mappings == [{}]
|
|
63
71
|
|
|
64
72
|
|
|
65
73
|
def test_serve_runs_custom_commands_without_existence_checks(
|
|
@@ -79,6 +87,30 @@ def test_serve_runs_custom_commands_without_existence_checks(
|
|
|
79
87
|
assert result.exit_code == 0, result.output
|
|
80
88
|
assert FakeRunner.instances[-1].calls == ["prepare-db", "warm-cache"]
|
|
81
89
|
assert FakeRunner.instances[-1].checked == []
|
|
90
|
+
assert FakeRunner.instances[-1].volume_mappings == [{}, {}]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_serve_loads_volume_mappings_from_json(
|
|
94
|
+
tmp_path: Path,
|
|
95
|
+
monkeypatch,
|
|
96
|
+
) -> None:
|
|
97
|
+
FakeRunner.instances.clear()
|
|
98
|
+
FakeRunner.available_commands = {"start"}
|
|
99
|
+
mappings_dir = tmp_path / ".shipit" / "volumes"
|
|
100
|
+
mappings_dir.mkdir(parents=True)
|
|
101
|
+
(mappings_dir / "mappings.json").write_text(
|
|
102
|
+
'{\n "wp-content": "/app/wp-content"\n}\n'
|
|
103
|
+
)
|
|
104
|
+
monkeypatch.setattr(cli, "LocalBuildBackend", FakeBuildBackend)
|
|
105
|
+
monkeypatch.setattr(cli, "LocalRunner", FakeRunner)
|
|
106
|
+
|
|
107
|
+
result = runner.invoke(cli.app, ["serve", str(tmp_path)])
|
|
108
|
+
|
|
109
|
+
assert result.exit_code == 0, result.output
|
|
110
|
+
assert FakeRunner.instances[-1].calls == ["start"]
|
|
111
|
+
assert FakeRunner.instances[-1].volume_mappings == [
|
|
112
|
+
{"wp-content": "/app/wp-content"}
|
|
113
|
+
]
|
|
82
114
|
|
|
83
115
|
|
|
84
116
|
def test_auto_passes_after_deploy_to_serve(
|
|
@@ -7,6 +7,7 @@ from shipit.cli import Ctx
|
|
|
7
7
|
from shipit.runners.local import LocalRunner
|
|
8
8
|
from shipit.runners.wasmer import WasmerRunner
|
|
9
9
|
from shipit.shipit_types import Package, Serve, Volume
|
|
10
|
+
from shipit.volumes import build_volumes, load_volume_mappings
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class DummyBuildBackend:
|
|
@@ -47,13 +48,12 @@ def test_ctx_volume_uses_shipit_volume_directory(tmp_path: Path) -> None:
|
|
|
47
48
|
assert not volume.path.exists()
|
|
48
49
|
|
|
49
50
|
|
|
50
|
-
def
|
|
51
|
+
def test_build_volumes_links_runtime_volume_to_host_directory(
|
|
51
52
|
tmp_path: Path,
|
|
52
53
|
) -> None:
|
|
53
54
|
assets_path = tmp_path / "assets"
|
|
54
55
|
assets_path.mkdir()
|
|
55
56
|
build_backend = LocalBuildBackend(tmp_path, assets_path)
|
|
56
|
-
runner = LocalRunner(build_backend, tmp_path)
|
|
57
57
|
|
|
58
58
|
target = build_backend.get_artifact_mount_path("app") / "wp-content"
|
|
59
59
|
target.mkdir(parents=True, exist_ok=True)
|
|
@@ -73,12 +73,14 @@ def test_local_runner_links_runtime_volume_to_host_directory(
|
|
|
73
73
|
volumes=[volume],
|
|
74
74
|
)
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
mappings = build_volumes(tmp_path, serve)
|
|
77
77
|
|
|
78
78
|
assert volume.path.is_dir()
|
|
79
79
|
assert (volume.path / "seed.txt").read_text() == "hello"
|
|
80
80
|
assert target.is_symlink()
|
|
81
81
|
assert target.resolve(strict=False) == volume.path.resolve()
|
|
82
|
+
assert mappings == {"wp-content": str(target)}
|
|
83
|
+
assert load_volume_mappings(tmp_path) == {"wp-content": str(target)}
|
|
82
84
|
|
|
83
85
|
|
|
84
86
|
def test_wasmer_runner_mounts_volume_paths_into_wasmer_run(
|
|
@@ -105,8 +107,6 @@ def test_wasmer_runner_mounts_volume_paths_into_wasmer_run(
|
|
|
105
107
|
],
|
|
106
108
|
)
|
|
107
109
|
|
|
108
|
-
runner.build_serve(serve)
|
|
109
|
-
|
|
110
110
|
captured: dict[str, object] = {}
|
|
111
111
|
|
|
112
112
|
def fake_run_command(
|
|
@@ -120,7 +120,11 @@ def test_wasmer_runner_mounts_volume_paths_into_wasmer_run(
|
|
|
120
120
|
|
|
121
121
|
monkeypatch.setattr(runner, "run_command", fake_run_command)
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
build_volumes(src_dir, serve)
|
|
124
|
+
runner.run_serve_command(
|
|
125
|
+
"start",
|
|
126
|
+
volume_mappings=load_volume_mappings(src_dir),
|
|
127
|
+
)
|
|
124
128
|
|
|
125
129
|
assert volume_path.is_dir()
|
|
126
130
|
assert captured["command"] == "wasmer"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|