Skip to content
Closed

pr #451

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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: CI
on:
push:
branches: [ "master", "pre-release" ]
branches: [ "master" ]
pull_request:
branches: [ "master", "pre-release" ]
branches: [ "master" ]
jobs:
test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -36,7 +36,7 @@ jobs:
enable-cache: true
- name: Install dependencies
run: |
uv pip install -e .[test,cpu]
uv pip install -e .[test,gpu]
- name: Run Tests
run: |
uv run pytest api/tests/ --asyncio-mode=auto --cov=api --cov-report=term-missing
108 changes: 53 additions & 55 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ name: Create Release and Publish Docker Images
on:
push:
branches:
- release # Auto-trigger only on release branch
- master
paths-ignore:
- '**.md'
- 'docs/**'
workflow_dispatch: # Manual trigger - explicitly specify branch
inputs:
branch_name:
description: 'Branch to build from (required)'
required: true
type: string
workflow_dispatch:

jobs:
prepare-release:
Expand All @@ -28,21 +23,8 @@ jobs:
id: get-version
run: |
VERSION_PLAIN=$(cat VERSION)

if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
BRANCH_NAME="${{ inputs.branch_name }}"
else
BRANCH_NAME="${{ github.ref_name }}"
fi

if [[ "$BRANCH_NAME" == "release" ]]; then
echo "version=${VERSION_PLAIN}" >> $GITHUB_OUTPUT
echo "version_tag=v${VERSION_PLAIN}" >> $GITHUB_OUTPUT
else
SAFE_BRANCH=$(echo "$BRANCH_NAME" | tr '/' '-' | tr '[:upper:]' '[:lower:]')
echo "version=${VERSION_PLAIN}-${SAFE_BRANCH}" >> $GITHUB_OUTPUT
echo "version_tag=v${VERSION_PLAIN}-${SAFE_BRANCH}" >> $GITHUB_OUTPUT
fi
echo "version=${VERSION_PLAIN}" >> $GITHUB_OUTPUT
echo "version_tag=v${VERSION_PLAIN}" >> $GITHUB_OUTPUT

build-images:
needs: prepare-release
Expand All @@ -55,24 +37,16 @@ jobs:
REGISTRY: ${{ vars.REGISTRY || 'ghcr.io' }}
OWNER: ${{ vars.OWNER || 'remsky' }}
REPO: ${{ vars.REPO || 'kokoro-fastapi' }}
DOCKERHUB_REPO: cipherdolls/kokoro-fastapi
strategy:
matrix:
include:
- build_target: "cpu"
- build_target: "default"
platform: "linux/amd64"
runs_on: "ubuntu-latest"
- build_target: "gpu"
platform: "linux/amd64"
runs_on: "ubuntu-latest"
- build_target: "cpu"
platform: "linux/arm64"
runs_on: "ubuntu-24.04-arm"
- build_target: "gpu"
- build_target: "default"
platform: "linux/arm64"
runs_on: "ubuntu-24.04-arm"
- build_target: "rocm"
platform: "linux/amd64"
runs_on: "ubuntu-latest"
runs-on: ${{ matrix.runs_on }}
steps:
- name: Checkout repository
Expand Down Expand Up @@ -103,31 +77,41 @@ jobs:
df -h

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 # Use v3
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
network=host

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3 # Use v3
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push single-platform image
run: |
PLATFORM="${{ matrix.platform }}"
BUILD_TARGET="${{ matrix.build_target }}"
VERSION_TAG="${{ needs.prepare-release.outputs.version_tag }}"
ARCH="$(echo ${PLATFORM} | cut -d'/' -f2)"

echo "Building ${PLATFORM} image for ${BUILD_TARGET} version ${VERSION_TAG}"

TARGET="${BUILD_TARGET}-$(echo ${PLATFORM} | cut -d'/' -f2)"
echo "Using bake target: $TARGET"
echo "Building ${PLATFORM} image version ${VERSION_TAG}"

docker buildx bake $TARGET --push --progress=plain
docker buildx build \
-f docker/Dockerfile \
--platform ${PLATFORM} \
--tag ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.REPO }}:${VERSION_TAG}-${ARCH} \
--tag ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.REPO }}:latest-${ARCH} \
--tag ${{ env.DOCKERHUB_REPO }}:${VERSION_TAG}-${ARCH} \
--tag ${{ env.DOCKERHUB_REPO }}:latest-${ARCH} \
--push --progress=plain .

create-manifests:
needs: [prepare-release, build-images]
Expand All @@ -138,9 +122,7 @@ jobs:
REGISTRY: ${{ vars.REGISTRY || 'ghcr.io' }}
OWNER: ${{ vars.OWNER || 'remsky' }}
REPO: ${{ vars.REPO || 'kokoro-fastapi' }}
strategy:
matrix:
build_target: ["cpu", "gpu", "rocm"]
DOCKERHUB_REPO: cipherdolls/kokoro-fastapi
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -149,24 +131,40 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create multi-platform manifest
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create multi-platform manifests
run: |
VERSION_TAG="${{ needs.prepare-release.outputs.version_tag }}"
TARGET="${{ matrix.build_target }}"
REGISTRY="${{ env.REGISTRY }}"
OWNER="${{ env.OWNER }}"
REPO="${{ env.REPO }}"
GHCR="${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.REPO }}"
DH="${{ env.DOCKERHUB_REPO }}"

# GHCR manifests
docker buildx imagetools create -t \
${GHCR}:${VERSION_TAG} \
${GHCR}:${VERSION_TAG}-amd64 \
${GHCR}:${VERSION_TAG}-arm64

# Docker Hub manifests
docker buildx imagetools create -t \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:${VERSION_TAG} \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:${VERSION_TAG}-amd64 \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:${VERSION_TAG}-arm64
${DH}:${VERSION_TAG} \
${DH}:${VERSION_TAG}-amd64 \
${DH}:${VERSION_TAG}-arm64

if [[ "$VERSION_TAG" != *"-"* ]]; then
docker buildx imagetools create -t \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:latest \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:${VERSION_TAG}-amd64 \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:${VERSION_TAG}-arm64
${GHCR}:latest \
${GHCR}:${VERSION_TAG}-amd64 \
${GHCR}:${VERSION_TAG}-arm64

docker buildx imagetools create -t \
${DH}:latest \
${DH}:${VERSION_TAG}-amd64 \
${DH}:${VERSION_TAG}-arm64
fi

create-release:
Expand Down
30 changes: 8 additions & 22 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,8 @@ on:
description: 'Branch to build from'
required: true
type: string
build_target:
description: 'Build target'
required: true
type: choice
options:
- all
- cpu
- gpu
- rocm
platform:
description: 'Platform (ignored for rocm)'
description: 'Platform'
required: true
type: choice
options:
Expand All @@ -44,26 +35,21 @@ jobs:
id: set-matrix
run: |
ALL_TARGETS='[
{"build_target":"cpu","platform":"amd64","runs_on":"ubuntu-latest"},
{"build_target":"cpu","platform":"arm64","runs_on":"ubuntu-24.04-arm"},
{"build_target":"gpu","platform":"amd64","runs_on":"ubuntu-latest"},
{"build_target":"gpu","platform":"arm64","runs_on":"ubuntu-24.04-arm"},
{"build_target":"rocm","platform":"amd64","runs_on":"ubuntu-latest"}
{"build_target":"default","platform":"amd64","runs_on":"ubuntu-latest"},
{"build_target":"default","platform":"arm64","runs_on":"ubuntu-24.04-arm"}
]'

FILTERED=$(echo "$ALL_TARGETS" | jq -c \
--arg target "${{ inputs.build_target }}" \
--arg platform "${{ inputs.platform }}" \
'[.[] | select(
($target == "all" or .build_target == $target) and
(.build_target == "rocm" or $platform == "all" or .platform == $platform)
$platform == "all" or .platform == $platform
)]')

if [ "$FILTERED" = "[]" ]; then
echo "::error::No matching build configurations"
exit 1
fi

echo "matrix={\"include\":$FILTERED}" >> "$GITHUB_OUTPUT"

build-images:
Expand Down Expand Up @@ -92,7 +78,7 @@ jobs:

- name: Build image
run: |
TARGET="${{ matrix.build_target }}-${{ matrix.platform }}"
TARGET="${{ matrix.platform }}"
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
docker buildx bake "$TARGET" --print
else
Expand Down
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ In addition to local `pytest` runs, test your changes using Docker Compose to en

```bash

docker compose -f docker/cpu/docker-compose.yml up --build
+
docker compose -f docker/gpu/docker-compose.yml up --build
docker compose -f docker/docker-compose.yml up --build
```
This command will build the Docker images (if they've changed) and start the services defined in the respective compose file. Verify the application starts correctly and test the relevant functionality.

Expand Down
Loading