: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
chore(ci): stop publishing deltalite from pull requests (#102528)
Raúl Negrón-Oterof0f6506d5f51
diff --git a/.github/workflows/build-deltalite.yml b/.github/workflows/build-deltalite.ymlindex 98b19f005c52..72ee7ab8b0ab 100644--- a/.github/workflows/build-deltalite.yml+++ b/.github/workflows/build-deltalite.yml@@ -1,41 +1,36 @@name: Release deltalite-# Publishes the `deltalite` Python wheel (the streaming Delta upsert, built from-# rust/deltalite/python via maturin) to PyPI, then auto-pins the new version in-# pyproject.toml + uv.lock so the app image installs it via `uv sync`. Mirrors-# build-hogql-parser-rs.yml exactly.-#-# ONE-TIME INFRA REQUIRED BEFORE THIS CAN PUBLISH (platform/infra team):-# 1. Create the `deltalite` project on PyPI.-# 2. Configure PyPI trusted publishing for it against this repo + workflow, and-# create a matching GitHub environment named `pypi-deltalite` (see the-# `pypi-hogql-parser-rs` environment for the template).-# Until that exists the build/version-check jobs still run (and correctly report-# "release needed"), but the publish job cannot upload. Nothing in the app imports-# `deltalite` until the pin lands, so this is inert until then.+# Builds the `deltalite` wheel (the streaming Delta upsert) from rust/deltalite/python+# and publishes it to PyPI. Bumping the `deltalite==` pin in the root pyproject.toml+# and uv.lock is a separate pull request after the publish job uploads the version.+# CI installs with `uv sync --frozen`, so a pin that names a version PyPI does not+# hold breaks every job that installs Python dependencies.on:pull_request:paths:- rust/deltalite/python/**- .github/workflows/build-deltalite.yml+ # Publishing is manual and only from master.+ workflow_dispatch:permissions:contents: read- pull-requests: writeconcurrency:group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}- cancel-in-progress: true+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}jobs:check-version:name: Check version legitimacyruns-on: ubuntu-22.04timeout-minutes: 5+ permissions:+ contents: read+ pull-requests: writeoutputs:deltalite-release-needed: ${{ steps.version.outputs.deltalite-release-needed }}- local-version: ${{ steps.version.outputs.local-version }}steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6with:@@ -44,6 +39,7 @@ jobs:- name: Check if rust/deltalite/python/ or the workflow has changedid: changed-files+ if: github.event_name == 'pull_request'uses: step-security/changed-files@2e07db73e5ccdb319b9a6c7766bd46d39d304bad # v47.0.5with:files_yaml: |@@ -55,17 +51,16 @@ jobs:- name: Check if version was bumpedshell: bashid: version+ if: github.event_name == 'pull_request'env:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}DELTALITE_CHANGED: ${{ steps.changed-files.outputs.deltalite_any_changed }}WORKFLOW_CHANGED: ${{ steps.changed-files.outputs.workflow_any_changed }}IS_FORK: ${{ github.event.pull_request.head.repo.full_name != 'PostHog/posthog' }}- PR_NUMBER: ${{ github.event.pull_request.number }}run: |deltalite_release_needed='false'- # Local version from pyproject.toml — single source of truth, matches Cargo.toml.+ # Local version from pyproject.toml, the single source of truth, matches Cargo.toml.local=$(grep -m1 '^version = ' rust/deltalite/python/pyproject.toml | sed -E 's/version = "(.*)"/\1/')- echo "local-version=$local" >> $GITHUB_OUTPUTif [[ "$DELTALITE_CHANGED" == 'true' ]]; then# 200 = version already on PyPI, 404 = needs release.http_code=$(curl -o /dev/null -sSL -w '%{http_code}' "https://pypi.org/pypi/deltalite/$local/json")@@ -84,14 +79,14 @@ jobs:if [ -f .github/scripts/post-reminder-section.mjs ]; thenBODY="$message_body" GITHUB_TOKEN="$GH_TOKEN" node .github/scripts/post-reminder-section.mjs deltalite warn "version bump needed"else- echo "Skipping deltalite section — script not present on this checkout"+ echo "$message_body"fielseecho "::warning::Unexpected HTTP $http_code from PyPI for deltalite $local; assuming not yet published."deltalite_release_needed='true'fifi- # Exercise the release pipeline on workflow-only edits; skip-existing makes publish a no-op.+ # Build the wheels on workflow-only edits too, so a change to this file is checked.if [[ "$WORKFLOW_CHANGED" == 'true' ]]; thendeltalite_release_needed='true'fi@@ -112,8 +107,9 @@ jobs:needs: check-versionruns-on: ${{ matrix.os }}timeout-minutes: 30- if: needs.check-version.outputs.deltalite-release-needed == 'true' &&- github.event.pull_request.head.repo.full_name == 'PostHog/posthog'+ if: github.event_name == 'workflow_dispatch' ||+ (needs.check-version.outputs.deltalite-release-needed == 'true' &&+ github.event.pull_request.head.repo.full_name == 'PostHog/posthog')strategy:fail-fast: falsematrix:@@ -178,7 +174,8 @@ jobs:publish:name: Publish on PyPI- needs: [check-version, build-wheels]+ needs: build-wheels+ if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master' && github.repository == 'PostHog/posthog'environment: pypi-deltalitepermissions:id-token: write # PyPI trusted publishing + provenance OIDC handshake@@ -204,91 +201,3 @@ jobs:# Attaches the attestations generated above to the PyPI release.attestations: trueskip-existing: true-- - 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 }}-- - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6- with:- ref: ${{ github.event.pull_request.head.ref }}- token: ${{ steps.app-token.outputs.token }}-- - name: Set up Python- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0- with:- python-version: 3.13.13-- # Direct install: Publishing commits to the PR head, which may predate the local action.- - name: Install uv- id: setup-uv- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0- with:- version: '0.12.13'- enable-cache: true- cache-dependency-glob: uv.lock- save-cache: ${{ github.ref == 'refs/heads/master' }}-- - name: Update deltalite in requirements- shell: bash- env:- RETRIES: 20- VERSION: ${{ needs.check-version.outputs.local-version }}- run: |- # `--refresh-package` bypasses the restored uv index cache, which- # otherwise won't have the version we just published. Retry anyway- # in case PyPI propagation lags the publish step.- for i in $(seq 1 "$RETRIES"); do- if uv add --refresh-package deltalite "deltalite==$VERSION"; then- break- fi- if [[ $i -eq $RETRIES ]]; then- echo "Failed to update deltalite in requirements"- exit 1- fi- sleep 0.5- done-- - name: Check for pin changes- id: check-pin- shell: bash- run: |- if git diff --quiet pyproject.toml uv.lock; then- echo "changed=false" >> $GITHUB_OUTPUT- else- echo "changed=true" >> $GITHUB_OUTPUT- fi-- - name: Commit pin- if: steps.check-pin.outputs.changed == 'true'- uses: planetscale/ghcommit-action@25309d8005ac7c3bcd61d3fe19b69e0fe47dbdde # v0.2.20- with:- commit_message: 'Use new deltalite version'- repo: ${{ github.repository }}- branch: ${{ github.event.pull_request.head.ref }}- file_pattern: 'pyproject.toml uv.lock'- env:- GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}-- - name: Verify pin is consistent with the published version- shell: bash- env:- CHANGED: ${{ steps.check-pin.outputs.changed }}- VERSION: ${{ needs.check-version.outputs.local-version }}- run: |- # The commit step is a no-op when pyproject.toml + uv.lock were already- # pre-bumped on the branch to the version we just published — fine.- # Verify the pin is consistent with the published version (i.e. the- # branch is in a deployable state) before declaring success.- if [[ "$CHANGED" != "true" ]]; then- pinned=$(grep -m1 'deltalite==' pyproject.toml | sed -E 's/.*deltalite==([^"]*).*/\1/')- if [[ "$pinned" != "$VERSION" ]]; then- echo "::error::deltalite published to PyPI as $VERSION but pyproject.toml pin says $pinned."- echo "Check the 'Update deltalite in requirements' step above for why uv add did not produce a diff."- exit 1- fi- echo "pyproject.toml already pinned to $VERSION; commit-pin no-op is expected."- fidiff --git a/tools/workflow-plan/src/scenarios.ts b/tools/workflow-plan/src/scenarios.tsindex 8bc4f2330a64..9381d58c06ca 100644--- a/tools/workflow-plan/src/scenarios.ts+++ b/tools/workflow-plan/src/scenarios.ts@@ -109,11 +109,11 @@ export function mergeQueue(options: Omit<PullRequestOptions, 'headRef' | 'draft'return pullRequest({ ...options, draft: true, headRef: 'trunk-merge/abc123' })}-function branchContext(eventName: string, actor: string): Context {+function branchContext(eventName: string, actor: string, branch: string = DEFAULT_BRANCH): Context {return {...baseContext(eventName, actor),- ref: `refs/heads/${DEFAULT_BRANCH}`,- ref_name: DEFAULT_BRANCH,+ ref: `refs/heads/${branch}`,+ ref_name: branch,head_ref: '',base_ref: '',}@@ -139,10 +139,10 @@ export function schedule(): Context {}}-export function workflowDispatch(): Context {+export function workflowDispatch(branch: string = DEFAULT_BRANCH): Context {return {- ...branchContext('workflow_dispatch', 'octocat'),- event: { inputs: {}, ref: `refs/heads/${DEFAULT_BRANCH}`, repository: repositoryPayload(REPOSITORY) },+ ...branchContext('workflow_dispatch', 'octocat', branch),+ event: { inputs: {}, ref: `refs/heads/${branch}`, repository: repositoryPayload(REPOSITORY) },}}@@ -196,7 +196,10 @@ type ScriptStubs = Pick<Scenario, 'vars' | 'jobOutputs'>// Values only a script produces at runtime, without which a workflow's gates cannot be planned.const DEPOT_BACKEND = '.depot/workflows/ci-backend.yml'-const SCRIPT_STUBS: Record<string, ScriptStubs> = {+export const SCRIPT_STUBS: Record<string, ScriptStubs> = {+ '.github/workflows/build-deltalite.yml': {+ jobOutputs: { 'check-version': { 'deltalite-release-needed': 'true' } },+ },'.github/workflows/release.yml': {jobOutputs: {plan: {diff --git a/tools/workflow-plan/tests/workflows.test.ts b/tools/workflow-plan/tests/workflows.test.tsindex b660ff109eb9..2778c325030b 100644--- a/tools/workflow-plan/tests/workflows.test.ts+++ b/tools/workflow-plan/tests/workflows.test.ts@@ -16,6 +16,7 @@ import {} from '../src/plan.ts'import {REPO_ROOT,+ SCRIPT_STUBS,allFiltersChanged,defaultScenarios,mergeQueue,@@ -23,6 +24,7 @@ import {pullRequest,push,schedule,+ workflowDispatch,} from '../src/scenarios.ts'const WORKFLOWS_DIR = path.join(REPO_ROOT, '.github/workflows')@@ -66,16 +68,23 @@ type ExpectationBuilder = (rest: Omit<Expectation, 'file' | 'scenario'>) => Expectation-const suite = (file: string, selectors: Stubs): ExpectationBuilder => {+const suite = (file: string, selectors: Stubs = {}): ExpectationBuilder => {const filters = allFiltersChanged(workflow(file))+ const scripted = SCRIPT_STUBS[`.github/workflows/${file}`]return (overrides, rest) => ({file,- scenario: { github: pullRequest(), ...overrides, steps: { ...filters, ...selectors, ...overrides.steps } },+ scenario: {+ github: pullRequest(),+ ...scripted,+ ...overrides,+ steps: { ...filters, ...selectors, ...overrides.steps },+ },...rest,})}const backend = suite('ci-backend.yml', backendSelectors)const frontend = suite('ci-frontend.yml', frontendSelectors)+const deltalite = suite('build-deltalite.yml')const PINNED_WORKFLOWS = ['ci-backend.yml', 'ci-frontend.yml']const frontendOnlyFilters: Stubs = {@@ -331,6 +340,19 @@ const EXPECTATIONS: Expectation[] = [results: { frontend_tests: 'cancelled' },}),+ deltalite({ name: 'ready PR' }, { runs: ['check-version', 'build-wheels'], skipped: ['publish'] }),+ deltalite(+ { name: 'fork PR', github: pullRequest({ fork: true }) },+ { runs: ['check-version'], skipped: ['build-wheels', 'publish'] }+ ),+ deltalite(+ { name: 'master dispatch', github: workflowDispatch() },+ { runs: ['check-version', 'build-wheels', 'publish'] }+ ),+ deltalite(+ { name: 'branch dispatch', github: workflowDispatch('feat/example') },+ { runs: ['check-version', 'build-wheels'], skipped: ['publish'] }+ ),]interface StepExpectation {