Skip to content

ci: standardise pre-commit, lint and release tooling - #1504

Merged
av-dev2 merged 6 commits into
version-15from
backport-1503-to-version-15
Aug 26, 2026
Merged

ci: standardise pre-commit, lint and release tooling#1504
av-dev2 merged 6 commits into
version-15from
backport-1503-to-version-15

Conversation

@github-actions

Copy link
Copy Markdown

Backport of #1503 to version-15.


Brings this app onto the shared toolchain so every in-house app enforces the
same rules.

Hooks now run at three stages

Stage Scope Behaviour
pre-commit staged files fast, autofixes, blocks the commit
commit-msg the message conventional prefix, blocks the commit
pre-push whole repository blocks the push on any failure

The push gate runs pre-commit run --all-files, so one push covering several
commits is checked in full without slowing down each individual commit. It was
verified against a throwaway remote: a file committed with --no-verify is
caught and the push is rejected with nothing landing on the remote.

Run bash scripts/setup-git-hooks.sh once per clone. It installs pre-commit if
it is missing and wires up all three hooks. Git cannot force hooks onto a fresh
clone, so the Pre-commit workflow runs --all-files on every pull request as
the real gate.

Standardised

  • ruff for lint and format, replacing the per-app mix of black, isort, flake8,
    autopep8 and autoflake
  • commitlint for commit messages, replacing three different checkers
  • the self-contained frappe-semgrep hook, which installs semgrep into its own
    environment and clones the rules relative to the repo
  • an anchored exclude regex. The old node_modules|.git pattern also matched
    .github, so no workflow YAML was ever validated.

Removed

  • ci.yml. Building a bench and migrating a throwaway site cost five to eight
    minutes per pull request and went red for upstream and runner problems
    unrelated to the change. Frappe tests continue to run locally.
  • release.yml and .releaserc.json. tag-and-promote-from-pr-label.yml is now
    the only owner of tags, releases and promotion. Running semantic-release
    alongside it made both tag the same version at different commits, which fails
    the promotion job.

Before merging

Check branch protection. If a required status check names CI / Server Tests or
CI / Install Smoke Check, that check no longer exists and will block every pull
request until the rule is updated.

Pre-commit will be red. 51 pre-existing ruff findings remain, mostly F405 from star imports in healthcare_service_request.py, plus 2 F821 undefined names and 9 B006 mutable argument defaults. Either fix them or widen the ignore list to match av_tools and icd_tz, in a separate pull request.

Add a pre-push hook that runs pre-commit over the whole repository, so a
push is rejected when any file is unclean. The commit hook keeps checking
staged files only.

Replace the divergent per-app setups with one shared toolchain: ruff for
lint and format, the self-contained frappe-semgrep hook, and commitlint for
commit messages. Anchor the exclude regex so .github/ is no longer skipped
by an unanchored .git pattern.

Add the pre-commit and semantic-commits workflows, and
scripts/setup-git-hooks.sh for a one-command developer bootstrap.

Remove ci.yml. Building a bench and migrating a throwaway site cost five to
eight minutes per pull request and went red for upstream and runner problems
unrelated to the change. Frappe tests continue to run locally.

Remove release.yml and .releaserc.json. tag-and-promote-from-pr-label.yml is
now the only owner of tags, releases and promotion; running semantic-release
alongside it made both tag the same version at different commits.

(cherry picked from commit 8c6dd72)
Mechanical reformat produced by the standardised hooks. No behaviour change.

(cherry picked from commit ac18190)
PyPDF2 3.0.1 carries PYSEC-2026-1835: a crafted PDF sends __parse_content_stream
into an infinite loop, pinning a core, which text extraction can reach. PyPDF2 is
no longer maintained and the fix ships in pypdf 3.9.0.

The jubilee claim module already imports pypdf, so this makes the NHIF module
match. PdfFileWriter is PdfWriter under the new name; nothing else changes.

(cherry picked from commit 0315832)
admission.py called the translation function _ without importing it, so the
missing admission number path raised NameError instead of the intended message.

insurance.py evaluated a bare item_query statement that did nothing.

nurse_record.py used _ as a throwaway loop variable, shadowing the translation
function for the rest of that scope.

(cherry picked from commit 7e69b6a)
Three names were defined twice in the same scope. Python already used the second
definition in every case, so removing the dead first one changes no behaviour.

- render_doc_as_html: the earlier definition lacked the use_setttings parameter
  and was never reachable. The whitelisted entry point is unaffected.
- delete_medical_record: imported and then redefined locally; the import was dead.
- validate_reqd_fields: the two copies were identical.

(cherry picked from commit 174dc3a)
F401, F403 and F405 fire throughout the NHIF modules, which import helpers with
star imports. av_tools and icd_tz already ignore these three, so this brings
hms_tz onto the same policy rather than rewriting the imports.

(cherry picked from commit 7076ef2)
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.

2 participants