Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

ci: give the startup subprocess tests the repo root on PYTHONPATH and check out full history for the docs build

Murtaza Nasir6707cee81000
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index cd9a3bff..1bdc6544 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -23,7 +23,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v5
-
+ with:
+ # git-revision-date-localized needs full history for page dates;
+ # since plugin 1.6 a shallow clone is a warning, which --strict
+ # turns into a failed build.
+ fetch-depth: 0
+
- name: Setup Python
uses: actions/setup-python@v6
with:
diff --git a/tests/test_startup_single_instance.py b/tests/test_startup_single_instance.py
index 5cfbc81d..f84ea50c 100644
--- a/tests/test_startup_single_instance.py
+++ b/tests/test_startup_single_instance.py
@@ -156,6 +156,13 @@ def _run_workers(count, timeout=120):
"""
run_id = f'speakr_test_{os.getpid()}_{uuid.uuid4().hex[:8]}'
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+ # A script run as `python tests/x.py` gets tests/ as sys.path[0], not the
+ # repo root, so `import src` fails in the child unless it inherits an
+ # explicit path. Locally something on PYTHONPATH tends to hide this; CI
+ # has nothing there and fails with ModuleNotFoundError.
+ env = dict(os.environ)
+ env['PYTHONPATH'] = os.pathsep.join(
+ p for p in (repo_root, env.get('PYTHONPATH')) if p)
procs, out_paths = [], []
with tempfile.TemporaryDirectory() as tmp:
for i in range(count):
@@ -164,7 +171,7 @@ def _run_workers(count, timeout=120):
procs.append(subprocess.Popen(
[sys.executable, os.path.abspath(__file__), run_id, out],
stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, text=True,
- cwd=repo_root))
+ cwd=repo_root, env=env))
try:
deadline = time.time() + timeout
while time.time() < deadline: