Project repo_url: worker can run tasks from any git repo
Projects gain repo_url (validated: https:// or git@ only, no userinfo/password, no file:// or local paths; old DBs get the column via idempotent ALTER in both SQLite and Postgres init). Worker resolves a project's repo_url to a local checkout under --repos-dir (default ./repos) before dispatch: clone if absent, verify remote origin matches and fetch if present, never force reset/clean, never push (push needs write credentials the control plane does not store). Resolve failure fails the task with a clear error, never completed. Docker workers need repos_dir under a same-path extra mount (e.g. /var/lib/codex-app-server/repos). Also: driver-missing test is now mocked instead of depending on the host really having no psycopg driver installed. Deploy package: Caddyfile template exposing only /webhooks/* and /oauth/* (tasks/projects/admin stay 403) plus a webhook-secret generator script that never prints the secret. Tests: host 27 pass, cloud 286 pass (8 skipped are environment-dependent real-Postgres tests).
This commit is contained in:
1 parent
71510a32d4
commit
bed3fc0dff
10 files changed
+788
-17
No files matched your search
@@ -16,6 +16,7 @@ import tempfile
|
||||
import threading
|
||||
import time
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
@@ -309,9 +310,14 @@ class MetricsAndBackupTestCase(unittest.TestCase):
|
||||
conn.close()
|
||||
|
||||
def test_postgres_backend_without_driver_fails_before_file(self):
|
||||
# 环境无关:用 mock 模拟驱动缺失,而不是依赖本机真的没装驱动
|
||||
# (另一任务已在本 VM 装了 psycopg2 + Postgres,原写法在该环境下
|
||||
# 前提不存在而失败,并非代码回归;CI runner 无驱动时原逻辑同样成立)。
|
||||
other_db = os.path.join(self.tmp.name, "pg.db")
|
||||
with self.assertRaises(PostgresDriverMissingError):
|
||||
create_server(other_db, "127.0.0.1", 0, backend="postgres")
|
||||
with mock.patch("cloud.db._load_postgres_driver",
|
||||
side_effect=PostgresDriverMissingError("no driver")):
|
||||
with self.assertRaises(PostgresDriverMissingError):
|
||||
create_server(other_db, "127.0.0.1", 0, backend="postgres")
|
||||
self.assertFalse(os.path.exists(other_db))
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user