Compare commits
1
Commits
cbcc9fa4b5
..
codex
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d01d02cc0 |
@@ -28,3 +28,5 @@ FORGE-F012 integration (2026-11-18): Captain requested an isolated worktree for
|
|||||||
|
|
||||||
FORGE-F013 integration (2026-11-18): Captain reviewed the isolated results and authorised commit and merge. Branch `codex-forge-f013` at `/tmp/bortstack-forge-f013`, based on `30f6a69`, was fast-forward integrated into local `codex` at `0d67619`. `testtask.sh` accepts a task ID or exact local branch name and reports the resolved task, branch and existing worktree before the same blocked-runtime exit. It performs no Git mutation. Usage and context reference were updated. On both candidate and combined `codex`, 21 tests, skill validation, installer dry-run and task ID audit passed; the candidate diff check passed. A live F013 invocation resolved correctly and exited 3 because Forge has no runtime. Windows and runtime manual testing remain unverified. Human acceptance is pending; the task worktree remains preserved. No push occurred.
|
FORGE-F013 integration (2026-11-18): Captain reviewed the isolated results and authorised commit and merge. Branch `codex-forge-f013` at `/tmp/bortstack-forge-f013`, based on `30f6a69`, was fast-forward integrated into local `codex` at `0d67619`. `testtask.sh` accepts a task ID or exact local branch name and reports the resolved task, branch and existing worktree before the same blocked-runtime exit. It performs no Git mutation. Usage and context reference were updated. On both candidate and combined `codex`, 21 tests, skill validation, installer dry-run and task ID audit passed; the candidate diff check passed. A live F013 invocation resolved correctly and exited 3 because Forge has no runtime. Windows and runtime manual testing remain unverified. Human acceptance is pending; the task worktree remains preserved. No push occurred.
|
||||||
FORGE-F005 selection (2026-12-02): Captain locked on to `bortstack-new` in direct `codex` mode from `31f8edf`. F002, F006, and F007 are complete. The Flask/React descriptor and generator provide the initial template path, and `bortstack-context` owns initial context and profile setup. Validate disposable generated projects for both profiles and local-only Git. Next command is `FORGE-F005 engage`.
|
FORGE-F005 selection (2026-12-02): Captain locked on to `bortstack-new` in direct `codex` mode from `31f8edf`. F002, F006, and F007 are complete. The Flask/React descriptor and generator provide the initial template path, and `bortstack-context` owns initial context and profile setup. Validate disposable generated projects for both profiles and local-only Git. Next command is `FORGE-F005 engage`.
|
||||||
|
|
||||||
|
FORGE-F008 follow-up candidate (2026-12-02): Review the clean generated launcher layout and opt-in acceptance snapshot resolution before migrating PitchInvader. Fixture tests cover task selection and simulated Compose/act dispatch. The uploaded baseline omits the tracked template example environment, so generation was also checked with a temporary local fixture. Live Docker and act were not exercised.
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ Implementation scope (2026-11-19): One canonical `toolkits/testing` package supp
|
|||||||
|
|
||||||
Validation: 29 Forge tests passed, including generated-project inclusion and invocation, branch/task/worktree resolution, isolated Compose fixture lifecycle, credential privacy and selection, suite results, and fake-runtime safe `act`. A generated Flask/React project's `docker compose config --quiet` passed. `context_audit.py`, installer dry-run, Python compilation, and `git diff --check` passed. `act` is installed (`0.2.91`) but the Docker daemon denied access, so live Compose startup, real local Actions execution, and account provisioning remain unverified. Windows is untested. No existing application repository or production resource was changed.
|
Validation: 29 Forge tests passed, including generated-project inclusion and invocation, branch/task/worktree resolution, isolated Compose fixture lifecycle, credential privacy and selection, suite results, and fake-runtime safe `act`. A generated Flask/React project's `docker compose config --quiet` passed. `context_audit.py`, installer dry-run, Python compilation, and `git diff --check` passed. `act` is installed (`0.2.91`) but the Docker daemon denied access, so live Compose startup, real local Actions execution, and account provisioning remain unverified. Windows is untested. No existing application repository or production resource was changed.
|
||||||
|
|
||||||
|
Follow-up candidate (2026-12-02): Generated Flask/React projects expose only the three shared launcher commands under `scripts/`. Testing helpers move under `.bortstack/testing/`. Manual task targets can select registered detached acceptance snapshots when configured. Colon-separated headings and three-digit task shorthand are supported. Existing applications require a separate migration.
|
||||||
|
|
||||||
## FORGE-F009 — Optional Gitea Integration
|
## FORGE-F009 — Optional Gitea Integration
|
||||||
Status: Planned (deferred). Priority: Deferred. Dependencies: FORGE-F005.
|
Status: Planned (deferred). Priority: Deferred. Dependencies: FORGE-F005.
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,13 @@
|
|||||||
"ports": {"BORTSTACK_API_PORT": 5001, "BORTSTACK_WEB_PORT": 8081},
|
"ports": {"BORTSTACK_API_PORT": 5001, "BORTSTACK_WEB_PORT": 8081},
|
||||||
"readiness": ["http://127.0.0.1:5001/api/health/ready", "http://127.0.0.1:8081/"],
|
"readiness": ["http://127.0.0.1:5001/api/health/ready", "http://127.0.0.1:8081/"],
|
||||||
"urls": ["http://127.0.0.1:8081/"],
|
"urls": ["http://127.0.0.1:8081/"],
|
||||||
"authentication": {"required": true, "provision": ["python3", "scripts/provision-test-user.py"]}
|
"authentication": {"required": true, "provision": ["python3", ".bortstack/testing/provision-test-user.py"]}
|
||||||
},
|
},
|
||||||
"automated": {
|
"automated": {
|
||||||
"default": ["unit"],
|
"default": ["unit"],
|
||||||
"suites": {
|
"suites": {
|
||||||
"unit": {"command": ["./scripts/run-unit-tests.sh"], "cwd": "."},
|
"unit": {"command": ["./.bortstack/testing/run-unit-tests.sh"], "cwd": "."},
|
||||||
"integration": {"command": ["./scripts/run-integration-tests.sh"], "cwd": "."}
|
"integration": {"command": ["./.bortstack/testing/run-integration-tests.sh"], "cwd": "."}
|
||||||
},
|
},
|
||||||
"act": []
|
"act": []
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
root=$(CDPATH= cd -- "$(dirname -- "$0")/../../.." && pwd)
|
||||||
if [ ! -d "$root/react/node_modules" ]; then
|
if [ ! -d "$root/react/node_modules" ]; then
|
||||||
echo 'integration tests unavailable: install react/node_modules first' >&2
|
echo 'integration tests unavailable: install react/node_modules first' >&2
|
||||||
exit 3
|
exit 3
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
root=$(CDPATH= cd -- "$(dirname -- "$0")/../../.." && pwd)
|
||||||
if [ ! -x "$root/api/.venv/bin/python" ] || [ ! -d "$root/react/node_modules" ]; then
|
if [ ! -x "$root/api/.venv/bin/python" ] || [ ! -d "$root/react/node_modules" ]; then
|
||||||
echo 'unit tests unavailable: install api/.venv and react/node_modules first' >&2
|
echo 'unit tests unavailable: install api/.venv and react/node_modules first' >&2
|
||||||
exit 3
|
exit 3
|
||||||
@@ -28,9 +28,10 @@ The generated testing toolkit is available without Forge at runtime:
|
|||||||
./scripts/testtask.sh --stop # stops only this worktree's Compose project
|
./scripts/testtask.sh --stop # stops only this worktree's Compose project
|
||||||
./scripts/testrunner.sh --unit
|
./scripts/testrunner.sh --unit
|
||||||
./scripts/testrunner.sh --integration
|
./scripts/testrunner.sh --integration
|
||||||
|
./scripts/create-chatgpt-snapshot.sh # ZIP of the current checkout after the first commit
|
||||||
```
|
```
|
||||||
|
|
||||||
The toolkit uses Git worktree metadata. Generate with `--git-init` or initialise
|
Testing helpers are under `.bortstack/testing/`. The toolkit uses Git worktree metadata. Generate with `--git-init` or initialise
|
||||||
Git locally before using the commands; an initial commit is not required for
|
Git locally before using the commands; an initial commit is not required for
|
||||||
the current worktree. Explicit branch targets require a local branch ref and
|
the current worktree. Explicit branch targets require a local branch ref and
|
||||||
an existing checkout.
|
an existing checkout.
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||||
|
exec python3 "$repo/.bortstack/create-chatgpt-snapshot.py" "$repo"
|
||||||
@@ -8,7 +8,8 @@ from pathlib import Path
|
|||||||
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parent
|
ROOT = Path(__file__).resolve().parent
|
||||||
TOOLKIT = ROOT.parent.parent / "toolkits/testing/scripts"
|
FORGE = ROOT.parent.parent
|
||||||
|
TOOLKIT = FORGE / "toolkits/testing"
|
||||||
TOKEN_FILES = (".env.example", "docker-compose.yml", "react/index.html",
|
TOKEN_FILES = (".env.example", "docker-compose.yml", "react/index.html",
|
||||||
".bortstack/testing.json",
|
".bortstack/testing.json",
|
||||||
"react/src/config/site.js", "react/src/components/Logo/Logo.jsx",
|
"react/src/config/site.js", "react/src/components/Logo/Logo.jsx",
|
||||||
@@ -31,10 +32,15 @@ def generate(name, destination, git_init=False):
|
|||||||
raise ValueError("destination parent must already exist")
|
raise ValueError("destination parent must already exist")
|
||||||
target.mkdir()
|
target.mkdir()
|
||||||
try:
|
try:
|
||||||
shutil.copytree(ROOT / "source", target, symlinks=False, dirs_exist_ok=True)
|
ignore_cache = shutil.ignore_patterns("__pycache__")
|
||||||
shutil.copytree(ROOT / "boilerplate", target, dirs_exist_ok=True)
|
shutil.copytree(ROOT / "source", target, dirs_exist_ok=True, ignore=ignore_cache)
|
||||||
for tool_name in ("testtask.sh", "testrunner.sh", "target.py", "toolkit.py"):
|
shutil.copytree(ROOT / "boilerplate", target, dirs_exist_ok=True, ignore=ignore_cache)
|
||||||
shutil.copy2(TOOLKIT / tool_name, target / "scripts" / tool_name)
|
for tool_name in ("testtask.sh", "testrunner.sh"):
|
||||||
|
shutil.copy2(TOOLKIT / "scripts" / tool_name, target / "scripts" / tool_name)
|
||||||
|
for module in ("target.py", "toolkit.py"):
|
||||||
|
shutil.copy2(TOOLKIT / "runtime" / module, target / ".bortstack/testing" / module)
|
||||||
|
shutil.copy2(FORGE / "scripts/create-chatgpt-snapshot.py",
|
||||||
|
target / ".bortstack/create-chatgpt-snapshot.py")
|
||||||
values = {"__PROJECT_NAME__": name, "__APP_SLUG__": slug,
|
values = {"__PROJECT_NAME__": name, "__APP_SLUG__": slug,
|
||||||
"__DATABASE_NAME__": slug.replace("-", "_")}
|
"__DATABASE_NAME__": slug.replace("-", "_")}
|
||||||
for relative in TOKEN_FILES:
|
for relative in TOKEN_FILES:
|
||||||
|
|||||||
@@ -19,3 +19,6 @@ test-results/
|
|||||||
*.sqlite
|
*.sqlite
|
||||||
*.sqlite3
|
*.sqlite3
|
||||||
*.db
|
*.db
|
||||||
|
|
||||||
|
/snapshots/
|
||||||
|
/.test-worktrees/
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ class FlaskReactTemplateTests(unittest.TestCase):
|
|||||||
self.assertFalse((project / ".git").exists())
|
self.assertFalse((project / ".git").exists())
|
||||||
self.assertFalse((project / ".github").exists())
|
self.assertFalse((project / ".github").exists())
|
||||||
self.assertFalse((project / ".bortstack/profile.yaml").exists())
|
self.assertFalse((project / ".bortstack/profile.yaml").exists())
|
||||||
self.assertTrue((project / "scripts/testtask.sh").is_file())
|
self.assertEqual(
|
||||||
self.assertTrue((project / "scripts/testrunner.sh").is_file())
|
{path.name for path in (project / "scripts").iterdir()},
|
||||||
|
{"create-chatgpt-snapshot.sh", "testtask.sh", "testrunner.sh"},
|
||||||
|
)
|
||||||
testing = json.loads((project / ".bortstack/testing.json").read_text())
|
testing = json.loads((project / ".bortstack/testing.json").read_text())
|
||||||
self.assertEqual(testing["manual"]["project"], "orion-starter")
|
self.assertEqual(testing["manual"]["project"], "orion-starter")
|
||||||
self.assertEqual(testing["automated"]["default"], ["unit"])
|
self.assertEqual(testing["automated"]["default"], ["unit"])
|
||||||
|
|||||||
@@ -11,11 +11,12 @@ import unittest
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
SOURCE = Path(__file__).resolve().parents[1] / "toolkits/testing/scripts"
|
SOURCE = Path(__file__).resolve().parents[1] / "toolkits/testing"
|
||||||
|
|
||||||
|
|
||||||
def run(*args, cwd=None, env=None):
|
def run(*args, cwd=None, env=None):
|
||||||
return subprocess.run(args, cwd=cwd, env=env, capture_output=True, text=True)
|
return subprocess.run(args, cwd=cwd, env=env, stdin=subprocess.DEVNULL,
|
||||||
|
capture_output=True, text=True)
|
||||||
|
|
||||||
|
|
||||||
class ToolkitTests(unittest.TestCase):
|
class ToolkitTests(unittest.TestCase):
|
||||||
@@ -27,9 +28,13 @@ class ToolkitTests(unittest.TestCase):
|
|||||||
(self.root / "scripts").mkdir()
|
(self.root / "scripts").mkdir()
|
||||||
(self.root / "docs").mkdir()
|
(self.root / "docs").mkdir()
|
||||||
(self.root / ".bortstack").mkdir()
|
(self.root / ".bortstack").mkdir()
|
||||||
for name in ("testtask.sh", "testrunner.sh", "toolkit.py", "target.py"):
|
for name in ("testtask.sh", "testrunner.sh"):
|
||||||
shutil.copy2(SOURCE / name, self.root / "scripts" / name)
|
shutil.copy2(SOURCE / "scripts" / name, self.root / "scripts" / name)
|
||||||
(self.root / "docs/TASKS.md").write_text("## PI-042 — Current\nBranch/worktree: `feature/homepage`\n\n## TASK-001 — Legacy\nBranch/worktree: `feature-legacy`\n")
|
runtime = self.root / ".bortstack/testing"
|
||||||
|
runtime.mkdir()
|
||||||
|
for name in ("toolkit.py", "target.py"):
|
||||||
|
shutil.copy2(SOURCE / "runtime" / name, runtime / name)
|
||||||
|
(self.root / "docs/TASKS.md").write_text("## PI-042 — Current\nBranch/worktree: `feature/homepage`\n\n## TASK-001: Legacy\nBranch/worktree: `feature-legacy`\n")
|
||||||
(self.root / ".bortstack/testing.json").write_text(json.dumps({
|
(self.root / ".bortstack/testing.json").write_text(json.dumps({
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"manual": {"kind": "compose", "environment": "development", "file": "compose.yml", "project": "fixture", "ports": {"TEST_PORT": 59991}, "urls": ["http://127.0.0.1:59991/"]},
|
"manual": {"kind": "compose", "environment": "development", "file": "compose.yml", "project": "fixture", "ports": {"TEST_PORT": 59991}, "urls": ["http://127.0.0.1:59991/"]},
|
||||||
@@ -84,6 +89,31 @@ class ToolkitTests(unittest.TestCase):
|
|||||||
run("git", "branch", "PI-042", cwd=self.root)
|
run("git", "branch", "PI-042", cwd=self.root)
|
||||||
self.assertIn("ambiguous identifier", self.runner("PI-042").stderr)
|
self.assertIn("ambiguous identifier", self.runner("PI-042").stderr)
|
||||||
|
|
||||||
|
def test_manual_task_selects_registered_detached_snapshot(self):
|
||||||
|
config = self.root / ".bortstack/testing.json"
|
||||||
|
value = json.loads(config.read_text())
|
||||||
|
value["manual"]["acceptance_snapshots"] = ".test-worktrees"
|
||||||
|
config.write_text(json.dumps(value))
|
||||||
|
branch_tree = Path(self.temp.name) / "legacy branch"
|
||||||
|
run("git", "worktree", "add", "-q", str(branch_tree), "feature-legacy", cwd=self.root)
|
||||||
|
launcher = str(self.root / "scripts/testtask.sh")
|
||||||
|
|
||||||
|
missing = run(launcher, "001", "--status", cwd=self.root)
|
||||||
|
self.assertEqual(missing.returncode, 2, missing.stderr)
|
||||||
|
self.assertIn("requires a registered detached acceptance snapshot", missing.stderr)
|
||||||
|
|
||||||
|
snapshot = self.root / ".test-worktrees/task-001"
|
||||||
|
added = run("git", "worktree", "add", "-q", "--detach", str(snapshot), cwd=self.root)
|
||||||
|
self.assertEqual(added.returncode, 0, added.stderr)
|
||||||
|
(snapshot / ".bortstack/testing.json").write_text(json.dumps(value))
|
||||||
|
for target in ("001", "TASK-001"):
|
||||||
|
result = run(launcher, target, "--status", cwd=self.root)
|
||||||
|
self.assertIn(f"worktree: {snapshot}", result.stdout)
|
||||||
|
self.assertNotEqual(result.returncode, 2, result.stderr)
|
||||||
|
automated = self.runner("TASK-001")
|
||||||
|
self.assertEqual(automated.returncode, 0, automated.stderr)
|
||||||
|
self.assertIn(f"worktree: {branch_tree}", automated.stdout)
|
||||||
|
|
||||||
def test_configuration_and_act_safety(self):
|
def test_configuration_and_act_safety(self):
|
||||||
config = self.root / ".bortstack/testing.json"
|
config = self.root / ".bortstack/testing.json"
|
||||||
value = json.loads(config.read_text())
|
value = json.loads(config.read_text())
|
||||||
@@ -156,9 +186,9 @@ class ToolkitTests(unittest.TestCase):
|
|||||||
self.assertIn("stop", Path(env["DOCKER_LOG"]).read_text())
|
self.assertIn("stop", Path(env["DOCKER_LOG"]).read_text())
|
||||||
|
|
||||||
def test_interactive_custom_credentials_are_ephemeral(self):
|
def test_interactive_custom_credentials_are_ephemeral(self):
|
||||||
sys.path.insert(0, str(SOURCE))
|
sys.path.insert(0, str(SOURCE / "runtime"))
|
||||||
self.addCleanup(lambda: sys.path.remove(str(SOURCE)))
|
self.addCleanup(lambda: sys.path.remove(str(SOURCE / "runtime")))
|
||||||
spec = importlib.util.spec_from_file_location("forge_toolkit_test", SOURCE / "toolkit.py")
|
spec = importlib.util.spec_from_file_location("forge_toolkit_test", SOURCE / "runtime/toolkit.py")
|
||||||
module = importlib.util.module_from_spec(spec)
|
module = importlib.util.module_from_spec(spec)
|
||||||
spec.loader.exec_module(module)
|
spec.loader.exec_module(module)
|
||||||
private = Path(self.temp.name) / "config"
|
private = Path(self.temp.name) / "config"
|
||||||
@@ -185,9 +215,9 @@ class ToolkitTests(unittest.TestCase):
|
|||||||
module.credentials("fixture", False)
|
module.credentials("fixture", False)
|
||||||
|
|
||||||
def test_port_conflict_does_not_start_compose(self):
|
def test_port_conflict_does_not_start_compose(self):
|
||||||
sys.path.insert(0, str(SOURCE))
|
sys.path.insert(0, str(SOURCE / "runtime"))
|
||||||
self.addCleanup(lambda: sys.path.remove(str(SOURCE)))
|
self.addCleanup(lambda: sys.path.remove(str(SOURCE / "runtime")))
|
||||||
spec = importlib.util.spec_from_file_location("forge_toolkit_port_test", SOURCE / "toolkit.py")
|
spec = importlib.util.spec_from_file_location("forge_toolkit_port_test", SOURCE / "runtime/toolkit.py")
|
||||||
module = importlib.util.module_from_spec(spec)
|
module = importlib.util.module_from_spec(spec)
|
||||||
spec.loader.exec_module(module)
|
spec.loader.exec_module(module)
|
||||||
bin_dir = Path(self.temp.name) / "bin-port"
|
bin_dir = Path(self.temp.name) / "bin-port"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
This package is copied into generated applications. `scripts/testtask.sh` starts,
|
This package is copied into generated applications. `scripts/testtask.sh` starts,
|
||||||
checks, or stops a **manual development environment**. `scripts/testrunner.sh`
|
checks, or stops a **manual development environment**. `scripts/testrunner.sh`
|
||||||
runs configured automated suites. Both use `scripts/target.py` to select a Git
|
runs configured automated suites. Both use `.bortstack/testing/target.py` to select a Git
|
||||||
worktree; neither needs Forge at runtime. This package does not migrate existing
|
worktree; neither needs Forge at runtime. This package does not migrate existing
|
||||||
Roborto application launchers. Forge's earlier `distribution/testtask` is a
|
Roborto application launchers. Forge's earlier `distribution/testtask` is a
|
||||||
separate existing-project automated runner and remains unchanged for its
|
separate existing-project automated runner and remains unchanged for its
|
||||||
@@ -17,12 +17,26 @@ The application owns `.bortstack/testing.json` (see
|
|||||||
`config/testing.example.json`). A no-argument command uses the current worktree
|
`config/testing.example.json`). A no-argument command uses the current worktree
|
||||||
and its checked-out branch. A branch name uses its existing worktree; a task ID
|
and its checked-out branch. A branch name uses its existing worktree; a task ID
|
||||||
uses `docs/TASKS.md` headings and `Branch/worktree: \`name\`` references or a
|
uses `docs/TASKS.md` headings and `Branch/worktree: \`name\`` references or a
|
||||||
matching branch slug. A branch needs no task record. Missing, ambiguous, and
|
matching branch slug. A branch needs no task record. Task headings accept a colon or dash separator, and three-digit targets such
|
||||||
detached targets fail without Git mutation.
|
as `134` also look up `TASK-134`. Missing or ambiguous targets fail without
|
||||||
|
Git mutation.
|
||||||
|
|
||||||
|
Generated Flask/React projects expose only `testtask.sh`, `testrunner.sh`
|
||||||
|
and `create-chatgpt-snapshot.sh` under `scripts/`. The testing implementation
|
||||||
|
and template-specific hooks live under `.bortstack/testing/`.
|
||||||
|
|
||||||
## Manual environments
|
## Manual environments
|
||||||
|
|
||||||
`./scripts/testtask.sh [target] [--start|--status|--stop]` starts by default.
|
`./scripts/testtask.sh [target] [--start|--status|--stop]` starts by default.
|
||||||
|
To use prepared acceptance snapshots for manual task IDs, set
|
||||||
|
`manual.acceptance_snapshots` in the launching checkout's testing
|
||||||
|
configuration to a directory such as `.test-worktrees`. A task target then
|
||||||
|
requires a registered detached Git worktree named after the lowercased task ID,
|
||||||
|
such as `.test-worktrees/task-134`. The command runs against the existing
|
||||||
|
snapshot files and its testing configuration. Prepare and verify the snapshot
|
||||||
|
before launch. Missing snapshots fail explicitly. Branch targets and automated
|
||||||
|
suites continue to resolve their own worktrees.
|
||||||
|
|
||||||
The current adapter supports Docker Compose. It uses a unique project name
|
The current adapter supports Docker Compose. It uses a unique project name
|
||||||
derived from the selected worktree and branch, checks declared host ports,
|
derived from the selected worktree and branch, checks declared host ports,
|
||||||
starts only that project, verifies configured loopback readiness URLs, and
|
starts only that project, verifies configured loopback readiness URLs, and
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
HEADING = re.compile(r"^## ([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+)\s+[—-]", re.M)
|
HEADING = re.compile(r"^## ([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+)(?::|[ \t]+[—-])", re.M)
|
||||||
LABEL = re.compile(r"(?:Task )?[Bb]ranch(?:/worktree)?:\s*`([^`]+)`")
|
LABEL = re.compile(r"(?:Task )?[Bb]ranch(?:/worktree)?:\s*`([^`]+)`")
|
||||||
|
|
||||||
|
|
||||||
@@ -38,7 +38,19 @@ def associated(task_id, section, branches):
|
|||||||
return found
|
return found
|
||||||
|
|
||||||
|
|
||||||
def resolve(script_path, identifier=None):
|
def acceptance_snapshot(root, directory, task_id):
|
||||||
|
directory = (root / directory).resolve()
|
||||||
|
selected = (directory / task_id.lower()).resolve()
|
||||||
|
if not directory.is_relative_to(root) or not selected.is_relative_to(directory):
|
||||||
|
raise TargetError("acceptance snapshot path leaves its configured location")
|
||||||
|
for block in git(root, "worktree", "list", "--porcelain").split("\n\n"):
|
||||||
|
lines = block.splitlines()
|
||||||
|
if f"worktree {selected}" in lines and "detached" in lines and selected.is_dir():
|
||||||
|
return selected
|
||||||
|
raise TargetError(f"task {task_id} requires a registered detached acceptance snapshot at {selected}")
|
||||||
|
|
||||||
|
|
||||||
|
def resolve(script_path, identifier=None, snapshot_directory=None):
|
||||||
origin = Path.cwd() if identifier is None else script_path.parent
|
origin = Path.cwd() if identifier is None else script_path.parent
|
||||||
root = Path(git(origin, "rev-parse", "--show-toplevel")).resolve()
|
root = Path(git(origin, "rev-parse", "--show-toplevel")).resolve()
|
||||||
branches = set(git(root, "for-each-ref", "--format=%(refname:short)", "refs/heads").splitlines())
|
branches = set(git(root, "for-each-ref", "--format=%(refname:short)", "refs/heads").splitlines())
|
||||||
@@ -50,14 +62,19 @@ def resolve(script_path, identifier=None):
|
|||||||
raise TargetError("current worktree has detached HEAD; specify a branch or task ID")
|
raise TargetError("current worktree has detached HEAD; specify a branch or task ID")
|
||||||
selected = Path(git(origin, "rev-parse", "--show-toplevel")).resolve()
|
selected = Path(git(origin, "rev-parse", "--show-toplevel")).resolve()
|
||||||
else:
|
else:
|
||||||
task_match = identifier in records
|
task_id = identifier
|
||||||
|
if re.fullmatch(r"[0-9]{3}", identifier):
|
||||||
|
task_id = f"TASK-{identifier}"
|
||||||
|
task_match = task_id in records
|
||||||
branch_match = identifier in branches
|
branch_match = identifier in branches
|
||||||
if task_match and branch_match:
|
if task_match and branch_match:
|
||||||
raise TargetError(f"ambiguous identifier {identifier}: both task ID and branch; disambiguate in project records")
|
raise TargetError(f"ambiguous identifier {identifier}: both task ID and branch; disambiguate in project records")
|
||||||
if task_match:
|
if task_match:
|
||||||
if len(records[identifier]) != 1:
|
if len(records[task_id]) != 1:
|
||||||
raise TargetError(f"ambiguous task ID {identifier}: duplicate records")
|
raise TargetError(f"ambiguous task ID {identifier}: duplicate records")
|
||||||
matches = associated(identifier, records[identifier][0], branches)
|
if snapshot_directory is not None:
|
||||||
|
return root, task_id, acceptance_snapshot(root, snapshot_directory, task_id)
|
||||||
|
matches = associated(task_id, records[task_id][0], branches)
|
||||||
if len(matches) != 1:
|
if len(matches) != 1:
|
||||||
raise TargetError(f"task {identifier} maps to {len(matches)} branches: {', '.join(sorted(matches))}")
|
raise TargetError(f"task {identifier} maps to {len(matches)} branches: {', '.join(sorted(matches))}")
|
||||||
branch = next(iter(matches))
|
branch = next(iter(matches))
|
||||||
@@ -323,7 +323,16 @@ def main(argv):
|
|||||||
parser.add_argument(f"--{name}", action="store_true")
|
parser.add_argument(f"--{name}", action="store_true")
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
try:
|
try:
|
||||||
root, branch, tree = resolve(Path(__file__).resolve(), args.target)
|
script = Path(__file__).resolve()
|
||||||
|
snapshot_directory = None
|
||||||
|
if mode == "manual" and args.target:
|
||||||
|
project = script.parents[2]
|
||||||
|
origin_config = project / ".bortstack/testing.json"
|
||||||
|
if origin_config.is_file():
|
||||||
|
manual_config = config_for(project).get("manual")
|
||||||
|
if isinstance(manual_config, dict) and "acceptance_snapshots" in manual_config:
|
||||||
|
snapshot_directory = local_path(project, manual_config["acceptance_snapshots"])
|
||||||
|
root, branch, tree = resolve(script, args.target, snapshot_directory)
|
||||||
print(f"repository: {root}\nbranch: {branch}\nworktree: {tree}", flush=True)
|
print(f"repository: {root}\nbranch: {branch}\nworktree: {tree}", flush=True)
|
||||||
config = config_for(tree)
|
config = config_for(tree)
|
||||||
return manual(mode, tree, branch, config, args) if mode == "manual" else automated(tree, config, args)
|
return manual(mode, tree, branch, config, args) if mode == "manual" else automated(tree, config, args)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||||
exec python3 "$script_dir/toolkit.py" automated "$@"
|
exec python3 "$script_dir/../.bortstack/testing/toolkit.py" automated "$@"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||||
exec python3 "$script_dir/toolkit.py" manual "$@"
|
exec python3 "$script_dir/../.bortstack/testing/toolkit.py" manual "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user