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.

chore(ci): update backend snapshots on depot (#103128)

Raúl Negrón-Oterob583f004523c
diff --git a/.depot/actions/commit-snapshots/action.yml b/.depot/actions/commit-snapshots/action.yml
new file mode 100644
index 000000000000..cf5a47f093b5
--- /dev/null
+++ b/.depot/actions/commit-snapshots/action.yml
@@ -0,0 +1,200 @@
+# Depot mirror of .github/actions/commit-snapshots. Only the CI report steps differ. On Depot CI
+# github.token is the Depot Code Access token that every Depot job shares, and it must not write,
+# so the section posts with inputs.ci-report-token. An empty token skips the section, because an
+# empty GITHUB_TOKEN leaves the ambient one in place. A checkout whose update-ci-report.mjs does
+# not adopt tests-posthog[bot] comments skips it too, because it would add a comment per write.
+name: Commit Aggregated Snapshots
+description: Applies snapshot patches, counts changes, commits, and updates the CI report
+
+inputs:
+ workflow-type:
+ description: 'Workflow type (storybook, playwright, or backend)'
+ required: true
+ patch-path:
+ description: 'Path where patch artifacts are already downloaded (e.g., /tmp/snapshot-patches/)'
+ required: true
+ snapshot-path:
+ description: 'Path to snapshot directory (e.g., frontend/__snapshots__/ or playwright/)'
+ required: true
+ commit-message:
+ description: 'Commit message for snapshot changes'
+ required: true
+ pr-number:
+ description: 'Pull request number'
+ required: true
+ repository:
+ description: 'Repository name (owner/repo)'
+ required: true
+ commit-sha:
+ description: 'Commit SHA that was tested'
+ required: true
+ branch-name:
+ description: 'Branch name'
+ required: true
+ github-token:
+ description: 'GitHub token for authentication'
+ required: true
+ ci-report-token:
+ description: 'GitHub token that posts the CI report section; empty skips the section'
+ required: false
+ default: ''
+ extra-files:
+ description: 'Additional file paths to include in the commit (space-separated)'
+ required: false
+ default: ''
+
+outputs:
+ committed:
+ description: 'Whether snapshots were committed (true/false)'
+ value: ${{ steps.commit.outputs.committed }}
+ changes:
+ description: 'JSON object with change counts'
+ value: ${{ steps.commit.outputs.changes }}
+
+runs:
+ using: composite
+ steps:
+ - name: Apply snapshot patches
+ shell: bash
+ env:
+ PATCH_PATH: ${{ inputs.patch-path }}
+ run: |
+ # Apply all patch files from the provided patch directory
+ # Patches handle A/M/D automatically including binary files
+ if [ -d "$PATCH_PATH" ]; then
+ PATCHES=$(find "$PATCH_PATH" -name "*.patch" | sort)
+ if [ -n "$PATCHES" ]; then
+ echo "::group::Applying snapshot patches"
+ echo "Applying patches from $PATCH_PATH..."
+ for patch in $PATCHES; do
+ if git apply --check "$patch" 2>/dev/null; then
+ echo "Applying $patch"
+ git apply --index "$patch"
+ elif git apply --reverse --check "$patch" 2>/dev/null; then
+ echo "Skipping $patch (already applied)"
+ else
+ echo "::warning::Patch $patch could not be applied — skipping"
+ fi
+ done
+ echo "::endgroup::"
+ else
+ echo "No patch files found in $PATCH_PATH"
+ fi
+ else
+ echo "Patch directory $PATCH_PATH does not exist"
+ fi
+
+ - name: Configure git
+ shell: bash
+ run: |
+ git config --global --add safe.directory '*'
+
+ - name: Verify branch hasn't advanced
+ id: verify
+ shell: bash
+ env:
+ BRANCH_NAME: ${{ inputs.branch-name }}
+ TESTED_SHA: ${{ inputs.commit-sha }}
+ run: |
+ echo "::group::Verifying branch hasn't advanced"
+ # Check if the remote branch HEAD still matches the commit we tested
+ CURRENT_SHA=$(git ls-remote origin "refs/heads/$BRANCH_NAME" | cut -f1)
+
+ if [ "$TESTED_SHA" != "$CURRENT_SHA" ]; then
+ echo "branch-advanced=true" >> $GITHUB_OUTPUT
+ echo "current-sha=$CURRENT_SHA" >> $GITHUB_OUTPUT
+ echo "::warning::⏭️ Branch advanced during workflow - snapshot commit skipped"
+ echo " Tested: $TESTED_SHA"
+ echo " Current: $CURRENT_SHA"
+ else
+ echo "branch-advanced=false" >> $GITHUB_OUTPUT
+ echo "::notice::✅ Branch HEAD matches tested commit - proceeding with snapshot commit"
+ fi
+ echo "::endgroup::"
+
+ - name: Post skipped snapshot update to CI report
+ if: steps.verify.outputs.branch-advanced == 'true' && inputs.ci-report-token != ''
+ shell: bash
+ env:
+ GITHUB_TOKEN: ${{ inputs.ci-report-token }}
+ TESTED_SHA: ${{ inputs.commit-sha }}
+ CURRENT_SHA: ${{ steps.verify.outputs.current-sha }}
+ WORKFLOW_TYPE: ${{ inputs.workflow-type }}
+ REPOSITORY: ${{ inputs.repository }}
+ run: |
+ grep -qF 'tests-posthog[bot]' frontend/bin/ci-report/update-ci-report.mjs || { echo "Skipping snapshot section: this checkout predates Depot CI authorship"; exit 0; }
+ node .github/scripts/post-snapshot-section.mjs \
+ "$WORKFLOW_TYPE" \
+ "skip" \
+ '{}' \
+ "$REPOSITORY" \
+ "$TESTED_SHA" \
+ "$CURRENT_SHA"
+
+ - name: Count changes and disable auto-merge
+ id: commit
+ if: steps.verify.outputs.branch-advanced == 'false'
+ shell: bash
+ env:
+ GH_TOKEN: ${{ inputs.github-token }}
+ SNAPSHOT_PATH: ${{ inputs.snapshot-path }}
+ PR_NUMBER: ${{ inputs.pr-number }}
+ run: |
+ CHANGES_JSON=$(.github/scripts/count-snapshot-changes.sh $SNAPSHOT_PATH)
+ echo "changes=$CHANGES_JSON" >> $GITHUB_OUTPUT
+ echo "Snapshot changes: $CHANGES_JSON"
+
+ TOTAL=$(echo "$CHANGES_JSON" | jq -r '.total')
+ if [ "$TOTAL" -gt 0 ]; then
+ # Disable auto-merge BEFORE committing
+ # This ensures auto-merge is disabled even if workflow gets cancelled after push
+ gh pr merge --disable-auto $PR_NUMBER || echo "Auto-merge was not enabled"
+ echo "::notice::🔒 Auto-merge disabled - snapshot changes require manual review"
+ echo "committed=true" >> $GITHUB_OUTPUT
+ else
+ echo "No snapshot changes to commit"
+ echo "committed=false" >> $GITHUB_OUTPUT
+ fi
+
+ - name: Commit snapshots via GitHub API (signed)
+ id: ghcommit
+ if: steps.commit.outputs.committed == 'true'
+ uses: planetscale/ghcommit-action@25309d8005ac7c3bcd61d3fe19b69e0fe47dbdde # v0.2.20
+ with:
+ commit_message: ${{ inputs.commit-message }}
+ repo: ${{ inputs.repository }}
+ branch: ${{ inputs.branch-name }}
+ file_pattern: '${{ inputs.snapshot-path }} ${{ inputs.extra-files }}'
+ env:
+ GITHUB_TOKEN: ${{ inputs.github-token }}
+
+ - name: Post snapshot section to CI report comment
+ if: steps.commit.outputs.committed == 'true' && inputs.ci-report-token != ''
+ shell: bash
+ env:
+ GITHUB_TOKEN: ${{ inputs.ci-report-token }}
+ SNAPSHOT_SHA: ${{ steps.ghcommit.outputs.commit-hash }}
+ COMMIT_SHA: ${{ inputs.commit-sha }}
+ WORKFLOW_TYPE: ${{ inputs.workflow-type }}
+ CHANGES: ${{ steps.commit.outputs.changes }}
+ REPOSITORY: ${{ inputs.repository }}
+ run: |
+ grep -qF 'tests-posthog[bot]' frontend/bin/ci-report/update-ci-report.mjs || { echo "Skipping snapshot section: this checkout predates Depot CI authorship"; exit 0; }
+ if [ -f .github/scripts/post-snapshot-section.mjs ]; then
+ node .github/scripts/post-snapshot-section.mjs \
+ "$WORKFLOW_TYPE" \
+ "update" \
+ "$CHANGES" \
+ "$REPOSITORY" \
+ "$COMMIT_SHA" \
+ "$SNAPSHOT_SHA"
+ else
+ echo "Skipping snapshot section — script not present on this checkout"
+ fi
+
+ - name: Fail workflow to signal snapshot changes
+ if: steps.commit.outputs.committed == 'true'
+ shell: bash
+ run: |
+ echo "::notice::Snapshots were updated and committed. Workflow fails to prevent auto-merge and signal review needed."
+ exit 1
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
index 8e6820993de7..19dc81f0ffd5 100644
--- a/.depot/workflows/ci-backend.yml
+++ b/.depot/workflows/ci-backend.yml
@@ -19,11 +19,14 @@
# local action a depot workflow uses needs a mirror even when it is identical to
# canonical: Depot resolves ./.github/actions/<x> from .depot/actions/<x>, so a missing
# mirror fails the step at setup with "action manifest not found".
-# - permissions: pull-requests:read (no comment/auto-commit side effects)
-# - Stripped side effects: CI report section posters (canonical
+# - permissions: read-only in every job, so the ambient token never writes. Canonical grants
+# handle-snapshots' github.token pull-requests:write for its CI report section; here the
+# section posts with a posthog-tests token scoped to pull-requests:write (see the header of
+# .depot/actions/commit-snapshots).
+# - Stripped side effects: CI report section posters other than backend snapshots (canonical
# additionally skips these on trunk-merge/** branches to save GITHUB_TOKEN budget;
-# the shadow strips them entirely, so that gating has nothing to mirror), snapshot
-# auto-commit (handle-snapshots), posthog-github-action telemetry (including the
+# the shadow strips them entirely, so that gating has nothing to mirror),
+# posthog-github-action telemetry (including the
# capture-test-selection job — turbo-discover still emits its telemetry outputs to
# stay apples-to-apples, they just have no consumer here; canonical mints the
# telemetry token from the GH_APP_TELEMETRY_APP_ID org variable rather than the
@@ -81,8 +84,8 @@
# GitHub's. A name missing there makes the setup-action mints (continue-on-error) fall
# back to the ambient GITHUB_TOKEN, the Depot Code Access installation token that every
# Depot CI job across repos shares, and fails the paths-filter mint outright. Mints whose
-# only consumer is a stripped side effect (OpenAPI auto-commit, snapshot commit,
-# telemetry) are stripped with it. The migration-risk check run is published here
+# only consumer is a stripped side effect (OpenAPI auto-commit, telemetry) are
+# stripped with it. The migration-risk check run is published here
# because stamphog waits for it on every pull request.
# - `depot ci run` fires with event_name `api`; the hand-off wait treats it like
# workflow_dispatch: it runs only when GitHub Actions already handed the commit off.
@@ -104,9 +107,9 @@
# depot-exempt. Login is best-effort because these jobs only pull public images and can
# fall back to anonymous pulls, which canonical relies on too.
# - Path-filter persons-SQL is folded into migrations
-# - Snapshot mode is pinned to check, because the snapshot patch upload/commit is stripped.
-# Canonical's per-schema-leg patch scoping (legacy legs exclude *.new_events_schema.ambr,
-# events_json legs ship only those) is therefore depot-exempt too
+# - handle-snapshots sets up Node from .nvmrc for its CI report steps, which canonical runs on
+# the node that ships with the GitHub-hosted image, and fails with a rebase hint when the PR
+# head predates .depot/actions/commit-snapshots
# - Test durations restored from Depot Cache (posthog-test-durations- prefix), refreshed by
# .depot/workflows/ci-backend-update-test-timing.yml, so shard counts match GitHub Actions.
# Committed .test_durations is the fallback.
@@ -604,14 +607,33 @@ jobs:
outputs:
mode: ${{ steps.detect.outputs.mode }}
steps:
- # Always check, never update. The steps that upload the snapshot patch and
- # commit it back are not ported here, so an update-mode run would rewrite the
- # snapshots on the runner, throw them away, and pass. A routed PR with stale
- # snapshots goes red here instead of merging stale. Restore canonical's mode
- # detection once handle-snapshots is ported.
- name: Detect mode
id: detect
- run: echo "mode=check" >> "$GITHUB_OUTPUT"
+ env:
+ PR_REPO: ${{ github.event.pull_request.head.repo.full_name }}
+ REPO: ${{ github.repository }}
+ HAS_NO_SNAPSHOT_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'no-snapshot-update') }}
+ AUTHOR: ${{ github.actor }}
+ run: |
+ if [ "$PR_REPO" != "$REPO" ] && [ -n "$PR_REPO" ]; then
+ echo "mode=check" >> $GITHUB_OUTPUT
+ echo "Fork detected - running in CHECK mode (no commits allowed)"
+ elif [ "$HAS_NO_SNAPSHOT_LABEL" == "true" ]; then
+ echo "mode=check" >> $GITHUB_OUTPUT
+ echo "::notice::🔍 Running in CHECK mode - 'no-snapshot-update' label detected"
+ else
+ echo "Workflow triggered by: $AUTHOR"
+ # Dependabot is excluded - it creates new PRs that may need snapshot updates
+ # Other bots (github-actions, posthog-bot) commit snapshots and must use CHECK mode to avoid loops
+ if [[ "$AUTHOR" != "dependabot[bot]" ]] && \
+ ([[ "$AUTHOR" == *"github-actions"* ]] || [[ "$AUTHOR" == *"[bot]"* ]] || [[ "$AUTHOR" == "posthog-bot" ]]); then
+ echo "mode=check" >> $GITHUB_OUTPUT
+ echo "::notice::🔍 Running in CHECK mode - snapshots must match exactly"
+ else
+ echo "mode=update" >> $GITHUB_OUTPUT
+ echo "::notice::🔄 Running in UPDATE mode - snapshots can be updated"
+ fi
+ fi
# Fast pre-job: determines which products need testing and if Django should run
# Only needs pnpm + node — no Python, Docker, or services
@@ -1412,6 +1434,43 @@ jobs:
retention-days: 2
overwrite: true # artifacts are immutable per run; re-run shards would 409 otherwise
+ - name: Verify new snapshots for flakiness
+ if: ${{ needs.wait-for-handoff.outputs.handed_off == 'true' && (always() && needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog') }}
+ shell: bash
+ run: |
+ .github/scripts/verify-new-snapshots.sh
+
+ - name: Generate snapshot patch
+ if: ${{ needs.wait-for-handoff.outputs.handed_off == 'true' && (always() && needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog') }}
+ shell: bash
+ env:
+ NEW_EVENTS_SCHEMA: ${{ matrix.new-events-schema && 'true' || 'false' }}
+ run: |
+ mkdir -p /tmp/patches
+ git add -N '*.ambr' || true
+ # Same leg scoping as the django job: a leg may only ship its own
+ # schema mode's snapshot files (see the comment there).
+ if [[ "$NEW_EVENTS_SCHEMA" == "true" ]]; then
+ ambr_pathspec=('*.new_events_schema.ambr')
+ else
+ ambr_pathspec=('*.ambr' ':(exclude)*.new_events_schema.ambr')
+ fi
+ if ! git diff --quiet -- "${ambr_pathspec[@]}" 2>/dev/null; then
+ git diff --binary --full-index -- "${ambr_pathspec[@]}" > /tmp/patches/backend-Products-${{ strategy.job-index }}.patch
+ echo "Generated patch with $(wc -l < /tmp/patches/backend-Products-${{ strategy.job-index }}.patch) lines"
+ else
+ echo "No snapshot changes to patch"
+ fi
+
+ - name: Upload snapshot patch
+ if: ${{ needs.wait-for-handoff.outputs.handed_off == 'true' && (always() && needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog') }}
+ uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
+ with:
+ name: snapshot-patch-Products-${{ strategy.job-index }}
+ path: /tmp/patches/
+ if-no-files-found: ignore
+ retention-days: 1
+
# Lightweight repo-wide checks that only need Python + uv (no Docker/DB).
# Consolidates checks that previously each spun up their own runner.
repo-checks:
@@ -3042,6 +3101,51 @@ jobs:
include-hidden-files: true
retention-days: 2
+ - name: Verify new snapshots for flakiness
+ # Only in UPDATE mode - CHECK mode doesn't update snapshots
+ if: ${{ needs.wait-for-handoff.outputs.handed_off == 'true' && (needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' && needs.changes.outputs.backend == 'true' && !matrix.person-on-events && !matrix.compat && steps.run-core-tests.outcome != 'failure' && steps.run-temporal-tests.outcome != 'failure') }}
+ shell: bash
+ run: |
+ unset GITHUB_TOKEN # reserved var injected by Depot CI; can't override via env: (see workflow env note)
+ .github/scripts/verify-new-snapshots.sh
+
+ - name: Generate snapshot patch
+ # Only in UPDATE mode - CHECK mode verifies snapshots match exactly
+ if: ${{ needs.wait-for-handoff.outputs.handed_off == 'true' && (needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' && needs.changes.outputs.backend == 'true' && !matrix.person-on-events && !matrix.compat && steps.run-core-tests.outcome != 'failure' && steps.run-temporal-tests.outcome != 'failure') }}
+ shell: bash
+ env:
+ NEW_EVENTS_SCHEMA: ${{ matrix.new-events-schema && 'true' || 'false' }}
+ run: |
+ mkdir -p /tmp/patches
+ # Stage any new/modified .ambr files so they appear in git diff
+ git add -N '*.ambr' || true
+ # Each schema leg may only ship its own snapshot files. A leg still
+ # *claims* the other schema mode's snapshot names without writing them,
+ # so syrupy deletes them from the working tree as unused; scoping the
+ # patch keeps those deletions out of the committed diff.
+ if [[ "$NEW_EVENTS_SCHEMA" == "true" ]]; then
+ ambr_pathspec=('*.new_events_schema.ambr')
+ else
+ ambr_pathspec=('*.ambr' ':(exclude)*.new_events_schema.ambr')
+ fi
+ # Generate patch if there are changes
+ if ! git diff --quiet -- "${ambr_pathspec[@]}" 2>/dev/null; then
+ git diff --binary --full-index -- "${ambr_pathspec[@]}" > /tmp/patches/backend-${{ matrix.artifact_key }}.patch
+ echo "Generated patch with $(wc -l < /tmp/patches/backend-${{ matrix.artifact_key }}.patch) lines"
+ else
+ echo "No snapshot changes to patch"
+ fi
+
+ - name: Upload snapshot patch
+ # Only in UPDATE mode
+ if: ${{ needs.wait-for-handoff.outputs.handed_off == 'true' && (needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' && needs.changes.outputs.backend == 'true' && !matrix.person-on-events && !matrix.compat && steps.run-core-tests.outcome != 'failure' && steps.run-temporal-tests.outcome != 'failure') }}
+ uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
+ with:
+ name: snapshot-patch-${{ matrix.artifact_key }}
+ path: /tmp/patches/
+ if-no-files-found: ignore
+ retention-days: 1
+
# Exports TRUNK_CODEOWNERS_PATH for the uploads below, so Trunk attributes each test to
# the team that owns its file. The guard is for an unrebased branch: this job checks out
# the PR head ref, which may predate the script. Without it the uploader keeps reading
@@ -3172,7 +3276,102 @@ jobs:
echo "compat_matrix=$compat_matrix" >> $GITHUB_OUTPUT
echo "Compat matrix: $compat_matrix"
fi
+ # Aggregate and commit snapshot changes from all matrix jobs
+ handle-snapshots:
+ name: Commit snapshot changes
+ needs: [changes, detect-snapshot-mode, django, turbo-tests]
+ # Only in UPDATE mode - CHECK mode verifies snapshots match exactly
+ # Run even if some matrix jobs failed (to commit snapshots from passing jobs)
+ if: ${{ !cancelled() && needs.detect-snapshot-mode.outputs.mode == 'update' && needs.changes.outputs.backend == 'true' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' }}
+ runs-on: depot-ubuntu-24.04
+ timeout-minutes: 5
+ steps:
+ # Use GitHub app token so Actions run after commiting updated snapshots
+ - name: Get app token
+ id: app-token
+ uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
+ with:
+ client-id: ${{ secrets.GH_APP_POSTHOG_TESTS_APP_ID }}
+ private-key: ${{ secrets.GH_APP_POSTHOG_TESTS_PRIVATE_KEY }}
+
+ - name: Checkout
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
+ token: ${{ steps.app-token.outputs.token }}
+ fetch-depth: 1
+
+ - name: Download all snapshot patches
+ id: download-patches
+ continue-on-error: true
+ uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
+ with:
+ pattern: snapshot-patch-*
+ path: /tmp/snapshot-patches
+ merge-multiple: true
+
+ - name: Check for patches
+ id: check-patches
+ run: |
+ if [ "${{ steps.download-patches.outcome }}" == "failure" ] || [ ! -d /tmp/snapshot-patches ]; then
+ echo "has-patches=false" >> $GITHUB_OUTPUT
+ echo "No snapshot patches found"
+ exit 0
+ fi
+
+ if [ -n "$(find /tmp/snapshot-patches -name '*.patch' -type f -size +0c 2>/dev/null)" ]; then
+ echo "has-patches=true" >> $GITHUB_OUTPUT
+ echo "Found patches:"
+ ls -la /tmp/snapshot-patches/
+ else
+ echo "has-patches=false" >> $GITHUB_OUTPUT
+ echo "Patch files empty or missing - no snapshot changes"
+ fi
+
+ # The commit action loads from the PR head, and a head that predates it would fail
+ # with "action manifest not found" instead of saying what to do.
+ - name: Require a PR head with the commit action
+ if: steps.check-patches.outputs.has-patches == 'true' && hashFiles('.depot/actions/commit-snapshots/action.yml') == ''
+ run: |
+ echo "::error::This PR head predates Depot CI snapshot commits. Rebase onto master so CI can commit the updated snapshots."
+ exit 1
+
+ - name: Get app token for CI report
+ # continue-on-error: an empty token skips the CI report section, not the commit.
+ if: steps.check-patches.outputs.has-patches == 'true'
+ id: ci-report-app-token
+ continue-on-error: true
+ uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
+ with:
+ client-id: ${{ secrets.GH_APP_POSTHOG_TESTS_APP_ID }}
+ private-key: ${{ secrets.GH_APP_POSTHOG_TESTS_PRIVATE_KEY }}
+ permission-pull-requests: write
+
+ - name: Set up Node.js
+ if: steps.ci-report-app-token.outputs.token != ''
+ uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ with:
+ node-version-file: .nvmrc
+ token: ${{ steps.ci-report-app-token.outputs.token }}
+
+ - name: Commit snapshots
+ if: steps.check-patches.outputs.has-patches == 'true'
+ uses: ./.depot/actions/commit-snapshots
+ with:
+ workflow-type: backend
+ patch-path: /tmp/snapshot-patches
+ snapshot-path: '.'
+ commit-message: 'test(backend): update query snapshots'
+ pr-number: ${{ github.event.pull_request.number }}
+ repository: ${{ github.repository }}
+ commit-sha: ${{ github.event.pull_request.head.sha }}
+ branch-name: ${{ github.event.pull_request.head.ref }}
+ github-token: ${{ steps.app-token.outputs.token }}
+ ci-report-token: ${{ steps.ci-report-app-token.outputs.token }}
+
# Job just to collate the status of the matrix jobs for requiring passing status
+ # Must depend on handle-snapshots to prevent auto-merge before commits complete
django_tests:
needs:
[
@@ -3187,6 +3386,7 @@ jobs:
build-product-test-matrix,
turbo-tests,
detect-snapshot-mode,
+ handle-snapshots,
repo-checks,
]
name: Django Tests Pass on Depot
@@ -3213,6 +3413,7 @@ jobs:
echo "| turbo-discover | ${{ needs.turbo-discover.result }} |"
echo "| build-product-test-matrix | ${{ needs.build-product-test-matrix.result }} |"
echo "| turbo-tests | ${{ needs.turbo-tests.result }} |"
+ echo "| handle-snapshots | ${{ needs.handle-snapshots.result }} |"
} | tee -a "$GITHUB_STEP_SUMMARY"
- name: Download shard JUnit results
@@ -3327,6 +3528,7 @@ jobs:
check_required_result "Product test matrix build" "${{ needs.build-product-test-matrix.result }}"
check_required_result "Product/Turbo tests" "${{ needs.turbo-tests.result }}"
check_required_result "Snapshot mode detection" "${{ needs.detect-snapshot-mode.result }}"
+ check_required_result "Snapshot commit job" "${{ needs.handle-snapshots.result }}"
echo "All backend and product checks passed."
# calculate-running-time is omitted so Depot runs are not recorded as canonical CI data.
diff --git a/tools/hogli-commands/hogli_commands/depot_mirrors.py b/tools/hogli-commands/hogli_commands/depot_mirrors.py
index 9eb0979491ef..6ebc1b34a639 100644
--- a/tools/hogli-commands/hogli_commands/depot_mirrors.py
+++ b/tools/hogli-commands/hogli_commands/depot_mirrors.py
@@ -15,7 +15,7 @@ CANONICAL_WORKFLOW = ".github/workflows/ci-backend.yml"
SHADOW_WORKFLOW = ".depot/workflows/ci-backend.yml"
# These mirrors carry intentional deltas that each mirror's header documents.
# Every other mirror stays byte-identical to its canonical action.
-DELTA_MIRRORS = frozenset({"pnpm-install", "setup-pnpm"})
+DELTA_MIRRORS = frozenset({"commit-snapshots", "pnpm-install", "setup-pnpm"})
# Depot resolves both `./.github/actions/<name>` and `./.depot/actions/<name>` from .depot/actions/<name>.
LOCAL_ACTION_USE = re.compile(r"""uses:\s*['"]?\./\.(?:github|depot)/actions/([A-Za-z0-9_.-]+)""")