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
91 changes: 91 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,97 @@ on:
workflow_dispatch: # Allows manual triggering from GitHub UI

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: '3.12'

- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-lint-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-lint-

- name: Collect changed Python files
id: changed-python
shell: bash
run: |
set -euo pipefail

if [ "${{ github.event_name }}" = "pull_request" ]; then
base_ref="${{ github.event.pull_request.base.ref }}"
git fetch --no-tags --prune --depth=1 origin "$base_ref"
merge_base="$(git merge-base "origin/$base_ref" "${{ github.sha }}")"
diff_from="$merge_base"
elif [ "${{ github.event_name }}" = "push" ]; then
before_sha="${{ github.event.before }}"
if [ -n "$before_sha" ] && [ "$before_sha" != "0000000000000000000000000000000000000000" ]; then
diff_from="$before_sha"
else
if git rev-parse --verify "${{ github.sha }}^" >/dev/null 2>&1; then
diff_from="$(git rev-parse "${{ github.sha }}^")"
else
diff_from="$(git hash-object -t tree /dev/null)"
fi
fi
else
echo "No PR/push diff context for ${GITHUB_EVENT_NAME}; skipping lint."
echo "has_python=false" >> "$GITHUB_OUTPUT"
exit 0
fi

mapfile -t files < <(git diff --name-only --diff-filter=ACMR "$diff_from" "${{ github.sha }}" -- '*.py')

if [ "${#files[@]}" -eq 0 ]; then
echo "No changed Python files detected; skipping lint."
echo "has_python=false" >> "$GITHUB_OUTPUT"
exit 0
fi

echo "Changed Python files:"
printf ' - %s\n' "${files[@]}"

{
echo "has_python=true"
echo "files<<EOF"
printf '%s\n' "${files[@]}"
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Install lint dependencies
if: steps.changed-python.outputs.has_python == 'true'
run: |
python -m pip install --upgrade pip
pip install ruff

- name: Run Ruff check
if: steps.changed-python.outputs.has_python == 'true'
shell: bash
env:
PYTHON_FILES: ${{ steps.changed-python.outputs.files }}
run: |
mapfile -t files <<< "$PYTHON_FILES"
ruff check "${files[@]}"

- name: Run Ruff format check
if: steps.changed-python.outputs.has_python == 'true'
shell: bash
env:
PYTHON_FILES: ${{ steps.changed-python.outputs.files }}
run: |
mapfile -t files <<< "$PYTHON_FILES"
ruff format --check "${files[@]}"

# -----------------------------------------------------------------------
# Fast client tests — lightweight base install only (no gRPC/crypto/MCP)
# Runs ONM unit tests + workspace backend tests
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format
16 changes: 14 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ dev = [
"pytest-xdist>=3.3.0", # Parallel test execution

# Code quality
"black>=23.7.0",
"flake8>=6.0.0",
"ruff>=0.6.0",
"mypy>=1.5.0",
"pre-commit>=3.3.0",
"coverage>=7.3.0",
Expand Down Expand Up @@ -191,3 +190,16 @@ exclude_lines = [
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]

[tool.ruff]
line-length = 120
src = ["src", "tests"]

[tool.ruff.lint]
select = ["E4", "E7", "E9", "F", "I"]

[tool.ruff.lint.isort]
known-first-party = ["openagents"]

[tool.ruff.format]
quote-style = "double"
Loading