Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(ci): handle pytest exit code 5 in product tests (#69871)

mendral-app[bot]ff4554e6c494
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
index eba4e98451b2..3b351ff70329 100644
--- a/.depot/workflows/ci-backend.yml
+++ b/.depot/workflows/ci-backend.yml
@@ -795,7 +795,17 @@ jobs:
--reuse-db
--durations-path ../../.test_durations
${{ needs.detect-snapshot-mode.outputs.mode == 'update' && '--snapshot-update --snapshot-warn-unused' || '' }}
- run: pnpm turbo run backend:test ${{ matrix.filters }} --concurrency=1 --output-logs=full --force --log-order=stream ${{ matrix.pytest_args }}
+ run: |
+ set +e
+ pnpm turbo run backend:test ${{ matrix.filters }} --concurrency=1 --output-logs=full --force --log-order=stream ${{ matrix.pytest_args }}
+ exit_code=$?
+ set -e
+ if [ $exit_code -eq 5 ]; then
+ echo "No tests collected for this shard, this is expected when splitting tests"
+ exit 0
+ else
+ exit $exit_code
+ fi
# Lightweight repo-wide checks that only need Python + uv (no Docker/DB).
# Consolidates checks that previously each spun up their own runner.
repo-checks:
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index 3a3f37ecf4ea..098e38584ef5 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -789,7 +789,17 @@ jobs:
--junitxml=junit-product.xml
${{ needs.detect-snapshot-mode.outputs.mode == 'update' && '--snapshot-update --snapshot-warn-unused' || '' }}
${{ github.ref == 'refs/heads/master' && '--store-durations' || '' }}
- run: pnpm turbo run backend:test ${{ matrix.filters }} --concurrency=1 --output-logs=full --force --log-order=stream ${{ matrix.pytest_args }}
+ run: |
+ set +e
+ pnpm turbo run backend:test ${{ matrix.filters }} --concurrency=1 --output-logs=full --force --log-order=stream ${{ matrix.pytest_args }}
+ exit_code=$?
+ set -e
+ if [ $exit_code -eq 5 ]; then
+ echo "No tests collected for this shard, this is expected when splitting tests"
+ exit 0
+ else
+ exit $exit_code
+ fi
# Upload results to Trunk for flaky-test detection. Non-gating (continue-on-error),
# so a Trunk outage never fails the job. Runs the token only on internal PRs,