<feat>(GH action): ruff githook #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ✅ Checks | |
| on: | |
| pull_request: | |
| # Trigger on any PR to ensure all code is standard | |
| branches: ["main"] | |
| # Optimization: Only run if Python or config files change | |
| paths: | |
| - "python/agents/**" | |
| - "pyproject.toml" | |
| - ".github/workflows/checks.yml" | |
| permissions: | |
| contents: write # Required for auto-committing fixes | |
| jobs: | |
| ruff-lint-and-format: | |
| name: Ruff Lint & Format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # FIX: Use the official setup action instead of a curl script | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| # This also handles Python installation for you | |
| python-version: "3.13" | |
| enable-cache: true | |
| - name: Run Ruff Format | |
| run: uvx ruff format . | |
| - name: Run Ruff Check WITHOUT Fix | |
| # Running with --fix will resolve the ruff errors automatically | |
| run: uvx ruff check --fix . | |
| - name: Commit and Push Fixes | |
| # This step only runs if Ruff actually changed files | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add . | |
| git commit -m "chore: auto-fix linting and formatting with ruff" | |
| git push | |
| else | |
| echo "No changes detected by Ruff." | |
| fi |