lint-fix.yml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. fetch-depth: 0
  18. token: ${{ secrets.GITHUB_TOKEN }}
  19. # Frontend lint fixes
  20. - name: Install Node.js 20
  21. uses: actions/setup-node@v4
  22. with:
  23. node-version: 20
  24. - name: Install frontend dependencies
  25. run: |
  26. cd frontend
  27. npm install --frozen-lockfile
  28. - name: Fix frontend lint issues
  29. run: |
  30. cd frontend
  31. npm run lint:fix
  32. # Python lint fixes
  33. - name: Set up python
  34. uses: actions/setup-python@v5
  35. with:
  36. python-version: 3.12
  37. cache: 'pip'
  38. - name: Install pre-commit
  39. run: pip install pre-commit==3.7.0
  40. - name: Fix python lint issues
  41. run: |
  42. pre-commit run --files openhands/**/* evaluation/**/* tests/**/* --config ./dev_config/python/.pre-commit-config.yaml --all-files
  43. # Commit and push changes if any
  44. - name: Check for changes
  45. id: git-check
  46. run: |
  47. git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT
  48. - name: Commit and push if there are changes
  49. if: steps.git-check.outputs.changes == 'true'
  50. run: |
  51. git config --local user.email "openhands@all-hands.dev"
  52. git config --local user.name "OpenHands Bot"
  53. git add -A
  54. git commit -m "🤖 Auto-fix linting issues"
  55. git push