diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2e09b5d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +# 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 + # 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 + # 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 "—")