Skip to content

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

Merged
av-dev2 merged 6 commits into
Aakvatech-Limited:version-15-betafrom
av-dev2:chore/ci-standardisation
Aug 26, 2026
Merged

ci: standardise pre-commit, lint and release tooling#1503
av-dev2 merged 6 commits into
Aakvatech-Limited:version-15-betafrom
av-dev2:chore/ci-standardisation

Conversation

@av-dev2

@av-dev2 av-dev2 commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

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.
Mechanical reformat produced by the standardised hooks. No behaviour change.
@av-dev2 av-dev2 added the backport-to-version-16 Backport this PR to version-16 after merge label Aug 26, 2026
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.
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.
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.
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.
@av-dev2 av-dev2 added backport-to-version-15 Production branch and removed backport-to-version-16 Backport this PR to version-16 after merge labels Aug 26, 2026
@av-dev2
av-dev2 merged commit 777fca9 into Aakvatech-Limited:version-15-beta Aug 26, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

Backport failed for version-15, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin version-15
git worktree add -d .worktree/backport-1503-to-version-15 origin/version-15
cd .worktree/backport-1503-to-version-15
git switch --create backport-1503-to-version-15
git cherry-pick -x 8c6dd72eeb615850983ba6ba8d88edf495e30291 ac18190365de5162e511ea6dcbf2151fb4103ab3 0315832b734b04f8c3f01755fdd981a69ecb506e 7e69b6a3210fcf8a1a359e2271b9b3b17149e5c0 174dc3af56654841ecd76452a0c551e388bd058e 7076ef2075e95a67779a981318ea9acc4d408497

@av-dev2 av-dev2 added backport-to-version-15 Production branch and removed backport-to-version-15 Production branch labels Aug 26, 2026
@github-actions

Copy link
Copy Markdown

Successfully created backport PR for version-15:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-version-15 Production branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants