Skip to content

chore: remove upstream Codespaces workflow #9

chore: remove upstream Codespaces workflow

chore: remove upstream Codespaces workflow #9

Workflow file for this run

# This workflow runs all of our backend django tests.
#
# 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
on:
push:
branches:
- master
pull_request:
paths-ignore:
- rust/**
- livestream/**
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# Job to decide if we should run backend ci
# See https://github.com/dorny/paths-filter#conditional-execution for more details
changes:
runs-on: ubuntu-24.04
timeout-minutes: 5
name: Determine need to run Hog checks
permissions:
contents: read
pull-requests: read
# Set job outputs to values from filter step
outputs:
hog: ${{ steps.filter.outputs.hog || '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
- uses: actions/checkout@v6
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
if: github.event_name != 'push' # Run all tests on master push
with:
filters: |
hog:
# Avoid running tests for irrelevant changes
- 'common/hogvm/**/*'
- 'posthog/hogql/**/*'
- 'bin/hog'
- 'bin/hoge'
- 'package.json'
- requirements.txt
- requirements-dev.txt
- .github/workflows/ci-hog.yml
hog-tests:
needs: changes
timeout-minutes: 30
name: Hog tests
runs-on: ubuntu-24.04
if: needs.changes.outputs.hog == 'true'
outputs:
committed-version: ${{ steps.check-package-version.outputs.committed-version }}
published-version: ${{ steps.check-package-version.outputs.published-version }}
is-new-version: ${{ steps.check-package-version.outputs.is-new-version }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version-file: 'pyproject.toml'
- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
with:
version: '0.10.2' # pinned: unpinned setup-uv calls GH API on every job, exhausts rate limit
enable-cache: true
cache-dependency-glob: uv.lock
save-cache: ${{ github.ref == 'refs/heads/master' }}
- name: Install SAML (python3-saml) dependencies
if: steps.setup-uv.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install libxml2-dev libxmlsec1 libxmlsec1-dev libxmlsec1-openssl
- name: Install Python dependencies
run: |
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Fix node-gyp permissions
run: chmod +x ~/setup-pnpm/node_modules/.pnpm/pnpm@*/node_modules/pnpm/dist/node_modules/node-gyp/gyp/gyp_main.py
- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
cache: 'pnpm'
- name: Check if ANTLR definitions are up to date
run: |
cd ..
sudo apt-get update && sudo apt-get install default-jre
mkdir antlr
cd antlr
curl -o antlr.jar https://www.antlr.org/download/antlr-$ANTLR_VERSION-complete.jar
export PWD=`pwd`
echo '#!/bin/bash' > antlr
echo "java -jar $PWD/antlr.jar \$*" >> antlr
chmod +x antlr
export CLASSPATH=".:$PWD/antlr.jar:$CLASSPATH"
export PATH="$PWD:$PATH"
cd ../posthog
antlr | grep "Version"
npm run grammar:build && git diff --exit-code
env:
# Installing a version of ANTLR compatible with what's in Homebrew as of August 2024 (version 4.13.2),
# as apt-get is quite out of date. The same version must be set in common/hogql_parser/pyproject.toml
ANTLR_VERSION: '4.13.2'
- name: Check if STL bytecode is up to date
run: |
python -m common.hogvm.stl.compile
git diff --exit-code
env:
TEST: 1
- name: Run HogVM Python tests
run: |
pytest common/hogvm
- name: Run HogVM TypeScript tests
run: |
pnpm --filter=@posthog/hogvm install --frozen-lockfile
pnpm --filter=@posthog/hogvm test
- name: Run Hog tests
run: |
pnpm --filter=@posthog/hogvm install --frozen-lockfile
pnpm --filter=@posthog/hogvm compile:stl
bin/turbo --filter=@posthog/hogvm build
cd common/hogvm
./test.sh && git diff --exit-code
env:
TEST: 1
- name: Check package version and detect an update
id: check-package-version
uses: PostHog/check-package-version@138438a8fed9213fa112f841b1c89f9bd68f5cca # v2.1.0
with:
path: common/hogvm/typescript
release-hogvm:
name: Release new HogVM TypeScript version
runs-on: ubuntu-24.04
timeout-minutes: 5
needs: hog-tests
if: needs.hog-tests.outputs.is-new-version == 'true'
permissions:
contents: read
id-token: write
env:
COMMITTED_VERSION: ${{ needs.hog-tests.outputs.committed-version }}
PUBLISHED_VERSION: ${{ needs.hog-tests.outputs.published-version }}
steps:
- name: Checkout the repository
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version-file: 'pyproject.toml'
- name: Install uv
id: setup-uv-hogql-python
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
with:
version: '0.10.2' # pinned: unpinned setup-uv calls GH API on every job, exhausts rate limit
enable-cache: true
cache-dependency-glob: uv.lock
save-cache: ${{ github.ref == 'refs/heads/master' }}
- name: Install SAML (python3-saml) dependencies
if: steps.setup-uv-hogql-python.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install libxml2-dev libxmlsec1 libxmlsec1-dev libxmlsec1-openssl
- name: Install Python dependencies
run: |
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Fix node-gyp permissions
run: chmod +x ~/setup-pnpm/node_modules/.pnpm/pnpm@*/node_modules/pnpm/dist/node_modules/node-gyp/gyp/gyp_main.py
- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
cache: 'pnpm'
registry-url: https://registry.npmjs.org
- name: Install package.json dependencies
run: pnpm --filter=@posthog/hogvm install --frozen-lockfile
- name: Publish the package in the npm registry
run: cd common/hogvm/typescript && npm publish --access public