Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
nox:
runs-on: ubuntu-latest
strategy:
matrix:
session: [mypy, lint]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install nox
- run: nox -s ${{ matrix.session }}
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,28 @@ zubax-forum-export --output-dir forum-cache https://forum.zubax.com/t/1234
```

This writes one Markdown file per fetched topic and downloads referenced attachments into the output directory.

## CI & Testing

Continuous integration is managed with [nox](https://nox.thea.codes/) and runs automatically on every push and pull request via GitHub Actions.

Available nox sessions:

| Session | Description |
|---------|-------------|
| `mypy` | Type-check scripts with mypy in relaxed (non-strict) mode |
| `lint` | Verify code formatting with Black |

Run all default sessions locally:

```bash
pip install nox
nox
```

Run a single session:

```bash
nox -s mypy
nox -s lint
```
30 changes: 30 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Nox sessions for CI testing of the toolkit scripts."""

from __future__ import annotations

import nox

SCRIPTS_DIR = "scripts"
SCRIPT_FILES = [
f"{SCRIPTS_DIR}/kicad2llm.py",
f"{SCRIPTS_DIR}/pdfsplit.py",
f"{SCRIPTS_DIR}/zubax_forum_export.py",
]

nox.options.sessions = ["mypy", "lint"]


@nox.session(python="3.12")
def mypy(session: nox.Session) -> None:
"""Run mypy in relaxed (non-strict) mode on every script."""
session.install("mypy")
# Install optional deps so type stubs are available where possible.
session.install("pymupdf>=1.24", "cairosvg>=2.7", "nox")
session.run("mypy", *SCRIPT_FILES, "noxfile.py")


@nox.session(python="3.12")
def lint(session: nox.Session) -> None:
"""Check code formatting with Black."""
session.install("black")
session.run("black", "--check", "--diff", *SCRIPT_FILES, "noxfile.py")
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,12 @@ py-modules = ["kicad2llm", "pdfsplit", "zubax_forum_export"]

[tool.black]
line-length = 120

[tool.mypy]
python_version = "3.12"
warn_unused_configs = true
# Non-strict (relaxed) mode: rely on mypy defaults; do not enable strict flags.
# Optional libraries without stubs are silently ignored.
ignore_missing_imports = true
# Relax checks that are overly noisy on untyped / third-party-stub-limited code.
disable_error_code = ["assignment", "call-overload", "union-attr", "no-any-return", "arg-type"]
4 changes: 3 additions & 1 deletion scripts/zubax_forum_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ def _with_auth_query(self, url: str) -> str:
if not self.api_key:
return url
parts = urlsplit(url)
existing_q = dict(item.split("=", 1) if "=" in item else (item, "") for item in parts.query.split("&") if item)
existing_q = dict(
tuple(item.split("=", 1)) if "=" in item else (item, "") for item in parts.query.split("&") if item
)
existing_q["api_key"] = self.api_key
existing_q["api_username"] = self.api_username
return urlunsplit((parts.scheme, parts.netloc, parts.path, urlencode(existing_q), parts.fragment))
Expand Down