Skip to content

Add prek hooks and CI - #2

Merged
jdoss merged 5 commits into
masterfrom
prek-ci
Oct 9, 2026
Merged

jdoss merged 5 commits into
masterfrom
prek-ci

Conversation

@jdoss

@jdoss jdoss commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Adds prek hooks and a CI workflow, and updates the dev tools they run.

What it does

  • Dev tools: pytest 9.1.1, ruff 0.16.10 and ty 0.0.84 in the dev extra. ruff 0.16 checks more rules by default; the code now uses X | None annotations, states check= on every subprocess.run, and treats typer.Argument/typer.Option as immutable calls.
  • Limits from AGENTS.md: ruff enforces cyclomatic complexity 8 (C901) and 100-character lines (E501). browser_bridge_host.py is exempt from C901 until the bridge rewrite replaces it.
  • prek hooks (.pre-commit-config.yaml): ruff check, ruff format, ty and pytest through uv run --extra dev, plus shellcheck on the shell scripts and image shims, gitleaks on staged changes, and actionlint and zizmor on workflows.
  • CI (.github/workflows/ci.yml): runs every prek hook on every file for pull requests and pushes to master. Actions are pinned to commit SHAs, permissions are read-only, checkout keeps no credentials, and a newer push cancels the run it supersedes.

Test plan

  • prek run --all-files passes locally (ruff, ruff format, ty, 340 tests, shellcheck, gitleaks, actionlint, zizmor)
  • gitleaks fails on a staged fake token; shellcheck picks up the extensionless shims
  • actionlint and zizmor --persona pedantic report nothing for the workflow
  • CI passes on this pull request

jdoss added 5 commits October 8, 2026 21:18
Bump the pinned dev dependencies to their newest releases at least a
week old: pytest 9.1.1, ruff 0.16.10 and ty 0.0.84 (from 0.0.17).

ruff 0.16 checks more rules by default. The fixes:
- Optional[X] annotations become X | None (the package needs 3.11).
- Each subprocess.run states check=: False where the caller reads the
  return code itself, True in tests where a failure should stop there.
- typer.Argument and typer.Option count as immutable calls, so the
  documented typer signature style is not flagged as a mutable default.
- browser_bridge_host.py loses its shebang; it is always run with
  python3 and is not executable.
- Test imports are sorted and Generator comes from collections.abc.
AGENTS.md caps functions at cyclomatic complexity 8 and lines at 100
characters, but ruff checked neither. Enable C901 (max 8) and E501
(100; the formatter keeps its 88-column wrap) and shorten the three
test lines that ran over.

browser_bridge_host.py is exempt from C901 for now: its main() relays
through closures at complexity 19, and the authenticated bridge rewrite
replaces the file.
Nothing ran the checks before a commit: the repo had no hook config.
.pre-commit-config.yaml runs ruff check, ruff format, ty and pytest
through `uv run --extra dev`, so the versions pinned in pyproject are
the ones that run, plus shellcheck on the shell scripts and image
shims, gitleaks on staged changes, and actionlint and zizmor on
workflow files. AGENTS.md covers `prek install`.
The repo had no CI. A GitHub Actions workflow now runs every prek hook
on every file for pull requests and for pushes to master, with uv
providing Python 3.13 and prek pinned to 0.5.4. The actions are pinned
to commit SHAs, the token is read-only, checkout keeps no
credentials, and a newer push cancels the run it supersedes.
actionlint and zizmor (pedantic) report nothing.
git exports GIT_INDEX_FILE and similar variables to its hooks. Run
from the new pre-commit hook, the tests' own git calls in temporary
repos used this repo's index instead, and `git worktree add` failed.
The autouse fixture now removes every inherited GIT_* variable.
@jdoss
jdoss merged commit 7e983a1 into master Oct 9, 2026
1 check passed
@jdoss
jdoss deleted the prek-ci branch October 9, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant