lint-fix.yml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. name: Lint Fix
  2. on:
  3. pull_request:
  4. types: [labeled]
  5. jobs:
  6. # Frontend lint fixes
  7. lint-fix-frontend:
  8. if: github.event.label.name == 'lint-fix'
  9. name: Fix frontend linting issues
  10. runs-on: ubuntu-latest
  11. permissions:
  12. contents: write
  13. pull-requests: write
  14. steps:
  15. - uses: actions/checkout@v4
  16. with:
  17. ref: ${{ github.head_ref }}
  18. repository: ${{ github.event.pull_request.head.repo.full_name }}
  19. fetch-depth: 0
  20. token: ${{ secrets.GITHUB_TOKEN }}
  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. # Commit and push changes if any
  34. - name: Check for changes
  35. id: git-check
  36. run: |
  37. git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT
  38. - name: Commit and push if there are changes
  39. if: steps.git-check.outputs.changes == 'true'
  40. run: |
  41. git config --local user.email "openhands@all-hands.dev"
  42. git config --local user.name "OpenHands Bot"
  43. git add -A
  44. git commit -m "🤖 Auto-fix frontend linting issues"
  45. git push
  46. # Python lint fixes
  47. lint-fix-python:
  48. if: github.event.label.name == 'lint-fix'
  49. name: Fix Python linting issues
  50. runs-on: ubuntu-latest
  51. permissions:
  52. contents: write
  53. pull-requests: write
  54. steps:
  55. - uses: actions/checkout@v4
  56. with:
  57. ref: ${{ github.head_ref }}
  58. repository: ${{ github.event.pull_request.head.repo.full_name }}
  59. fetch-depth: 0
  60. token: ${{ secrets.GITHUB_TOKEN }}
  61. - name: Set up python
  62. uses: actions/setup-python@v5
  63. with:
  64. python-version: 3.12
  65. cache: 'pip'
  66. - name: Install pre-commit
  67. run: pip install pre-commit==3.7.0
  68. - name: Fix python lint issues
  69. run: |
  70. # Run all pre-commit hooks and continue even if they modify files (exit code 1)
  71. pre-commit run --config ./dev_config/python/.pre-commit-config.yaml --files openhands/**/* evaluation/**/* tests/**/* || true
  72. # Commit and push changes if any
  73. - name: Check for changes
  74. id: git-check
  75. run: |
  76. git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT
  77. - name: Commit and push if there are changes
  78. if: steps.git-check.outputs.changes == 'true'
  79. run: |
  80. git config --local user.email "openhands@all-hands.dev"
  81. git config --local user.name "OpenHands Bot"
  82. git add -A
  83. git commit -m "🤖 Auto-fix Python linting issues"
  84. git push