: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
fix(ci): diff storybook flake verification from the merge base (#116986)
James Gillc004086acb81
diff --git a/.github/scripts/verify-storybook-new-stories.sh b/.github/scripts/verify-storybook-new-stories.shindex b80cd82a7ada..a6988b96ac67 100755--- a/.github/scripts/verify-storybook-new-stories.sh+++ b/.github/scripts/verify-storybook-new-stories.sh@@ -7,8 +7,11 @@ set -euo pipefail# Usage:# verify-storybook-new-stories.sh <base_sha> [repeat_count]#+# Pass the merge base, not the base branch tip. A branch tip that moved on since the+# fork point makes its own story changes look like this branch's.+## Example:-# .github/scripts/verify-storybook-new-stories.sh origin/master 3+# .github/scripts/verify-storybook-new-stories.sh "$(git merge-base origin/master HEAD)" 3if [ $# -lt 1 ] || [ $# -gt 2 ]; thenecho "Usage: $0 <base_sha> [repeat_count]" >&2diff --git a/.github/workflows/ci-storybook.yml b/.github/workflows/ci-storybook.ymlindex 95f36e6ff456..de9394afd607 100644--- a/.github/workflows/ci-storybook.yml+++ b/.github/workflows/ci-storybook.yml@@ -919,7 +919,7 @@ jobs:name: Storybook flake verificationruns-on: ubuntu-24.04needs: [changes, build-storybook]- # Skipped on trunk-merge/**: the job diffs against base.sha to find changed stories,+ # Skipped on trunk-merge/**: the job diffs against the merge base to find changed stories,# which on a queue branch is the same set the PR's own run already re-ran three times.if: |needs.changes.outputs.frontend == 'true'@@ -990,11 +990,28 @@ jobs:id: flake-verifyenv:HOME: /root+ GH_TOKEN: ${{ github.token }}+ REPO: ${{ github.repository }}+ BASE_SHA: ${{ github.event.pull_request.base.sha }}+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}+ # The merge base comes from the API because the depth-1 checkout cannot compute it.+ # It is resolved here, not in the script, because unrebased branches keep their old script.run: |git config --global --add safe.directory '*'- BASE_SHA="${{ github.event.pull_request.base.sha }}"- git fetch --no-tags --prune --depth=50 origin "$BASE_SHA"- .github/scripts/verify-storybook-new-stories.sh "$BASE_SHA" 3+ skip() {+ echo "::warning::$1, so flake verification is skipped."+ exit 0+ }+ curl -fsS --retry 3 --connect-timeout 10 -o "$RUNNER_TEMP/compare.json" \+ -H "Authorization: Bearer $GH_TOKEN" -H 'Accept: application/vnd.github+json' \+ "https://api.github.com/repos/$REPO/compare/$BASE_SHA...$HEAD_SHA?per_page=1" \+ || skip "The GitHub API did not return the merge base of $BASE_SHA and $HEAD_SHA"+ MERGE_BASE=$(node -e 'process.stdout.write(require(process.argv[1]).merge_base_commit?.sha ?? "")' "$RUNNER_TEMP/compare.json") || MERGE_BASE=""+ [ -n "$MERGE_BASE" ] || skip "The compare response has no merge base for $BASE_SHA and $HEAD_SHA"+ git fetch --no-tags --depth=1 "https://github.com/$REPO" "$MERGE_BASE" \+ || skip "Could not fetch merge base $MERGE_BASE"+ echo "Diffing from merge base $MERGE_BASE (PR base is $BASE_SHA)"+ .github/scripts/verify-storybook-new-stories.sh "$MERGE_BASE" 3- name: Upload flake verification screenshotsif: failure() && steps.flake-verify.outcome == 'failure'