mirror of
https://github.com/langgenius/dify.git
synced 2026-04-10 11:37:11 +08:00
254 lines
7.6 KiB
YAML
254 lines
7.6 KiB
YAML
name: Main CI Pipeline
|
|
|
|
on:
|
|
pull_request:
|
|
branches: ["main"]
|
|
merge_group:
|
|
branches: ["main"]
|
|
types: [checks_requested]
|
|
push:
|
|
branches: ["main"]
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
checks: write
|
|
statuses: write
|
|
|
|
concurrency:
|
|
group: main-ci-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
# Check which paths were changed to determine which tests to run
|
|
check-changes:
|
|
name: Check Changed Files
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
api-changed: ${{ steps.changes.outputs.api }}
|
|
web-changed: ${{ steps.changes.outputs.web }}
|
|
vdb-changed: ${{ steps.changes.outputs.vdb }}
|
|
migration-changed: ${{ steps.changes.outputs.migration }}
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
|
|
id: changes
|
|
with:
|
|
filters: |
|
|
api:
|
|
- 'api/**'
|
|
- 'docker/**'
|
|
- '.github/workflows/api-tests.yml'
|
|
web:
|
|
- 'web/**'
|
|
- '.github/workflows/web-tests.yml'
|
|
- '.github/actions/setup-web/**'
|
|
vdb:
|
|
- 'api/core/rag/datasource/**'
|
|
- 'docker/**'
|
|
- '.github/workflows/vdb-tests.yml'
|
|
- 'api/uv.lock'
|
|
- 'api/pyproject.toml'
|
|
migration:
|
|
- 'api/migrations/**'
|
|
- '.github/workflows/db-migration-test.yml'
|
|
|
|
# Run tests in parallel while always emitting stable required checks.
|
|
api-tests-run:
|
|
name: Run API Tests
|
|
needs: check-changes
|
|
if: needs.check-changes.outputs.api-changed == 'true'
|
|
uses: ./.github/workflows/api-tests.yml
|
|
secrets: inherit
|
|
|
|
api-tests-skip:
|
|
name: Skip API Tests
|
|
needs: check-changes
|
|
if: needs.check-changes.outputs.api-changed != 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Report skipped API tests
|
|
run: echo "No API-related changes detected; skipping API tests."
|
|
|
|
api-tests:
|
|
name: API Tests
|
|
if: ${{ always() }}
|
|
needs:
|
|
- check-changes
|
|
- api-tests-run
|
|
- api-tests-skip
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Finalize API Tests status
|
|
env:
|
|
TESTS_CHANGED: ${{ needs.check-changes.outputs.api-changed }}
|
|
RUN_RESULT: ${{ needs.api-tests-run.result }}
|
|
SKIP_RESULT: ${{ needs.api-tests-skip.result }}
|
|
run: |
|
|
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
|
if [[ "$RUN_RESULT" == 'success' ]]; then
|
|
echo "API tests ran successfully."
|
|
exit 0
|
|
fi
|
|
|
|
echo "API tests were required but finished with result: $RUN_RESULT" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$SKIP_RESULT" == 'success' ]]; then
|
|
echo "API tests were skipped because no API-related files changed."
|
|
exit 0
|
|
fi
|
|
|
|
echo "API tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2
|
|
exit 1
|
|
|
|
web-tests-run:
|
|
name: Run Web Tests
|
|
needs: check-changes
|
|
if: needs.check-changes.outputs.web-changed == 'true'
|
|
uses: ./.github/workflows/web-tests.yml
|
|
secrets: inherit
|
|
|
|
web-tests-skip:
|
|
name: Skip Web Tests
|
|
needs: check-changes
|
|
if: needs.check-changes.outputs.web-changed != 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Report skipped web tests
|
|
run: echo "No web-related changes detected; skipping web tests."
|
|
|
|
web-tests:
|
|
name: Web Tests
|
|
if: ${{ always() }}
|
|
needs:
|
|
- check-changes
|
|
- web-tests-run
|
|
- web-tests-skip
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Finalize Web Tests status
|
|
env:
|
|
TESTS_CHANGED: ${{ needs.check-changes.outputs.web-changed }}
|
|
RUN_RESULT: ${{ needs.web-tests-run.result }}
|
|
SKIP_RESULT: ${{ needs.web-tests-skip.result }}
|
|
run: |
|
|
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
|
if [[ "$RUN_RESULT" == 'success' ]]; then
|
|
echo "Web tests ran successfully."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Web tests were required but finished with result: $RUN_RESULT" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$SKIP_RESULT" == 'success' ]]; then
|
|
echo "Web tests were skipped because no web-related files changed."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Web tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2
|
|
exit 1
|
|
|
|
style-check:
|
|
name: Style Check
|
|
uses: ./.github/workflows/style.yml
|
|
|
|
vdb-tests-run:
|
|
name: Run VDB Tests
|
|
needs: check-changes
|
|
if: needs.check-changes.outputs.vdb-changed == 'true'
|
|
uses: ./.github/workflows/vdb-tests.yml
|
|
|
|
vdb-tests-skip:
|
|
name: Skip VDB Tests
|
|
needs: check-changes
|
|
if: needs.check-changes.outputs.vdb-changed != 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Report skipped VDB tests
|
|
run: echo "No VDB-related changes detected; skipping VDB tests."
|
|
|
|
vdb-tests:
|
|
name: VDB Tests
|
|
if: ${{ always() }}
|
|
needs:
|
|
- check-changes
|
|
- vdb-tests-run
|
|
- vdb-tests-skip
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Finalize VDB Tests status
|
|
env:
|
|
TESTS_CHANGED: ${{ needs.check-changes.outputs.vdb-changed }}
|
|
RUN_RESULT: ${{ needs.vdb-tests-run.result }}
|
|
SKIP_RESULT: ${{ needs.vdb-tests-skip.result }}
|
|
run: |
|
|
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
|
if [[ "$RUN_RESULT" == 'success' ]]; then
|
|
echo "VDB tests ran successfully."
|
|
exit 0
|
|
fi
|
|
|
|
echo "VDB tests were required but finished with result: $RUN_RESULT" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$SKIP_RESULT" == 'success' ]]; then
|
|
echo "VDB tests were skipped because no VDB-related files changed."
|
|
exit 0
|
|
fi
|
|
|
|
echo "VDB tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2
|
|
exit 1
|
|
|
|
db-migration-test-run:
|
|
name: Run DB Migration Test
|
|
needs: check-changes
|
|
if: needs.check-changes.outputs.migration-changed == 'true'
|
|
uses: ./.github/workflows/db-migration-test.yml
|
|
|
|
db-migration-test-skip:
|
|
name: Skip DB Migration Test
|
|
needs: check-changes
|
|
if: needs.check-changes.outputs.migration-changed != 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Report skipped DB migration tests
|
|
run: echo "No migration-related changes detected; skipping DB migration tests."
|
|
|
|
db-migration-test:
|
|
name: DB Migration Test
|
|
if: ${{ always() }}
|
|
needs:
|
|
- check-changes
|
|
- db-migration-test-run
|
|
- db-migration-test-skip
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Finalize DB Migration Test status
|
|
env:
|
|
TESTS_CHANGED: ${{ needs.check-changes.outputs.migration-changed }}
|
|
RUN_RESULT: ${{ needs.db-migration-test-run.result }}
|
|
SKIP_RESULT: ${{ needs.db-migration-test-skip.result }}
|
|
run: |
|
|
if [[ "$TESTS_CHANGED" == 'true' ]]; then
|
|
if [[ "$RUN_RESULT" == 'success' ]]; then
|
|
echo "DB migration tests ran successfully."
|
|
exit 0
|
|
fi
|
|
|
|
echo "DB migration tests were required but finished with result: $RUN_RESULT" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$SKIP_RESULT" == 'success' ]]; then
|
|
echo "DB migration tests were skipped because no migration-related files changed."
|
|
exit 0
|
|
fi
|
|
|
|
echo "DB migration tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2
|
|
exit 1
|