refactor: rename project #8
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
| # This workflow packs the Docker images for the Benchmark Runner. | |
| name: Pack | |
| permissions: | |
| actions: read | |
| contents: write | |
| pull-requests: write | |
| defaults: | |
| run: | |
| shell: bash | |
| on: | |
| workflow_dispatch: {} | |
| push: | |
| branches: | |
| - "main" | |
| - "v*-dev" | |
| tags: | |
| - "v*.*.*" | |
| paths-ignore: | |
| - "mkdocs.yml" | |
| - "docs/**" | |
| - "**.md" | |
| - "**.mdx" | |
| - "**.png" | |
| - "**.jpg" | |
| - "**.gif" | |
| pull_request: | |
| branches: | |
| - "main" | |
| - "v*-dev" | |
| paths: | |
| - ".github/workflows/pack.yaml" | |
| - "Dockerfile" | |
| env: | |
| INPUT_PYTHON_VERSION: 3.11 | |
| INPUT_USERNAME: ${{ secrets.CI_DOCKERHUB_USERNAME || 'gpustack' }} | |
| INPUT_PASSWORD: ${{ secrets.CI_DOCKERHUB_PASSWORD }} | |
| INPUT_NAMESPACE: ${{ secrets.CI_DOCKERHUB_NAMESPACE || 'gpustack' }} | |
| INPUT_REPOSITORY: benchmark-runner | |
| jobs: | |
| pack: | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 360 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| persist-credentials: false | |
| - name: Maximize Docker Build Space | |
| uses: gpustack/.github/.github/actions/maximize-docker-build-space@main | |
| with: | |
| deep-clean: true | |
| root-reserve-mb: 20480 | |
| - name: Setup BuildX Cache | |
| id: setup-buildx-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ github.workspace }}/.cache | |
| key: cache-mount-${{ hashFiles('uv.lock') }} | |
| - name: Restore BuildX Cache | |
| uses: reproducible-containers/buildkit-cache-dance@v3 | |
| with: | |
| builder: ${{ steps.setup-buildx.outputs.name }} | |
| cache-dir: ${{ github.workspace }}/.cache | |
| dockerfile: ${{ github.workspace }}/Dockerfile | |
| skip-extraction: ${{ steps.setup-buildx-cache.outputs.cache-hit }} | |
| - name: Setup QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| image: tonistiigi/binfmt:qemu-v9.2.2 | |
| platforms: "arm64" | |
| - name: Setup BuildX | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: | | |
| network=host | |
| env.BUILDKIT_STEP_LOG_MAX_SIZE=-1 | |
| env.BUILDKIT_STEP_LOG_MAX_SPEED=-1 | |
| - name: Login DockerHub | |
| if: ${{ github.event_name != 'pull_request' }} | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ env.INPUT_USERNAME }} | |
| password: ${{ env.INPUT_PASSWORD }} | |
| - name: Get Metadata | |
| id: metadata | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: "${{ env.INPUT_NAMESPACE }}/${{ env.INPUT_REPOSITORY }}" | |
| tags: | | |
| type=ref,event=pr | |
| type=raw,value=dev,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=sha,prefix=dev-,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=ref,event=branch,enable=${{ contains(github.ref, 'refs/heads/v') && endsWith(github.ref, '-dev') }} | |
| type=sha,prefix={{branch}}-,enable=${{ contains(github.ref, 'refs/heads/v') && endsWith(github.ref, '-dev') }} | |
| type=pep440,pattern={{raw}} | |
| type=pep440,pattern=v{{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc') }} | |
| type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc') }} | |
| flavor: | | |
| latest=false | |
| - name: Get Cache Ref | |
| run: | | |
| # | |
| # Use different cache ref for different branches. | |
| # | |
| # Examples: | |
| # CACHE_FROM_REF | |
| # - vX.Y.Z -> "gpustack/build-cache:benchmark-runner-${VERSION|DEFAULT_BRANCH}" | |
| # - PR/PUSH to branch -> "gpustack/build-cache:benchmark-runner-${BRANCH|DEFUALT_BRANCH}" | |
| # CACHE_TO_REF | |
| # - vX.Y.Z -> "gpustack/build-cache:benchmark-runner-${VERSION}" | |
| # - PUSH to branch -> "gpustack/build-cache:benchmark-runner-${BRANCH}" | |
| # | |
| # Stories: | |
| # CACHE_FROM_REF | |
| # - Release tag v0.7.0rc1 -> gpustack/build-cache:benchmark-runner-v0.7, if not found, fallback to gpustack/build-cache:benchmark-runner-main | |
| # - Release tag v0.7.0 -> gpustack/build-cache:benchmark-runner-v0.7 | |
| # - PR to "main" branch -> gpustack/build-cache:benchmark-runner-main | |
| # - PR to "v0.7-dev" branch -> gpustack/build-cache:benchmark-runner-v0.7, if not found, fallback to gpustack/build-cache:benchmark-runner-main | |
| # - Push to "main" branch -> gpustack/build-cache:benchmark-runner-main | |
| # - Push to "v0.7-dev" branch -> gpustack/build-cache:benchmark-runner-v0.7, if not found, fallback to gpustack/build-cache:benchmark-runner-main | |
| # CACHE_TO_REF | |
| # - Release tag v0.7.0rc1 -> gpustack/build-cache:benchmark-runner-v0.7 | |
| # - Release tag v0.7.0 -> gpustack/build-cache:benchmark-runner-v0.7 | |
| # - PR to "main" branch -> gpustack/build-cache:benchmark-runner-main | |
| # - PR to "v0.7-dev" branch -> gpustack/build-cache:benchmark-runner-v0.7 | |
| # - Push to "main" branch -> gpustack/build-cache:benchmark-runner-main | |
| # - Push to "v0.7-dev" branch -> gpustack/build-cache:benchmark-runner-v0.7 | |
| # | |
| DEFAULT_BRANCH="main" | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| REF="${GITHUB_REF#refs/tags/}" | |
| IFS="." read -r VERSION_MAJOR VERSION_MINOR VERSION_PATCH <<< "${REF}" | |
| VERSION="${VERSION_MAJOR}.${VERSION_MINOR}" | |
| CACHE_FROM_REF="gpustack/build-cache:benchmark-runner-${VERSION}" | |
| CACHE_TO_REF="${CACHE_FROM_REF}" | |
| else | |
| REF="${GITHUB_BASE_REF:-${GITHUB_REF}}" | |
| BRANCH="${REF#refs/heads/}" | |
| BRANCH="${BRANCH%-dev}" | |
| CACHE_FROM_REF="gpustack/build-cache:benchmark-runner-${BRANCH}" | |
| CACHE_TO_REF="${CACHE_FROM_REF}" | |
| fi | |
| if ! docker manifest inspect "${CACHE_FROM_REF}" >/dev/null 2>&1; then | |
| CACHE_FROM_REF="gpustack/build-cache:benchmark-runner-${DEFAULT_BRANCH}" | |
| fi | |
| echo "CACHE_FROM_REF=${CACHE_FROM_REF}" >> $GITHUB_ENV | |
| echo "CACHE_TO_REF=${CACHE_TO_REF}" >> $GITHUB_ENV | |
| echo "DEBUG: GITHUB_BASE_REF=${GITHUB_BASE_REF}" | |
| echo "DEBUG: GITHUB_REF=${GITHUB_REF}" | |
| echo "DEBUG: CACHE_FROM_REF=${CACHE_FROM_REF}" | |
| echo "DEBUG: CACHE_TO_REF=${CACHE_TO_REF}" | |
| - name: Get Image Labels | |
| run: | | |
| #!/usr/bin/env bash | |
| set -eo pipefail | |
| LABELS=( | |
| "org.opencontainers.image.source=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.source'] }}" | |
| "org.opencontainers.image.version=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.version'] }}" | |
| "org.opencontainers.image.revision=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.revision'] }}" | |
| "org.opencontainers.image.created=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.created'] }}" | |
| ) | |
| INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS=$(printf "%s;" "${LABELS[@]}") | |
| echo "INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS=${INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS}" >> $GITHUB_ENV | |
| - name: Package | |
| uses: docker/build-push-action@v6 | |
| with: | |
| allow: | | |
| network.host | |
| security.insecure | |
| ulimit: | | |
| nofile=65536:65536 | |
| shm-size: 16G | |
| provenance: true | |
| sbom: true | |
| push: ${{ github.event_name != 'pull_request' }} | |
| file: ${{ github.workspace }}/Dockerfile | |
| context: ${{ github.workspace }} | |
| platforms: "linux/amd64,linux/arm64" | |
| build-args: | | |
| PYTHON_VERSION=${{ env.INPUT_PYTHON_VERSION }} | |
| GPUSTACK_RUNTIME_DOCKER_MIRRORED_NAME_FILTER_LABELS=${{ env.INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS }} | |
| tags: | | |
| ${{ steps.metadata.outputs.tags }} | |
| labels: | | |
| ${{ steps.metadata.outputs.labels }} | |
| cache-from: | | |
| type=registry,ref=${{ env.CACHE_FROM_REF }} | |
| cache-to: | | |
| ${{ github.event_name != 'pull_request' && format('type=registry,mode=max,compression=gzip,ref={0},ignore-error=true', env.CACHE_TO_REF) || '' }} |