Skip to content

chore(deps): upgrade to Python 3.13 #53629

chore(deps): upgrade to Python 3.13

chore(deps): upgrade to Python 3.13 #53629

Workflow file for this run

name: Rust CI
on:
workflow_dispatch:
push:
branches: [master, main]
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
# Job to decide if we should run rust ci
# See https://github.com/dorny/paths-filter#conditional-execution for more details
changes:
runs-on: ubuntu-24.04
timeout-minutes: 5
if: github.repository == 'PostHog/posthog'
name: Determine need to run Rust checks
# Set job outputs to values from filter step
outputs:
rust: ${{ steps.filter.outputs.rust }}
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: |
rust:
# Avoid running rust tests for irrelevant changes
- 'rust/**'
- '.github/workflows/ci-rust.yml'
- '.github/workflows/rust.yml'
- '.github/workflows/rust-docker-build.yml'
- 'posthog/management/commands/setup_test_environment.py'
- 'posthog/migrations/**'
- 'ee/migrations/**'
- 'docker-compose.dev.yml'
build:
name: Build Rust services
needs: changes
runs-on: depot-ubuntu-22.04-4
defaults:
run:
working-directory: rust
steps:
# Checkout project code
# Use sparse checkout to only select files in rust directory
# Turning off cone mode ensures that files in the project root are not included during checkout
- uses: actions/checkout@v4
if: needs.changes.outputs.rust == 'true'
with:
sparse-checkout: 'rust/'
sparse-checkout-cone-mode: false
- name: Install rust
if: needs.changes.outputs.rust == 'true'
uses: dtolnay/rust-toolchain@6691ebadcb18182cc1391d07c9f295f657c593cd # 1.88
- name: Install sccache
if: needs.changes.outputs.rust == 'true'
uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
- name: Configure sccache
if: needs.changes.outputs.rust == 'true'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
sccache --start-server
- name: Run cargo build
if: needs.changes.outputs.rust == 'true'
run: cargo build --all --locked --release && find target/release/ -maxdepth 1 -executable -type f | xargs strip
test:
name: Test Rust services
strategy:
matrix:
package:
- batch-import-worker
- capture
- common-alloc
- common-cookieless
- common-compression
- common-database
- common-dns
- common-geoip
- common-hypercache
- common-metrics
- common-kafka
- common-profiler
- common-s3
- cyclotron-core
- cyclotron-node
- cyclotron-janitor
- cymbal
- embedding-worker
- feature-flags
- health
- hogvm
- hook-api
- hook-common
- hook-janitor
- hook-worker
- kafka-deduplicator
- limiters
- log-capture
- posthog-symbol-data
- property-defs-rs
- serve-metrics
needs: changes
runs-on: depot-ubuntu-24.04-4
timeout-minutes: 20
defaults:
run:
working-directory: rust
steps:
- uses: actions/checkout@v4
if: needs.changes.outputs.rust == 'true'
- name: Setup main repo and dependencies
if: needs.changes.outputs.rust == 'true'
run: |
docker compose -f ../docker-compose.dev.yml down
docker compose -f ../docker-compose.dev.yml up -d
echo "127.0.0.1 kafka clickhouse" | sudo tee -a /etc/hosts
- name: Dump Kafka logs on failure
if: failure()
run: |
docker ps -a || true
docker logs --tail=500 rust-kafka-1 || true
docker inspect rust-kafka-1 || true
# please keep the tag version here in sync with rust-version in rust/*/Cargo.toml
- name: Install rust
if: needs.changes.outputs.rust == 'true'
uses: dtolnay/rust-toolchain@6691ebadcb18182cc1391d07c9f295f657c593cd # 1.88
- name: Install sccache
if: needs.changes.outputs.rust == 'true'
uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
- name: Configure sccache
if: needs.changes.outputs.rust == 'true'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
sccache --start-server
- name: Set up Python
if: needs.changes.outputs.rust == 'true'
uses: actions/setup-python@v5
with:
python-version-file: 'pyproject.toml'
- name: Install uv
id: setup-uv
if: needs.changes.outputs.rust == 'true'
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
with:
enable-cache: true
version: 0.7.8
- name: Install SAML (python3-saml) dependencies
if: needs.changes.outputs.rust == 'true' && steps.setup-uv.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl postgresql-client
- name: Install python dependencies
if: needs.changes.outputs.rust == 'true'
run: |
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev --directory ..
- name: Install sqlx-cli
if: needs.changes.outputs.rust == 'true'
run: |
cargo install sqlx-cli --version 0.8.0 --features postgres --no-default-features --locked
- name: Set up databases
if: needs.changes.outputs.rust == 'true'
env:
DEBUG: 'true'
TEST: 'true'
SECRET_KEY: 'abcdef' # unsafe - for testing only
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog'
run: cd ../ && python manage.py setup_test_environment
- name: Run sqlx migrations
if: needs.changes.outputs.rust == 'true'
env:
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog_persons'
run: |
sqlx migrate run --source persons_migrations/
- name: Download MaxMind Database
if: needs.changes.outputs.rust == 'true'
run: |
cd ../ && ./bin/download-mmdb
- name: Run cargo test
if: needs.changes.outputs.rust == 'true'
env:
RUST_BACKTRACE: 1
# Set up dual database environment for feature-flags service
PERSONS_READ_DATABASE_URL: ${{ matrix.package == 'feature-flags' && 'postgres://posthog:posthog@localhost:5432/posthog_persons' || '' }}
PERSONS_WRITE_DATABASE_URL: ${{ matrix.package == 'feature-flags' && 'postgres://posthog:posthog@localhost:5432/posthog_persons' || '' }}
run: |
echo "Starting cargo test"
cargo test -p ${{matrix.package}}
echo "Cargo test completed"
linting:
name: Lint Rust services
needs: changes
runs-on: depot-ubuntu-22.04-4
defaults:
run:
working-directory: rust
steps:
# Checkout project code
# Use sparse checkout to only select files in rust directory
# Turning off cone mode ensures that files in the project root are not included during checkout
- uses: actions/checkout@v4
if: needs.changes.outputs.rust == 'true'
with:
sparse-checkout: 'rust/'
sparse-checkout-cone-mode: false
- name: Install rust
if: needs.changes.outputs.rust == 'true'
uses: dtolnay/rust-toolchain@6691ebadcb18182cc1391d07c9f295f657c593cd # 1.88
with:
components: clippy,rustfmt
- name: Install sccache
if: needs.changes.outputs.rust == 'true'
uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
- name: Configure sccache
if: needs.changes.outputs.rust == 'true'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
sccache --start-server
- name: Check format
if: needs.changes.outputs.rust == 'true'
run: cargo fmt -- --check
- name: Run clippy
if: needs.changes.outputs.rust == 'true'
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run cargo check
if: needs.changes.outputs.rust == 'true'
run: cargo check --all-features
shear:
name: Shear Rust services
needs: changes
runs-on: depot-ubuntu-22.04-4
defaults:
run:
working-directory: rust
steps:
# Checkout project code
# Use sparse checkout to only select files in rust directory
# Turning off cone mode ensures that files in the project root are not included during checkout
- uses: actions/checkout@v4
if: needs.changes.outputs.rust == 'true'
with:
sparse-checkout: 'rust/'
sparse-checkout-cone-mode: false
- name: Install cargo-binstall
if: needs.changes.outputs.rust == 'true'
uses: cargo-bins/cargo-binstall@5cbf019d8cb9b9d5b086218c41458ea35d817691 # main
- name: Install cargo-shear
if: needs.changes.outputs.rust == 'true'
run: cargo binstall --no-confirm [email protected]
- run: cargo shear
if: needs.changes.outputs.rust == 'true'