2023-01-31 12:14:05 -07:00
|
|
|
name: Build and push docker image to internal registry
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'main'
|
2023-02-03 04:43:37 -07:00
|
|
|
tags:
|
|
|
|
- 'v*'
|
2023-01-31 12:14:05 -07:00
|
|
|
pull_request:
|
2023-03-23 11:01:30 -06:00
|
|
|
paths:
|
|
|
|
- ".github/workflows/build.yaml"
|
2023-05-16 12:22:11 -06:00
|
|
|
- "integration-tests/**"
|
2023-03-23 11:01:30 -06:00
|
|
|
- "server/**"
|
|
|
|
- "proto/**"
|
|
|
|
- "router/**"
|
|
|
|
- "launcher/**"
|
|
|
|
- "Cargo.lock"
|
|
|
|
- "rust-toolchain.toml"
|
|
|
|
- "Dockerfile"
|
2024-06-06 10:51:42 -06:00
|
|
|
- "Dockerfile_amd"
|
|
|
|
- "Dockerfile_intel"
|
2023-01-31 12:14:05 -07:00
|
|
|
branches:
|
|
|
|
- 'main'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build-and-push-image:
|
2023-05-15 15:36:30 -06:00
|
|
|
concurrency:
|
2024-06-06 10:51:42 -06:00
|
|
|
group: ${{ github.workflow }}-build-and-push-image-${{ matrix.name }}-${{ github.head_ref || github.run_id }}
|
2023-05-15 15:36:30 -06:00
|
|
|
cancel-in-progress: true
|
2024-06-06 10:51:42 -06:00
|
|
|
runs-on: [self-hosted, nvidia-gpu , multi-gpu, 4-a10, ci]
|
|
|
|
strategy:
|
2024-05-31 05:51:42 -06:00
|
|
|
matrix:
|
2024-06-06 10:51:42 -06:00
|
|
|
include:
|
|
|
|
- name: "cuda"
|
|
|
|
label: ""
|
|
|
|
dockerfile: "Dockerfile"
|
|
|
|
- name: "amd"
|
|
|
|
label: "-rocm"
|
|
|
|
dockerfile: "Dockerfile_amd"
|
|
|
|
- name: "intel"
|
|
|
|
label: "-intel"
|
|
|
|
dockerfile: "Dockerfile_intel"
|
2023-04-13 07:26:34 -06:00
|
|
|
permissions:
|
2023-04-13 08:23:47 -06:00
|
|
|
contents: write
|
2023-04-13 07:26:34 -06:00
|
|
|
packages: write
|
|
|
|
# This is used to complete the identity challenge
|
|
|
|
# with sigstore/fulcio when running outside of PRs.
|
|
|
|
id-token: write
|
2023-04-13 08:32:37 -06:00
|
|
|
security-events: write
|
2023-01-31 12:14:05 -07:00
|
|
|
steps:
|
2023-04-13 07:26:34 -06:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v3
|
2024-06-18 01:38:21 -06:00
|
|
|
|
2023-04-13 07:26:34 -06:00
|
|
|
- name: Inject slug/short variables
|
|
|
|
uses: rlespinasse/github-slug-action@v4.4.1
|
2023-01-31 12:14:05 -07:00
|
|
|
- name: Tailscale
|
2024-06-06 10:51:42 -06:00
|
|
|
uses: huggingface/tailscale-action@main
|
2023-01-31 12:14:05 -07:00
|
|
|
with:
|
|
|
|
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
|
2024-06-18 01:13:04 -06:00
|
|
|
slackChannel: ${{ secrets.SLACK_CIFEEDBACK_CHANNEL }}
|
|
|
|
slackToken: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }}
|
|
|
|
- name: Initialize Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v2.0.0
|
|
|
|
with:
|
|
|
|
install: true
|
2023-01-31 12:14:05 -07:00
|
|
|
- name: Login to GitHub Container Registry
|
2023-04-13 07:26:34 -06:00
|
|
|
if: github.event_name != 'pull_request'
|
2023-01-31 12:14:05 -07:00
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to internal Container Registry
|
|
|
|
uses: docker/login-action@v2.1.0
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.TAILSCALE_DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.TAILSCALE_DOCKER_PASSWORD }}
|
|
|
|
registry: registry.internal.huggingface.tech
|
2023-02-06 06:33:56 -07:00
|
|
|
- name: Login to Azure Container Registry
|
2023-04-20 03:07:40 -06:00
|
|
|
if: github.event_name != 'pull_request'
|
2023-02-06 06:33:56 -07:00
|
|
|
uses: docker/login-action@v2.1.0
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.AZURE_DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.AZURE_DOCKER_PASSWORD }}
|
|
|
|
registry: db4c2190dd824d1f950f5d1555fbadf0.azurecr.io
|
2023-05-15 15:36:30 -06:00
|
|
|
# If pull request
|
2023-01-31 12:14:05 -07:00
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
2023-05-15 15:36:30 -06:00
|
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
|
|
id: meta-pr
|
|
|
|
uses: docker/metadata-action@v4.3.0
|
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
registry.internal.huggingface.tech/api-inference/community/text-generation-inference
|
|
|
|
tags: |
|
2024-06-06 10:51:42 -06:00
|
|
|
type=raw,value=sha-${{ env.GITHUB_SHA_SHORT }}${{ matrix.label }}
|
2023-05-15 15:36:30 -06:00
|
|
|
# If main, release or tag
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
|
|
if: ${{ github.event_name != 'pull_request' }}
|
2023-01-31 12:14:05 -07:00
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v4.3.0
|
|
|
|
with:
|
|
|
|
flavor: |
|
|
|
|
latest=auto
|
|
|
|
images: |
|
|
|
|
registry.internal.huggingface.tech/api-inference/community/text-generation-inference
|
2023-04-16 16:26:47 -06:00
|
|
|
ghcr.io/huggingface/text-generation-inference
|
2023-02-06 06:33:56 -07:00
|
|
|
db4c2190dd824d1f950f5d1555fbadf0.azurecr.io/text-generation-inference
|
2023-01-31 12:14:05 -07:00
|
|
|
tags: |
|
2024-06-06 10:51:42 -06:00
|
|
|
type=semver,pattern={{version}}${{ matrix.label }}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}${{ matrix.label }}
|
|
|
|
type=raw,value=latest${{ matrix.label }},enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
|
|
|
|
type=raw,value=sha-${{ env.GITHUB_SHA_SHORT }}${{ matrix.label }}
|
2023-01-31 12:14:05 -07:00
|
|
|
- name: Build and push Docker image
|
2023-04-13 07:43:17 -06:00
|
|
|
id: build-and-push
|
2023-04-13 07:26:34 -06:00
|
|
|
uses: docker/build-push-action@v4
|
2023-01-31 12:14:05 -07:00
|
|
|
with:
|
|
|
|
context: .
|
2024-06-06 10:51:42 -06:00
|
|
|
file: ${{ matrix.dockerfile }}
|
2023-05-15 15:36:30 -06:00
|
|
|
push: true
|
2023-01-31 12:14:05 -07:00
|
|
|
platforms: 'linux/amd64'
|
2023-04-19 13:36:59 -06:00
|
|
|
build-args: |
|
2023-04-20 10:50:47 -06:00
|
|
|
GIT_SHA=${{ env.GITHUB_SHA }}
|
2024-06-06 10:51:42 -06:00
|
|
|
DOCKER_LABEL=sha-${{ env.GITHUB_SHA_SHORT }}${{ matrix.label }}
|
2023-05-15 15:36:30 -06:00
|
|
|
tags: ${{ steps.meta.outputs.tags || steps.meta-pr.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels || steps.meta-pr.outputs.labels }}
|
2024-06-18 01:13:04 -06:00
|
|
|
network: host
|
2024-06-06 10:51:42 -06:00
|
|
|
cache-from: type=registry,ref=registry.internal.huggingface.tech/api-inference/community/text-generation-inference:cache${{ matrix.label }},mode=min
|
|
|
|
cache-to: type=registry,ref=registry.internal.huggingface.tech/api-inference/community/text-generation-inference:cache${{ matrix.label }},mode=min
|
2023-12-15 04:52:24 -07:00
|
|
|
- name: Set up Python
|
2024-06-06 11:08:16 -06:00
|
|
|
if: matrix.name == 'cuda'
|
2023-12-15 04:52:24 -07:00
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: 3.9
|
|
|
|
- name: Install
|
2024-06-06 11:08:16 -06:00
|
|
|
if: matrix.name == 'cuda'
|
2023-12-15 04:52:24 -07:00
|
|
|
run: |
|
|
|
|
make install-integration-tests
|
|
|
|
- name: Run tests
|
2024-06-06 11:08:16 -06:00
|
|
|
if: matrix.name == 'cuda'
|
2023-12-15 04:52:24 -07:00
|
|
|
run: |
|
2024-06-06 10:51:42 -06:00
|
|
|
export DOCKER_VOLUME=/mnt/cache
|
2023-12-15 04:52:24 -07:00
|
|
|
export DOCKER_IMAGE=registry.internal.huggingface.tech/api-inference/community/text-generation-inference:sha-${{ env.GITHUB_SHA_SHORT }}
|
|
|
|
export HUGGING_FACE_HUB_TOKEN=${{ secrets.HUGGING_FACE_HUB_TOKEN }}
|
|
|
|
pytest -s -vv integration-tests
|
2024-06-18 01:13:04 -06:00
|
|
|
- name: Tailscale Wait
|
|
|
|
if: ${{ failure() || runner.debug == '1' }}
|
|
|
|
uses: huggingface/tailscale-action@main
|
|
|
|
with:
|
|
|
|
waitForSSH: true
|