refactor: reorganize the CI pipeline (#24817)
Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
parent
9ff6baaf52
commit
d9420c7224
2 changed files with 20 additions and 73 deletions
3
.github/workflows/autofix.yml
vendored
3
.github/workflows/autofix.yml
vendored
|
|
@ -1,6 +1,7 @@
|
||||||
name: autofix.ci
|
name: autofix.ci
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
pull_request:
|
||||||
|
branches: ["main"]
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
|
|
|
||||||
72
.github/workflows/main-ci.yml
vendored
72
.github/workflows/main-ci.yml
vendored
|
|
@ -17,58 +17,6 @@ concurrency:
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# First, run autofix if needed
|
|
||||||
autofix:
|
|
||||||
name: Auto-fix code issues
|
|
||||||
if: github.repository == 'langgenius/dify'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
changes-made: ${{ steps.check-changes.outputs.changes }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
ref: ${{ github.event.pull_request.head.ref }}
|
|
||||||
|
|
||||||
- uses: astral-sh/setup-uv@v6
|
|
||||||
with:
|
|
||||||
python-version: "3.12"
|
|
||||||
|
|
||||||
- name: Run Python fixes
|
|
||||||
run: |
|
|
||||||
cd api
|
|
||||||
uv sync --dev
|
|
||||||
# Fix lint errors
|
|
||||||
uv run ruff check --fix-only .
|
|
||||||
# Format code
|
|
||||||
uv run ruff format .
|
|
||||||
|
|
||||||
- name: Run ast-grep
|
|
||||||
run: |
|
|
||||||
uvx --from ast-grep-cli sg --pattern 'db.session.query($WHATEVER).filter($HERE)' --rewrite 'db.session.query($WHATEVER).where($HERE)' -l py --update-all
|
|
||||||
|
|
||||||
- name: Run mdformat
|
|
||||||
run: |
|
|
||||||
uvx mdformat .
|
|
||||||
|
|
||||||
- name: Check for changes
|
|
||||||
id: check-changes
|
|
||||||
run: |
|
|
||||||
if [ -n "$(git diff --name-only)" ]; then
|
|
||||||
echo "changes=true" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "changes=false" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Commit and push changes
|
|
||||||
if: steps.check-changes.outputs.changes == 'true'
|
|
||||||
run: |
|
|
||||||
git config --local user.email "action@github.com"
|
|
||||||
git config --local user.name "GitHub Action"
|
|
||||||
git add -A
|
|
||||||
git commit -m "Auto-fix: Apply code formatting and linting fixes"
|
|
||||||
git push
|
|
||||||
|
|
||||||
# Check which paths were changed to determine which tests to run
|
# Check which paths were changed to determine which tests to run
|
||||||
check-changes:
|
check-changes:
|
||||||
name: Check Changed Files
|
name: Check Changed Files
|
||||||
|
|
@ -100,33 +48,31 @@ jobs:
|
||||||
- 'api/migrations/**'
|
- 'api/migrations/**'
|
||||||
- '.github/workflows/db-migration-test.yml'
|
- '.github/workflows/db-migration-test.yml'
|
||||||
|
|
||||||
# After autofix completes (or if no changes needed), run tests in parallel
|
# Run tests in parallel
|
||||||
api-tests:
|
api-tests:
|
||||||
name: API Tests
|
name: API Tests
|
||||||
needs: [autofix, check-changes]
|
needs: check-changes
|
||||||
if: always() && !cancelled() && needs.check-changes.outputs.api-changed == 'true'
|
if: needs.check-changes.outputs.api-changed == 'true'
|
||||||
uses: ./.github/workflows/api-tests.yml
|
uses: ./.github/workflows/api-tests.yml
|
||||||
|
|
||||||
web-tests:
|
web-tests:
|
||||||
name: Web Tests
|
name: Web Tests
|
||||||
needs: [autofix, check-changes]
|
needs: check-changes
|
||||||
if: always() && !cancelled() && needs.check-changes.outputs.web-changed == 'true'
|
if: needs.check-changes.outputs.web-changed == 'true'
|
||||||
uses: ./.github/workflows/web-tests.yml
|
uses: ./.github/workflows/web-tests.yml
|
||||||
|
|
||||||
style-check:
|
style-check:
|
||||||
name: Style Check
|
name: Style Check
|
||||||
needs: autofix
|
|
||||||
if: always() && !cancelled()
|
|
||||||
uses: ./.github/workflows/style.yml
|
uses: ./.github/workflows/style.yml
|
||||||
|
|
||||||
vdb-tests:
|
vdb-tests:
|
||||||
name: VDB Tests
|
name: VDB Tests
|
||||||
needs: [autofix, check-changes]
|
needs: check-changes
|
||||||
if: always() && !cancelled() && needs.check-changes.outputs.vdb-changed == 'true'
|
if: needs.check-changes.outputs.vdb-changed == 'true'
|
||||||
uses: ./.github/workflows/vdb-tests.yml
|
uses: ./.github/workflows/vdb-tests.yml
|
||||||
|
|
||||||
db-migration-test:
|
db-migration-test:
|
||||||
name: DB Migration Test
|
name: DB Migration Test
|
||||||
needs: [autofix, check-changes]
|
needs: check-changes
|
||||||
if: always() && !cancelled() && needs.check-changes.outputs.migration-changed == 'true'
|
if: needs.check-changes.outputs.migration-changed == 'true'
|
||||||
uses: ./.github/workflows/db-migration-test.yml
|
uses: ./.github/workflows/db-migration-test.yml
|
||||||
Loading…
Add table
Add a link
Reference in a new issue