From 579b058372aaec8b89b0ce5df73f5410b4685b57 Mon Sep 17 00:00:00 2001 From: Nathanael Anderson Date: Tue, 3 Nov 2026 13:27:37 -0500 Subject: [PATCH] Fix CI failures on Linux and clean checkouts The fixture bootstrap refuses to run in the real checkout, so the jobs now use an isolated workspace. Test setup copies the schemas instead of linking them, because Linux followed the link and copied the folder onto itself. Also fixes what that failure was hiding: f-strings that only parse on Python 3.12, a Windows drive path accepted as a package path on Linux, tests that relied on directory order or earlier tests, and FastAPI 0.137 turning app.routes into a tree. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/audit.yml | 4 ++- .github/workflows/test.yml | 2 ++ .github/workflows/validate.yml | 2 ++ app/services/foundation_contract_service.py | 5 +-- pyproject.toml | 2 +- .../generate_research_portfolio_dashboard.py | 35 +++++-------------- ...morphology_acquisition_readiness_report.py | 7 +--- tests/conftest.py | 15 +------- tests/golden/test_composer_quality.py | 2 +- tests/golden/test_composer_quality_audit.py | 6 +++- tests/unit/test_greek_preview.py | 2 +- tests/unit/test_versification.py | 11 ++++++ 12 files changed, 39 insertions(+), 54 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 569b79a3..04462f37 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -16,6 +16,8 @@ jobs: audit: runs-on: ubuntu-latest timeout-minutes: 15 + env: + ALEPHTAV_ROOT_DIR: /tmp/alephtav-ci steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -28,4 +30,4 @@ jobs: - uses: actions/upload-artifact@v4 with: name: audit-reports - path: reports/ + path: /tmp/alephtav-ci/reports/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 94630468..d9d20fd1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,6 +16,8 @@ jobs: test: runs-on: ubuntu-latest timeout-minutes: 25 + env: + ALEPHTAV_ROOT_DIR: /tmp/alephtav-ci steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 6517968b..5d29d7df 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -16,6 +16,8 @@ jobs: validate: runs-on: ubuntu-latest timeout-minutes: 15 + env: + ALEPHTAV_ROOT_DIR: /tmp/alephtav-ci steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 diff --git a/app/services/foundation_contract_service.py b/app/services/foundation_contract_service.py index a0e1b141..a006c206 100644 --- a/app/services/foundation_contract_service.py +++ b/app/services/foundation_contract_service.py @@ -4,7 +4,7 @@ import json import unicodedata -from pathlib import Path +from pathlib import Path, PureWindowsPath from typing import Any from jsonschema import Draft202012Validator, RefResolver # type: ignore[import-untyped] @@ -23,7 +23,8 @@ def validate_contract(schema_name: str, payload: Any) -> None: def workspace_path(value: str) -> Path: root = get_settings().root_dir.resolve() relative = Path(value) - if relative.is_absolute() or ".." in relative.parts or "\\" in value: + is_drive_path = bool(PureWindowsPath(value).drive) + if relative.is_absolute() or is_drive_path or ".." in relative.parts or "\\" in value: raise ValueError("Package paths must be portable relative workspace paths") result = (root / relative).resolve() if not result.is_relative_to(root) or result == root: diff --git a/pyproject.toml b/pyproject.toml index 0026410b..f364b514 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ authors = [ { name = "AlphaOmega Contributors" } ] dependencies = [ - "fastapi>=0.115.0", + "fastapi>=0.115.0,<0.137", "uvicorn[standard]>=0.30.0", "typer>=0.12.3", "pydantic>=2.8.0", diff --git a/scripts/generate_research_portfolio_dashboard.py b/scripts/generate_research_portfolio_dashboard.py index 0dd56e88..9cb64f9a 100644 --- a/scripts/generate_research_portfolio_dashboard.py +++ b/scripts/generate_research_portfolio_dashboard.py @@ -4426,12 +4426,7 @@ def build_dashboard() -> dict[str, Any]: f"{oshb_exception['sequence_only_exception_verse_count']} sequence-only " "exceptions. " + ( - f"All { - oshb_exception.get( - 'review_row_count', - oshb_exception['sample_row_count'], - ) - } " + f"All {oshb_exception.get('review_row_count', oshb_exception['sample_row_count'])} " "review rows are exported, but reviewer signoff is still absent." if int(oshb_exception["unexported_exception_row_count"]) == 0 else ( @@ -8241,9 +8236,7 @@ def render_html(dashboard: dict[str, Any]) -> str: "OSHB exceptions", fmt_int(headline["oshb_exception_review_mismatch_verse_count"]), ( - f'{fmt_int(headline[ - "oshb_exception_review_token_count_exception_verse_count" - ])} ' + f'{fmt_int(headline["oshb_exception_review_token_count_exception_verse_count"])} ' "token-count exceptions." ), ), @@ -8251,9 +8244,7 @@ def render_html(dashboard: dict[str, Any]) -> str: "OSHB review rows", fmt_int(headline["oshb_exception_review_review_row_count"]), ( - f'{fmt_int(headline[ - "oshb_exception_review_unexported_exception_row_count" - ])} ' + f'{fmt_int(headline["oshb_exception_review_unexported_exception_row_count"])} ' "rows remain unexported." ), ), @@ -8277,9 +8268,7 @@ def render_html(dashboard: dict[str, Any]) -> str: "OSHB rule-routing", f'{headline["oshb_mapping_rule_simulation_candidate_rule_reduction_pct"]:.2f}%', ( - f'{fmt_int(headline[ - "oshb_mapping_rule_simulation_rule_candidate_after_review_count" - ])} ' + f'{fmt_int(headline["oshb_mapping_rule_simulation_rule_candidate_after_review_count"])} ' "high-confidence rows; candidate only." ), ), @@ -8287,9 +8276,7 @@ def render_html(dashboard: dict[str, Any]) -> str: "OSHB residual", fmt_int(headline["oshb_mapping_rule_simulation_manual_residual_row_count"]), ( - f'{fmt_int(headline[ - "oshb_mapping_rule_simulation_targeted_rule_review_count" - ])} ' + f'{fmt_int(headline["oshb_mapping_rule_simulation_targeted_rule_review_count"])} ' "targeted-rule review rows." ), ), @@ -8297,9 +8284,7 @@ def render_html(dashboard: dict[str, Any]) -> str: "Morph unlock units", fmt_int(headline["morph_unlock_unlockable_units"]), ( - f'{headline[ - "morph_unlock_projected_review_ready_score_pct" - ]:.2f}% ' + f'{headline["morph_unlock_projected_review_ready_score_pct"]:.2f}% ' "projected review-ready lane score." ), ), @@ -8556,9 +8541,7 @@ def render_html(dashboard: dict[str, Any]) -> str: ( f'{fmt_int(headline["local_bakeoff_contextual_attempt_count"])} ' "contextual attempts; " - f'{fmt_int(headline[ - "local_bakeoff_contextual_source_anchor_issues" - ])} ' + f'{fmt_int(headline["local_bakeoff_contextual_source_anchor_issues"])} ' "anchor issues." ), ), @@ -11923,9 +11906,7 @@ def render_html(dashboard: dict[str, Any]) -> str: "Unlockable units", fmt_int(headline["morph_unlock_unlockable_units"]), ( - f'{headline[ - "morph_unlock_projected_review_ready_score_pct" - ]:.2f}% ' + f'{headline["morph_unlock_projected_review_ready_score_pct"]:.2f}% ' "projected review-ready lane score." ), ), diff --git a/scripts/generate_whole_tanakh_morphology_acquisition_readiness_report.py b/scripts/generate_whole_tanakh_morphology_acquisition_readiness_report.py index fecaf304..fd6c5e3b 100644 --- a/scripts/generate_whole_tanakh_morphology_acquisition_readiness_report.py +++ b/scripts/generate_whole_tanakh_morphology_acquisition_readiness_report.py @@ -517,12 +517,7 @@ def build_gate_rows( "evidence": ( ( "OSHB exception workbook exports " - f"{ - exception_summary.get( - 'review_row_count', - exception_summary.get('sample_row_count', 0), - ) - } " + f"{exception_summary.get('review_row_count', exception_summary.get('sample_row_count', 0))} " "review rows for " f"{exception_summary.get('mismatch_verse_count', 0)} remaining " "exception verses; " diff --git a/tests/conftest.py b/tests/conftest.py index 92ccad48..627bdfe7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -22,19 +22,6 @@ os.environ["ALEPHTAV_ROOT_DIR"] = str(TEST_ROOT) -def _link_or_copy(source: Path, target: Path) -> None: - if target.exists() or target.is_symlink(): - return - target.parent.mkdir(parents=True, exist_ok=True) - try: - target.symlink_to(source, target_is_directory=source.is_dir()) - except OSError: - if source.is_dir(): - shutil.copytree(source, target) - else: - shutil.copy2(source, target) - - def _copy_tree(source: Path, target: Path) -> None: if target.is_symlink() or target.is_file(): target.unlink() @@ -45,7 +32,7 @@ def _copy_tree(source: Path, target: Path) -> None: TEST_ROOT.mkdir(parents=True, exist_ok=True) -_link_or_copy(ROOT / "schemas", TEST_ROOT / "schemas") +_copy_tree(ROOT / "schemas", TEST_ROOT / "schemas") from tests.support import bootstrap_fixture_repo # noqa: E402 diff --git a/tests/golden/test_composer_quality.py b/tests/golden/test_composer_quality.py index fefe017f..35ab9221 100644 --- a/tests/golden/test_composer_quality.py +++ b/tests/golden/test_composer_quality.py @@ -17,7 +17,7 @@ FIXTURES_DIR = Path(__file__).resolve().parent / "fixtures" COMPOSER_FIXTURE = FIXTURES_DIR / "composer_quality.json" COMPOSER_SOURCE = Path(__file__).resolve().parents[2] / "app/ui/src/lib/composerSynthesis.ts" -pytestmark = pytest.mark.no_seeded_repo +pytestmark = [pytest.mark.no_seeded_repo, pytest.mark.usefixtures("fixture_sources")] def _load_fixture() -> dict[str, object]: diff --git a/tests/golden/test_composer_quality_audit.py b/tests/golden/test_composer_quality_audit.py index ca11a5c1..89fc4737 100644 --- a/tests/golden/test_composer_quality_audit.py +++ b/tests/golden/test_composer_quality_audit.py @@ -10,7 +10,11 @@ write_audit_reports, ) -pytestmark = [pytest.mark.no_seeded_repo, pytest.mark.corpus_audit] +pytestmark = [ + pytest.mark.no_seeded_repo, + pytest.mark.corpus_audit, + pytest.mark.usefixtures("fixture_sources"), +] def test_full_psalter_composer_audit_writes_report(tmp_path_factory) -> None: diff --git a/tests/unit/test_greek_preview.py b/tests/unit/test_greek_preview.py index 40d4e7a5..0f2ee481 100644 --- a/tests/unit/test_greek_preview.py +++ b/tests/unit/test_greek_preview.py @@ -90,7 +90,7 @@ def test_without_owner_approval_the_released_message_is_unchanged(staged, tmp_pa def test_package_changed_after_approval_shows_no_text(staged): - unit_file = next((staged / "psalms").rglob("*.json")) + unit_file = next((staged / "psalms" / "ps001").rglob("*.json")) unit_file.write_bytes(unit_file.read_bytes().replace("ἀνὴρ".encode(), "ἀνήρ".encode())) result = sources.greek_evidence("ps001") assert result["available"] is False diff --git a/tests/unit/test_versification.py b/tests/unit/test_versification.py index a33ddd87..8d4d0a95 100644 --- a/tests/unit/test_versification.py +++ b/tests/unit/test_versification.py @@ -22,6 +22,14 @@ def _table() -> dict: return json.loads((ROOT / "content" / "versification.json").read_text(encoding="utf-8")) +@pytest.fixture +def committed_table(monkeypatch: pytest.MonkeyPatch) -> None: + from app.core import versification + + # This module runs unseeded, so the workspace has no table of its own. + monkeypatch.setattr(versification, "_table", lambda: _table()["psalms"]) + + def test_table_covers_the_whole_psalter() -> None: psalms = _table()["psalms"] @@ -118,6 +126,7 @@ def test_a_psalm_without_a_superscription_displays_its_masoretic_reference() -> assert versification.display_reference("ps001", "Psalm 1:6", 6) == "Psalm 1:6" +@pytest.mark.usefixtures("committed_table") def test_superscription_verses_are_labelled_rather_than_misnumbered() -> None: from app.core import versification @@ -127,6 +136,7 @@ def test_superscription_verses_are_labelled_rather_than_misnumbered() -> None: assert versification.display_reference("ps051", "Psalm 51:2", 2) == "Psalm 51 (heading)" +@pytest.mark.usefixtures("committed_table") def test_verses_after_a_superscription_shift_to_english_numbering() -> None: from app.core import versification @@ -139,6 +149,7 @@ def test_verses_after_a_superscription_shift_to_english_numbering() -> None: assert versification.display_reference("ps003", "Psalm 3:2", 2) == "Psalm 3:1" +@pytest.mark.usefixtures("committed_table") def test_canonical_numbering_reports_the_greek_divergence() -> None: from app.core import versification