Skip to content
Latchkey

Integration test against TestPyPI workflow (tensorlakeai/tensorlake)

The Integration test against TestPyPI workflow from tensorlakeai/tensorlake, explained and optimized by Latchkey.

B

CI health: B - good

Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: tensorlakeai/tensorlake.github/workflows/integration_test.yamlLicense Apache-2.0View source

What it does

This is the Integration test against TestPyPI workflow from the tensorlakeai/tensorlake repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Integration test against TestPyPI

on:
  workflow_dispatch:
    inputs:
      version:
        description: Version of Tensorlake to test
        required: true
  workflow_call:
    inputs:
      version:
        description: Version of Tensorlake to test
        required: true
        type: string

permissions:
  id-token: write
  contents: read

jobs:
  integration-test:
    name: Integration test against TestPyPI
    environment: prod
    runs-on: ubuntu-latest
    steps:
      - name: Write test application
        run: |
          SUFFIX=$(openssl rand -hex 6)
          cat > /tmp/test_app.py << EOF
          from tensorlake.applications import Image, application, function

          image = Image(name="test-image-${SUFFIX}", base_image="python:3.11-slim")

          @application()
          @function(image=image)
          def hello_${SUFFIX}(name: str) -> str:
              return f"Hello, {name}!"
          EOF

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
          role-session-name: github-actions-integration-test
          aws-region: ${{ vars.AWS_REGION }}

      - name: Login to Amazon ECR
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v2

      - name: Start Indexify Server
        uses: JarvusInnovations/background-action@v1
        with:
          run: |
            docker run -i -a stdout -a stderr --rm \
              --network host \
              --name indexify-server \
              ${{ steps.login-ecr.outputs.registry }}/indexify-server:latest &
          wait-on: |
            tcp:localhost:8900
          tail: true
          wait-for: 30s
          log-output: true
          log-output-if: true

      - name: Run integration tests in Docker
        run: |
          PYPI_VERSION="${{ inputs.version }}"
          PYPI_VERSION="${PYPI_VERSION/-dev/.dev}"

          docker run --rm \
            --network host \
            -e TENSORLAKE_API_URL="http://localhost:8900" \
            -e TENSORLAKE_API_KEY="${{ secrets.TENSORLAKE_API_KEY }}" \
            -e TENSORLAKE_ONPREM=true \
            -e PYPI_VERSION="${PYPI_VERSION}" \
            -v /tmp/test_app.py:/tmp/test_app.py \
            -v /var/run/docker.sock:/var/run/docker.sock \
            python:3.11-slim bash -c '
              set -e

              echo "--- Installing tensorlake from TestPyPI ---"
              for attempt in $(seq 1 8); do
                if pip install --index-url https://test.pypi.org/simple/ \
                                --extra-index-url https://pypi.org/simple/ \
                                tensorlake==${PYPI_VERSION}; then
                  break
                fi
                if [ "$attempt" -eq 8 ]; then
                  echo "tensorlake==${PYPI_VERSION} still not resolvable on TestPyPI after 8 attempts"
                  exit 1
                fi
                echo "TestPyPI index propagation not caught up yet (attempt ${attempt}/8), retrying in 30s..."
                sleep 30
              done

              echo "--- 1. Build images ---"
              tl build-images /tmp/test_app.py \
                --build-env PIP_INDEX_URL=https://test.pypi.org/simple/ \
                --build-env PIP_EXTRA_INDEX_URL=https://pypi.org/simple/

              echo "--- 2. Deploy ---"
              tl deploy /tmp/test_app.py \
                --build-env PIP_INDEX_URL=https://test.pypi.org/simple/ \
                --build-env PIP_EXTRA_INDEX_URL=https://pypi.org/simple/

              echo "--- All integration tests passed ---"
            '

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Integration test against TestPyPI
 
on:
  workflow_dispatch:
    inputs:
      version:
        description: Version of Tensorlake to test
        required: true
  workflow_call:
    inputs:
      version:
        description: Version of Tensorlake to test
        required: true
        type: string
 
permissions:
  id-token: write
  contents: read
 
jobs:
  integration-test:
    timeout-minutes: 30
    name: Integration test against TestPyPI
    environment: prod
    runs-on: latchkey-small
    steps:
      - name: Write test application
        run: |
          SUFFIX=$(openssl rand -hex 6)
          cat > /tmp/test_app.py << EOF
          from tensorlake.applications import Image, application, function
 
          image = Image(name="test-image-${SUFFIX}", base_image="python:3.11-slim")
 
          @application()
          @function(image=image)
          def hello_${SUFFIX}(name: str) -> str:
              return f"Hello, {name}!"
          EOF
 
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
          role-session-name: github-actions-integration-test
          aws-region: ${{ vars.AWS_REGION }}
 
      - name: Login to Amazon ECR
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v2
 
      - name: Start Indexify Server
        uses: JarvusInnovations/background-action@v1
        with:
          run: |
            docker run -i -a stdout -a stderr --rm \
              --network host \
              --name indexify-server \
              ${{ steps.login-ecr.outputs.registry }}/indexify-server:latest &
          wait-on: |
            tcp:localhost:8900
          tail: true
          wait-for: 30s
          log-output: true
          log-output-if: true
 
      - name: Run integration tests in Docker
        run: |
          PYPI_VERSION="${{ inputs.version }}"
          PYPI_VERSION="${PYPI_VERSION/-dev/.dev}"
 
          docker run --rm \
            --network host \
            -e TENSORLAKE_API_URL="http://localhost:8900" \
            -e TENSORLAKE_API_KEY="${{ secrets.TENSORLAKE_API_KEY }}" \
            -e TENSORLAKE_ONPREM=true \
            -e PYPI_VERSION="${PYPI_VERSION}" \
            -v /tmp/test_app.py:/tmp/test_app.py \
            -v /var/run/docker.sock:/var/run/docker.sock \
            python:3.11-slim bash -c '
              set -e
 
              echo "--- Installing tensorlake from TestPyPI ---"
              for attempt in $(seq 1 8); do
                if pip install --index-url https://test.pypi.org/simple/ \
                                --extra-index-url https://pypi.org/simple/ \
                                tensorlake==${PYPI_VERSION}; then
                  break
                fi
                if [ "$attempt" -eq 8 ]; then
                  echo "tensorlake==${PYPI_VERSION} still not resolvable on TestPyPI after 8 attempts"
                  exit 1
                fi
                echo "TestPyPI index propagation not caught up yet (attempt ${attempt}/8), retrying in 30s..."
                sleep 30
              done
 
              echo "--- 1. Build images ---"
              tl build-images /tmp/test_app.py \
                --build-env PIP_INDEX_URL=https://test.pypi.org/simple/ \
                --build-env PIP_EXTRA_INDEX_URL=https://pypi.org/simple/
 
              echo "--- 2. Deploy ---"
              tl deploy /tmp/test_app.py \
                --build-env PIP_INDEX_URL=https://test.pypi.org/simple/ \
                --build-env PIP_EXTRA_INDEX_URL=https://pypi.org/simple/
 
              echo "--- All integration tests passed ---"
            '
 

What changed

3 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow