workpeg 0.157.0__tar.gz → 0.158.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.
- {workpeg-0.157.0/src/workpeg.egg-info → workpeg-0.158.1}/PKG-INFO +1 -1
- {workpeg-0.157.0 → workpeg-0.158.1}/pyproject.toml +1 -1
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/build.py +33 -1
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/cli.py +7 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/create_new.py +8 -1
- workpeg-0.158.1/src/workpeg/function_check.py +241 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/project.py +5 -4
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/run.py +8 -6
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/submit.py +11 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/agents/AGENTS.md +5 -2
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/functions/Dockerfile +3 -3
- workpeg-0.158.1/src/workpeg/templates/functions/wheels/README.txt +30 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/project/function/Dockerfile +3 -3
- workpeg-0.158.1/src/workpeg/templates/project/function/wheels/README.txt +30 -0
- {workpeg-0.157.0 → workpeg-0.158.1/src/workpeg.egg-info}/PKG-INFO +1 -1
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg.egg-info/SOURCES.txt +2 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_build.py +5 -5
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_cli.py +39 -2
- workpeg-0.158.1/tests/test_function_check.py +454 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_pegfn_base.py +25 -2
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_submit.py +7 -7
- workpeg-0.157.0/src/workpeg/templates/functions/wheels/README.txt +0 -11
- workpeg-0.157.0/src/workpeg/templates/project/function/wheels/README.txt +0 -11
- {workpeg-0.157.0 → workpeg-0.158.1}/LICENSE +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/MANIFEST.in +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/README.md +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/setup.cfg +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/__init__.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/auth.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/cdn.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/config.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/context.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/doctor.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/function_base.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/runtime.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/sandbox/__init__.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/sandbox/docker_driver.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/sandbox/driver.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/starter.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/__init__.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/agents/CLAUDE.md +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/functions/LICENSE +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/functions/README.md +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/functions/app/__init__.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/functions/app/main.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/functions/requirements.txt +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/project/README.md +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/project/function/app/__init__.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/project/function/app/main.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/project/function/requirements.txt +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/project/workpeg.json +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/starter/app_shell.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/starter/components.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/starter/main.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/starter/pages/__init__.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/starter/pages/customer.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/starter/pages/customers.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/starter/pages/home.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/templates/starter/pages/not_found.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/terminal.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/__init__.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/actions.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/actions_manifest.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/app.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/build.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/calendar.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/compiler/__init__.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/compiler/ast_parser.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/compiler/ir.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/compiler/js_generator.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/compiler/rtc_checks.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/compiler/rtc_tables.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/create.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/dates.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/dev_refused_names.json +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/devmode.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/devserve.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/devsite.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/fake_cloud.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/minify.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/render_nodes.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/renderers_manifest.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/rtc.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/ai-concurrent-replies.md +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/ai-prompt-queue.md +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/ai-question-frame.md +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/ai-subagent-frame.md +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/ai.js +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/editor.js +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/fonts/OFL.txt +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/fonts/geist-italic-cyrillic-ext.af944491.woff2 +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/fonts/geist-italic-cyrillic.88be6946.woff2 +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/fonts/geist-italic-latin-ext.370a8962.woff2 +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/fonts/geist-italic-latin.7611b95c.woff2 +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/fonts/geist-italic-vietnamese.8dfcf303.woff2 +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/fonts/geist-normal-cyrillic-ext.b7a545bb.woff2 +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/fonts/geist-normal-cyrillic.6129fc85.woff2 +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/fonts/geist-normal-latin-ext.58a6b173.woff2 +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/fonts/geist-normal-latin.9b6f5ff4.woff2 +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/fonts/geist-normal-vietnamese.f689f638.woff2 +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/icons.css.gz +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/overlay.js +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/pegment.css +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/rtc.js +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/scaffold.js +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/runtime/workpeg-runtime.js +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/scaffold.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/search_manifest.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/serve.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/skills_manifest.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/state.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/validators.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/watcher.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/widgets/__init__.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/widgets/base.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/widgets/canvas.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/widgets/display.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/widgets/fields.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/widgets/forms.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/widgets/futures.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/widgets/gestures.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/widgets/interactive.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/widgets/layout.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/ui/widgets/pickers.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg/utils.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg.egg-info/dependency_links.txt +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg.egg-info/entry_points.txt +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg.egg-info/requires.txt +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/src/workpeg.egg-info/top_level.txt +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_agents_guide.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_auth.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_cdn.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_cdn_publish.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_changelog.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_changelog_guard.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_config.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_context.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_create_new.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_doctor.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_project_create.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_release_script.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_run.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_runtime.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_utils.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_version.py +0 -0
- {workpeg-0.157.0 → workpeg-0.158.1}/tests/test_watch_pipeline.py +0 -0
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
# src/workpeg/build.py
|
|
2
2
|
import subprocess
|
|
3
|
+
import sys
|
|
3
4
|
from pathlib import Path
|
|
4
5
|
|
|
5
6
|
from workpeg.config import load_config
|
|
7
|
+
from workpeg.function_check import BundleRefused, check_config, check_files
|
|
8
|
+
|
|
9
|
+
#: What Workpeg's install adds to every function build (the api's
|
|
10
|
+
#: BUILD_ARGV_HEAD): pull the base from the registry and give no RUN step a
|
|
11
|
+
#: network. The platform is what Workpeg runs, so an Apple silicon Mac
|
|
12
|
+
#: builds the image Workpeg would, with the x86_64 wheels the docs vendor,
|
|
13
|
+
#: instead of an arm64 one. ``--like-workpeg`` builds with these.
|
|
14
|
+
WORKPEG_BUILD_FLAGS = ("--pull", "--network=none", "--platform=linux/amd64")
|
|
6
15
|
|
|
7
16
|
|
|
8
17
|
def slugify(value: str) -> str:
|
|
@@ -39,18 +48,41 @@ def build_image(
|
|
|
39
48
|
path: str = ".",
|
|
40
49
|
tag: str | None = None,
|
|
41
50
|
timeout: "float | None" = None,
|
|
51
|
+
like_workpeg: bool = False,
|
|
42
52
|
) -> str:
|
|
53
|
+
"""Build the function at *path* and return the image's tag.
|
|
54
|
+
|
|
55
|
+
The Dockerfile is checked first, by the rules Workpeg's install applies
|
|
56
|
+
(workpeg.function_check), and a Dockerfile Workpeg would refuse is
|
|
57
|
+
refused here with the same message, before Docker runs: a build that
|
|
58
|
+
succeeds locally on a Dockerfile Workpeg refuses tells the developer
|
|
59
|
+
nothing true. A ``build.image`` in workpeg.json is still used as the
|
|
60
|
+
local tag, with a warning, because only the upload is refused for it.
|
|
61
|
+
|
|
62
|
+
*like_workpeg* adds WORKPEG_BUILD_FLAGS, so the build fails here when a
|
|
63
|
+
step downloads, or when the wheels are not for linux/amd64."""
|
|
43
64
|
project_path = Path(path).resolve()
|
|
44
65
|
|
|
45
66
|
validate_function_project(project_path)
|
|
67
|
+
check_files(project_path)
|
|
68
|
+
try:
|
|
69
|
+
check_config(project_path)
|
|
70
|
+
except BundleRefused as refused:
|
|
71
|
+
print(f"WARNING: {refused} `workpeg function submit` will refuse "
|
|
72
|
+
"this project.", file=sys.stderr)
|
|
46
73
|
|
|
47
74
|
cfg = load_config(project_path / "workpeg.json")
|
|
48
75
|
|
|
49
76
|
image = tag or cfg.get("build", {}).get("image") or default_image_name(project_path)
|
|
50
77
|
|
|
78
|
+
argv = ["docker", "build"]
|
|
79
|
+
if like_workpeg:
|
|
80
|
+
argv += WORKPEG_BUILD_FLAGS
|
|
81
|
+
argv += ["-t", image, str(project_path)]
|
|
82
|
+
|
|
51
83
|
try:
|
|
52
84
|
subprocess.run(
|
|
53
|
-
|
|
85
|
+
argv,
|
|
54
86
|
check=True,
|
|
55
87
|
timeout=timeout,
|
|
56
88
|
)
|
|
@@ -94,6 +94,12 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
94
94
|
)
|
|
95
95
|
build_p.add_argument("--path", default=".")
|
|
96
96
|
build_p.add_argument("--tag", default=None)
|
|
97
|
+
build_p.add_argument(
|
|
98
|
+
"--like-workpeg",
|
|
99
|
+
action="store_true",
|
|
100
|
+
help="build as Workpeg's install does: --pull, no network for any "
|
|
101
|
+
"RUN step, and linux/amd64",
|
|
102
|
+
)
|
|
97
103
|
build_p.set_defaults(_handler="function.build")
|
|
98
104
|
|
|
99
105
|
run_p = function_sub.add_parser(
|
|
@@ -745,6 +751,7 @@ def main(argv=None) -> None:
|
|
|
745
751
|
image = build.build_image(
|
|
746
752
|
path=args.path,
|
|
747
753
|
tag=args.tag,
|
|
754
|
+
like_workpeg=args.like_workpeg,
|
|
748
755
|
)
|
|
749
756
|
print(image)
|
|
750
757
|
except (FileNotFoundError, NotADirectoryError, RuntimeError) as e:
|
|
@@ -12,6 +12,11 @@ class TemplateError(Exception):
|
|
|
12
12
|
pass
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
#: Template files that name the function base, filled with this SDK's
|
|
16
|
+
#: version as they are copied.
|
|
17
|
+
_FILLED = frozenset((Path("Dockerfile"), Path("wheels") / "README.txt"))
|
|
18
|
+
|
|
19
|
+
|
|
15
20
|
def _copy_tree(src_root: Path, dst_root: Path, *, force: bool,
|
|
16
21
|
base_version: str) -> None:
|
|
17
22
|
"""
|
|
@@ -35,7 +40,9 @@ def _copy_tree(src_root: Path, dst_root: Path, *, force: bool,
|
|
|
35
40
|
raise TemplateError(f"Target file exists: {dst} (use --force)")
|
|
36
41
|
|
|
37
42
|
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
38
|
-
|
|
43
|
+
# The Dockerfile's FROM line and the wheels/README.txt command
|
|
44
|
+
# that fills wheels/ both name the base at this SDK's version.
|
|
45
|
+
if rel in _FILLED:
|
|
39
46
|
body = item.read_text(encoding="utf-8")
|
|
40
47
|
dst.write_text(function_base.fill(body, base_version),
|
|
41
48
|
encoding="utf-8")
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"""What Workpeg's install refuses in a function bundle, checked before it
|
|
2
|
+
leaves the developer's machine.
|
|
3
|
+
|
|
4
|
+
Workpeg reads a function bundle's ``Dockerfile`` and ``workpeg.json`` before
|
|
5
|
+
it builds anything (``check_bundle`` and ``check_dockerfile`` in the api's
|
|
6
|
+
``installed_pegs/function_container.py``), and refuses one that could reach
|
|
7
|
+
past its own build context. Until this module the SDK read neither, so a
|
|
8
|
+
refused bundle uploaded cleanly and the refusal was seen only by an operator
|
|
9
|
+
at install, never by the developer who could fix it.
|
|
10
|
+
|
|
11
|
+
This is a port of those rules, not a call to them: the api is the authority
|
|
12
|
+
and keeps its own copy, so nothing a developer changes in their SDK can
|
|
13
|
+
loosen the install's check. The two must agree, which is why the messages
|
|
14
|
+
are the api's own, word for word, and why ``tests/test_function_check.py``
|
|
15
|
+
carries the api's cases. When the api's rules change, change this file and
|
|
16
|
+
those tests in the same release.
|
|
17
|
+
|
|
18
|
+
Fail closed, as the api does: anything this cannot read as Docker does is
|
|
19
|
+
refused, not guessed at.
|
|
20
|
+
"""
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import itertools
|
|
24
|
+
import json
|
|
25
|
+
import re
|
|
26
|
+
import stat
|
|
27
|
+
from pathlib import Path
|
|
28
|
+
|
|
29
|
+
from workpeg.function_base import IMAGE as PLATFORM_BASE
|
|
30
|
+
from workpeg.function_base import RELEASE as _RELEASE
|
|
31
|
+
|
|
32
|
+
#: The official images a function's FROM may name, written ``<name>`` or
|
|
33
|
+
#: ``<name>:<tag>``: python only, and never an ``-onbuild`` tag.
|
|
34
|
+
ALLOWED_BASES = ("python",)
|
|
35
|
+
|
|
36
|
+
#: Docker's rule for a tag (distribution/reference).
|
|
37
|
+
_TAG = re.compile(r"[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}")
|
|
38
|
+
|
|
39
|
+
#: What Workpeg builds: the Dockerfile, and the function itself.
|
|
40
|
+
_REQUIRED = ("Dockerfile", "app/main.py")
|
|
41
|
+
|
|
42
|
+
#: Printable ASCII, tabs and line ends: the only text the check reads
|
|
43
|
+
#: exactly as Docker does. A carriage return is a line end only before a
|
|
44
|
+
#: newline.
|
|
45
|
+
_UNREADABLE = re.compile(r"[^\t\n\r\x20-\x7e]|\r(?!\n)")
|
|
46
|
+
|
|
47
|
+
#: A parser directive: ``# name=value`` before the first instruction.
|
|
48
|
+
_DIRECTIVE = re.compile(r"#[ \t]*[A-Za-z][A-Za-z0-9]*[ \t]*=")
|
|
49
|
+
|
|
50
|
+
#: A backslash, then spaces or tabs only, at the end of a line: it
|
|
51
|
+
#: continues on the next.
|
|
52
|
+
_CONTINUES = re.compile(r"\\[ \t]*\Z")
|
|
53
|
+
|
|
54
|
+
#: Two at the end, which one Docker parser reads as continued and another
|
|
55
|
+
#: as ended.
|
|
56
|
+
_ESCAPED_END = re.compile(r"\\\\[ \t]*\Z")
|
|
57
|
+
|
|
58
|
+
#: Docker's rule for a stage's AS name, which it folds to lower case.
|
|
59
|
+
_STAGE = re.compile(r"[a-z][a-z0-9_.-]*")
|
|
60
|
+
|
|
61
|
+
#: Every instruction but ONBUILD, VOLUME and LABEL.
|
|
62
|
+
_INSTRUCTIONS = frozenset((
|
|
63
|
+
"add", "arg", "cmd", "copy", "entrypoint", "env", "expose", "from",
|
|
64
|
+
"healthcheck", "maintainer", "run", "shell", "stopsignal", "user",
|
|
65
|
+
"workdir"))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class BundleRefused(RuntimeError):
|
|
69
|
+
"""Workpeg's install would refuse this function bundle. The message is
|
|
70
|
+
the one the install gives."""
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def check_bundle(directory) -> Path:
|
|
74
|
+
"""The project as a resolved Path, once Workpeg would build it: a
|
|
75
|
+
regular ``Dockerfile`` and ``app/main.py``, a Dockerfile
|
|
76
|
+
:func:`check_dockerfile` accepts, and a ``workpeg.json`` that names no
|
|
77
|
+
image. Otherwise :class:`BundleRefused`."""
|
|
78
|
+
project = check_files(directory)
|
|
79
|
+
check_config(project)
|
|
80
|
+
return project
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def check_files(directory) -> Path:
|
|
84
|
+
"""The Dockerfile and ``app/main.py`` half of :func:`check_bundle`."""
|
|
85
|
+
project = Path(directory).resolve()
|
|
86
|
+
for required in _REQUIRED:
|
|
87
|
+
if not _is_regular(project / required):
|
|
88
|
+
raise BundleRefused(
|
|
89
|
+
f"The function bundle has no regular file {required}.")
|
|
90
|
+
# Bytes, not text mode: text mode would turn a lone carriage return
|
|
91
|
+
# into a line end, which Docker does not.
|
|
92
|
+
try:
|
|
93
|
+
dockerfile = (project / "Dockerfile").read_bytes().decode("utf-8")
|
|
94
|
+
except ValueError:
|
|
95
|
+
raise BundleRefused(
|
|
96
|
+
"The function bundle's Dockerfile cannot be read as UTF-8 text.")
|
|
97
|
+
check_dockerfile(dockerfile)
|
|
98
|
+
return project
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def check_config(project) -> None:
|
|
102
|
+
"""Refuse a ``workpeg.json`` that is not a JSON object, or that names
|
|
103
|
+
the image (``build.image``): Workpeg names every function image."""
|
|
104
|
+
try:
|
|
105
|
+
config = json.loads(
|
|
106
|
+
(Path(project) / "workpeg.json").read_text(encoding="utf-8"))
|
|
107
|
+
except FileNotFoundError:
|
|
108
|
+
return
|
|
109
|
+
except (OSError, ValueError, RecursionError):
|
|
110
|
+
raise BundleRefused(
|
|
111
|
+
"The function bundle's workpeg.json cannot be read as JSON.")
|
|
112
|
+
if not isinstance(config, dict):
|
|
113
|
+
raise BundleRefused(
|
|
114
|
+
"The function bundle's workpeg.json is not a JSON object.")
|
|
115
|
+
build = config.get("build")
|
|
116
|
+
if build is not None and (not isinstance(build, dict)
|
|
117
|
+
or build.get("image") is not None):
|
|
118
|
+
raise BundleRefused(
|
|
119
|
+
"The function bundle names its own image (build.image in "
|
|
120
|
+
"workpeg.json). The platform names every function image; "
|
|
121
|
+
"upload a new version without build.image.")
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def check_dockerfile(text: str) -> None:
|
|
125
|
+
"""Refuse, with :class:`BundleRefused` naming the line, a function
|
|
126
|
+
Dockerfile Workpeg's install would refuse (docs/function-base.md, "The
|
|
127
|
+
rules for every function build")."""
|
|
128
|
+
bad = _UNREADABLE.search(text)
|
|
129
|
+
if bad:
|
|
130
|
+
_refuse(text.count("\n", 0, bad.start()) + 1,
|
|
131
|
+
"is not plain ASCII text with tabs and line ends only, "
|
|
132
|
+
"which is all this check can read exactly as Docker does")
|
|
133
|
+
stages: list[str] = [] # each stage's AS name so far, '' when none
|
|
134
|
+
for number, line in _instructions(text):
|
|
135
|
+
if "<<" in line:
|
|
136
|
+
_refuse(number, "has a heredoc (<<), which Docker reads by "
|
|
137
|
+
"rules of its own; write the file and COPY it")
|
|
138
|
+
keyword, *words = line.split()
|
|
139
|
+
keyword = keyword.lower()
|
|
140
|
+
flags = list(itertools.takewhile(lambda w: w.startswith("--"), words))
|
|
141
|
+
args = words[len(flags):]
|
|
142
|
+
if keyword not in _INSTRUCTIONS:
|
|
143
|
+
_refuse(number, "is not an instruction a function Dockerfile "
|
|
144
|
+
"may use (ONBUILD, VOLUME and LABEL are not)")
|
|
145
|
+
if any(c in flag for flag in flags for c in "\"'\\"):
|
|
146
|
+
_refuse(number, "has a flag with a quote or a backslash in it")
|
|
147
|
+
if keyword == "from":
|
|
148
|
+
stages.append(_from(number, args, stages))
|
|
149
|
+
if keyword == "run" and flags:
|
|
150
|
+
_refuse(number, "is a RUN step with a -- flag (--network, "
|
|
151
|
+
"--security, --device, --mount): a function RUN step "
|
|
152
|
+
"takes none")
|
|
153
|
+
for flag in flags if keyword in ("copy", "add") else ():
|
|
154
|
+
name, _, value = flag[2:].partition("=")
|
|
155
|
+
# Docker folds a stage name to lower case where AS defines it
|
|
156
|
+
# and where --from looks it up, so --from=Build is the stage
|
|
157
|
+
# 'build'. A stage name is only ever _STAGE once folded, so no
|
|
158
|
+
# image reference, with its ':' or '/', can match one.
|
|
159
|
+
if name.lower() == "from" and value.lower() not in stages[:-1]:
|
|
160
|
+
_refuse(number, "has a --from that is not an earlier stage "
|
|
161
|
+
"of this Dockerfile, named with AS")
|
|
162
|
+
if keyword == "add" and ("://" in line
|
|
163
|
+
or any(c in line for c in "@$\"'\\")):
|
|
164
|
+
_refuse(number, "is an ADD with a URL, a git source or a $, "
|
|
165
|
+
"quote or backslash: ADD takes plain local paths only, "
|
|
166
|
+
"and COPY does the rest")
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _from(number, args, stages):
|
|
170
|
+
"""The AS name of the stage a FROM starts ('' when it has none), once
|
|
171
|
+
its base is an earlier stage or an allowed image. A stage is looked up
|
|
172
|
+
folded to lower case, as Docker folds it where AS defines it and where
|
|
173
|
+
FROM names it, so `FROM Build` after `AS Build` is that stage. An image
|
|
174
|
+
is matched as written: Docker refuses an upper-case reference."""
|
|
175
|
+
named = len(args) == 3 and args[1].lower() == "as"
|
|
176
|
+
name = args[2].lower() if named else ""
|
|
177
|
+
if not (len(args) == 1 or (named and _STAGE.fullmatch(name))) or not (
|
|
178
|
+
args[0].lower() in stages or _allowed_base(args[0])):
|
|
179
|
+
_refuse(number, "must be FROM python or python:<tag>, FROM "
|
|
180
|
+
f"{PLATFORM_BASE}:<X.Y.Z>, or FROM an earlier stage of "
|
|
181
|
+
"this Dockerfile, with an optional AS <name>")
|
|
182
|
+
return name
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def _allowed_base(image):
|
|
186
|
+
name, colon, tag = image.partition(":")
|
|
187
|
+
if name == PLATFORM_BASE:
|
|
188
|
+
return bool(colon) and bool(_RELEASE.fullmatch(tag))
|
|
189
|
+
return (name in ALLOWED_BASES and (not colon or bool(_TAG.fullmatch(tag)))
|
|
190
|
+
and "onbuild" not in tag)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _instructions(text):
|
|
194
|
+
"""(line number, instruction) for each instruction of *text*, joined as
|
|
195
|
+
moby/buildkit's parser joins them: a line ending in a backslash and
|
|
196
|
+
spaces or tabs continues on the next; inside a continuation, comment
|
|
197
|
+
and blank lines are dropped and do not end it. Refuses a parser
|
|
198
|
+
directive before the first instruction."""
|
|
199
|
+
lines = [line.removesuffix("\r") for line in text.split("\n")]
|
|
200
|
+
index, first = 0, True
|
|
201
|
+
while index < len(lines):
|
|
202
|
+
number, line = index + 1, lines[index].lstrip(" \t")
|
|
203
|
+
index += 1
|
|
204
|
+
if line.startswith("#"):
|
|
205
|
+
if first and _DIRECTIVE.match(line):
|
|
206
|
+
_refuse(number, "is a parser directive (# name=value "
|
|
207
|
+
"before the first instruction): # syntax= chooses "
|
|
208
|
+
"the image that builds a Dockerfile and # escape= "
|
|
209
|
+
"how it is read, so a function Dockerfile has none")
|
|
210
|
+
continue
|
|
211
|
+
line, more = _continued(number, line)
|
|
212
|
+
while more and index < len(lines):
|
|
213
|
+
part = lines[index]
|
|
214
|
+
index += 1
|
|
215
|
+
if not part.strip(" \t") or part.lstrip(" \t").startswith("#"):
|
|
216
|
+
continue
|
|
217
|
+
part, more = _continued(index, part)
|
|
218
|
+
line += part
|
|
219
|
+
if line.strip(" \t"):
|
|
220
|
+
first = False
|
|
221
|
+
yield number, line
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def _continued(number, line):
|
|
225
|
+
"""*line* without its continuation backslash, and 1 if it had one."""
|
|
226
|
+
if _ESCAPED_END.search(line):
|
|
227
|
+
_refuse(number, "ends in two backslashes, which one version of "
|
|
228
|
+
"Docker's parser reads as continued and another as ended")
|
|
229
|
+
return _CONTINUES.subn("", line)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def _refuse(number, why):
|
|
233
|
+
raise BundleRefused(
|
|
234
|
+
f"Line {number} of the function bundle's Dockerfile {why}.")
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _is_regular(path: Path) -> bool:
|
|
238
|
+
try:
|
|
239
|
+
return stat.S_ISREG(path.lstat().st_mode)
|
|
240
|
+
except OSError:
|
|
241
|
+
return False
|
|
@@ -109,10 +109,11 @@ def create_project(target: Path, namespace: str, *, force: bool = False):
|
|
|
109
109
|
source = resources.files("workpeg") / "templates" / "project"
|
|
110
110
|
with resources.as_file(source) as root:
|
|
111
111
|
_copy(Path(root), target, namespace, force=force)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
for filled in ("Dockerfile", "wheels/README.txt"):
|
|
113
|
+
path = target / "function" / filled
|
|
114
|
+
path.write_text(
|
|
115
|
+
function_base.fill(path.read_text(encoding="utf-8"),
|
|
116
|
+
base_version), encoding="utf-8")
|
|
116
117
|
try:
|
|
117
118
|
write_starter(target / "ui", namespace, force=force)
|
|
118
119
|
except TemplateExists as exc:
|
|
@@ -28,12 +28,14 @@ def run_with_docker(
|
|
|
28
28
|
behaviour. The container itself is started with ``-d`` (detached), so this
|
|
29
29
|
returns as soon as it is running, not when it stops.
|
|
30
30
|
|
|
31
|
-
*env* is passed to the container as ``-e NAME=VALUE``. It
|
|
32
|
-
|
|
33
|
-
Tables API
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
*env* is passed to the container as ``-e NAME=VALUE``. It was added so a
|
|
32
|
+
function could be handed ``WORKPEG_PK`` for its calls back into the
|
|
33
|
+
Tables API, but the Tables API refuses that key: the dashboard's
|
|
34
|
+
``WORKPEG_PK`` is signed by the registry, which the API cannot verify. A
|
|
35
|
+
function authenticates those calls with the token the platform mints
|
|
36
|
+
per invocation and puts in ``context["token"]`` (docs/tables.md,
|
|
37
|
+
"Backend access from a function"). *env* remains for anything else a
|
|
38
|
+
local container needs.
|
|
37
39
|
|
|
38
40
|
**Values are secrets.** They are passed as arguments to ``docker run``,
|
|
39
41
|
which means anyone who can read the process list on the host can read
|
|
@@ -96,11 +96,22 @@ def build_tar_gz_bytes(source_dir: Path) -> bytes:
|
|
|
96
96
|
|
|
97
97
|
from workpeg.build import validate_function_project
|
|
98
98
|
|
|
99
|
+
from workpeg.function_check import BundleRefused, check_bundle
|
|
100
|
+
|
|
99
101
|
try:
|
|
100
102
|
validate_function_project(source_dir)
|
|
101
103
|
except (FileNotFoundError, NotADirectoryError) as e:
|
|
102
104
|
_fail(str(e))
|
|
103
105
|
|
|
106
|
+
# What Workpeg's install would refuse is refused here, before anything
|
|
107
|
+
# is uploaded, with the install's own message. Before this check a refused
|
|
108
|
+
# bundle uploaded cleanly and only an operator saw why it never ran.
|
|
109
|
+
try:
|
|
110
|
+
check_bundle(source_dir)
|
|
111
|
+
except BundleRefused as e:
|
|
112
|
+
_fail(f"{e} Workpeg would refuse to build this function, so it "
|
|
113
|
+
"was not uploaded.")
|
|
114
|
+
|
|
104
115
|
exclude_names = {
|
|
105
116
|
".git",
|
|
106
117
|
"__pycache__",
|
|
@@ -69,8 +69,11 @@ compiler, not you, decides what reaches the browser.
|
|
|
69
69
|
`WORKPEG_CHROME` unset too: it is the default for `--chrome`, so
|
|
70
70
|
`WORKPEG_CHROME=bundled` turns every build into a bundled one.
|
|
71
71
|
4. **No secrets in a page.** The compiled page is public JavaScript.
|
|
72
|
-
`WORKPEG_PK`
|
|
73
|
-
in UI code
|
|
72
|
+
`WORKPEG_PK` belongs in your shell or CI, for `workpeg function submit`
|
|
73
|
+
and `workpeg cdn submit`, never in UI code and never in a function: the
|
|
74
|
+
Tables API refuses it. A function calls the Tables API with the token in
|
|
75
|
+
each call's `context["token"]`. Every other key stays in a function or
|
|
76
|
+
your shell, never in UI code.
|
|
74
77
|
5. **Do not build sign-in, sign-up or a business picker.** The `Scaffold`
|
|
75
78
|
signs the person in, loads their businesses and draws the switcher.
|
|
76
79
|
6. **The SDK's components are the design.** Compose widgets, variants and
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
FROM registry.gitlab.com/workpeg/workpeg-sdk/pegfn-base:REPLACE_PEGFN_BASE_VERSION
|
|
5
5
|
|
|
6
6
|
# Workpeg builds this image with no network, so nothing here may download.
|
|
7
|
-
# Extra packages come from wheels/, filled before you build or submit
|
|
8
|
-
# pip
|
|
9
|
-
#
|
|
7
|
+
# Extra packages come from wheels/, filled before you build or submit by
|
|
8
|
+
# running pip inside this FROM image (wheels/README.txt has the command).
|
|
9
|
+
# Never list workpeg itself: the base already has it.
|
|
10
10
|
COPY wheels /wheels
|
|
11
11
|
COPY requirements.txt /app/requirements.txt
|
|
12
12
|
USER root
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Wheels for the packages in requirements.txt go here.
|
|
2
|
+
|
|
3
|
+
Workpeg builds a function image with no network, so the Dockerfile installs
|
|
4
|
+
from this folder only (pip install --no-index --find-links=/wheels). Fill it
|
|
5
|
+
before you build or submit, by running pip inside the image your Dockerfile
|
|
6
|
+
starts FROM. Run it from the folder that holds the Dockerfile and
|
|
7
|
+
requirements.txt (the one above this README). If you change the FROM line,
|
|
8
|
+
change the image below to match:
|
|
9
|
+
|
|
10
|
+
docker run --rm --platform linux/amd64 \
|
|
11
|
+
--user "$(id -u):$(id -g)" -e HOME=/tmp \
|
|
12
|
+
-v "$PWD:/w" -w /w --entrypoint pip \
|
|
13
|
+
registry.gitlab.com/workpeg/workpeg-sdk/pegfn-base:REPLACE_PEGFN_BASE_VERSION \
|
|
14
|
+
wheel --no-cache-dir --wheel-dir wheels -r requirements.txt
|
|
15
|
+
|
|
16
|
+
Inside that image pip picks the wheels it can install, with every package
|
|
17
|
+
they depend on. Avoid `pip download --platform ...` on your own computer: it
|
|
18
|
+
matches one tag exactly and misses wheels tagged with older Linux names.
|
|
19
|
+
|
|
20
|
+
Run it again whenever requirements.txt changes. When requirements.txt is
|
|
21
|
+
empty there is nothing to fill, but keep this folder and this file: the
|
|
22
|
+
Dockerfile copies wheels/, and the build fails without it. The SDK itself is
|
|
23
|
+
already in the base image; do not list workpeg in requirements.txt.
|
|
24
|
+
|
|
25
|
+
To build the way Workpeg does before you submit, from the same folder:
|
|
26
|
+
|
|
27
|
+
workpeg function build --like-workpeg
|
|
28
|
+
|
|
29
|
+
It checks the Dockerfile by the rules Workpeg's install applies, then builds
|
|
30
|
+
with --pull --network=none --platform=linux/amd64, as Workpeg does.
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
FROM registry.gitlab.com/workpeg/workpeg-sdk/pegfn-base:REPLACE_PEGFN_BASE_VERSION
|
|
5
5
|
|
|
6
6
|
# Workpeg builds this image with no network, so nothing here may download.
|
|
7
|
-
# Extra packages come from wheels/, filled before you build or submit
|
|
8
|
-
# pip
|
|
9
|
-
#
|
|
7
|
+
# Extra packages come from wheels/, filled before you build or submit by
|
|
8
|
+
# running pip inside this FROM image (wheels/README.txt has the command).
|
|
9
|
+
# Never list workpeg itself: the base already has it.
|
|
10
10
|
COPY wheels /wheels
|
|
11
11
|
COPY requirements.txt /app/requirements.txt
|
|
12
12
|
USER root
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Wheels for the packages in requirements.txt go here.
|
|
2
|
+
|
|
3
|
+
Workpeg builds a function image with no network, so the Dockerfile installs
|
|
4
|
+
from this folder only (pip install --no-index --find-links=/wheels). Fill it
|
|
5
|
+
before you build or submit, by running pip inside the image your Dockerfile
|
|
6
|
+
starts FROM. Run it from the folder that holds the Dockerfile and
|
|
7
|
+
requirements.txt (the one above this README). If you change the FROM line,
|
|
8
|
+
change the image below to match:
|
|
9
|
+
|
|
10
|
+
docker run --rm --platform linux/amd64 \
|
|
11
|
+
--user "$(id -u):$(id -g)" -e HOME=/tmp \
|
|
12
|
+
-v "$PWD:/w" -w /w --entrypoint pip \
|
|
13
|
+
registry.gitlab.com/workpeg/workpeg-sdk/pegfn-base:REPLACE_PEGFN_BASE_VERSION \
|
|
14
|
+
wheel --no-cache-dir --wheel-dir wheels -r requirements.txt
|
|
15
|
+
|
|
16
|
+
Inside that image pip picks the wheels it can install, with every package
|
|
17
|
+
they depend on. Avoid `pip download --platform ...` on your own computer: it
|
|
18
|
+
matches one tag exactly and misses wheels tagged with older Linux names.
|
|
19
|
+
|
|
20
|
+
Run it again whenever requirements.txt changes. When requirements.txt is
|
|
21
|
+
empty there is nothing to fill, but keep this folder and this file: the
|
|
22
|
+
Dockerfile copies wheels/, and the build fails without it. The SDK itself is
|
|
23
|
+
already in the base image; do not list workpeg in requirements.txt.
|
|
24
|
+
|
|
25
|
+
To build the way Workpeg does before you submit, from the same folder:
|
|
26
|
+
|
|
27
|
+
workpeg function build --like-workpeg
|
|
28
|
+
|
|
29
|
+
It checks the Dockerfile by the rules Workpeg's install applies, then builds
|
|
30
|
+
with --pull --network=none --platform=linux/amd64, as Workpeg does.
|
|
@@ -12,6 +12,7 @@ src/workpeg/context.py
|
|
|
12
12
|
src/workpeg/create_new.py
|
|
13
13
|
src/workpeg/doctor.py
|
|
14
14
|
src/workpeg/function_base.py
|
|
15
|
+
src/workpeg/function_check.py
|
|
15
16
|
src/workpeg/project.py
|
|
16
17
|
src/workpeg/run.py
|
|
17
18
|
src/workpeg/runtime.py
|
|
@@ -129,6 +130,7 @@ tests/test_config.py
|
|
|
129
130
|
tests/test_context.py
|
|
130
131
|
tests/test_create_new.py
|
|
131
132
|
tests/test_doctor.py
|
|
133
|
+
tests/test_function_check.py
|
|
132
134
|
tests/test_pegfn_base.py
|
|
133
135
|
tests/test_project_create.py
|
|
134
136
|
tests/test_release_script.py
|
|
@@ -7,7 +7,7 @@ def _scaffold(tmp_path):
|
|
|
7
7
|
project = tmp_path / "demo"
|
|
8
8
|
project.mkdir()
|
|
9
9
|
(project / "workpeg.json").write_text("{}")
|
|
10
|
-
(project / "Dockerfile").write_text("FROM
|
|
10
|
+
(project / "Dockerfile").write_text("FROM python:3.12-slim\n")
|
|
11
11
|
(project / "app").mkdir()
|
|
12
12
|
(project / "app" / "main.py").write_text("")
|
|
13
13
|
return project
|
|
@@ -42,7 +42,7 @@ def test_validate_raises_without_a_dockerfile(tmp_path):
|
|
|
42
42
|
def test_validate_raises_without_app_main(tmp_path):
|
|
43
43
|
p = tmp_path / "p"
|
|
44
44
|
p.mkdir()
|
|
45
|
-
(p / "Dockerfile").write_text("FROM
|
|
45
|
+
(p / "Dockerfile").write_text("FROM python:3.12-slim\n")
|
|
46
46
|
with pytest.raises(FileNotFoundError, match="No app/main.py"):
|
|
47
47
|
build.validate_function_project(p)
|
|
48
48
|
|
|
@@ -82,7 +82,7 @@ def test_build_image_uses_default_name(monkeypatch, tmp_path):
|
|
|
82
82
|
project = tmp_path / "demo"
|
|
83
83
|
project.mkdir()
|
|
84
84
|
(project / "workpeg.json").write_text("{}")
|
|
85
|
-
(project / "Dockerfile").write_text("FROM
|
|
85
|
+
(project / "Dockerfile").write_text("FROM python:3.12-slim\n")
|
|
86
86
|
(project / "app").mkdir()
|
|
87
87
|
(project / "app" / "main.py").write_text("")
|
|
88
88
|
|
|
@@ -106,7 +106,7 @@ def test_build_image_uses_explicit_tag(monkeypatch, tmp_path):
|
|
|
106
106
|
project = tmp_path / "demo"
|
|
107
107
|
project.mkdir()
|
|
108
108
|
(project / "workpeg.json").write_text("{}")
|
|
109
|
-
(project / "Dockerfile").write_text("FROM
|
|
109
|
+
(project / "Dockerfile").write_text("FROM python:3.12-slim\n")
|
|
110
110
|
(project / "app").mkdir()
|
|
111
111
|
(project / "app" / "main.py").write_text("")
|
|
112
112
|
|
|
@@ -131,7 +131,7 @@ def test_build_image_uses_config_image(monkeypatch, tmp_path):
|
|
|
131
131
|
(project / "workpeg.json").write_text(
|
|
132
132
|
'{"build": {"image": "configured-image"}}'
|
|
133
133
|
)
|
|
134
|
-
(project / "Dockerfile").write_text("FROM
|
|
134
|
+
(project / "Dockerfile").write_text("FROM python:3.12-slim\n")
|
|
135
135
|
(project / "app").mkdir()
|
|
136
136
|
(project / "app" / "main.py").write_text("")
|
|
137
137
|
|