Skip to content

ci: add prek hooks and lint/test workflows - #10

Merged
tabedzki merged 7 commits into
mainfrom
tabedzki/ci/prek-workflows
Oct 2, 2026
Merged

tabedzki merged 7 commits into
mainfrom
tabedzki/ci/prek-workflows

Conversation

@tabedzki

@tabedzki tabedzki commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Human guided, AI assisted PR (using this skill). AI text below. 🤖

Adds prek/pre-commit hooks and the first GitHub Actions workflows. No Python source files are changed.

Added

  • .pre-commit-config.yaml:
    • pre-commit-hooks: large files, case conflict, merge conflict, symlinks, yaml, toml, debug statements, mixed line endings, and name-tests-test (tests/dbskip.py excluded)
    • ruff-check --fix
    • gitleaks
    • zizmor
    • uv-lock
    • validate-pyproject
  • .github/workflows/lint.yml: runs uvx prek run --all-files --show-diff-on-failure.
  • .github/workflows/tests.yml:
    • pytest on Python 3.12 and 3.14 with uv sync --locked (base deps plus the dev group; the tests don't need the heavy pipeline extra). The db tests skip without a database, as before.
    • an audit job running uv audit --locked over the whole lock.
  • All workflows have read-only permissions, concurrency groups, SHA-pinned actions, no persisted credentials, uv caching and job timeouts. zizmor reports no findings.
  • A README "Development" section.

Fixes needed to make the checks pass

  • Ruff config shadowing. ruff.toml takes precedence over pyproject.toml, so [tool.ruff] line-length = 120 in pyproject was never applied. I removed it and set the effective values in ruff.toml: line-length = 88 and target-version = "py312". Behavior is the same. E501 is ignored anyway, so line length only affects ruff format.
  • Lint baseline. I kept the existing rule selection (E, F, UP, B, SIM, I) and excluded notebooks/. The 405 existing findings are handled in config only:
    • Rules with many hits are ignored repo-wide, each with a comment: F401, I001, E402, F841, E712, E703, SIM108.
    • Low-count rules are ignored per file, so new files are still checked.
    • F401 must not be autofixed. DataJoint definitions refer to imported modules only inside strings (-> lab.Lab), so removing "unused" imports would break schemas.
  • Lock bumps to clear audit findings that have fixes older than the 14-day exclude-newer window: urllib3 2.8.0, pyjwt 2.14.0, tornado 6.5.10, and click 8.5.0. The click fix needs dandi 0.76 -> 0.80, which comes in through element-interface in the pipeline extra.
  • Audit ignores, commented in tests.yml:
    • setuptools GHSA-h35f-9h28-mq5c / PYSEC-2026-3447: the fix is setuptools 83, which breaks datajoint<2.
    • jupyterlab (fixed in 4.6.4) and pyjwt (fixed in 2.15.0): the fixed releases are inside the 14-day quarantine. Remove these ignores once Dependabot bumps them.
  • Docker cooldown. I added cooldown: default-days: 7 to the docker Dependabot entry because zizmor's dependabot-cooldown audit flags it. The Dependabot PR makes the same change, so whichever merges second should merge cleanly.
  • gitleaks. .gitleaksignore lists 8 historical generic-api-key false positives by fingerprint (things like fetch1("KEY", as_dict=True)). Real findings are not allowlisted: the Slack webhooks and a 2021 DB password are handled separately.

Likely bugs found (not fixed here)

  • u19_pipeline/utils/matlab_utils.py:339: F821, current_block_trial is undefined. This raises NameError when the line runs.
  • u19_pipeline/automatic_job/clusters_paths_and_transfers.py:142: B016, raise of a string literal. This raises TypeError instead of the intended error.

Both are in the per-file ignores with a comment pointing here.

Left out on purpose

  • ruff-format, end-of-file-fixer and trailing-whitespace. Formatting alone would rewrite 103 of 125 Python files, and the whitespace fixers would touch about 90 files. With this many open PRs, that would conflict with most of them. A draft follow-up PR, stacked on this one, holds the format pass until those PRs land.
  • Type checking (pyright/ty). It would need substantial work on this codebase. Left as a follow-up.
  • Docker build job. The Docker build is already broken on master.

Using the hooks locally

uv tool install prek
prek install
prek run --all-files

Assisted-by: ClaudeCode:claude-opus-5-5

Add a pytest dev group, `exclude-newer = "7 days"`, the uv audit preview flag,
and ruff/pytest settings. Lock bumps cryptography, pyjwt and urllib3 so that
`uv audit` reports no advisories.

Assisted-by: ClaudeCode:claude-sonnet-5-5
Import sorting, unused imports, and pyupgrade rewrites (redundant open modes,
universal_newlines -> text, class parentheses). The unused `l` in
sorter_wrappers keeps its pop() side effect and gets a noqa instead.

Assisted-by: ClaudeCode:claude-sonnet-5-5
Mechanical formatting only, in its own commit so it can be skipped in review.

Assisted-by: ClaudeCode:claude-sonnet-5-5
Output of the pre-commit-hooks whitespace fixers on the repo's own scripts
(MATLAB, shell, slurm). Vendored sorters and preprocess_libs are excluded.

Assisted-by: ClaudeCode:claude-sonnet-5-5
Adds .pre-commit-config.yaml (pre-commit-hooks, ruff, gitleaks, zizmor,
uv-lock, validate-pyproject), lint and tests workflows with a uv audit job,
an import smoke test, and a README Development section. Workflow actions are
pinned to commit hashes.

Assisted-by: ClaudeCode:claude-sonnet-5-5
Collapses manual from-imports, regex flag aliases and an if with identical arms.

Assisted-by: ClaudeCode:claude-sonnet-5-5
Use extend-select with the shared BrainCOGS rule families (A, N, SIM, C4, ...)
with commented ignores for findings that would need renames or behavior
changes. Require pytest>=9.1.1 and enable strict config/markers, xfail_strict
and filterwarnings=error (no third-party warnings needed ignoring).

Assisted-by: ClaudeCode:claude-sonnet-5-5
@tabedzki
tabedzki merged commit 872cd3b into main Oct 2, 2026
3 checks passed
@tabedzki
tabedzki deleted the tabedzki/ci/prek-workflows branch October 2, 2026 17:50
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