From bed1b373813f9dfcb8e9c5547d74f748fa83f631 Mon Sep 17 00:00:00 2001 From: Jiahui Chen Date: Sat, 10 Oct 2026 15:52:30 -0500 Subject: [PATCH 1/2] CI: tests, schema validation and dry-runs on every PR and push to main (#22) GitHub Actions on Python 3.10 and 3.12: install every module's requirements, lint for errors only (syntax, undefined names), run the suite (which validates the committed fixtures against the schema), and run every module's --dry-run from fixtures. No network. M6 imported datetime.UTC, which needs Python 3.11, while setup_env.sh accepts 3.10; it now uses timezone.utc like the rest of the code. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 54 +++++++++++++++++++++++++++++++++++++++ s2f/m6_report/__main__.py | 4 +-- s2f/m6_report/view.py | 4 +-- 3 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fb4596c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +# Tests, schema validation and dry-runs on every pull request and every push to main (#22). +# Nothing here touches the network: the suite and the dry-runs run from committed fixtures. +name: CI + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.12"] + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: pip + + - name: Install every module's requirements + # The same glob scripts/setup_env.sh uses, so a module that adds a requirements file + # is picked up here too. jinja2 is listed explicitly until M6 has its own file (#76). + run: | + python -m pip install --upgrade pip + python -m pip install $(for f in requirements-*.txt; do echo "-r $f"; done) \ + "jinja2>=3.1,<4" pytest ruff + + - name: Lint (errors only) + # Syntax errors and undefined names, not style: a style rule nobody agreed to would + # fail every open PR on day one. + run: ruff check --select E9,F63,F7,F82 s2f tests + + - name: Unit tests, including schema validation of the committed fixtures + run: python -m pytest -q + + - name: Every module's --dry-run completes from fixtures + run: | + for module in m2_triage m3_fold m6_report full_report; do + echo "::group::$module --dry-run" + python -m "s2f.$module" --run "$RUNNER_TEMP/dry/$module" --dry-run + echo "::endgroup::" + done diff --git a/s2f/m6_report/__main__.py b/s2f/m6_report/__main__.py index c02a4dd..80635a6 100644 --- a/s2f/m6_report/__main__.py +++ b/s2f/m6_report/__main__.py @@ -16,7 +16,7 @@ import argparse import json -from datetime import UTC, datetime +from datetime import datetime, timezone from pathlib import Path from jinja2 import Environment, FileSystemLoader, StrictUndefined @@ -76,7 +76,7 @@ def main(argv: list[str] | None = None) -> int: "report", { "rendered_path": str(out_path), - "rendered_at": datetime.now(UTC).isoformat(timespec="seconds"), + "rendered_at": datetime.now(timezone.utc).isoformat(timespec="seconds"), "counts": built.counts, "sections": status, }, diff --git a/s2f/m6_report/view.py b/s2f/m6_report/view.py index 92ec2d5..2f370fd 100644 --- a/s2f/m6_report/view.py +++ b/s2f/m6_report/view.py @@ -12,7 +12,7 @@ from __future__ import annotations from dataclasses import dataclass, field -from datetime import UTC, datetime +from datetime import datetime, timezone from typing import Any #: Sections the report knows how to show, in the order `docs/06-m6-report.md` lays out. @@ -140,7 +140,7 @@ def _protein_row(protein: dict[str, Any], structure: dict[str, Any] | None) -> d def build(report: dict[str, Any], *, top: int = 25) -> ReportView: """Build the whole view. Missing sections become 'not run', never empty successes.""" - view = ReportView(generated_at=datetime.now(UTC).isoformat(timespec="seconds")) + view = ReportView(generated_at=datetime.now(timezone.utc).isoformat(timespec="seconds")) run = report.get("run") or {} view.run_id = str(run.get("run_id") or "—") From 5fe2cac4f765d2a9faf22336ee8b8586a1f3b090 Mon Sep 17 00:00:00 2001 From: Jiahui Chen Date: Sat, 10 Oct 2026 15:53:02 -0500 Subject: [PATCH 2/2] CI: point the pip cache at the per-module requirements files Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb4596c..2e09b5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,8 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: pip + # The default looks for requirements.txt; this repo has one file per module. + cache-dependency-path: requirements-*.txt - name: Install every module's requirements # The same glob scripts/setup_env.sh uses, so a module that adds a requirements file