lint-fix.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. # Run all pre-commit hooks and continue even if they modify files (exit code 1)
  44. pre-commit run --config ./dev_config/python/.pre-commit-config.yaml --files openhands/**/* evaluation/**/* tests/**/* || true
  45. # Commit and push changes if any
  46. - name: Check for changes
  47. id: git-check
  48. run: |
  49. git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT
  50. - name: Commit and push if there are changes
  51. if: steps.git-check.outputs.changes == 'true'
  52. run: |
  53. git config --local user.email "openhands@all-hands.dev"
  54. git config --local user.name "OpenHands Bot"
  55. git add -A
  56. git commit -m "🤖 Auto-fix linting issues"
  57. git push