Skip to content
Merged
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
5 changes: 4 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

## Checklist

- [ ] Version bumped in `reyal_core/__init__.py` (if behavior changed)
- [ ] Version bumped in `reyal_core/__init__.py`
- [ ] `CHANGELOG.md` updated
- [ ] Local bench migration ran successfully (if schema/patch changes)
- [ ] No secrets or local-only files included

## Validation

- [ ] Tested manually
- [ ] `ruff check .` passes
- [ ] `ruff format --check .` passes
- [ ] `pytest` passes
- [ ] Relevant logs/screenshots attached (if useful)
34 changes: 34 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Quality

on:
pull_request:
push:
branches: [main]

jobs:
quality:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install quality tools
run: python -m pip install pytest ruff

- name: Run Ruff lint
run: ruff check .

- name: Check Ruff formatting
run: ruff format --check .

- name: Run tests
run: python -m pytest
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog.

## [0.0.11] - 2026-08-29

### Changed

- Add automated Ruff linting, formatting, and pytest checks for pull requests
- Document local quality checks for contributors

## [0.0.10] - 2026-08-10

### Changed
Expand Down
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ git commit -m "type: short description"

Commit types: `feat`, `fix`, `bump`, `chore`, `refactor`, `docs`.

### Local quality checks

Run these checks before opening a pull request:

```bash
uv run --with ruff ruff check .
uv run --with ruff ruff format --check .
uv run --with pytest pytest
```

Ruff checks Python lint rules and formatting; pytest runs the automated test suite.

### Pull requests

- Never push directly to `main`.
Expand Down
2 changes: 1 addition & 1 deletion reyal_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.10"
__version__ = "0.0.11"
3 changes: 2 additions & 1 deletion reyal_core/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

def apply_patches():
"""Apply all reyal_core patches. Safe to call repeatedly; patches only once."""
import frappe.utils as fu
import frappe.desk.search as fs
import frappe.utils as fu

if getattr(fu, "_reyal_core_patched", False):
return
Expand All @@ -29,6 +29,7 @@ def apply_patches():

# Patched implementations:


def _get_fullname(user=None):
"""Return custom_short_name when set, otherwise fall back to full_name."""
if not user:
Expand Down
7 changes: 5 additions & 2 deletions reyal_core/setup/install.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields


_CUSTOM_FIELDS = {
"User": [
{
Expand All @@ -27,7 +26,11 @@ def _backfill_short_names():
"""Compute short_name for all existing users after install."""
from reyal_core.utils import compute_short_name_value

users = frappe.db.get_all("User", filters={"user_type": "System User"}, fields=["name", "first_name", "middle_name", "last_name"])
users = frappe.db.get_all(
"User",
filters={"user_type": "System User"},
fields=["name", "first_name", "middle_name", "last_name"],
)
for u in users:
short_name = compute_short_name_value(u.first_name, u.last_name, u.get("middle_name"))
frappe.db.set_value("User", u.name, "custom_short_name", short_name, update_modified=False)
14 changes: 9 additions & 5 deletions reyal_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ def get_display_name(user: str | None) -> str:
return ""

u = frappe.db.get_value(
"User", user, ["first_name", "middle_name", "last_name", "full_name", "custom_short_name"], as_dict=True
"User",
user,
["first_name", "middle_name", "last_name", "full_name", "custom_short_name"],
as_dict=True,
)
if not u:
return user
Expand Down Expand Up @@ -36,7 +39,10 @@ def compute_short_name_value(

def _get_format() -> str:
try:
return frappe.db.get_single_value("Reyal Settings", "user_short_display_name_format") or "First + Last Initial"
return (
frappe.db.get_single_value("Reyal Settings", "user_short_display_name_format")
or "First + Last Initial"
)
except Exception:
return "First + Last Initial"

Expand All @@ -49,9 +55,7 @@ def _first_last_initial(first_name: str | None, last_name: str | None) -> str:
return first or last


def _first_middle_last_initial(
first_name: str | None, middle_name: str | None, last_name: str | None
) -> str:
def _first_middle_last_initial(first_name: str | None, middle_name: str | None, last_name: str | None) -> str:
first = (first_name or "").strip()
middle = (middle_name or "").strip()
last = (last_name or "").strip()
Expand Down
Loading