diff --git a/.github/workflows/build-and-deploy-prod.yml b/.github/workflows/build-and-deploy-prod.yml
index 3e491cd25dcc5..3ca21341d11aa 100644
--- a/.github/workflows/build-and-deploy-prod.yml
+++ b/.github/workflows/build-and-deploy-prod.yml
@@ -7,6 +7,8 @@ on:
push:
branches:
- master
+ paths-ignore:
+ - 'rust/**'
jobs:
slack:
diff --git a/.github/workflows/ci-hog.yml b/.github/workflows/ci-hog.yml
index 7e6a5caf94005..db26722eb7e84 100644
--- a/.github/workflows/ci-hog.yml
+++ b/.github/workflows/ci-hog.yml
@@ -51,7 +51,7 @@ jobs:
# 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@v3
- if: github.actor != 'posthog-bot' && needs.changes.outputs.backend == 'true'
+ if: github.actor != 'posthog-bot' && needs.changes.outputs.hog == 'true'
with:
token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/container-images-cd.yml b/.github/workflows/container-images-cd.yml
index 9611588bc1700..ec353909ae486 100644
--- a/.github/workflows/container-images-cd.yml
+++ b/.github/workflows/container-images-cd.yml
@@ -13,6 +13,8 @@ on:
push:
branches:
- master
+ paths-ignore:
+ - 'rust/**'
workflow_dispatch:
jobs:
@@ -120,17 +122,22 @@ jobs:
- name: Trigger Batch Exports Temporal Worker Cloud deployment
if: steps.check_changes_batch_exports_temporal_worker.outputs.changed == 'true'
- uses: mvasigh/dispatch-action@main
+ uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.deployer.outputs.token }}
- repo: charts
- owner: PostHog
- event_type: temporal_worker_deploy
- message: |
+ repository: PostHog/charts
+ event-type: commit_state_update
+ client-payload: |
{
- "image_tag": "${{ steps.build.outputs.digest }}",
- "worker_name": "temporal-worker",
- "context": ${{ toJson(github) }}
+ "values": {
+ "image": {
+ "sha": "${{ steps.build.outputs.digest }}"
+ }
+ },
+ "release": "temporal-worker",
+ "commit": ${{ toJson(github.event.head_commit) }},
+ "repository": ${{ toJson(github.repository) }},
+ "labels": ${{ steps.labels.outputs.labels }}
}
- name: Check for changes that affect general purpose temporal worker
@@ -140,17 +147,22 @@ jobs:
- name: Trigger General Purpose Temporal Worker Cloud deployment
if: steps.check_changes_general_purpose_temporal_worker.outputs.changed == 'true'
- uses: mvasigh/dispatch-action@main
+ uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.deployer.outputs.token }}
- repo: charts
- owner: PostHog
- event_type: temporal_worker_deploy
- message: |
+ repository: PostHog/charts
+ event-type: commit_state_update
+ client-payload: |
{
- "image_tag": "${{ steps.build.outputs.digest }}",
- "worker_name": "temporal-worker-general-purpose",
- "context": ${{ toJson(github) }}
+ "values": {
+ "image": {
+ "sha": "${{ steps.build.outputs.digest }}"
+ }
+ },
+ "release": "temporal-worker-general-purpose",
+ "commit": ${{ toJson(github.event.head_commit) }},
+ "repository": ${{ toJson(github.repository) }},
+ "labels": ${{ steps.labels.outputs.labels }}
}
- name: Check for changes that affect data warehouse temporal worker
@@ -160,15 +172,20 @@ jobs:
- name: Trigger Data Warehouse Temporal Worker Cloud deployment
if: steps.check_changes_data_warehouse_temporal_worker.outputs.changed == 'true'
- uses: mvasigh/dispatch-action@main
+ uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.deployer.outputs.token }}
- repo: charts
- owner: PostHog
- event_type: temporal_worker_deploy
- message: |
+ repository: PostHog/charts
+ event-type: commit_state_update
+ client-payload: |
{
- "image_tag": "${{ steps.build.outputs.digest }}",
- "worker_name": "temporal-worker-data-warehouse",
- "context": ${{ toJson(github) }}
+ "values": {
+ "image": {
+ "sha": "${{ steps.build.outputs.digest }}"
+ }
+ },
+ "release": "temporal-worker-data-warehouse",
+ "commit": ${{ toJson(github.event.head_commit) }},
+ "repository": ${{ toJson(github.repository) }},
+ "labels": ${{ steps.labels.outputs.labels }}
}
diff --git a/rust/.github/workflows/docker-build.yml b/.github/workflows/rust-docker-build.yml
similarity index 78%
rename from rust/.github/workflows/docker-build.yml
rename to .github/workflows/rust-docker-build.yml
index 94f36ef0d249b..d44e5d847e601 100644
--- a/rust/.github/workflows/docker-build.yml
+++ b/.github/workflows/rust-docker-build.yml
@@ -3,8 +3,10 @@ name: Build container images
on:
workflow_dispatch:
push:
+ paths:
+ - 'rust/**'
branches:
- - 'main'
+ - 'master'
jobs:
build:
@@ -22,9 +24,19 @@ jobs:
contents: read # allow reading the repo contents
packages: write # allow push to ghcr.io
+ defaults:
+ run:
+ working-directory: rust
+
steps:
- name: Check Out Repo
+ # 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@v3
+ with:
+ sparse-checkout: 'rust/'
+ sparse-checkout-cone-mode: false
- name: Set up Depot CLI
uses: depot/setup-action@v1
@@ -41,6 +53,7 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
+ logout: false
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
@@ -49,7 +62,7 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
- images: ghcr.io/posthog/hog-rs/${{ matrix.image }}
+ images: ghcr.io/posthog/posthog/${{ matrix.image }}
tags: |
type=ref,event=pr
type=ref,event=branch
@@ -65,8 +78,8 @@ jobs:
id: docker_build
uses: depot/build-push-action@v1
with:
- context: ./
- file: ./Dockerfile
+ context: ./rust/
+ file: ./rust/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
diff --git a/rust/.github/workflows/docker-migrator.yml b/.github/workflows/rust-hook-migrator-docker.yml
similarity index 80%
rename from rust/.github/workflows/docker-migrator.yml
rename to .github/workflows/rust-hook-migrator-docker.yml
index 69f14acd83fa8..2dd7c01d015dc 100644
--- a/rust/.github/workflows/docker-migrator.yml
+++ b/.github/workflows/rust-hook-migrator-docker.yml
@@ -3,8 +3,10 @@ name: Build hook-migrator docker image
on:
workflow_dispatch:
push:
+ paths:
+ - 'rust/**'
branches:
- - 'main'
+ - 'master'
permissions:
packages: write
@@ -18,9 +20,19 @@ jobs:
contents: read # allow reading the repo contents
packages: write # allow push to ghcr.io
+ defaults:
+ run:
+ working-directory: rust
+
steps:
- name: Check Out Repo
+ # 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@v3
+ with:
+ sparse-checkout: 'rust/'
+ sparse-checkout-cone-mode: false
- name: Set up Depot CLI
uses: depot/setup-action@v1
@@ -61,8 +73,8 @@ jobs:
id: docker_build_hook_migrator
uses: depot/build-push-action@v1
with:
- context: ./
- file: ./Dockerfile.migrate
+ context: ./rust/
+ file: ./rust/Dockerfile.migrate
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
new file mode 100644
index 0000000000000..c2c379334980e
--- /dev/null
+++ b/.github/workflows/rust.yml
@@ -0,0 +1,192 @@
+name: Rust
+
+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-latest
+ 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@v3
+ - uses: dorny/paths-filter@v2
+ id: filter
+ with:
+ filters: |
+ rust:
+ # Avoid running rust tests for irrelevant changes
+ - 'rust/**'
+
+ build:
+ 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@v3
+ 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@1.77
+
+ - uses: actions/cache@v3
+ if: needs.changes.outputs.rust == 'true'
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
+
+ - 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:
+ needs: changes
+ runs-on: depot-ubuntu-22.04-4
+ timeout-minutes: 10
+
+ 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@v3
+ if: needs.changes.outputs.rust == 'true'
+ with:
+ sparse-checkout: 'rust/'
+ sparse-checkout-cone-mode: false
+
+ - name: Login to DockerHub
+ if: needs.changes.outputs.rust == 'true'
+ uses: docker/login-action@v2
+ with:
+ username: posthog
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Setup dependencies
+ if: needs.changes.outputs.rust == 'true'
+ run: |
+ docker compose up kafka redis db echo_server -d --wait
+ docker compose up setup_test_db
+ echo "127.0.0.1 kafka" | sudo tee -a /etc/hosts
+
+ - name: Install rust
+ if: needs.changes.outputs.rust == 'true'
+ uses: dtolnay/rust-toolchain@1.77
+
+ - uses: actions/cache@v3
+ if: needs.changes.outputs.rust == 'true'
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: ${ runner.os }-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
+
+ - name: Run cargo test
+ if: needs.changes.outputs.rust == 'true'
+ run: cargo test --all-features
+
+ linting:
+ 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@v3
+ 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@1.77
+ with:
+ components: clippy,rustfmt
+
+ - uses: actions/cache@v3
+ if: needs.changes.outputs.rust == 'true'
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ rust/target
+ key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
+
+ - 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 -- -D warnings
+
+ - name: Run cargo check
+ if: needs.changes.outputs.rust == 'true'
+ run: cargo check --all-features
+
+ shear:
+ 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@v3
+ 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@main
+
+ - name: Install cargo-shear
+ if: needs.changes.outputs.rust == 'true'
+ run: cargo binstall --no-confirm cargo-shear
+
+ - run: cargo shear
+ if: needs.changes.outputs.rust == 'true'
diff --git a/README.md b/README.md
index f261c5f98d466..fcdeaa17cdadc 100644
--- a/README.md
+++ b/README.md
@@ -19,13 +19,15 @@
- See PostHog in action
+
See PostHog in action
([
},
],
})),
- events(({ actions, cache, props }) => ({
+ events(({ actions, cache, props, values }) => ({
afterMount: () => {
if (props.id) {
if (props.dashboard) {
@@ -843,7 +844,7 @@ export const dashboardLogic = kea
You can now use key "{key.label}" for authentication:
-