feat: tarball build pipeline for process injection #362
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/flash | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' || github.head_ref != 'release-please--branches--main' | |
| strategy: | |
| matrix: | |
| python-version: ${{ github.event_name == 'pull_request' && fromJSON('["3.11", "3.12"]') || fromJSON('["3.10", "3.11", "3.12", "3.13", "3.14"]') }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - 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 | |
| cache-dependency-glob: | | |
| **/pyproject.toml | |
| **/uv.lock | |
| - name: Setup dependencies | |
| run: make setup | |
| - name: Run all tests with coverage | |
| run: make test-coverage | |
| lint: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' || github.head_ref != 'release-please--branches--main' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - 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 | |
| - name: Reject git-ref dependencies | |
| run: make check-deps | |
| docker-test: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' || github.head_ref != 'release-please--branches--main' | |
| strategy: | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build CPU Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-cpu | |
| platforms: linux/amd64 | |
| push: false | |
| tags: flash-cpu:test | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| cache-from: type=gha,scope=cpu-test-py${{ matrix.python-version }} | |
| cache-to: type=gha,mode=max,scope=cpu-test-py${{ matrix.python-version }} | |
| load: true | |
| - name: Test CPU handler execution in Docker environment | |
| run: | | |
| echo "Testing CPU handler (Python ${{ matrix.python-version }})..." | |
| docker run --rm flash-cpu:test ./test-handler.sh | |
| docker-test-lb-cpu: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' || github.head_ref != 'release-please--branches--main' | |
| strategy: | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - 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: flash-lb-cpu:test | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| cache-from: type=gha,scope=lb-cpu-test-py${{ matrix.python-version }} | |
| cache-to: type=gha,mode=max,scope=lb-cpu-test-py${{ matrix.python-version }} | |
| load: true | |
| - name: Test LB handler execution in Docker environment | |
| run: | | |
| echo "Testing LB handler (Python ${{ matrix.python-version }})..." | |
| docker run --rm flash-lb-cpu:test ./test-lb-handler.sh | |
| docker-test-gpu: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' || github.head_ref != 'release-please--branches--main' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - name: Clear space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet \ | |
| /opt/ghc /usr/local/.ghcup \ | |
| /usr/local/lib/android \ | |
| /usr/local/share/boost \ | |
| /opt/hostedtoolcache/CodeQL \ | |
| /opt/microsoft /opt/google \ | |
| /imagegeneration \ | |
| "$AGENT_TOOLSDIRECTORY" | |
| docker system prune -af | |
| df -h | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build GPU Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64 | |
| push: false | |
| tags: flash-gpu:test | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| cache-from: type=gha,scope=gpu-test-py${{ matrix.python-version }} | |
| cache-to: type=gha,mode=max,scope=gpu-test-py${{ matrix.python-version }} | |
| docker-test-lb: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' || github.head_ref != 'release-please--branches--main' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - name: Clear space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet \ | |
| /opt/ghc /usr/local/.ghcup \ | |
| /usr/local/lib/android \ | |
| /usr/local/share/boost \ | |
| /opt/hostedtoolcache/CodeQL \ | |
| /opt/microsoft /opt/google \ | |
| /imagegeneration \ | |
| "$AGENT_TOOLSDIRECTORY" | |
| docker system prune -af | |
| df -h | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build GPU Load Balancer Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-lb | |
| platforms: linux/amd64 | |
| push: false | |
| tags: flash-lb:test | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| cache-from: type=gha,scope=lb-test-py${{ matrix.python-version }} | |
| cache-to: type=gha,mode=max,scope=lb-test-py${{ matrix.python-version }} | |
| tarball: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Build tarball | |
| env: | |
| PYTHON_VERSION: "3.11" | |
| run: bash scripts/build-tarball.sh | |
| - name: Test tarball in bare ubuntu container | |
| run: | | |
| TARBALL=$(ls dist/flash-worker-v*-py3.11-linux-x86_64.tar.gz) | |
| docker run --rm -v "$(pwd)/dist:/dist" ubuntu:22.04 \ | |
| bash -c "tar xzf /dist/$(basename $TARBALL) -C /opt && /opt/flash-worker/bootstrap.sh --test" | |
| - name: Upload tarball artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: flash-worker-tarball | |
| path: dist/flash-worker-v*-py3.11-linux-x86_64.tar.gz | |
| retention-days: 30 | |
| overwrite: true | |
| - name: Post artifact link on PR | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| TARBALL=$(basename dist/flash-worker-v*-py3.11-linux-x86_64.tar.gz) | |
| RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| BODY="**Tarball artifact:** [\`${TARBALL}\`](${RUN_URL}#artifacts) | |
| To test: \`FLASH_WORKER_TARBALL_URL=<download-url> flash deploy\`" | |
| # Delete previous tarball comments to keep PR clean | |
| gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \ | |
| --jq '.[] | select(.body | contains("Tarball artifact:")) | .id' | \ | |
| xargs -I{} gh api -X DELETE "repos/${{ github.repository }}/issues/comments/{}" 2>/dev/null || true | |
| gh pr comment "${{ github.event.pull_request.number }}" --body "$BODY" | |
| docker-validation: | |
| runs-on: ubuntu-latest | |
| needs: [test, lint, docker-test, docker-test-lb-cpu, docker-test-gpu, docker-test-lb] | |
| if: always() | |
| steps: | |
| - name: Check all jobs succeeded | |
| run: | | |
| results=( | |
| "${{ needs.test.result }}" | |
| "${{ needs.lint.result }}" | |
| "${{ needs.docker-test.result }}" | |
| "${{ needs.docker-test-lb-cpu.result }}" | |
| "${{ needs.docker-test-gpu.result }}" | |
| "${{ needs.docker-test-lb.result }}" | |
| ) | |
| for result in "${results[@]}"; do | |
| if [[ "$result" != "success" && "$result" != "skipped" ]]; then | |
| echo "One or more quality checks failed (got: $result)" | |
| exit 1 | |
| fi | |
| done | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [docker-validation] | |
| 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: googleapis/release-please-action@v4 | |
| id: release | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| docker-prod-gpu: | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| if: needs.release.outputs.release_created | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - python-version: "3.10" | |
| is-default: false | |
| - python-version: "3.11" | |
| is-default: false | |
| - python-version: "3.12" | |
| is-default: true | |
| - python-version: "3.13" | |
| is-default: false | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet /opt/ghc /usr/local/share/boost "$AGENT_TOOLSDIRECTORY" | |
| docker system prune -af | |
| df -h | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| 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: Build versioned tags | |
| id: tags | |
| run: | | |
| VERSION="${{ needs.release.outputs.tag_name }}" | |
| VERSION="${VERSION#v}" | |
| PYVER="${{ matrix.python-version }}" | |
| IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | |
| TAGS="${IMAGE}:py${PYVER}-${VERSION},${IMAGE}:py${PYVER}-latest" | |
| if [ "${{ matrix.is-default }}" = "true" ]; then | |
| TAGS="${TAGS},${IMAGE}:${VERSION},${IMAGE}:latest" | |
| fi | |
| echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: uv sync | |
| - 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.tags.outputs.tags }} | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| cache-from: type=gha,scope=gpu-py${{ matrix.python-version }} | |
| cache-to: type=gha,mode=max,scope=gpu-py${{ matrix.python-version }} | |
| tarball-release: | |
| needs: [release] | |
| if: needs.release.outputs.release_created | |
| uses: ./.github/workflows/release-tarball.yml | |
| with: | |
| tag_name: ${{ needs.release.outputs.tag_name }} | |
| docker-prod-cpu: | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| if: needs.release.outputs.release_created | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - python-version: "3.10" | |
| is-default: false | |
| - python-version: "3.11" | |
| is-default: false | |
| - python-version: "3.12" | |
| is-default: true | |
| - python-version: "3.13" | |
| is-default: false | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet /opt/ghc /usr/local/share/boost "$AGENT_TOOLSDIRECTORY" | |
| docker system prune -af | |
| df -h | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| 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: Build versioned tags | |
| id: tags | |
| run: | | |
| VERSION="${{ needs.release.outputs.tag_name }}" | |
| VERSION="${VERSION#v}" | |
| PYVER="${{ matrix.python-version }}" | |
| IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-cpu" | |
| TAGS="${IMAGE}:py${PYVER}-${VERSION},${IMAGE}:py${PYVER}-latest" | |
| if [ "${{ matrix.is-default }}" = "true" ]; then | |
| TAGS="${TAGS},${IMAGE}:${VERSION},${IMAGE}:latest" | |
| fi | |
| echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: uv sync | |
| - name: Build and push CPU Docker image (prod) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile-cpu | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.tags.outputs.tags }} | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| cache-from: type=gha,scope=cpu-py${{ matrix.python-version }} | |
| cache-to: type=gha,mode=max,scope=cpu-py${{ matrix.python-version }} | |
| docker-prod-lb: | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| if: needs.release.outputs.release_created | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - python-version: "3.10" | |
| is-default: false | |
| - python-version: "3.11" | |
| is-default: false | |
| - python-version: "3.12" | |
| is-default: true | |
| - python-version: "3.13" | |
| is-default: false | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet /opt/ghc /usr/local/share/boost "$AGENT_TOOLSDIRECTORY" | |
| docker system prune -af | |
| df -h | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| 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: Build versioned tags | |
| id: tags | |
| run: | | |
| VERSION="${{ needs.release.outputs.tag_name }}" | |
| VERSION="${VERSION#v}" | |
| PYVER="${{ matrix.python-version }}" | |
| IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-lb" | |
| TAGS="${IMAGE}:py${PYVER}-${VERSION},${IMAGE}:py${PYVER}-latest" | |
| if [ "${{ matrix.is-default }}" = "true" ]; then | |
| TAGS="${TAGS},${IMAGE}:${VERSION},${IMAGE}:latest" | |
| fi | |
| echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: uv sync | |
| - 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.tags.outputs.tags }} | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| cache-from: type=gha,scope=lb-py${{ matrix.python-version }} | |
| cache-to: type=gha,mode=max,scope=lb-py${{ matrix.python-version }} | |
| docker-prod-lb-cpu: | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| if: needs.release.outputs.release_created | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - python-version: "3.10" | |
| is-default: false | |
| - python-version: "3.11" | |
| is-default: false | |
| - python-version: "3.12" | |
| is-default: true | |
| - python-version: "3.13" | |
| is-default: false | |
| steps: | |
| - name: Clear Space | |
| run: | | |
| rm -rf /usr/share/dotnet /opt/ghc /usr/local/share/boost "$AGENT_TOOLSDIRECTORY" | |
| docker system prune -af | |
| df -h | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| 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: Build versioned tags | |
| id: tags | |
| run: | | |
| VERSION="${{ needs.release.outputs.tag_name }}" | |
| VERSION="${VERSION#v}" | |
| PYVER="${{ matrix.python-version }}" | |
| IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-lb-cpu" | |
| TAGS="${IMAGE}:py${PYVER}-${VERSION},${IMAGE}:py${PYVER}-latest" | |
| if [ "${{ matrix.is-default }}" = "true" ]; then | |
| TAGS="${TAGS},${IMAGE}:${VERSION},${IMAGE}:latest" | |
| fi | |
| echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Setup dependencies | |
| run: uv sync | |
| - 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,linux/arm64 | |
| push: true | |
| tags: ${{ steps.tags.outputs.tags }} | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| cache-from: type=gha,scope=lb-cpu-py${{ matrix.python-version }} | |
| cache-to: type=gha,mode=max,scope=lb-cpu-py${{ matrix.python-version }} |