From 0efc2d312b29e0cca57d57b761e84d128924a862 Mon Sep 17 00:00:00 2001 From: JY Tan Date: Sun, 18 Jan 2026 22:25:59 -0800 Subject: [PATCH 1/3] Commit --- .github/workflows/e2e.yml | 96 ++++++++++++++++++- .../aiohttp/e2e-tests/Dockerfile | 3 +- .../aiohttp/e2e-tests/docker-compose.yml | 2 +- .../django/e2e-tests/Dockerfile | 3 +- .../django/e2e-tests/docker-compose.yml | 2 +- .../fastapi/e2e-tests/Dockerfile | 3 +- .../fastapi/e2e-tests/docker-compose.yml | 2 +- .../flask/e2e-tests/Dockerfile | 3 +- .../flask/e2e-tests/docker-compose.yml | 2 +- .../instrumentation/grpc/e2e-tests/Dockerfile | 3 +- .../grpc/e2e-tests/docker-compose.yml | 2 +- .../httpx/e2e-tests/Dockerfile | 3 +- .../httpx/e2e-tests/docker-compose.yml | 2 +- .../psycopg/e2e-tests/Dockerfile | 3 +- .../psycopg/e2e-tests/docker-compose.yml | 2 +- .../psycopg2/e2e-tests/Dockerfile | 3 +- .../psycopg2/e2e-tests/docker-compose.yml | 2 +- .../redis/e2e-tests/Dockerfile | 3 +- .../redis/e2e-tests/docker-compose.yml | 2 +- .../requests/e2e-tests/Dockerfile | 3 +- .../requests/e2e-tests/docker-compose.yml | 2 +- .../urllib3/e2e-tests/Dockerfile | 3 +- .../urllib3/e2e-tests/docker-compose.yml | 2 +- 23 files changed, 126 insertions(+), 25 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b67dad6..d7f6ac0 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -13,16 +13,31 @@ on: - '.github/workflows/e2e.yml' workflow_dispatch: {} +env: + BASE_IMAGE: ghcr.io/${{ github.repository }}/python-e2e-base + jobs: discover: name: Discover E2E Tests runs-on: ubuntu-latest outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} + is_fork: ${{ steps.check-fork.outputs.is_fork }} steps: - name: Checkout uses: actions/checkout@v4 + - name: Check if fork PR + id: check-fork + run: | + if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.pull_request.head.repo.fork }}" = "true" ]; then + echo "is_fork=true" >> $GITHUB_OUTPUT + echo "This is a fork PR - will build base image locally" + else + echo "is_fork=false" >> $GITHUB_OUTPUT + echo "Not a fork PR - will use GHCR cache" + fi + - name: Find all e2e-tests directories id: set-matrix run: | @@ -34,9 +49,68 @@ jobs: echo "Found libraries with e2e-tests: $LIBRARIES" echo "matrix=$LIBRARIES" >> $GITHUB_OUTPUT + build-base: + name: Build Base Image + runs-on: ubuntu-latest + needs: discover + # Skip for fork PRs (can't push to GHCR) + if: needs.discover.outputs.is_fork != 'true' + permissions: + contents: read + packages: write + outputs: + image: ${{ steps.meta.outputs.tags }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Get latest Tusk CLI version + id: tusk-version + run: | + VERSION=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/Use-Tusk/tusk-drift-cli/releases/latest" \ + | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Latest Tusk CLI version: $VERSION" + + - name: Generate base image tag + id: meta + run: | + # Create a content-based hash from Dockerfile + Tusk CLI version + HASH=$(cat drift/instrumentation/e2e_common/Dockerfile.base | sha256sum | cut -c1-12) + TAG="${HASH}-${{ steps.tusk-version.outputs.version }}" + echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "tags=${{ env.BASE_IMAGE }}:$TAG" >> $GITHUB_OUTPUT + + - name: Build and push base image + uses: docker/build-push-action@v5 + with: + context: . + file: drift/instrumentation/e2e_common/Dockerfile.base + push: true + tags: | + ${{ env.BASE_IMAGE }}:${{ steps.meta.outputs.tag }} + ${{ env.BASE_IMAGE }}:latest + build-args: | + TUSK_CLI_VERSION=${{ steps.tusk-version.outputs.version }} + cache-from: type=registry,ref=${{ env.BASE_IMAGE }}:cache + cache-to: type=registry,ref=${{ env.BASE_IMAGE }}:cache,mode=max + e2e: name: E2E Tests - ${{ matrix.library }} - needs: discover + needs: [discover, build-base] + # Run even if build-base was skipped (fork PRs) + if: always() && needs.discover.result == 'success' runs-on: ubuntu-latest timeout-minutes: 30 strategy: @@ -48,6 +122,14 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Login to GHCR + if: needs.discover.outputs.is_fork != 'true' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Install uv uses: astral-sh/setup-uv@v4 with: @@ -73,6 +155,7 @@ jobs: test -f dist/*.whl || (echo "SDK build incomplete!" && exit 1) - name: Get latest Tusk CLI version + if: needs.discover.outputs.is_fork == 'true' id: tusk-version run: | VERSION=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ @@ -81,20 +164,27 @@ jobs: echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Latest Tusk CLI version: $VERSION" - - name: Build base image + - name: Build base image locally (fork PRs only) + if: needs.discover.outputs.is_fork == 'true' env: DOCKER_DEFAULT_PLATFORM: linux/amd64 run: | + echo "Building base image locally (fork PR - no GHCR access)" docker build \ --build-arg TUSK_CLI_VERSION=${{ steps.tusk-version.outputs.version }} \ -t python-e2e-base:latest \ -f drift/instrumentation/e2e_common/Dockerfile.base \ . + - name: Pull base image from GHCR + if: needs.discover.outputs.is_fork != 'true' + run: docker pull ${{ env.BASE_IMAGE }}:latest + - name: Run E2E tests for ${{ matrix.library }} env: DOCKER_DEFAULT_PLATFORM: linux/amd64 - TUSK_CLI_VERSION: ${{ steps.tusk-version.outputs.version }} + # Use GHCR image for non-forks, local image for forks + BASE_IMAGE: ${{ needs.discover.outputs.is_fork == 'true' && 'python-e2e-base:latest' || format('{0}:latest', env.BASE_IMAGE) }} run: | chmod +x ./drift/instrumentation/${{ matrix.library }}/e2e-tests/run.sh cd ./drift/instrumentation/${{ matrix.library }}/e2e-tests && ./run.sh 8000 diff --git a/drift/instrumentation/aiohttp/e2e-tests/Dockerfile b/drift/instrumentation/aiohttp/e2e-tests/Dockerfile index c1c15be..ff4e6a4 100644 --- a/drift/instrumentation/aiohttp/e2e-tests/Dockerfile +++ b/drift/instrumentation/aiohttp/e2e-tests/Dockerfile @@ -1,4 +1,5 @@ -FROM python-e2e-base:latest +ARG BASE_IMAGE=python-e2e-base:latest +FROM ${BASE_IMAGE} # Copy SDK source for editable install COPY . /sdk diff --git a/drift/instrumentation/aiohttp/e2e-tests/docker-compose.yml b/drift/instrumentation/aiohttp/e2e-tests/docker-compose.yml index d298dba..c0af8d8 100644 --- a/drift/instrumentation/aiohttp/e2e-tests/docker-compose.yml +++ b/drift/instrumentation/aiohttp/e2e-tests/docker-compose.yml @@ -4,7 +4,7 @@ services: context: ../../../.. dockerfile: drift/instrumentation/aiohttp/e2e-tests/Dockerfile args: - - TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest} + - BASE_IMAGE=${BASE_IMAGE:-python-e2e-base:latest} environment: - PORT=8000 - TUSK_ANALYTICS_DISABLED=1 diff --git a/drift/instrumentation/django/e2e-tests/Dockerfile b/drift/instrumentation/django/e2e-tests/Dockerfile index 72f2ce4..05a8c36 100644 --- a/drift/instrumentation/django/e2e-tests/Dockerfile +++ b/drift/instrumentation/django/e2e-tests/Dockerfile @@ -1,4 +1,5 @@ -FROM python-e2e-base:latest +ARG BASE_IMAGE=python-e2e-base:latest +FROM ${BASE_IMAGE} # Copy SDK source for editable install COPY . /sdk diff --git a/drift/instrumentation/django/e2e-tests/docker-compose.yml b/drift/instrumentation/django/e2e-tests/docker-compose.yml index 72c8039..fdf0025 100644 --- a/drift/instrumentation/django/e2e-tests/docker-compose.yml +++ b/drift/instrumentation/django/e2e-tests/docker-compose.yml @@ -4,7 +4,7 @@ services: context: ../../../.. dockerfile: drift/instrumentation/django/e2e-tests/Dockerfile args: - - TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest} + - BASE_IMAGE=${BASE_IMAGE:-python-e2e-base:latest} environment: - PORT=8000 - TUSK_ANALYTICS_DISABLED=1 diff --git a/drift/instrumentation/fastapi/e2e-tests/Dockerfile b/drift/instrumentation/fastapi/e2e-tests/Dockerfile index 83a1649..4d240f1 100644 --- a/drift/instrumentation/fastapi/e2e-tests/Dockerfile +++ b/drift/instrumentation/fastapi/e2e-tests/Dockerfile @@ -1,4 +1,5 @@ -FROM python-e2e-base:latest +ARG BASE_IMAGE=python-e2e-base:latest +FROM ${BASE_IMAGE} # Copy SDK source for editable install COPY . /sdk diff --git a/drift/instrumentation/fastapi/e2e-tests/docker-compose.yml b/drift/instrumentation/fastapi/e2e-tests/docker-compose.yml index fdefeea..eaad76c 100644 --- a/drift/instrumentation/fastapi/e2e-tests/docker-compose.yml +++ b/drift/instrumentation/fastapi/e2e-tests/docker-compose.yml @@ -4,7 +4,7 @@ services: context: ../../../.. dockerfile: drift/instrumentation/fastapi/e2e-tests/Dockerfile args: - - TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest} + - BASE_IMAGE=${BASE_IMAGE:-python-e2e-base:latest} environment: - PORT=8000 - TUSK_ANALYTICS_DISABLED=1 diff --git a/drift/instrumentation/flask/e2e-tests/Dockerfile b/drift/instrumentation/flask/e2e-tests/Dockerfile index 7e23699..7aa158f 100644 --- a/drift/instrumentation/flask/e2e-tests/Dockerfile +++ b/drift/instrumentation/flask/e2e-tests/Dockerfile @@ -1,4 +1,5 @@ -FROM python-e2e-base:latest +ARG BASE_IMAGE=python-e2e-base:latest +FROM ${BASE_IMAGE} # Copy SDK source for editable install COPY . /sdk diff --git a/drift/instrumentation/flask/e2e-tests/docker-compose.yml b/drift/instrumentation/flask/e2e-tests/docker-compose.yml index b622476..f04450a 100644 --- a/drift/instrumentation/flask/e2e-tests/docker-compose.yml +++ b/drift/instrumentation/flask/e2e-tests/docker-compose.yml @@ -4,7 +4,7 @@ services: context: ../../../.. dockerfile: drift/instrumentation/flask/e2e-tests/Dockerfile args: - - TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest} + - BASE_IMAGE=${BASE_IMAGE:-python-e2e-base:latest} environment: - PORT=8000 - TUSK_ANALYTICS_DISABLED=1 diff --git a/drift/instrumentation/grpc/e2e-tests/Dockerfile b/drift/instrumentation/grpc/e2e-tests/Dockerfile index 91dc058..6426889 100644 --- a/drift/instrumentation/grpc/e2e-tests/Dockerfile +++ b/drift/instrumentation/grpc/e2e-tests/Dockerfile @@ -1,4 +1,5 @@ -FROM python-e2e-base:latest +ARG BASE_IMAGE=python-e2e-base:latest +FROM ${BASE_IMAGE} # Copy SDK source for editable install COPY . /sdk diff --git a/drift/instrumentation/grpc/e2e-tests/docker-compose.yml b/drift/instrumentation/grpc/e2e-tests/docker-compose.yml index a249d83..36a0211 100644 --- a/drift/instrumentation/grpc/e2e-tests/docker-compose.yml +++ b/drift/instrumentation/grpc/e2e-tests/docker-compose.yml @@ -4,7 +4,7 @@ services: context: ../../../.. dockerfile: drift/instrumentation/grpc/e2e-tests/Dockerfile args: - - TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest} + - BASE_IMAGE=${BASE_IMAGE:-python-e2e-base:latest} environment: - PORT=8000 - TUSK_ANALYTICS_DISABLED=1 diff --git a/drift/instrumentation/httpx/e2e-tests/Dockerfile b/drift/instrumentation/httpx/e2e-tests/Dockerfile index b9551db..6dcc56b 100644 --- a/drift/instrumentation/httpx/e2e-tests/Dockerfile +++ b/drift/instrumentation/httpx/e2e-tests/Dockerfile @@ -1,4 +1,5 @@ -FROM python-e2e-base:latest +ARG BASE_IMAGE=python-e2e-base:latest +FROM ${BASE_IMAGE} # Copy SDK source for editable install COPY . /sdk diff --git a/drift/instrumentation/httpx/e2e-tests/docker-compose.yml b/drift/instrumentation/httpx/e2e-tests/docker-compose.yml index e29c4e7..e90ce31 100644 --- a/drift/instrumentation/httpx/e2e-tests/docker-compose.yml +++ b/drift/instrumentation/httpx/e2e-tests/docker-compose.yml @@ -4,7 +4,7 @@ services: context: ../../../.. dockerfile: drift/instrumentation/httpx/e2e-tests/Dockerfile args: - - TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest} + - BASE_IMAGE=${BASE_IMAGE:-python-e2e-base:latest} environment: - PORT=8000 - TUSK_ANALYTICS_DISABLED=1 diff --git a/drift/instrumentation/psycopg/e2e-tests/Dockerfile b/drift/instrumentation/psycopg/e2e-tests/Dockerfile index a76f07a..d855825 100644 --- a/drift/instrumentation/psycopg/e2e-tests/Dockerfile +++ b/drift/instrumentation/psycopg/e2e-tests/Dockerfile @@ -1,4 +1,5 @@ -FROM python-e2e-base:latest +ARG BASE_IMAGE=python-e2e-base:latest +FROM ${BASE_IMAGE} # Copy SDK source for editable install COPY . /sdk diff --git a/drift/instrumentation/psycopg/e2e-tests/docker-compose.yml b/drift/instrumentation/psycopg/e2e-tests/docker-compose.yml index 53f51f8..e30a82a 100644 --- a/drift/instrumentation/psycopg/e2e-tests/docker-compose.yml +++ b/drift/instrumentation/psycopg/e2e-tests/docker-compose.yml @@ -16,7 +16,7 @@ services: context: ../../../.. dockerfile: drift/instrumentation/psycopg/e2e-tests/Dockerfile args: - - TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest} + - BASE_IMAGE=${BASE_IMAGE:-python-e2e-base:latest} depends_on: postgres: condition: service_healthy diff --git a/drift/instrumentation/psycopg2/e2e-tests/Dockerfile b/drift/instrumentation/psycopg2/e2e-tests/Dockerfile index 7fb20ce..7d8fe89 100644 --- a/drift/instrumentation/psycopg2/e2e-tests/Dockerfile +++ b/drift/instrumentation/psycopg2/e2e-tests/Dockerfile @@ -1,4 +1,5 @@ -FROM python-e2e-base:latest +ARG BASE_IMAGE=python-e2e-base:latest +FROM ${BASE_IMAGE} # Copy SDK source for editable install COPY . /sdk diff --git a/drift/instrumentation/psycopg2/e2e-tests/docker-compose.yml b/drift/instrumentation/psycopg2/e2e-tests/docker-compose.yml index fd74bd5..62af50d 100644 --- a/drift/instrumentation/psycopg2/e2e-tests/docker-compose.yml +++ b/drift/instrumentation/psycopg2/e2e-tests/docker-compose.yml @@ -16,7 +16,7 @@ services: context: ../../../.. dockerfile: drift/instrumentation/psycopg2/e2e-tests/Dockerfile args: - - TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest} + - BASE_IMAGE=${BASE_IMAGE:-python-e2e-base:latest} depends_on: postgres: condition: service_healthy diff --git a/drift/instrumentation/redis/e2e-tests/Dockerfile b/drift/instrumentation/redis/e2e-tests/Dockerfile index 49d02e7..aa47e5f 100644 --- a/drift/instrumentation/redis/e2e-tests/Dockerfile +++ b/drift/instrumentation/redis/e2e-tests/Dockerfile @@ -1,4 +1,5 @@ -FROM python-e2e-base:latest +ARG BASE_IMAGE=python-e2e-base:latest +FROM ${BASE_IMAGE} # Copy SDK source for editable install COPY . /sdk diff --git a/drift/instrumentation/redis/e2e-tests/docker-compose.yml b/drift/instrumentation/redis/e2e-tests/docker-compose.yml index 9e6df91..ebd2896 100644 --- a/drift/instrumentation/redis/e2e-tests/docker-compose.yml +++ b/drift/instrumentation/redis/e2e-tests/docker-compose.yml @@ -12,7 +12,7 @@ services: context: ../../../.. dockerfile: drift/instrumentation/redis/e2e-tests/Dockerfile args: - - TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest} + - BASE_IMAGE=${BASE_IMAGE:-python-e2e-base:latest} depends_on: redis: condition: service_healthy diff --git a/drift/instrumentation/requests/e2e-tests/Dockerfile b/drift/instrumentation/requests/e2e-tests/Dockerfile index 6964984..b2dfb34 100644 --- a/drift/instrumentation/requests/e2e-tests/Dockerfile +++ b/drift/instrumentation/requests/e2e-tests/Dockerfile @@ -1,4 +1,5 @@ -FROM python-e2e-base:latest +ARG BASE_IMAGE=python-e2e-base:latest +FROM ${BASE_IMAGE} # Copy SDK source for editable install COPY . /sdk diff --git a/drift/instrumentation/requests/e2e-tests/docker-compose.yml b/drift/instrumentation/requests/e2e-tests/docker-compose.yml index 31099f3..496ace4 100644 --- a/drift/instrumentation/requests/e2e-tests/docker-compose.yml +++ b/drift/instrumentation/requests/e2e-tests/docker-compose.yml @@ -4,7 +4,7 @@ services: context: ../../../.. dockerfile: drift/instrumentation/requests/e2e-tests/Dockerfile args: - - TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest} + - BASE_IMAGE=${BASE_IMAGE:-python-e2e-base:latest} environment: - PORT=8000 - TUSK_ANALYTICS_DISABLED=1 diff --git a/drift/instrumentation/urllib3/e2e-tests/Dockerfile b/drift/instrumentation/urllib3/e2e-tests/Dockerfile index f19a7c2..8f3a448 100644 --- a/drift/instrumentation/urllib3/e2e-tests/Dockerfile +++ b/drift/instrumentation/urllib3/e2e-tests/Dockerfile @@ -1,4 +1,5 @@ -FROM python-e2e-base:latest +ARG BASE_IMAGE=python-e2e-base:latest +FROM ${BASE_IMAGE} # Copy SDK source for editable install COPY . /sdk diff --git a/drift/instrumentation/urllib3/e2e-tests/docker-compose.yml b/drift/instrumentation/urllib3/e2e-tests/docker-compose.yml index 6accb34..9659b60 100644 --- a/drift/instrumentation/urllib3/e2e-tests/docker-compose.yml +++ b/drift/instrumentation/urllib3/e2e-tests/docker-compose.yml @@ -4,7 +4,7 @@ services: context: ../../../.. dockerfile: drift/instrumentation/urllib3/e2e-tests/Dockerfile args: - - TUSK_CLI_VERSION=${TUSK_CLI_VERSION:-latest} + - BASE_IMAGE=${BASE_IMAGE:-python-e2e-base:latest} environment: - PORT=8000 - TUSK_ANALYTICS_DISABLED=1 From b9b6b9672c16f19aca1b5b83fc60641797e72dbb Mon Sep 17 00:00:00 2001 From: JY Tan Date: Sun, 18 Jan 2026 22:28:26 -0800 Subject: [PATCH 2/3] Use lowercase org name --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index d7f6ac0..7d8848a 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -14,7 +14,7 @@ on: workflow_dispatch: {} env: - BASE_IMAGE: ghcr.io/${{ github.repository }}/python-e2e-base + BASE_IMAGE: ghcr.io/use-tusk/drift-python-sdk/python-e2e-base jobs: discover: From 6530662a43c2ea69afc0aa261f3b5149d11dceaf Mon Sep 17 00:00:00 2001 From: JY Tan Date: Sun, 18 Jan 2026 22:38:02 -0800 Subject: [PATCH 3/3] Use content-hashed based image tag --- .github/workflows/e2e.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 7d8848a..b166ab3 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -178,13 +178,13 @@ jobs: - name: Pull base image from GHCR if: needs.discover.outputs.is_fork != 'true' - run: docker pull ${{ env.BASE_IMAGE }}:latest + run: docker pull ${{ needs.build-base.outputs.image }} - name: Run E2E tests for ${{ matrix.library }} env: DOCKER_DEFAULT_PLATFORM: linux/amd64 - # Use GHCR image for non-forks, local image for forks - BASE_IMAGE: ${{ needs.discover.outputs.is_fork == 'true' && 'python-e2e-base:latest' || format('{0}:latest', env.BASE_IMAGE) }} + # Use content-hashed GHCR image for non-forks, local image for forks + BASE_IMAGE: ${{ needs.discover.outputs.is_fork == 'true' && 'python-e2e-base:latest' || needs.build-base.outputs.image }} run: | chmod +x ./drift/instrumentation/${{ matrix.library }}/e2e-tests/run.sh cd ./drift/instrumentation/${{ matrix.library }}/e2e-tests && ./run.sh 8000