lint-fix.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. name: Lint Fix
  2. on:
  3. pull_request:
  4. types: [labeled]
  5. jobs:
  6. lint-fix:
  7. if: github.event.label.name == 'lint-fix'
  8. name: Fix linting issues
  9. runs-on: ubuntu-latest
  10. permissions:
  11. contents: write
  12. pull-requests: write
  13. steps:
  14. - uses: actions/checkout@v4
  15. with:
  16. ref: ${{ github.head_ref }}
  17. repository: ${{ github.event.pull_request.head.repo.full_name }}
  18. fetch-depth: 0
  19. token: ${{ secrets.GITHUB_TOKEN }}
  20. # Frontend lint fixes
  21. - name: Install Node.js 20
  22. uses: actions/setup-node@v4
  23. with:
  24. node-version: 20
  25. - name: Install frontend dependencies
  26. run: |
  27. cd frontend
  28. npm install --frozen-lockfile
  29. - name: Fix frontend lint issues
  30. run: |
  31. cd frontend
  32. npm run lint:fix
  33. # Python lint fixes
  34. - name: Set up python
  35. uses: actions/setup-python@v5
  36. with:
  37. python-version: 3.12
  38. cache: 'pip'
  39. - name: Install pre-commit
  40. run: pip install pre-commit==3.7.0
  41. - name: Fix python lint issues
  42. run: |
  43. pre-commit run trailing-whitespace --files openhands/**/* evaluation/**/* tests/**/* --config ./dev_config/python/.pre-commit-config.yaml
  44. pre-commit run end-of-file-fixer --files openhands/**/* evaluation/**/* tests/**/* --config ./dev_config/python/.pre-commit-config.yaml
  45. pre-commit run pyproject-fmt --files openhands/**/* evaluation/**/* tests/**/* --config ./dev_config/python/.pre-commit-config.yaml
  46. pre-commit run ruff --files openhands/**/* evaluation/**/* tests/**/* --config ./dev_config/python/.pre-commit-config.yaml
  47. pre-commit run ruff-format --files openhands/**/* evaluation/**/* tests/**/* --config ./dev_config/python/.pre-commit-config.yaml
  48. # Commit and push changes if any
  49. - name: Check for changes
  50. id: git-check
  51. run: |
  52. git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT
  53. - name: Commit and push if there are changes
  54. if: steps.git-check.outputs.changes == 'true'
  55. run: |
  56. git config --local user.email "openhands@all-hands.dev"
  57. git config --local user.name "OpenHands Bot"
  58. git add -A
  59. git commit -m "🤖 Auto-fix linting issues"
  60. git push