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): smoke the sandbox agent inside the image build (#106654)

Alessandro Pogliaghie811d1752958
diff --git a/.github/scripts/test_sandbox_agent_release.py b/.github/scripts/test_sandbox_agent_release.py
index f6f8b9b30740..6171121a7c2b 100644
--- a/.github/scripts/test_sandbox_agent_release.py
+++ b/.github/scripts/test_sandbox_agent_release.py
@@ -181,25 +181,12 @@ def test_gateway_rejects_image_runs_outside_the_bump_pr(
assert not (tmp_path / "output").exists()
-def test_packaging_smoke_uses_each_platform_digest(tmp_path: Path) -> None:
- image = "ghcr.io/posthog/posthog-sandbox-base"
- digests = {"amd64": "sha256:" + "c" * 64, "arm64": "sha256:" + "d" * 64}
- dockerfile = tmp_path / "products/tasks/backend/sandbox/images/Dockerfile.sandbox-base"
- dockerfile.parent.mkdir(parents=True)
- dockerfile.write_text("ARG AGENT_VERSION=2.0.1\n")
- manifest = {
- "manifests": [
- {"platform": {"os": "linux", "architecture": arch}, "digest": digest} for arch, digest in digests.items()
- ]
- }
[email protected]("platforms,ok", [("linux/amd64\nlinux/arm64\n", True), ("linux/amd64\n", False)])
+def test_packaging_smoke_requires_both_platform_manifests(tmp_path: Path, platforms: str, ok: bool) -> None:
docker = """
docker() {
case "$*" in
- "manifest inspect "*) printf '%s' "$MANIFEST" ;;
- "run "*)
- printf '%s %s\\n' "$4" "$5" >> "$RUNNER_TEMP/containers"
- printf '%s' "$PINNED"
- ;;
+ "buildx imagetools inspect "*) printf '%s' "$PLATFORMS" ;;
*) return 1 ;;
esac
}
@@ -207,11 +194,7 @@ docker() {
result = run(
tmp_path,
docker + script(BUILD, "smoke", "sandbox_base_build"),
- IMAGE=f"{image}@{DIGEST}",
- MANIFEST=json.dumps(manifest),
- PINNED="2.0.1",
+ IMAGE=f"ghcr.io/posthog/posthog-sandbox-base@{DIGEST}",
+ PLATFORMS=platforms,
)
- assert result.returncode == 0, result.stderr
- assert (tmp_path / "containers").read_text().splitlines() == [
- f"linux/{arch} {image}@{digest}" for arch, digest in digests.items() for _ in range(2)
- ]
+ assert (result.returncode == 0) == ok, result.stderr
diff --git a/.github/workflows/cd-sandbox-base-image.yml b/.github/workflows/cd-sandbox-base-image.yml
index 125b8a0731cd..6616f933afc9 100644
--- a/.github/workflows/cd-sandbox-base-image.yml
+++ b/.github/workflows/cd-sandbox-base-image.yml
@@ -338,9 +338,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- - name: Set up QEMU
- uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
-
- name: Set up Depot CLI
uses: depot/setup-action@15c09a5f77a0840ad4bce955686522a257853461 # v1.7.1
@@ -412,7 +409,7 @@ jobs:
path: ${{ runner.temp }}/sandbox-base-image.json
if-no-files-found: error
- - name: Smoke the installed agent on both architectures
+ - name: Check the pushed image lists both architectures
id: smoke
if: >-
!cancelled() && steps.build.outcome == 'success' &&
@@ -421,23 +418,14 @@ jobs:
env:
IMAGE: ghcr.io/posthog/posthog-sandbox-base@${{ steps.build.outputs.digest }}
run: |
- pinned=$(sed -n 's/^ARG AGENT_VERSION=//p' products/tasks/backend/sandbox/images/Dockerfile.sandbox-base)
- manifest=$(docker manifest inspect "$IMAGE")
+ platforms=$(docker buildx imagetools inspect "$IMAGE" \
+ --format '{{range .Manifest.Manifests}}{{.Platform.OS}}/{{.Platform.Architecture}}{{"\n"}}{{end}}')
for platform in linux/amd64 linux/arm64; do
- echo "::group::$platform"
- digest=$(jq -er --arg platform "$platform" '.manifests[] |
- select((.platform.os + "/" + .platform.architecture) == $platform) | .digest' <<< "$manifest")
- platform_image="${IMAGE%@*}@$digest"
- installed=$(docker run --rm --platform "$platform" "$platform_image" \
- node -p "require('/scripts/node_modules/@posthog/agent/package.json').version")
- if [ "$installed" != "$pinned" ]; then
- echo "::error::$platform image has @posthog/agent $installed, Dockerfile pins $pinned"
+ if ! grep -qx "$platform" <<< "$platforms"; then
+ echo "::error::$IMAGE has no $platform manifest"
exit 1
fi
- docker run --rm --platform "$platform" "$platform_image" \
- /scripts/node_modules/.bin/agent-server --help >/dev/null
- echo "@posthog/agent $installed starts on $platform"
- echo "::endgroup::"
+ echo "$IMAGE serves $platform"
done
- name: Promote the smoked base image to :master
diff --git a/products/tasks/backend/sandbox/images/Dockerfile.sandbox-base b/products/tasks/backend/sandbox/images/Dockerfile.sandbox-base
index fc40e576d742..81e83d89a4fb 100644
--- a/products/tasks/backend/sandbox/images/Dockerfile.sandbox-base
+++ b/products/tasks/backend/sandbox/images/Dockerfile.sandbox-base
@@ -205,6 +205,11 @@ WORKDIR /tmp/workspace
RUN python3 --version && \
node --version && \
- npm --version
+ npm --version && \
+ installed="$(node -p "require('/scripts/node_modules/@posthog/agent/package.json').version")" && \
+ if [ "$installed" != "${AGENT_VERSION}" ]; then \
+ echo "installed @posthog/agent $installed, expected ${AGENT_VERSION}" >&2; exit 1; \
+ fi && \
+ /scripts/node_modules/.bin/agent-server --help >/dev/null
CMD ["/bin/bash"]