name: Run Pytest on: workflow_call: secrets: CODECOV_TOKEN: required: false permissions: contents: read concurrency: group: api-tests-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: test: name: API Tests runs-on: ubuntu-latest env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} defaults: run: shell: bash strategy: matrix: python-version: - "3.11" - "3.12" steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 persist-credentials: false - name: Setup UV and Python uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0 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@4894d2492015c1774ee5a13a95b1072093087ec3 # v2.5.0 with: compose-file: | docker/docker-compose.middleware.yaml services: | db_postgres 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 \ -n auto \ --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: Report coverage if: ${{ env.CODECOV_TOKEN != '' && matrix.python-version == '3.12' }} uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3 with: files: ./coverage.xml disable_search: true flags: api env: CODECOV_TOKEN: ${{ env.CODECOV_TOKEN }}