Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 93 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,31 @@ on:
- '.github/workflows/e2e.yml'
workflow_dispatch: {}

env:
BASE_IMAGE: ghcr.io/use-tusk/drift-python-sdk/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: |
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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 }}" \
Expand All @@ -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 ${{ needs.build-base.outputs.image }}

- name: Run E2E tests for ${{ matrix.library }}
env:
DOCKER_DEFAULT_PLATFORM: linux/amd64
TUSK_CLI_VERSION: ${{ steps.tusk-version.outputs.version }}
# 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
Expand Down
3 changes: 2 additions & 1 deletion drift/instrumentation/aiohttp/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion drift/instrumentation/aiohttp/e2e-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drift/instrumentation/django/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion drift/instrumentation/django/e2e-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drift/instrumentation/fastapi/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion drift/instrumentation/fastapi/e2e-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drift/instrumentation/flask/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion drift/instrumentation/flask/e2e-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drift/instrumentation/grpc/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion drift/instrumentation/grpc/e2e-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drift/instrumentation/httpx/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion drift/instrumentation/httpx/e2e-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drift/instrumentation/psycopg/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion drift/instrumentation/psycopg/e2e-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drift/instrumentation/psycopg2/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drift/instrumentation/redis/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion drift/instrumentation/redis/e2e-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drift/instrumentation/requests/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drift/instrumentation/urllib3/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion drift/instrumentation/urllib3/e2e-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down