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.

ci: make Hog, Playwright and visual review steps independent of the checkout (#121158)

Georges-Antoine Assi3ecc9a2d055b
diff --git a/.github/workflows/ci-e2e-playwright.yml b/.github/workflows/ci-e2e-playwright.yml
index 4f2d8d004eb8..94e911788a8d 100644
--- a/.github/workflows/ci-e2e-playwright.yml
+++ b/.github/workflows/ci-e2e-playwright.yml
@@ -633,8 +633,11 @@ jobs:
- name: Determine if hogql-parser has changed compared to master
shell: bash
id: hogql-parser-diff
+ env:
+ GH_TOKEN: ${{ github.token }}
run: |
- git fetch --no-tags --prune --depth=1 origin master
+ git -c "http.https://github.com/.extraheader=AUTHORIZATION: basic $(printf 'x-access-token:%s' "$GH_TOKEN" | base64 | tr -d '\n')" \
+ fetch --no-tags --prune --depth=1 origin master
changed=$(git diff --quiet HEAD origin/master -- common/hogql_parser/ && echo "false" || echo "true")
echo "changed=$changed" >> $GITHUB_OUTPUT
@@ -997,7 +1000,7 @@ jobs:
# workspace root here, so this is a separate entry. No restore-keys.
- name: Restore VR CLI build
id: restore-vr-cli
- if: always() && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push')
+ if: always() && (github.repository != 'PostHog/posthog' || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push')
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
@@ -1009,7 +1012,7 @@ jobs:
# in ci-storybook.yml.
- name: Build VR CLI
id: build-vr-cli
- if: always() && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') && steps.restore-vr-cli.outputs.cache-hit != 'true'
+ if: always() && (github.repository != 'PostHog/posthog' || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') && steps.restore-vr-cli.outputs.cache-hit != 'true'
timeout-minutes: 8
shell: bash
working-directory: products/visual_review/cli
@@ -1024,7 +1027,7 @@ jobs:
- name: Save VR CLI build
# Master only, because the key is immutable once written. vr-complete reads
# this entry, so it runs on the same runner provider.
- if: github.ref == 'refs/heads/master' && steps.restore-vr-cli.outputs.cache-hit != 'true'
+ if: github.repository == 'PostHog/posthog' && github.ref == 'refs/heads/master' && steps.restore-vr-cli.outputs.cache-hit != 'true'
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
@@ -1036,7 +1039,7 @@ jobs:
# missing module. A skipped build (cache hit) is not a failure.
- name: Create VR run
id: vr-create
- if: always() && steps.build-vr-cli.outcome != 'failure' && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push')
+ if: always() && steps.build-vr-cli.outcome != 'failure' && github.repository == 'PostHog/posthog' && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push')
env:
VR_TOKEN: ${{ secrets.VR_API_TOKEN }}
VR_BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }}
@@ -1076,6 +1079,34 @@ jobs:
--baseline playwright/snapshots.yml \
--token "$VR_TOKEN"
+ - name: Verify snapshots against the baseline offline
+ if: ${{ !cancelled() && github.repository != 'PostHog/posthog' }}
+ shell: bash
+ run: |
+ set +e
+ node products/visual_review/cli/dist/cli/src/index.js verify --partial \
+ --dir playwright/__snapshots__/ \
+ --baseline playwright/snapshots.yml > /tmp/vr-verify.log 2>&1
+ status=$?
+ set -e
+ cat /tmp/vr-verify.log
+ {
+ echo "### Offline snapshot check"
+ echo
+ echo "This run has no Visual Review run, so it compares its screenshots with \`playwright/snapshots.yml\` offline."
+ echo "This fallback accepts only an exact pixel match. It does not know the tolerated hashes or the quarantine of Visual Review, so a flaky snapshot can also fail it."
+ echo
+ echo '```'
+ cat /tmp/vr-verify.log
+ echo '```'
+ } >> "$GITHUB_STEP_SUMMARY"
+ if [ "$status" -ne 0 ] && grep -q 'Baseline mismatch' /tmp/vr-verify.log; then
+ echo "::error title=Snapshots differ from the baseline::These screenshots do not match playwright/snapshots.yml. This run has no Visual Review run, so this offline fallback accepts only an exact pixel match. Update the baseline after reviewing the change. The job log lists the snapshots that differ."
+ elif [ "$status" -ne 0 ]; then
+ echo "::error title=Offline snapshot check failed::The offline snapshot check could not compare the screenshots. The job log shows the error."
+ fi
+ exit "$status"
+
# ── Artifacts on failure / always ─────────────────────────────────────
- name: Capture docker logs
if: always()
diff --git a/.github/workflows/ci-hog.yml b/.github/workflows/ci-hog.yml
index f85addf50496..f19852746aff 100644
--- a/.github/workflows/ci-hog.yml
+++ b/.github/workflows/ci-hog.yml
@@ -150,7 +150,7 @@ jobs:
export CLASSPATH=".:$PWD/antlr.jar:$CLASSPATH"
export PATH="$PWD:$PATH"
- cd ../posthog
+ cd "$GITHUB_WORKSPACE"
antlr | grep "Version"
npm run grammar:build && git diff --exit-code
env:
diff --git a/.github/workflows/ci-storybook.yml b/.github/workflows/ci-storybook.yml
index de9394afd607..372d8c4b8b1c 100644
--- a/.github/workflows/ci-storybook.yml
+++ b/.github/workflows/ci-storybook.yml
@@ -456,6 +456,7 @@ jobs:
&& needs.changes.outputs.frontend == 'true'
&& needs.build-storybook.result == 'success'
&& needs.select-stories.outputs.should_run != 'false'
+ && github.repository == 'PostHog/posthog'
&& (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push')
outputs:
run_id: ${{ steps.create.outputs.run_id }}
@@ -754,7 +755,7 @@ jobs:
# from the base branch (see vr-setup for the rationale), which also keeps fork
# code out of the CLI.
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- if: always() && (needs.vr-setup.outputs.run_id != '' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository))
+ if: always() && (needs.vr-setup.outputs.run_id != '' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) || github.repository != 'PostHog/posthog')
with:
ref: ${{ github.event.pull_request.base.ref || github.sha }}
path: vr-cli
@@ -768,7 +769,7 @@ jobs:
# the cache version. The save below writes the container version.
- name: Restore VR CLI build
id: restore-vr-cli
- if: always() && (needs.vr-setup.outputs.run_id != '' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository))
+ if: always() && (needs.vr-setup.outputs.run_id != '' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) || github.repository != 'PostHog/posthog')
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
@@ -779,7 +780,7 @@ jobs:
# Runs only on a miss, and retries the install for the reason given at vr-setup.
- name: Build VR CLI
id: build-vr-cli
- if: always() && (needs.vr-setup.outputs.run_id != '' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)) && steps.restore-vr-cli.outputs.cache-hit != 'true'
+ if: always() && (needs.vr-setup.outputs.run_id != '' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) || github.repository != 'PostHog/posthog') && steps.restore-vr-cli.outputs.cache-hit != 'true'
timeout-minutes: 8
shell: bash
working-directory: vr-cli/products/visual_review/cli
@@ -826,7 +827,7 @@ jobs:
# !cancelled() keeps the check after a test-runner failure. A failed CLI build
# fails this step too, so a fork PR never passes unverified.
- name: Verify snapshots against the baseline offline
- if: ${{ !cancelled() && (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
+ if: ${{ !cancelled() && ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) || github.repository != 'PostHog/posthog') }}
shell: bash
run: |
set +e
@@ -839,7 +840,7 @@ jobs:
{
echo "### Offline snapshot check (${{ matrix.browser }} ${{ matrix.shard }}/${{ matrix.shard_count }})"
echo
- echo "Fork PRs get no Visual Review run, so this shard compares its screenshots with \`frontend/snapshots.yml\` offline."
+ echo "This run has no Visual Review run, so this shard compares its screenshots with \`frontend/snapshots.yml\` offline."
echo "This fallback accepts only an exact pixel match. It does not know the tolerated hashes or the quarantine of Visual Review, so a flaky story can also fail it."
echo
echo '```'
@@ -847,7 +848,7 @@ jobs:
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
if [ "$status" -ne 0 ] && grep -q 'Baseline mismatch' /tmp/vr-verify.log; then
- echo "::error title=Snapshots differ from the baseline::This shard's screenshots do not match frontend/snapshots.yml. Fork PRs get no Visual Review run, so this offline fallback accepts only an exact pixel match, without the tolerated hashes or the quarantine of Visual Review. A maintainer must review the change and update the baseline before this PR can merge. The job log lists the snapshots that differ."
+ echo "::error title=Snapshots differ from the baseline::This shard's screenshots do not match frontend/snapshots.yml. This run has no Visual Review run, so this offline fallback accepts only an exact pixel match, without the tolerated hashes or the quarantine of Visual Review. A maintainer must review the change and update the baseline before this PR can merge. The job log lists the snapshots that differ."
elif [ "$status" -ne 0 ]; then
echo "::error title=Offline snapshot check failed::The offline snapshot check could not compare this shard's screenshots. The job log shows the error."
fi