Skip to content

: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.

chore(ci): stop building rust images on every pr push (#118067)

Raúl Negrón-Oteroc0949e6c44db
diff --git a/.github/workflows/rust-docker-build.yml b/.github/workflows/rust-docker-build.yml
index 7c2829dc19be..5e9bcb778c52 100644
--- a/.github/workflows/rust-docker-build.yml
+++ b/.github/workflows/rust-docker-build.yml
@@ -5,6 +5,7 @@ name: Build and deploy rust container images
# workflow_dispatch builds all images unless image-filter names a subset (escape hatch).
#
# Image list: .github/rust-images.yml
+# PR images: .github/workflows/rust-smoke-test-build.yml (smoke_test labels)
# Build steps: .github/workflows/_rust-build-images.yml
# Affected-set computation: rust/affected-services (Rust binary crate)
@@ -25,33 +26,18 @@ on:
- '.github/rust-images.yml'
branches:
- 'master'
- pull_request:
- paths:
- - 'rust/**'
- - 'proto/**'
- - '.github/workflows/rust-docker-build.yml'
- - '.github/workflows/_rust-build-images.yml'
- - '.github/rust-images.yml'
- branches:
- - 'master'
concurrency:
- group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
- cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: false
jobs:
affected:
name: compute affected images
runs-on: ubuntu-24.04
timeout-minutes: 10
- # Skip on workflow_dispatch — always build everything (escape hatch)
- # Skipped on trunk-merge/** branches: merge-queue PRs are ephemeral, nothing
- # pulls images pushed for them, and each constituent PR already built its own.
- if: >-
- github.event_name != 'workflow_dispatch' &&
- !startsWith(github.head_ref, 'trunk-merge/') &&
- (github.event_name != 'pull_request' ||
- github.event.pull_request.head.repo.full_name == 'PostHog/posthog')
+ # workflow_dispatch skips this job and builds everything.
+ if: github.event_name != 'workflow_dispatch'
permissions:
contents: read
outputs:
@@ -78,31 +64,22 @@ jobs:
uses: ./.github/actions/rust-compute-affected
with:
event-name: ${{ github.event_name }}
- pr-base-sha: ${{ github.event.pull_request.base.sha }}
push-before-sha: ${{ github.event.before }}
build-images:
needs: affected
- # A status function is required because 'affected' may be skipped (workflow_dispatch)
- # and a skipped need would otherwise cascade a skip here. !cancelled() covers that
- # while still stopping the build after manual workflow cancellation.
- # Run unless affected explicitly found zero images ('none') or failed.
- # The trunk-merge guard is repeated here because a skipped 'affected' leaves
- # image-filter empty, which this condition would otherwise treat as buildable.
+ # !cancelled() keeps this job alive when workflow_dispatch skips 'affected',
+ # and still stops it after a manual cancellation.
if: |
!cancelled() &&
- !startsWith(github.head_ref, 'trunk-merge/') &&
- (github.event_name != 'pull_request' ||
- github.event.pull_request.head.repo.full_name == 'PostHog/posthog') &&
needs.affected.result != 'failure' &&
needs.affected.outputs.image-filter != 'none'
uses: ./.github/workflows/_rust-build-images.yml
with:
- # Only the canonical deploy repo pushes prod images on master; PRs still push for validation.
- push: ${{ github.event_name == 'pull_request' || vars.CD_DEPLOY_ENABLED == 'true' }}
+ # Only the deploy repo pushes images.
+ push: ${{ vars.CD_DEPLOY_ENABLED == 'true' }}
image-filter: ${{ needs.affected.outputs.image-filter || inputs.image-filter || '' }}
tag-rules: |
- type=ref,event=pr
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
diff --git a/rust/AGENTS.md b/rust/AGENTS.md
index c03f50f95fc0..236a8abd0066 100644
--- a/rust/AGENTS.md
+++ b/rust/AGENTS.md
@@ -12,3 +12,11 @@ When emitting metrics via the `metrics` crate (`histogram!`, `counter!`, `gauge!
## personhog
- **A change to the publish outbox contract between `personhog-identity` and `personhog-publisher` lands in the publisher first, in its own PR, and in identity in a later PR.** The two are separate deployments with no ordering between them. The contract (the outbox row shapes, the `lifecycle_op_person.moved` entries, the pointer cursor, the GC guard) is listed under "Publish outbox contract" in [personhog-identity/README.md](personhog-identity/README.md). Read it before you change `rust/personhog-identity/src/publish/`, the outbox writers in `src/lifecycle/` and `src/storage/`, or a persons migration that touches the outbox or `lifecycle_op_person`.
+
+## Container images
+
+A pull request builds no Rust image unless it carries a `smoke_test:<image>` label (one image) or `smoke_test` (all images).
+`ci-rust.yml` compiles every affected crate, so a code change needs no image build.
+Add a label when the change can break the image build but not `cargo build`: a new binary or image entry, a `build.rs` or system dependency change, a new workspace crate, or a Dockerfile edit.
+Add one too when the PR needs a deployable image.
+Master builds and deploys after merge, and a broken image stops that deploy.
diff --git a/rust/affected-services/determinator-rules.toml b/rust/affected-services/determinator-rules.toml
index 8397866671c3..431b76d5e832 100644
--- a/rust/affected-services/determinator-rules.toml
+++ b/rust/affected-services/determinator-rules.toml
@@ -84,6 +84,12 @@ mark-changed = "all"
globs = ["../**"]
mark-changed = []
+# An unmatched workspace-root file marks every crate, and the default rules
+# do not match AGENTS.md.
+[[path-rule]]
+globs = ["AGENTS.md"]
+mark-changed = []
+
# Migration directories are not cargo crates. Tell the determinator to
# ignore them (don't try ancestor-walk package matching). The sqlx-migrate
# image trigger is handled in custom code outside the determinator.
diff --git a/rust/affected-services/tests/integration.rs b/rust/affected-services/tests/integration.rs
index dfb732c82cdc..57351a49d8ed 100644
--- a/rust/affected-services/tests/integration.rs
+++ b/rust/affected-services/tests/integration.rs
@@ -70,10 +70,12 @@ fn rebuild_all_marks_every_workspace_crate() {
#[test]
fn file_outside_workspace_produces_no_crates() {
let (graph, images) = load_test_fixtures();
- let result = compute_affected(&["README.md".into()], None, &graph, &images).unwrap();
- assert!(!result.rebuild_all);
- assert!(result.crates.is_empty());
- assert!(result.images.is_empty());
+ for file in ["README.md", "rust/AGENTS.md"] {
+ let result = compute_affected(&[file.into()], None, &graph, &images).unwrap();
+ assert!(!result.rebuild_all, "{file} must not mark every crate");
+ assert!(result.crates.is_empty());
+ assert!(result.images.is_empty());
+ }
}
#[test]