mirror of
https://github.com/BillyOutlast/posthog.git
synced 2026-02-04 03:01:23 +01:00
206 lines
8.1 KiB
YAML
206 lines
8.1 KiB
YAML
# 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
|
|
paths-ignore:
|
|
- rust/**
|
|
- livestream/**
|
|
pull_request:
|
|
paths-ignore:
|
|
- rust/**
|
|
- livestream/**
|
|
|
|
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
|
|
# Set job outputs to values from filter step
|
|
outputs:
|
|
hog: ${{ steps.filter.outputs.hog }}
|
|
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@v4
|
|
|
|
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2
|
|
id: filter
|
|
with:
|
|
filters: |
|
|
hog:
|
|
# Avoid running tests for irrelevant changes
|
|
- 'common/hogvm/**/*'
|
|
- 'posthog/hogql/**/*'
|
|
- 'bin/hog'
|
|
- 'bin/hoge'
|
|
- 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'
|
|
|
|
steps:
|
|
# If this run wasn't initiated by the bot (meaning: snapshot update) and we've determined
|
|
# there are backend changes, cancel previous runs
|
|
- uses: n1hility/cancel-previous-runs@e709d8e41b16d5d0b8d529d293c5e126c57dc022 # v3
|
|
if: github.actor != 'posthog-bot'
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version-file: 'pyproject.toml'
|
|
|
|
- name: Install uv
|
|
id: setup-uv
|
|
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
|
|
with:
|
|
enable-cache: true
|
|
version: 0.8.19
|
|
|
|
- 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@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18
|
|
cache: 'pnpm'
|
|
|
|
- name: Check if ANTLR definitions are up to date
|
|
run: |
|
|
cd ..
|
|
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
|
|
|
|
- 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
|
|
|
|
check-package-version:
|
|
name: Check HogVM TypeScript package version and detect an update
|
|
needs: hog-tests
|
|
if: needs.hog-tests.result == 'success' && needs.changes.outputs.hog == 'true'
|
|
runs-on: ubuntu-24.04
|
|
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:
|
|
- name: Checkout the repository
|
|
uses: actions/checkout@v4
|
|
- name: Check package version and detect an update
|
|
id: check-package-version
|
|
uses: PostHog/check-package-version@v2
|
|
with:
|
|
path: common/hogvm/typescript
|
|
|
|
release-hogvm:
|
|
name: Release new HogVM TypeScript version
|
|
runs-on: ubuntu-24.04
|
|
needs: check-package-version
|
|
if: needs.changes.outputs.hog == 'true' && needs.check-package-version.outputs.is-new-version == 'true'
|
|
env:
|
|
COMMITTED_VERSION: ${{ needs.check-package-version.outputs.committed-version }}
|
|
PUBLISHED_VERSION: ${{ needs.check-package-version.outputs.published-version }}
|
|
steps:
|
|
- name: Checkout the repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version-file: 'pyproject.toml'
|
|
- name: Install uv
|
|
id: setup-uv-hogql-python
|
|
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
|
|
with:
|
|
enable-cache: true
|
|
version: 0.8.19
|
|
- 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@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
|
|
- name: Set up Node 18
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18
|
|
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
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
- name: Sleep 60 seconds to allow npm to update the package
|
|
run: sleep 60
|