: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(hogvm): add bin/hoglang and move the hogvm suite onto it (#124301)
Rafael Audibert14a0296e19e2
diff --git a/.github/scripts/trunk-impacted-targets.js b/.github/scripts/trunk-impacted-targets.jsindex 6c13f9676b60..6f99db6b73f3 100644--- a/.github/scripts/trunk-impacted-targets.js+++ b/.github/scripts/trunk-impacted-targets.js@@ -279,7 +279,7 @@ const TRIPWIRE_RULES = [// the cd-*-image rule below.['.github/workflows/ci-e2e-playwright.yml', FULLSTACK],['.github/workflows/ci-e2e-playwright-audit.yml', FULLSTACK],- ['.github/workflows/ci-hog.yml', FULLSTACK],+ ['.github/workflows/ci-hoglang.yml', FULLSTACK],['.github/workflows/container-images-ci.yml', FULLSTACK],['.github/workflows/cd-sandbox-base-image.yml', FULLSTACK],['.github/workflows/ci-recording-rasterizer-container.yml', FULLSTACK],@@ -718,12 +718,13 @@ const TRIPWIRE_RULES = [['bin/lint-feature-flag-sorting.mjs', JAVASCRIPT],['bin/fix-rdkafka-paths', JAVASCRIPT],['bin/create-notebook-node.sh', JAVASCRIPT],- // The Hog CLI backs the Hog suite, the jest-timing helpers feed+ // bin/hoglang backs the HogLang suite, the jest-timing helpers feed// report_test_timings, the dockerignore check runs in container-images-ci,// and the sandbox scripts are baked into the sandbox image; all of those// sit on the fullstack lanes already.['bin/hog', FULLSTACK],['bin/hoge', FULLSTACK],+ ['bin/hoglang', FULLSTACK],['bin/report-jest-timings', FULLSTACK],['bin/render-jest-timings-example', FULLSTACK],['bin/dockerignore-drop-check', FULLSTACK],@@ -842,8 +843,8 @@ const STANDALONE_TREES = new Map([// the pnpm workspace). ci-cli.yml also builds it from services/mcp sources,// so the two trees have to share a lane.['cli', ['cli', 'svc:mcp']],- // Go service with its own CI. ci-hog.yml ignores livestream/** explicitly,- // so its Hog implementation is not covered by the shared hog suite either.+ // Go service with its own CI. ci-hoglang.yml ignores livestream/** explicitly,+ // so its Hog implementation is not covered by the shared HogLang suite either.['livestream', ['livestream']],// Another standalone cargo workspace, and nothing in the dev or CI stack// builds it: the UDF binary reaches ClickHouse through its image.diff --git a/.github/scripts/trunk-impacted-targets.test.js b/.github/scripts/trunk-impacted-targets.test.jsindex 2d51ae004caa..7a559c25ee88 100644--- a/.github/scripts/trunk-impacted-targets.test.js+++ b/.github/scripts/trunk-impacted-targets.test.js@@ -623,7 +623,7 @@ test('a single-language workflow claims that language rather than everything', (test('a full-stack suite claims both language families and no rust crate', () => {for (const file of ['.github/workflows/ci-e2e-playwright.yml',- '.github/workflows/ci-hog.yml',+ '.github/workflows/ci-hoglang.yml','.github/workflows/container-images-ci.yml','.github/workflows/cd-sandbox-base-image.yml','.github/workflows/ci-recording-rasterizer-container.yml',diff --git a/.github/workflows/ci-hog.yml b/.github/workflows/ci-hoglang.ymlsimilarity index 95%rename from .github/workflows/ci-hog.ymlrename to .github/workflows/ci-hoglang.ymlindex c276328a2673..fa2fd57df036 100644--- a/.github/workflows/ci-hog.yml+++ b/.github/workflows/ci-hoglang.yml@@ -2,7 +2,7 @@## If these tests get too slow, look at increasing concurrency and re-timing the tests by manually dispatching# .github/workflows/ci-backend-update-test-timing.yml action-name: Hog CI+name: HogLang CIon:push:branches:@@ -50,13 +50,13 @@ jobs:if: github.repository == 'PostHog/posthog' || (github.event_name != 'push' && github.event_name != 'schedule')runs-on: ubuntu-24.04timeout-minutes: 5- name: Determine need to run Hog checks+ name: Determine need to run HogLang checkspermissions:contents: readpull-requests: read# Set job outputs to values from filter stepoutputs:- hog: ${{ steps.filter.outputs.hog || 'true' }}+ hoglang: ${{ steps.filter.outputs.hoglang || 'true' }}steps:# For pull requests it's not necessary to checkout the code, but we# also want this to run on master so we need to checkout@@ -77,24 +77,23 @@ jobs:with:token: ${{ steps.app-token.outputs.token || github.token }}filters: |- hog:+ hoglang:# Avoid running tests for irrelevant changes- 'common/hogvm/**/*'- 'posthog/hogql/**/*'- - 'bin/hog'- - 'bin/hoge'+ - 'bin/hoglang'- 'package.json'- requirements.txt- requirements-dev.txt- - .github/workflows/ci-hog.yml+ - .github/workflows/ci-hoglang.yml- .github/actions/setup-uv/**- hog-tests:+ hoglang-tests:needs: changestimeout-minutes: 30- name: Hog tests+ name: HogLang testsruns-on: ubuntu-24.04- if: needs.changes.outputs.hog == 'true'+ if: needs.changes.outputs.hoglang == 'true'steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:@@ -176,7 +175,7 @@ jobs:pnpm --filter=@posthog/hogvm install --frozen-lockfilepnpm --filter=@posthog/hogvm test- - name: Run Hog tests+ - name: Run HogLang testsrun: |pnpm --filter=@posthog/hogvm install --frozen-lockfilepnpm --filter=@posthog/hogvm compile:stldiff --git a/bin/hoglang b/bin/hoglangnew file mode 100755index 000000000000..5e3511323d7c--- /dev/null+++ b/bin/hoglang@@ -0,0 +1,54 @@+#!/bin/bash+set -e++usage() {+ echo "bin/hoglang - run and compile HogLang programs"+ echo ""+ echo "Usage: bin/hoglang <file.hog> run .hog source code"+ echo " bin/hoglang <file.hoge> run compiled .hoge bytecode"+ echo " bin/hoglang compile <file.hog> [output.hoge] compile .hog into .hoge"+ echo " bin/hoglang compile <file.hog> <output.js> compile .hog into .js"+ echo ""+ echo "Options: bin/hoglang --debug run the debugger (Python only)"+ echo " bin/hoglang --python use the Python VM"+ echo " bin/hoglang --nodejs use the Node.js VM"+}++if [[ "$1" == "compile" ]]; then+ shift+ if [[ "$*" == *".hog"* || "$*" == *".js"* ]]; then+ exec python3 -m posthog.hogql.cli --compile "$@"+ fi+ usage+ exit 1+fi++if [[ "$*" == *".hoge"* ]]; then+ if [[ "$*" == *"--python"* ]]; then+ exec python3 -m common.hogvm.python.cli "$@"++ elif [[ "$*" == *"--debug"* ]]; then+ echo "Running in Python VM with debug mode"+ exec python3 -m common.hogvm.python.cli "$@"++ else # default to nodejs because it's fastest+ set -- "${@/--nodejs/}"+ VM_PATH="$(dirname "$0")/../common/hogvm/typescript"+ CLI_PATH="$(dirname "$0")/../common/hogvm/typescript/dist/cli.js"+ # TODO: recompile if something changed+ if [ ! -f "$CLI_PATH" ]; then+ echo "Building TypeScript HogVM"+ cd "$VM_PATH"+ pnpm run build+ cd -+ fi+ exec node "$CLI_PATH" "$@"+ fi+elif [[ "$*" == *"--out"* ]]; then+ exec python3 -m posthog.hogql.cli --out "$@"+elif [[ "$*" == *".hog"* ]]; then+ exec python3 -m posthog.hogql.cli --run "$@"+else+ usage+ exit 1+fidiff --git a/common/hogvm/test.sh b/common/hogvm/test.shindex afd04b7f6232..eb92554e71cd 100755--- a/common/hogvm/test.sh+++ b/common/hogvm/test.sh@@ -79,10 +79,10 @@ for file in "${test_files[@]}"; dofilename=$(basename "$file")# Compile to .hoge- ./bin/hoge "$file" "$basename.hoge"+ ./bin/hoglang compile "$file" "$basename.hoge"# Always run Node.js test- ./bin/hog --nodejs "$basename.hoge" > "$basename.stdout.nodejs"+ ./bin/hoglang --nodejs "$basename.hoge" > "$basename.stdout.nodejs"# If this file is in ONLY_NODEJS_FILES, skip python + compiledjsif is_in_array "$filename" "${ONLY_NODEJS_FILES[@]}"; then@@ -92,7 +92,7 @@ for file in "${test_files[@]}"; dofi# Otherwise, run Python- ./bin/hog --python "$basename.hoge" > "$basename.stdout.python"+ ./bin/hoglang --python "$basename.hoge" > "$basename.stdout.python"# Check if compiledjs is skippedif is_in_array "$filename" "${SKIP_COMPILEDJS_FILES[@]}"; then@@ -110,7 +110,7 @@ for file in "${test_files[@]}"; doelse# Run compiledjsset +e- ./bin/hoge "$file" "$basename.js"+ ./bin/hoglang compile "$file" "$basename.js"node "$basename.js" > "$basename.stdout.compiledjs" 2>&1set -ediff --git a/hogli.yaml b/hogli.yamlindex b88866169bf6..d8f12e48bfd9 100644--- a/hogli.yaml+++ b/hogli.yaml@@ -1000,6 +1000,9 @@ tools:tool:hoge:bin_script: hogedescription: Compile HogQL source to bytecode or JavaScript+ tool:hoglang:+ bin_script: hoglang+ description: Run HogLang source or bytecode, or compile source to bytecode or JavaScripttool:ruff:bin_script: ruff.shdescription: Python linter and formatter with virtualenv auto-activation