feat(load-balancer): implement Live Load Balancer runtime Docker infrastructure #158
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| env: | |
| REGISTRY: docker.io | |
| IMAGE_NAME: runpod/tetra-rp | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: make setup | |
| - name: Run unit tests | |
| run: make test-unit | |
| - name: Run integration tests | |
| run: make test-integration | |
| - name: Run all tests with coverage | |
| run: make test-coverage | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Check code formatting with ruff | |
| run: make format-check | |
| - name: Check code style with ruff | |
| run: make lint | |
| docker-test: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint] | |
| steps: | |
| - name: Clear Space | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| rm -rf /usr/share/dotnet | |
| rm -rf /opt/ghc | |
| rm -rf "/usr/local/share/boost" | |
| rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: | | |
| uv sync | |
| git submodule update | |
| cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/ | |
| - name: Build CPU Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-cpu | |
| platforms: linux/amd64 | |
| push: false | |
| tags: tetra-rp-cpu:test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| load: true | |
| - name: Test CPU handler execution in Docker environment | |
| run: | | |
| echo "Testing CPU handler in Docker environment..." | |
| docker run --rm tetra-rp-cpu:test ./test-handler.sh | |
| docker-test-lb: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint] | |
| steps: | |
| - name: Clear Space | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| rm -rf /usr/share/dotnet | |
| rm -rf /opt/ghc | |
| rm -rf "/usr/local/share/boost" | |
| rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: | | |
| uv sync | |
| git submodule update | |
| cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/ | |
| - name: Build Load Balancer Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-lb | |
| platforms: linux/amd64 | |
| push: false | |
| tags: tetra-rp-lb:test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| load: true | |
| docker-test-lb-cpu: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint] | |
| steps: | |
| - name: Clear Space | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| rm -rf /usr/share/dotnet | |
| rm -rf /opt/ghc | |
| rm -rf "/usr/local/share/boost" | |
| rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: | | |
| uv sync | |
| git submodule update | |
| cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/ | |
| - name: Build CPU Load Balancer Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-lb-cpu | |
| platforms: linux/amd64 | |
| push: false | |
| tags: tetra-rp-lb-cpu:test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| load: true | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint, docker-test, docker-test-lb, docker-test-lb-cpu] | |
| if: github.ref == 'refs/heads/main' | |
| outputs: | |
| release_created: ${{ steps.release.outputs.release_created }} | |
| tag_name: ${{ steps.release.outputs.tag_name }} | |
| steps: | |
| - name: Generate GitHub App Token | |
| id: app-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.RELEASE_APP_ID }} | |
| private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} | |
| - uses: google-github-actions/release-please-action@v4 | |
| id: release | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| docker-main-gpu: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint, docker-test, release] | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' && !needs.release.outputs.release_created | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet | |
| rm -rf /opt/ghc | |
| rm -rf "/usr/local/share/boost" | |
| rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: | | |
| uv sync | |
| git submodule update | |
| cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/ | |
| - name: Build and push GPU Docker image (main) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| docker-main-cpu: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint, docker-test, release] | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' && !needs.release.outputs.release_created | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet | |
| rm -rf /opt/ghc | |
| rm -rf "/usr/local/share/boost" | |
| rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: | | |
| uv sync | |
| git submodule update | |
| cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/ | |
| - name: Build and push CPU Docker image (main) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-cpu | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-cpu:main | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| docker-main-lb: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint, docker-test, docker-test-lb, release] | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' && !needs.release.outputs.release_created | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet | |
| rm -rf /opt/ghc | |
| rm -rf "/usr/local/share/boost" | |
| rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: | | |
| uv sync | |
| git submodule update | |
| cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/ | |
| - name: Build and push Load Balancer Docker image (main) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-lb | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-lb:main | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| docker-main-lb-cpu: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint, docker-test, docker-test-lb-cpu, release] | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' && !needs.release.outputs.release_created | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet | |
| rm -rf /opt/ghc | |
| rm -rf "/usr/local/share/boost" | |
| rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: | | |
| uv sync | |
| git submodule update | |
| cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/ | |
| - name: Build and push CPU Load Balancer Docker image (main) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-lb-cpu | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-lb-cpu:main | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| docker-prod-gpu: | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| if: needs.release.outputs.release_created | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet | |
| rm -rf /opt/ghc | |
| rm -rf "/usr/local/share/boost" | |
| rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract GPU metadata | |
| id: meta-gpu | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: | | |
| uv sync | |
| git submodule update | |
| cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/ | |
| - name: Build and push GPU Docker image (prod) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.meta-gpu.outputs.tags }} | |
| labels: ${{ steps.meta-gpu.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| docker-prod-cpu: | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| if: needs.release.outputs.release_created | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet | |
| rm -rf /opt/ghc | |
| rm -rf "/usr/local/share/boost" | |
| rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract CPU metadata | |
| id: meta-cpu | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-cpu | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: | | |
| uv sync | |
| git submodule update | |
| cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/ | |
| - name: Build and push CPU Docker image (prod) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-cpu | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.meta-cpu.outputs.tags }} | |
| labels: ${{ steps.meta-cpu.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| docker-prod-lb: | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| if: needs.release.outputs.release_created | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet | |
| rm -rf /opt/ghc | |
| rm -rf "/usr/local/share/boost" | |
| rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract Load Balancer metadata | |
| id: meta-lb | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-lb | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: | | |
| uv sync | |
| git submodule update | |
| cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/ | |
| - name: Build and push Load Balancer Docker image (prod) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-lb | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.meta-lb.outputs.tags }} | |
| labels: ${{ steps.meta-lb.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| docker-prod-lb-cpu: | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| if: needs.release.outputs.release_created | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet | |
| rm -rf /opt/ghc | |
| rm -rf "/usr/local/share/boost" | |
| rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract CPU Load Balancer metadata | |
| id: meta-lb-cpu | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-lb-cpu | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: | | |
| uv sync | |
| git submodule update | |
| cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/ | |
| - name: Build and push CPU Load Balancer Docker image (prod) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-lb-cpu | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.meta-lb-cpu.outputs.tags }} | |
| labels: ${{ steps.meta-lb-cpu.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |