mirror of
https://github.com/YFGaia/dify-plus.git
synced 2026-06-14 20:41:21 +08:00
b2f5707676
# Conflicts: # .github/workflows/tool-test-sdks.yaml # api/.env.example # api/README.md # api/commands.py # api/controllers/console/explore/wraps.py # api/controllers/web/workflow.py # api/extensions/ext_commands.py # api/models/model.py # api/pyproject.toml # api/services/feature_service.py # web/README.md # web/app/components/explore/app-card/index.tsx # web/app/components/explore/app-list/index.tsx # web/app/components/explore/sidebar/index.tsx # web/app/signin/components/mail-and-password-auth.tsx # web/i18n/uk-UA/app-overview.json # web/i18n/uk-UA/app.json # web/i18n/uk-UA/billing.json # web/i18n/uk-UA/common.json # web/i18n/uk-UA/dataset-creation.json # web/i18n/uk-UA/dataset-documents.json # web/i18n/uk-UA/dataset-hit-testing.json # web/i18n/uk-UA/dataset-settings.json # web/i18n/uk-UA/dataset.json # web/i18n/uk-UA/explore.json # web/i18n/uk-UA/plugin.json # web/i18n/uk-UA/tools.json # web/next.config.js # web/package.json # web/pnpm-lock.yaml # web/service/common.ts # web/service/explore.ts # web/service/fetch.ts # web/service/use-explore.ts # web/types/feature.ts
99 lines
2.7 KiB
YAML
99 lines
2.7 KiB
YAML
name: Run Pytest
|
|
|
|
on:
|
|
workflow_call:
|
|
|
|
concurrency:
|
|
group: api-tests-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test:
|
|
name: API Tests
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
strategy:
|
|
matrix:
|
|
python-version:
|
|
- "3.11"
|
|
- "3.12"
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup UV and Python
|
|
uses: astral-sh/setup-uv@v7
|
|
with:
|
|
enable-cache: true
|
|
python-version: ${{ matrix.python-version }}
|
|
cache-dependency-glob: api/uv.lock
|
|
|
|
- name: Check UV lockfile
|
|
run: uv lock --project api --check
|
|
|
|
- name: Install dependencies
|
|
run: uv sync --project api --dev
|
|
|
|
- name: Run dify config tests
|
|
run: uv run --project api dev/pytest/pytest_config_tests.py
|
|
|
|
- name: Set up dotenvs
|
|
run: |
|
|
cp docker/.env.example docker/.env
|
|
cp docker/middleware.env.example docker/middleware.env
|
|
|
|
- name: Expose Service Ports
|
|
run: sh .github/workflows/expose_service_ports.sh
|
|
|
|
- name: Set up Sandbox
|
|
uses: hoverkraft-tech/compose-action@v2
|
|
with:
|
|
compose-file: |
|
|
docker/docker-compose.middleware.yaml
|
|
services: |
|
|
db
|
|
redis
|
|
sandbox
|
|
ssrf_proxy
|
|
|
|
- name: setup test config
|
|
run: |
|
|
cp api/tests/integration_tests/.env.example api/tests/integration_tests/.env
|
|
|
|
- name: Run API Tests
|
|
env:
|
|
STORAGE_TYPE: opendal
|
|
OPENDAL_SCHEME: fs
|
|
OPENDAL_FS_ROOT: /tmp/dify-storage
|
|
run: |
|
|
uv run --project api pytest \
|
|
--timeout "${PYTEST_TIMEOUT:-180}" \
|
|
api/tests/integration_tests/workflow \
|
|
api/tests/integration_tests/tools \
|
|
api/tests/test_containers_integration_tests \
|
|
api/tests/unit_tests
|
|
|
|
- name: Coverage Summary
|
|
run: |
|
|
set -x
|
|
# Extract coverage percentage and create a summary
|
|
TOTAL_COVERAGE=$(python -c 'import json; print(json.load(open("coverage.json"))["totals"]["percent_covered_display"])')
|
|
|
|
# Create a detailed coverage summary
|
|
echo "### Test Coverage Summary :test_tube:" >> $GITHUB_STEP_SUMMARY
|
|
echo "Total Coverage: ${TOTAL_COVERAGE}%" >> $GITHUB_STEP_SUMMARY
|
|
{
|
|
echo ""
|
|
echo "<details><summary>File-level coverage (click to expand)</summary>"
|
|
echo ""
|
|
echo '```'
|
|
uv run --project api coverage report -m
|
|
echo '```'
|
|
echo "</details>"
|
|
} >> $GITHUB_STEP_SUMMARY
|