Skip to content
Open
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
41 changes: 22 additions & 19 deletions .ci/scripts/check_deprecated_terms.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python3
# .ci/scripts/check_deprecated_terms.py

import os
import re
import sys
import argparse

# ---- Term sets ----
# Block these when you're on the *2.x* branch (i.e., forbid legacy 1.x names):
TERMS_1X = [
Expand All @@ -16,7 +16,7 @@
"load-worker-coordinator-hosts",
"execute-test",
]

# Block these when you're on the *1.x* branch (i.e., forbid 2.x names):
TERMS_2X = [
"cluster-configs",
Expand All @@ -25,15 +25,13 @@
"run-test",
"test-run",
]

SKIP_DIRS = {".git", "venv", "__pycache__", ".pytest_cache", ".ci", "tests"}
VALID_EXTENSIONS = (".py", ".yml", ".yaml", ".md", ".sh", ".json", ".txt")

SUPRESS_MARKERS = {
"block-1x": "check-deprecated-terms-disable-1x",
"block-2x": "check-deprecated-terms-disable-2x"
}


SUPRESS_MARKERS = {"block-1x": "check-deprecated-terms-disable-1x", "block-2x": "check-deprecated-terms-disable-2x"}


def generate_variants(term: str) -> set[str]:
base = term.replace("-", " ").replace("_", " ")
words = base.split()
Expand All @@ -43,24 +41,27 @@ def generate_variants(term: str) -> set[str]:
variants.add("_".join(words))
variants.add("".join([w.capitalize() for w in words])) # PascalCase
variants.add(words[0] + "".join([w.capitalize() for w in words[1:]])) # camelCase

# Optional: flip order for 2-word terms, but avoid silly "-ip" flips creating noise
if len(words) == 2 and not words[1].lower() == "ip":
variants.add("-".join(words[::-1]))
variants.add("_".join(words[::-1]))
variants.add(words[1] + words[0].capitalize()) # camelCase reverse
return variants



def build_patterns(terms: list[str]) -> list[re.Pattern]:
pats = []
for t in terms:
for v in generate_variants(t):
pats.append(re.compile(re.escape(v), re.IGNORECASE))
return pats



def should_check_file(path: str) -> bool:
return path.endswith(VALID_EXTENSIONS)



def walk_and_check(patterns: list[re.Pattern], mode: str) -> int:
error_found = 0
suppress_marker = SUPRESS_MARKERS.get(mode)
Expand All @@ -86,31 +87,33 @@ def walk_and_check(patterns: list[re.Pattern], mode: str) -> int:
except Exception as e:
print(f"[Warning] Skipped file {full_path}: {e}")
return error_found



def main():
p = argparse.ArgumentParser(description="Check forbidden term set by mode or env.")
p.add_argument("--mode", choices=["block-1x", "block-2x"], default=os.getenv("OSB_TERM_MODE"))
args = p.parse_args()

mode = args.mode
if not mode:
print("No mode provided (use --mode block-1x | block-2x or set OSB_TERM_MODE). Exiting 0.")
sys.exit(0)

if mode == "block-1x":
terms = TERMS_1X
banner = "❌ 1.x terms found in 2.x branch. Replace with 2.x names."
else:
terms = TERMS_2X
banner = "❌ 2.x terms found in 1.x branch. Replace with 1.x names."

patterns = build_patterns(terms)
failed = walk_and_check(patterns, mode)
if failed:
print("\n" + banner)
sys.exit(1)
print("✅ No forbidden terms found for", mode)
sys.exit(0)



if __name__ == "__main__":
main()
7 changes: 4 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ source .venv/bin/activate # Activate virtual environment
## Common Commands

```bash
make lint # Run ruff check on all Python source files
make format # Auto-format all Python source files (run before committing)
make lint # Run ruff check + ruff format --check (enforced in CI)
make test # Run unit tests (pytest tests/)
pytest tests/path/to/test_file.py::TestClass::test_method # Run a single test
make it # Run integration tests via tox (requires Java, Docker; ~30 min)
Expand All @@ -29,9 +30,9 @@ make clean # Remove build artifacts, caches, tox environments

## Code Style

- **Linter**: [ruff](https://docs.astral.sh/ruff/) (configured in `pyproject.toml` under `[tool.ruff]`)
- **Linter + formatter**: [ruff](https://docs.astral.sh/ruff/) (configured in `pyproject.toml` under `[tool.ruff]`)
- **Max line length**: 180 characters
- Run `make lint` before committing; CI enforces this on every PR
- Run `ruff format .` then `make lint` before committing; CI enforces both on every PR

## Architecture

Expand Down
23 changes: 22 additions & 1 deletion DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Apache Solr Orbit.
- [Importing the project into an IDE](#importing-the-project-into-an-ide)
- [Setting Up a Local Solr Instance (Optional)](#setting-up-a-local-solr-instance-optional)
- [Running Tests](#running-tests)
- [Code Style](#code-style)
- [Submitting a Pull Request](#submitting-a-pull-request)
- [Developing Breaking Changes](#developing-breaking-changes)
- [Miscellaneous](#miscellaneous)
Expand Down Expand Up @@ -110,9 +111,29 @@ Integration tests require a running Solr instance (local or Docker).
make it
```

## Code Style

The project uses [ruff](https://docs.astral.sh/ruff/) for both linting and formatting.
`make lint` runs both checks and is enforced in CI on every PR.

### Before committing

Always run:

```bash
make format # auto-format all Python files
make lint # verify lint and format are clean
```

Or set up your editor to format on save — the [ruff VS Code extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) and the [ruff PyCharm plugin](https://plugins.jetbrains.com/plugin/20574-ruff) both support this.

Configuration lives in `pyproject.toml` under `[tool.ruff]`. Key settings:
- **Max line length**: 180 characters
- **Rules**: pycodestyle (`E`) and pyflakes (`F`)

## Submitting a Pull Request

1. **Run tests**: `make test` (and `make it` if applicable).
1. **Run tests and lint**: `make test` and `make lint` (and `make it` if applicable).
2. **Rebase** onto the latest `main` before opening a PR.
3. Open the PR, referencing the related issue (`Closes #123`).
4. Respond to review comments; squash commits if asked.
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ tox-env-clean:

lint:
ruff check .
# ruff format --check . # uncomment once the codebase has been formatted
ruff format --check .

format:
ruff format .

test: develop
pytest tests/
Expand All @@ -105,4 +108,4 @@ release-checks:
release: release-checks clean it
./release.sh $(release_version) $(next_version)

.PHONY: install clean python-caches-clean tox-env-clean test it it312 benchmark coverage release release-checks pyinst
.PHONY: install clean python-caches-clean tox-env-clean lint format test it it312 benchmark coverage release release-checks pyinst
2 changes: 1 addition & 1 deletion benchmarks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/worker_coordinator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
Expand Down
Loading