Skip to content

trunk-merge/pr-111192/0e5342a4-45b4-4f4f-a85c-ec9dd80132f4 #265247

trunk-merge/pr-111192/0e5342a4-45b4-4f4f-a85c-ec9dd80132f4

trunk-merge/pr-111192/0e5342a4-45b4-4f4f-a85c-ec9dd80132f4 #265247

Workflow file for this run

name: Proto CI
on:
workflow_dispatch:
push:
branches: [master]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
pull-requests: read
jobs:
changes:
runs-on: ubuntu-24.04
timeout-minutes: 5
if: github.repository == 'PostHog/posthog'
name: Determine need to run proto checks
outputs:
proto: ${{ steps.filter.outputs.proto || 'true' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
clean: false
sparse-checkout: .github/actions/paths-filter
sparse-checkout-cone-mode: false
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
with:
client-id: ${{ vars.GH_APP_POSTHOG_PATHS_FILTER_APP_ID }}
private-key: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }}
- uses: ./.github/actions/paths-filter
id: filter
if: github.event_name != 'push'
with:
token: ${{ steps.app-token.outputs.token || github.token }}
filters: |
proto:
- 'proto/**'
- 'packages/personhog-proto/**'
- 'pyproject.toml'
- 'uv.lock'
- 'bin/generate_personhog_proto.sh'
- 'nodejs/src/common/generated/personhog/**'
- 'nodejs/src/common/generated/ingestion-worker/**'
- 'nodejs/buf.gen.yaml'
- 'nodejs/buf.gen.ingestion-worker.yaml'
- 'nodejs/package.json'
- '.github/workflows/ci-proto.yml'
lint:
name: Lint proto definitions (depot-ubuntu-22.04-4)
needs: changes
if: needs.changes.outputs.proto == 'true'
runs-on: depot-ubuntu-22.04-4
timeout-minutes: 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
clean: false
- name: Install buf
uses: bufbuild/buf-action@fd21066df7214747548607aaa45548ba2b9bc1ff # v1.4.0
with:
setup_only: true
version: '1.50.0'
- name: Lint protos
run: buf lint proto/
breaking:
name: Check for breaking changes (depot-ubuntu-22.04-4)
needs: changes
if: needs.changes.outputs.proto == 'true'
runs-on: depot-ubuntu-22.04-4
timeout-minutes: 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
clean: false
- name: Install buf
uses: bufbuild/buf-action@fd21066df7214747548607aaa45548ba2b9bc1ff # v1.4.0
with:
setup_only: true
version: '1.50.0'
- name: Check for breaking changes
run: buf breaking proto/ --against 'https://github.com/PostHog/posthog.git#branch=master,subdir=proto'
python-codegen:
name: Check Python proto stubs are up to date (depot-ubuntu-22.04-4)
needs: changes
if: needs.changes.outputs.proto == 'true'
runs-on: depot-ubuntu-22.04-4
timeout-minutes: 10
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
clean: false
- name: Mint setup-action GitHub token
id: setup-gh-token
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
continue-on-error: true
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
with:
client-id: ${{ vars.GH_APP_POSTHOG_SETUP_ACTIONS_APP_ID }}
private-key: ${{ secrets.GH_APP_POSTHOG_SETUP_ACTIONS_PRIVATE_KEY }}
skip-token-revoke: true
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.14.7'
token: ${{ steps.setup-gh-token.outputs.token || github.token }}
- uses: ./.github/actions/setup-uv
with:
enable-cache: 'false'
- name: Install codegen tools from the lock
run: UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --no-install-project --only-group proto-codegen
- name: Regenerate Python proto stubs
run: bash bin/generate_personhog_proto.sh
- name: Check for diff
run: |
# Intent-to-add so brand-new generated files show up in git diff
git add -N packages/personhog-proto/
if ! git diff --exit-code packages/personhog-proto/; then
echo ""
echo "ERROR: Generated Python proto stubs are out of date."
echo "Run 'bash bin/generate_personhog_proto.sh' and commit the result."
exit 1
fi
echo "Generated Python proto stubs are up to date."
node-codegen:
name: Check Node proto stubs are up to date (depot-ubuntu-22.04-4)
needs: changes
if: needs.changes.outputs.proto == 'true'
runs-on: depot-ubuntu-22.04-4
timeout-minutes: 10
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
clean: false
- name: Install buf
uses: bufbuild/buf-action@fd21066df7214747548607aaa45548ba2b9bc1ff # v1.4.0
with:
setup_only: true
version: '1.50.0'
- name: Install pnpm and dependencies
uses: ./.github/actions/pnpm-install
with:
install-command: pnpm --filter=@posthog/nodejs... install --frozen-lockfile
- name: Regenerate Node proto stubs
run: |
pnpm --dir nodejs run generate:personhog-proto
pnpm --dir nodejs run generate:ingestion-worker-proto
- name: Check for diff
run: |
# Intent-to-add so brand-new generated files show up in git diff
git add -N nodejs/src/common/generated/personhog/ nodejs/src/common/generated/ingestion-worker/
if ! git diff --exit-code nodejs/src/common/generated/personhog/ nodejs/src/common/generated/ingestion-worker/; then
echo ""
echo "ERROR: Generated Node proto stubs are out of date."
echo "Run 'pnpm run generate:personhog-proto' and 'pnpm run generate:ingestion-worker-proto' in nodejs/ and commit the result."
exit 1
fi
echo "Generated Node proto stubs are up to date."
proto_checks:
needs: [changes, lint, breaking, python-codegen, node-codegen]
name: Proto Checks Pass
runs-on: ubuntu-24.04
timeout-minutes: 5
if: ${{ !cancelled() }}
steps:
- name: Check all proto jobs
run: |
# Fail if change detection failed or was cancelled (outputs are empty on cancel, so the exit below would report green).
if [[ "${{ needs.changes.result }}" != "success" && "${{ needs.changes.result }}" != "skipped" ]]; then
echo "Change detection did not succeed (result: ${{ needs.changes.result }})."
exit 1
fi
if [[ "${{ needs.changes.outputs.proto }}" != "true" ]]; then
echo "Proto checks were skipped (no relevant changes)"
exit 0
fi
if [[ "${{ needs.lint.result }}" != "success" && "${{ needs.lint.result }}" != "skipped" ]]; then
echo "Proto lint failed."
exit 1
fi
if [[ "${{ needs.breaking.result }}" != "success" && "${{ needs.breaking.result }}" != "skipped" ]]; then
echo "Proto breaking change check failed."
exit 1
fi
if [[ "${{ needs.python-codegen.result }}" != "success" && "${{ needs.python-codegen.result }}" != "skipped" ]]; then
echo "Python proto codegen staleness check failed."
exit 1
fi
if [[ "${{ needs.node-codegen.result }}" != "success" && "${{ needs.node-codegen.result }}" != "skipped" ]]; then
echo "Node proto codegen staleness check failed."
exit 1
fi
echo "All proto checks passed."