: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(ci): emit jest test signals from frontend CI (#73530)
Raúl Negrón-Oteroc83e3fbfa8d5
diff --git a/.github/workflows/ci-frontend.yml b/.github/workflows/ci-frontend.ymlindex 0164a20c7e5b..0285f096007d 100644--- a/.github/workflows/ci-frontend.yml+++ b/.github/workflows/ci-frontend.yml@@ -716,8 +716,12 @@ jobs:if: always()uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0with:- name: junit-results-frontend-${{ matrix.segment }}-${{ matrix.chunk }}- path: junit-results/junit-*.xml+ # Keep attempt 1's artifact available so the reporter can identify same-job+ # failures that pass when GitHub re-runs failed jobs on the same commit.+ name: junit-results-frontend-${{ matrix.segment }}-${{ matrix.chunk }}${{ github.run_attempt != '1' && format('-attempt{0}', github.run_attempt) || '' }}+ path: |+ junit-results/junit-*.xml+ junit-results/posthog-jest-quarantine-*.jsonlif-no-files-found: ignoreretention-days: 1@@ -809,6 +813,69 @@ jobs:shell: bashrun: exit 1+ report-test-signals:+ name: Report Jest test signals+ needs: [jest]+ runs-on: ubuntu-latest+ continue-on-error: true+ timeout-minutes: 10+ permissions:+ actions: read+ contents: read+ # Runs on every attempt so a same-job failure followed by a pass proves a flake. The+ # parser comes from the trusted base ref because this job receives project tokens.+ if: >-+ !cancelled() &&+ needs.jest.result != 'skipped' &&+ github.repository == 'PostHog/posthog' &&+ (+ (github.event_name != 'pull_request' && github.ref == 'refs/heads/master') ||+ (github.event_name == 'pull_request' &&+ github.event.pull_request.head.repo.full_name == 'PostHog/posthog')+ )+ steps:+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.sha }}+ fetch-depth: 1+ - name: Check for trusted test reporter+ id: test-reporter+ shell: bash+ run: |+ available=false+ if [[ -f .github/scripts/report_test_timings.py && -d tools/owners ]] && grep -q -- '"jest"' .github/scripts/report_test_timings.py; then+ available=true+ fi+ if [[ "$GITHUB_RUN_ATTEMPT" != "1" ]] && ! grep -q "def partition_run_attempt" .github/scripts/report_test_timings.py 2>/dev/null; then+ available=false+ fi+ if [[ "$available" != "true" ]]; then+ echo "Trusted Jest reporter is not available on the checked-out ref for attempt $GITHUB_RUN_ATTEMPT; skipping emit."+ fi+ echo "available=$available" >> "$GITHUB_OUTPUT"+ - uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0+ if: steps.test-reporter.outputs.available == 'true'+ with:+ version: '0.11.28'+ - name: Download Jest results+ if: steps.test-reporter.outputs.available == 'true'+ uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0+ with:+ path: ./junit-artifacts+ pattern: junit-results-frontend-*+ - name: Emit per-test signals+ if: steps.test-reporter.outputs.available == 'true'+ continue-on-error: true+ env:+ POSTHOG_DEVEX_PROJECT_API_TOKEN: ${{ secrets.POSTHOG_DEVEX_PROJECT_API_TOKEN }}+ POSTHOG_CI_TRACES_EXTRA_TOKEN: ${{ secrets.POSTHOG_API_TOKEN }}+ POSTHOG_OTLP_TRACES_ENDPOINT: ${{ vars.POSTHOG_OTLP_TRACES_ENDPOINT || 'https://us.i.posthog.com/i/v1/traces' }}+ run: |+ uv run --script .github/scripts/report_test_timings.py \+ --runner=jest \+ --signals-only \+ ./junit-artifacts+calculate-running-time:name: Calculate running timeneeds: