Test llama stack build #3
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: Test Llama Stack Build | |
| run-name: Test llama stack build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'llama_stack/cli/stack/build.py' | |
| - 'llama_stack/cli/stack/_build.py' | |
| - 'llama_stack/core/build.*' | |
| - 'llama_stack/core/*.sh' | |
| - '.github/workflows/providers-build.yml' | |
| - 'llama_stack/distributions/**' | |
| - 'pyproject.toml' | |
| pull_request: | |
| paths: | |
| - 'llama_stack/cli/stack/build.py' | |
| - 'llama_stack/cli/stack/_build.py' | |
| - 'llama_stack/core/build.*' | |
| - 'llama_stack/core/*.sh' | |
| - '.github/workflows/providers-build.yml' | |
| - 'llama_stack/distributions/**' | |
| - 'pyproject.toml' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| generate-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| distros: ${{ steps.set-matrix.outputs.distros }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Generate Distribution List | |
| id: set-matrix | |
| run: | | |
| distros=$(ls llama_stack/distributions/*/*build.yaml | awk -F'/' '{print $(NF-1)}' | jq -R -s -c 'split("\n")[:-1]') | |
| echo "distros=$distros" >> "$GITHUB_OUTPUT" | |
| build: | |
| needs: generate-matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| distro: ${{ fromJson(needs.generate-matrix.outputs.distros) }} | |
| image-type: [venv, container] | |
| fail-fast: false # We want to run all jobs even if some fail | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Install dependencies | |
| uses: ./.github/actions/setup-runner | |
| - name: Print build dependencies | |
| run: | | |
| uv run llama stack build --distro ${{ matrix.distro }} --image-type ${{ matrix.image-type }} --image-name test --print-deps-only | |
| - name: Run Llama Stack Build | |
| run: | | |
| # USE_COPY_NOT_MOUNT is set to true since mounting is not supported by docker buildx, we use COPY instead | |
| # LLAMA_STACK_DIR is set to the current directory so we are building from the source | |
| USE_COPY_NOT_MOUNT=true LLAMA_STACK_DIR=. uv run llama stack build --distro ${{ matrix.distro }} --image-type ${{ matrix.image-type }} --image-name test | |
| - name: Print dependencies in the image | |
| if: matrix.image-type == 'venv' | |
| run: | | |
| uv pip list | |
| build-single-provider: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Install dependencies | |
| uses: ./.github/actions/setup-runner | |
| - name: Build a single provider | |
| run: | | |
| USE_COPY_NOT_MOUNT=true LLAMA_STACK_DIR=. uv run llama stack build --image-type venv --image-name test --providers inference=remote::ollama | |
| build-custom-container-distribution: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Install dependencies | |
| uses: ./.github/actions/setup-runner | |
| - name: Build a single provider | |
| run: | | |
| yq -i '.image_type = "container"' llama_stack/distributions/ci-tests/build.yaml | |
| yq -i '.image_name = "test"' llama_stack/distributions/ci-tests/build.yaml | |
| USE_COPY_NOT_MOUNT=true LLAMA_STACK_DIR=. uv run llama stack build --config llama_stack/distributions/ci-tests/build.yaml | |
| - name: Inspect the container image entrypoint | |
| run: | | |
| IMAGE_ID=$(docker images --format "{{.Repository}}:{{.Tag}}" | head -n 1) | |
| if [ -z "$IMAGE_ID" ]; then | |
| echo "No image found" | |
| exit 1 | |
| fi | |
| entrypoint=$(docker inspect --format '{{ .Config.Entrypoint }}' $IMAGE_ID) | |
| echo "Entrypoint: $entrypoint" | |
| if [ "$entrypoint" != "[python -m llama_stack.core.server.server /app/run.yaml]" ]; then | |
| echo "Entrypoint is not correct" | |
| exit 1 | |
| fi | |
| build-ubi9-container-distribution: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Install dependencies | |
| uses: ./.github/actions/setup-runner | |
| - name: Pin distribution to UBI9 base | |
| run: | | |
| yq -i ' | |
| .image_type = "container" | | |
| .image_name = "ubi9-test" | | |
| .distribution_spec.container_image = "registry.access.redhat.com/ubi9:latest" | |
| ' llama_stack/distributions/ci-tests/build.yaml | |
| - name: Build dev container (UBI9) | |
| env: | |
| USE_COPY_NOT_MOUNT: "true" | |
| LLAMA_STACK_DIR: "." | |
| run: | | |
| uv run llama stack build --config llama_stack/distributions/ci-tests/build.yaml | |
| - name: Inspect UBI9 image | |
| run: | | |
| IMAGE_ID=$(docker images --format "{{.Repository}}:{{.Tag}}" | head -n 1) | |
| if [ -z "$IMAGE_ID" ]; then | |
| echo "No image found" | |
| exit 1 | |
| fi | |
| entrypoint=$(docker inspect --format '{{ .Config.Entrypoint }}' $IMAGE_ID) | |
| echo "Entrypoint: $entrypoint" | |
| if [ "$entrypoint" != "[python -m llama_stack.core.server.server /app/run.yaml]" ]; then | |
| echo "Entrypoint is not correct" | |
| exit 1 | |
| fi | |
| echo "Checking /etc/os-release in $IMAGE_ID" | |
| docker run --rm --entrypoint sh "$IMAGE_ID" -c \ | |
| 'source /etc/os-release && echo "$ID"' \ | |
| | grep -qE '^(rhel|ubi)$' \ | |
| || { echo "Base image is not UBI 9!"; exit 1; } |