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: shard API unit tests across runners (#42374)
Stephen Zhoue58e5b087986
diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.ymlindex f579862eb8b..1e0d0b8f541 100644--- a/.github/workflows/api-tests.yml+++ b/.github/workflows/api-tests.yml@@ -15,23 +15,30 @@ concurrency:jobs:api-unit:- name: API Unit Tests+ name: API Unit Tests (${{ matrix.python-version }}, shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})runs-on: depot-ubuntu-24.04env:- COVERAGE_FILE: coverage-unit+ COVERAGE_FILE: coverage-unit-${{ matrix.python-version }}-${{ matrix.shardIndex }}defaults:run:shell: bashstrategy:+ fail-fast: falsematrix:python-version:- '3.12'+ shardIndex:+ - 1+ - 2+ - 3+ - 4+ shardTotal:+ - 4steps:- name: Checkout codeuses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:- fetch-depth: 0persist-credentials: false- name: Setup UV and Python@@ -53,6 +60,10 @@ jobs:-p no:benchmark \--timeout "${PYTEST_TIMEOUT:-20}" \-n auto \+ --shard-index "${{ matrix.shardIndex }}" \+ --shard-total "${{ matrix.shardTotal }}" \+ -o 'addopts=--cov=./api --cov-branch --import-mode=importlib' \+ --cov-report= \api/tests/unit_tests \api/providers/vdb/*/tests/unit_tests \api/providers/trace/*/tests/unit_tests \@@ -60,14 +71,19 @@ jobs:# Controller tests register Flask routes at import time, so keep them out of xdist.uv run --project api pytest \--timeout "${PYTEST_TIMEOUT:-20}" \+ --shard-index "${{ matrix.shardIndex }}" \+ --shard-total "${{ matrix.shardTotal }}" \+ -o 'addopts=--cov=./api --cov-branch --import-mode=importlib' \+ --cov-report= \--cov-append \api/tests/unit_tests/controllers- name: Upload unit coverage datauses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1with:- name: api-coverage-unit- path: coverage-unit+ name: api-coverage-unit-${{ matrix.python-version }}-${{ matrix.shardIndex }}+ path: ${{ env.COVERAGE_FILE }}+ if-no-files-found: errorretention-days: 1api-integration:@@ -98,7 +114,6 @@ jobs:- name: Checkout codeuses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:- fetch-depth: 0persist-credentials: false- name: Setup UV and Python@@ -122,6 +137,8 @@ jobs:-n auto \--shard-index "${{ matrix.shardIndex }}" \--shard-total "${{ matrix.shardTotal }}" \+ -o 'addopts=--cov=./api --cov-branch --import-mode=importlib' \+ --cov-report= \--timeout "${PYTEST_TIMEOUT:-180}" \api/tests/integration_tests/workflow \api/tests/integration_tests/tools \@@ -181,16 +198,19 @@ jobs:echo "Merged backend coverage report generated for Codecov project status." >> "$GITHUB_STEP_SUMMARY"echo "" >> "$GITHUB_STEP_SUMMARY"- unit_coverage="$(find coverage-data -type f -name coverage-unit -print -quit)"+ mapfile -t unit_coverage < <(find coverage-data -type f -name 'coverage-unit-*' -print | sort)mapfile -t integration_coverage < <(find coverage-data -type f -name 'coverage-integration-*' -print | sort)- : "${unit_coverage:?coverage-unit artifact not found}"+ if [[ "${#unit_coverage[@]}" -ne 4 ]]; then+ echo "expected 4 unit coverage artifacts, found ${#unit_coverage[@]}" >&2+ exit 1+ fiif [[ "${#integration_coverage[@]}" -ne 4 ]]; thenecho "expected 4 integration coverage artifacts, found ${#integration_coverage[@]}" >&2exit 1fireport_file="$(mktemp)"- uv run --project api coverage combine "$unit_coverage" "${integration_coverage[@]}"+ uv run --project api coverage combine "${unit_coverage[@]}" "${integration_coverage[@]}"uv run --project api coverage report --show-missing | tee "$report_file"echo "Summary: \`$(tail -n 1 "$report_file")\`" >> "$GITHUB_STEP_SUMMARY"{