2023-01-31 12:14:05 -07:00
|
|
|
name: Build and push docker image to internal registry
|
|
|
|
|
|
|
|
on:
|
2024-06-24 10:08:34 -06:00
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
hardware:
|
|
|
|
type: string
|
|
|
|
description: Hardware
|
|
|
|
# options:
|
|
|
|
# - cuda
|
|
|
|
# - rocm
|
|
|
|
# - intel
|
|
|
|
required: true
|
2024-07-05 06:12:16 -06:00
|
|
|
release-tests:
|
|
|
|
description: "Run release integration tests"
|
|
|
|
required: true
|
|
|
|
default: false
|
|
|
|
type: boolean
|
2023-01-31 12:14:05 -07:00
|
|
|
|
|
|
|
jobs:
|
2024-06-24 10:08:34 -06:00
|
|
|
build-and-push:
|
|
|
|
outputs:
|
|
|
|
docker_image: ${{ steps.final.outputs.docker_image }}
|
|
|
|
docker_devices: ${{ steps.final.outputs.docker_devices }}
|
|
|
|
runs_on: ${{ steps.final.outputs.runs_on }}
|
|
|
|
label: ${{ steps.final.outputs.label }}
|
2023-05-15 15:36:30 -06:00
|
|
|
concurrency:
|
2024-06-24 10:08:34 -06:00
|
|
|
group: ${{ github.workflow }}-build-and-push-image-${{ inputs.hardware }}-${{ github.head_ref || github.run_id }}
|
2023-05-15 15:36:30 -06:00
|
|
|
cancel-in-progress: true
|
2024-07-19 23:06:40 -06:00
|
|
|
runs-on:
|
2024-07-22 13:50:53 -06:00
|
|
|
group: aws-highmemory-32-plus-priv
|
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
|
2023-01-31 12:14:05 -07:00
|
|
|
steps:
|
2023-04-13 07:26:34 -06:00
|
|
|
- name: Checkout repository
|
2024-06-24 10:08:34 -06:00
|
|
|
uses: actions/checkout@v4
|
2023-04-13 07:26:34 -06:00
|
|
|
- name: Inject slug/short variables
|
|
|
|
uses: rlespinasse/github-slug-action@v4.4.1
|
2024-06-24 10:08:34 -06:00
|
|
|
- name: Construct harware variables
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
case ${{ inputs.hardware }} in
|
|
|
|
cuda)
|
|
|
|
export dockerfile="Dockerfile"
|
|
|
|
export label_extension=""
|
|
|
|
export docker_devices=""
|
2024-07-25 08:06:00 -06:00
|
|
|
export runs_on="aws-g6-12xlarge-plus-priv"
|
2024-08-12 06:10:30 -06:00
|
|
|
export platform=""
|
2024-06-24 10:08:34 -06:00
|
|
|
;;
|
|
|
|
rocm)
|
|
|
|
export dockerfile="Dockerfile_amd"
|
|
|
|
export label_extension="-rocm"
|
|
|
|
export docker_devices="/dev/kfd,/dev/dri"
|
|
|
|
# TODO Re-enable when they pass.
|
|
|
|
# export runs_on="amd-gpu-tgi"
|
|
|
|
export runs_on="ubuntu-latest"
|
2024-08-12 06:10:30 -06:00
|
|
|
export platform=""
|
2024-06-24 10:08:34 -06:00
|
|
|
;;
|
2024-08-12 06:10:30 -06:00
|
|
|
intel-xpu)
|
2024-06-24 10:08:34 -06:00
|
|
|
export dockerfile="Dockerfile_intel"
|
2024-08-12 06:10:30 -06:00
|
|
|
export label_extension="-intel-xpu"
|
2024-06-24 10:08:34 -06:00
|
|
|
export docker_devices=""
|
|
|
|
export runs_on="ubuntu-latest"
|
2024-08-12 06:10:30 -06:00
|
|
|
export platform="xpu"
|
|
|
|
;;
|
|
|
|
intel-cpu)
|
|
|
|
export dockerfile="Dockerfile_intel"
|
|
|
|
export label_extension="-intel-cpu"
|
|
|
|
export docker_devices=""
|
|
|
|
export runs_on="ubuntu-latest"
|
|
|
|
export platform="cpu"
|
2024-06-24 10:08:34 -06:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo $dockerfile
|
|
|
|
echo "Dockerfile=${dockerfile}"
|
|
|
|
echo $label_extension
|
|
|
|
echo $docker_devices
|
|
|
|
echo $runs_on
|
2024-08-12 06:10:30 -06:00
|
|
|
echo $platform
|
2024-06-24 10:08:34 -06:00
|
|
|
echo "DOCKERFILE=${dockerfile}" >> $GITHUB_ENV
|
|
|
|
echo "LABEL=${label_extension}" >> $GITHUB_ENV
|
2024-08-12 06:10:30 -06:00
|
|
|
echo "PLATFORM=${platform}" >> $GITHUB_ENV
|
2024-06-24 10:08:34 -06:00
|
|
|
echo "DOCKER_DEVICES=${docker_devices}" >> $GITHUB_ENV
|
|
|
|
echo "RUNS_ON=${runs_on}" >> $GITHUB_ENV
|
2024-07-25 08:06:00 -06:00
|
|
|
echo REGISTRY_MIRROR=$REGISTRY_MIRROR >> $GITHUB_ENV
|
2024-06-18 01:13:04 -06:00
|
|
|
- name: Initialize Docker Buildx
|
2024-06-24 10:08:34 -06:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2024-06-18 01:13:04 -06:00
|
|
|
with:
|
|
|
|
install: true
|
2024-07-29 01:25:56 -06:00
|
|
|
buildkitd-config: /tmp/buildkitd.toml
|
2024-07-19 23:06:40 -06:00
|
|
|
- name: Login to internal Container Registry
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
registry: registry.internal.huggingface.tech
|
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'
|
2024-06-24 10:08:34 -06:00
|
|
|
uses: docker/login-action@v3
|
2023-01-31 12:14:05 -07:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
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'
|
2024-06-24 10:08:34 -06:00
|
|
|
uses: docker/login-action@v3
|
2023-02-06 06:33:56 -07:00
|
|
|
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
|
2024-06-24 10:08:34 -06:00
|
|
|
uses: docker/metadata-action@v5
|
2023-05-15 15:36:30 -06:00
|
|
|
with:
|
|
|
|
images: |
|
2024-07-19 23:06:40 -06:00
|
|
|
registry.internal.huggingface.tech/api-inference/community/text-generation-inference
|
2023-05-15 15:36:30 -06:00
|
|
|
tags: |
|
2024-06-24 10:08:34 -06:00
|
|
|
type=raw,value=sha-${{ env.GITHUB_SHA_SHORT }}${{ env.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: |
|
2024-07-25 08:06:00 -06:00
|
|
|
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-24 10:08:34 -06:00
|
|
|
type=semver,pattern={{version}}${{ env.LABEL }}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}${{ env.LABEL }}
|
|
|
|
type=raw,value=latest${{ env.LABEL }},enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
|
|
|
|
type=raw,value=sha-${{ env.GITHUB_SHA_SHORT }}${{ env.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-24 10:08:34 -06:00
|
|
|
file: ${{ env.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-24 10:08:34 -06:00
|
|
|
DOCKER_LABEL=sha-${{ env.GITHUB_SHA_SHORT }}${{ env.LABEL }}
|
2024-08-12 06:10:30 -06:00
|
|
|
PLATFORM=${{ env.PLATFORM }}
|
2023-05-15 15:36:30 -06:00
|
|
|
tags: ${{ steps.meta.outputs.tags || steps.meta-pr.outputs.tags }}
|
2024-07-09 09:23:48 -06:00
|
|
|
labels: ${{ steps.meta.outputs.labels || steps.meta-pr.outputs.labels }}
|
2024-07-08 10:13:32 -06:00
|
|
|
cache-from: type=s3,region=us-east-1,bucket=ci-docker-buildx-cache,name=text-generation-inference-cache${{ env.LABEL }},mode=min,access_key_id=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_ACCESS_KEY_ID }},secret_access_key=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_SECRET_ACCESS_KEY }},mode=min
|
|
|
|
cache-to: type=s3,region=us-east-1,bucket=ci-docker-buildx-cache,name=text-generation-inference-cache${{ env.LABEL }},mode=min,access_key_id=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_ACCESS_KEY_ID }},secret_access_key=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_SECRET_ACCESS_KEY }},mode=min
|
2024-06-24 10:08:34 -06:00
|
|
|
- name: Final
|
|
|
|
id: final
|
|
|
|
run: |
|
2024-07-25 08:06:00 -06:00
|
|
|
echo "docker_image=registry.internal.huggingface.tech/api-inference/community/text-generation-inference:sha-${{ env.GITHUB_SHA_SHORT}}${{ env.LABEL }}" >> "$GITHUB_OUTPUT"
|
2024-06-24 10:08:34 -06:00
|
|
|
echo "docker_devices=${{ env.DOCKER_DEVICES }}" >> "$GITHUB_OUTPUT"
|
|
|
|
echo "runs_on=${{ env.RUNS_ON }}" >> "$GITHUB_OUTPUT"
|
|
|
|
echo "label=${{ env.LABEL }}" >> "$GITHUB_OUTPUT"
|
|
|
|
integration_tests:
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.job }}-${{ needs.build-and-push.outputs.label }}-${{ github.head_ref || github.run_id }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
needs: build-and-push
|
2024-07-19 23:06:40 -06:00
|
|
|
runs-on:
|
|
|
|
group: ${{ needs.build-and-push.outputs.runs_on }}
|
2024-06-24 10:08:34 -06:00
|
|
|
if: needs.build-and-push.outputs.runs_on != 'ubuntu-latest'
|
2024-06-25 08:53:20 -06:00
|
|
|
env:
|
2024-08-16 13:19:46 -06:00
|
|
|
PYTEST_FLAGS: ${{ (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || inputs.release-tests == true) && '--release' || '--release' }}
|
2024-06-24 10:08:34 -06:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Inject slug/short variables
|
|
|
|
uses: rlespinasse/github-slug-action@v4.4.1
|
2023-12-15 04:52:24 -07:00
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
2024-06-24 10:08:34 -06:00
|
|
|
python-version: "3.10"
|
2023-12-15 04:52:24 -07:00
|
|
|
- name: Install
|
|
|
|
run: |
|
|
|
|
make install-integration-tests
|
|
|
|
- name: Run tests
|
|
|
|
run: |
|
2024-06-06 10:51:42 -06:00
|
|
|
export DOCKER_VOLUME=/mnt/cache
|
2024-06-24 10:08:34 -06:00
|
|
|
export DOCKER_IMAGE=${{ needs.build-and-push.outputs.docker_image }}
|
|
|
|
export DOCKER_DEVICES=${{ needs.build-and-push.outputs.docker_devices }}
|
2024-06-25 05:20:57 -06:00
|
|
|
export HF_TOKEN=${{ secrets.HF_TOKEN }}
|
2024-06-24 10:08:34 -06:00
|
|
|
echo $DOCKER_IMAGE
|
2024-06-25 08:53:20 -06:00
|
|
|
pytest -s -vv integration-tests ${PYTEST_FLAGS}
|