Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

main-ci.yml 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. name: Main CI Pipeline
  2. on:
  3. pull_request:
  4. branches: [ "main" ]
  5. permissions:
  6. contents: write
  7. pull-requests: write
  8. checks: write
  9. concurrency:
  10. group: main-ci-${{ github.head_ref || github.run_id }}
  11. cancel-in-progress: true
  12. jobs:
  13. # First, run autofix if needed
  14. autofix:
  15. name: Auto-fix code issues
  16. if: github.repository == 'langgenius/dify'
  17. runs-on: ubuntu-latest
  18. outputs:
  19. changes-made: ${{ steps.check-changes.outputs.changes }}
  20. steps:
  21. - uses: actions/checkout@v4
  22. with:
  23. token: ${{ secrets.GITHUB_TOKEN }}
  24. ref: ${{ github.event.pull_request.head.ref }}
  25. - uses: astral-sh/setup-uv@v6
  26. with:
  27. python-version: "3.12"
  28. - name: Run Python fixes
  29. run: |
  30. cd api
  31. uv sync --dev
  32. # Fix lint errors
  33. uv run ruff check --fix-only .
  34. # Format code
  35. uv run ruff format .
  36. - name: Run ast-grep
  37. run: |
  38. uvx --from ast-grep-cli sg --pattern 'db.session.query($WHATEVER).filter($HERE)' --rewrite 'db.session.query($WHATEVER).where($HERE)' -l py --update-all
  39. - name: Run mdformat
  40. run: |
  41. uvx mdformat .
  42. - name: Check for changes
  43. id: check-changes
  44. run: |
  45. if [ -n "$(git diff --name-only)" ]; then
  46. echo "changes=true" >> $GITHUB_OUTPUT
  47. else
  48. echo "changes=false" >> $GITHUB_OUTPUT
  49. fi
  50. - name: Commit and push changes
  51. if: steps.check-changes.outputs.changes == 'true'
  52. run: |
  53. git config --local user.email "action@github.com"
  54. git config --local user.name "GitHub Action"
  55. git add -A
  56. git commit -m "Auto-fix: Apply code formatting and linting fixes"
  57. git push
  58. # Check which paths were changed to determine which tests to run
  59. check-changes:
  60. name: Check Changed Files
  61. runs-on: ubuntu-latest
  62. outputs:
  63. api-changed: ${{ steps.changes.outputs.api }}
  64. web-changed: ${{ steps.changes.outputs.web }}
  65. vdb-changed: ${{ steps.changes.outputs.vdb }}
  66. migration-changed: ${{ steps.changes.outputs.migration }}
  67. steps:
  68. - uses: actions/checkout@v4
  69. - uses: dorny/paths-filter@v3
  70. id: changes
  71. with:
  72. filters: |
  73. api:
  74. - 'api/**'
  75. - 'docker/**'
  76. - '.github/workflows/api-tests.yml'
  77. web:
  78. - 'web/**'
  79. vdb:
  80. - 'api/core/rag/datasource/**'
  81. - 'docker/**'
  82. - '.github/workflows/vdb-tests.yml'
  83. - 'api/uv.lock'
  84. - 'api/pyproject.toml'
  85. migration:
  86. - 'api/migrations/**'
  87. - '.github/workflows/db-migration-test.yml'
  88. # After autofix completes (or if no changes needed), run tests in parallel
  89. api-tests:
  90. name: API Tests
  91. needs: [autofix, check-changes]
  92. if: always() && !cancelled() && needs.check-changes.outputs.api-changed == 'true'
  93. uses: ./.github/workflows/api-tests.yml
  94. web-tests:
  95. name: Web Tests
  96. needs: [autofix, check-changes]
  97. if: always() && !cancelled() && needs.check-changes.outputs.web-changed == 'true'
  98. uses: ./.github/workflows/web-tests.yml
  99. style-check:
  100. name: Style Check
  101. needs: autofix
  102. if: always() && !cancelled()
  103. uses: ./.github/workflows/style.yml
  104. vdb-tests:
  105. name: VDB Tests
  106. needs: [autofix, check-changes]
  107. if: always() && !cancelled() && needs.check-changes.outputs.vdb-changed == 'true'
  108. uses: ./.github/workflows/vdb-tests.yml
  109. db-migration-test:
  110. name: DB Migration Test
  111. needs: [autofix, check-changes]
  112. if: always() && !cancelled() && needs.check-changes.outputs.migration-changed == 'true'
  113. uses: ./.github/workflows/db-migration-test.yml