Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
ci: run the dify-agent test suite (#41327)
alanhuangyoo97b5d8092cfb
diff --git a/.github/workflows/dify-agent-tests.yml b/.github/workflows/dify-agent-tests.ymlnew file mode 100644index 00000000000..84d36b780dd--- /dev/null+++ b/.github/workflows/dify-agent-tests.yml@@ -0,0 +1,47 @@+name: Dify Agent Tests++on:+ workflow_call:++permissions:+ contents: read++concurrency:+ group: dify-agent-tests-${{ github.head_ref || github.run_id }}+ cancel-in-progress: true++jobs:+ dify-agent-unit:+ name: Dify Agent Unit Tests+ runs-on: depot-ubuntu-24.04+ defaults:+ run:+ shell: bash+ working-directory: dify-agent+ strategy:+ matrix:+ python-version:+ - '3.12'++ steps:+ - name: Checkout code+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ fetch-depth: 0+ persist-credentials: false++ - name: Setup UV and Python+ uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1+ with:+ enable-cache: true+ python-version: ${{ matrix.python-version }}+ cache-dependency-glob: dify-agent/uv.lock++ - name: Check UV lockfile+ run: uv lock --check++ - name: Install dependencies+ run: uv sync --extra server --dev++ - name: Run unit tests+ run: uv run pytestdiff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.ymlindex 36dd7e05fad..7ad86aa41b8 100644--- a/.github/workflows/main-ci.yml+++ b/.github/workflows/main-ci.yml@@ -48,6 +48,7 @@ jobs:vdb-changed: ${{ steps.changes.outputs.vdb }}migration-changed: ${{ steps.changes.outputs.migration }}sandbox-runtime-changed: ${{ steps.changes.outputs.sandbox-runtime }}+ dify-agent-changed: ${{ steps.changes.outputs.dify-agent }}steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3@@ -138,6 +139,9 @@ jobs:sandbox-runtime:- 'dify-agent-runtime/**'- '.github/workflows/sandbox-runtime-tests.yml'+ dify-agent:+ - 'dify-agent/**'+ - '.github/workflows/dify-agent-tests.yml'migration:- 'api/migrations/**'- 'api/.env.example'@@ -578,3 +582,63 @@ jobs:echo "Sandbox runtime tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2exit 1++ dify-agent-tests-run:+ name: Run Dify Agent Tests+ needs:+ - pre_job+ - check-changes+ if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.dify-agent-changed == 'true'+ uses: ./.github/workflows/dify-agent-tests.yml+ secrets: inherit++ dify-agent-tests-skip:+ name: Skip Dify Agent Tests+ needs:+ - pre_job+ - check-changes+ if: needs.pre_job.outputs.should_skip != 'true' && needs.check-changes.outputs.dify-agent-changed != 'true'+ runs-on: depot-ubuntu-24.04+ steps:+ - name: Report skipped dify agent tests+ run: echo "No dify-agent-related changes detected; skipping dify agent tests."++ dify-agent-tests:+ name: Dify Agent Tests+ if: ${{ always() }}+ needs:+ - pre_job+ - check-changes+ - dify-agent-tests-run+ - dify-agent-tests-skip+ runs-on: depot-ubuntu-24.04+ steps:+ - name: Finalize Dify Agent Tests status+ env:+ SHOULD_SKIP_WORKFLOW: ${{ needs.pre_job.outputs.should_skip }}+ TESTS_CHANGED: ${{ needs.check-changes.outputs.dify-agent-changed }}+ RUN_RESULT: ${{ needs.dify-agent-tests-run.result }}+ SKIP_RESULT: ${{ needs.dify-agent-tests-skip.result }}+ run: |+ if [[ "$SHOULD_SKIP_WORKFLOW" == 'true' ]]; then+ echo "Dify agent tests were skipped because this workflow run duplicated a successful or newer run."+ exit 0+ fi++ if [[ "$TESTS_CHANGED" == 'true' ]]; then+ if [[ "$RUN_RESULT" == 'success' ]]; then+ echo "Dify agent tests ran successfully."+ exit 0+ fi++ echo "Dify agent tests were required but finished with result: $RUN_RESULT" >&2+ exit 1+ fi++ if [[ "$SKIP_RESULT" == 'success' ]]; then+ echo "Dify agent tests were skipped because no dify-agent-related files changed."+ exit 0+ fi++ echo "Dify agent tests were not required, but the skip job finished with result: $SKIP_RESULT" >&2+ exit 1diff --git a/dify-agent/pyproject.toml b/dify-agent/pyproject.tomlindex fa428113c4f..07d0dec20ad 100644--- a/dify-agent/pyproject.toml+++ b/dify-agent/pyproject.toml@@ -46,6 +46,10 @@ pythonVersion = "3.12"extraPaths = ["src", "examples/agenton", "examples/dify_agent"][tool.pytest.ini_options]+# Several test modules share a basename across directories (test_layer.py,+# test_client.py, ...). The default prepend import mode derives module names+# from the basename, so collecting them together is an import file mismatch.+addopts = ["--import-mode=importlib"]testpaths = ["tests"]python_files = ["test_*.py", "*_test.py"]markers = ["integration: requires a real external service or exercises multiple concrete adapters"]