Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Github Actions #2

Merged
merged 4 commits into from
Mar 12, 2024
Merged
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
36 changes: 36 additions & 0 deletions .github/actions/free-up-disk-space/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Free up disk space"
description: "Removes non-essential tools, libraries and cached files from GitHub action runner node"

runs:
using: "composite"
steps:
- name: "Remove non-essential tools and libraries"
shell: bash
run: |
# https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
echo "Disk usage before cleanup:"
df -h
echo "Removing non-essential tools and libraries ..."
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /usr/share/dotnet
# sudo rm -rf /usr/local/share/boost
echo "Deleting libraries for Android (12G), CodeQL (5.3G), PowerShell (1.3G), Swift (1.7G) ..."
sudo rm -rf /usr/local/lib/android
sudo rm -rf "${AGENT_TOOLSDIRECTORY}/CodeQL"
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/share/swift
# ref: https://github.com/jlumbroso/free-disk-space/blob/main/action.yml
echo "Deleting some larger apt packages:"
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing || echo "::warning::The command [sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing] failed to complete successfully. Proceeding..."
echo "Disk usage after cleanup:"
df -h

- name: "Prune docker images"
shell: bash
run: |
echo "Pruning docker images ..."
docker image prune -a -f
docker system df
echo "Disk usage after pruning docker images:"
df -h
128 changes: 128 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: "Build"

on:
workflow_dispatch:

push:
branches:
- main
paths-ignore:
- "**.md"
- "proto/**"

pull_request:
branches:
- main
paths-ignore:
- "**.md"
- "proto/**"

defaults:
run:
shell: bash

env:
SERVER_IMAGE: "quay.io/wxpe/tgis-vllm"
IMAGE_REGISTRY: "quay.io"

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
env:
CACHE_IMAGE: "ghcr.io/ibm/tgis-vllm:build-cache"
CACHE_REGISTRY: "ghcr.io"
CACHE_PACKAGE_NAME: "tgis-vllm"

steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Free up disk space"
uses: ./.github/actions/free-up-disk-space

- name: "Set up QEMU"
uses: docker/setup-qemu-action@v3

- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v3

- name: "Log in to container registry (server-release)"
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ secrets.WXPE_QUAY_USER }}
password: ${{ secrets.WXPE_QUAY_TOKEN }}

- name: "Log in to container registry (cache image)"
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ${{ env.CACHE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: "Set build cache target"
run: |
# For push to `main` (PR merged), push a new cache image with all layers (cache-mode=max).
# For PR builds, use GitHub action cache which isolates cached layers by PR/branch.
# to optimize builds for subsequent pushes to the same PR/branch.
# Do not set a cache-to image for PR builds to not overwrite the `main` cache image and
# to not ping-pong cache images for two or more different PRs.
# Do not push cache images for each PR or multiple branches to not exceed GitHub package
# usage and traffic limitations.
# UPDATE 2024/02/26: GHA cache appears to have issues, cannot use `cache-to: gha,mode=min`
# if `cache-from: reg...,mode=max` but `cache-to: gha,mode=max` takes longer than uncached
# build and exhausts GHA cache size limits, so use cache `type=inline` (no external cache).
if [ "${{ github.event_name }}" == "pull_request" ]
then
#CACHE_TO="type=gha,mode=min"
CACHE_TO="type=inline"
else
CACHE_TO="type=registry,ref=${{ env.CACHE_IMAGE }},mode=max"
fi
echo "CACHE_TO=$CACHE_TO" >> $GITHUB_ENV

- name: "Generate tags"
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.SERVER_IMAGE }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,enable=true,priority=100,prefix=,suffix=,format=short
type=sha,enable=true,priority=100,prefix=${{ github.ref_name }}.,suffix=,format=short

- name: "UBI Docker build"
uses: docker/build-push-action@v5
with:
context: .
target: vllm-openai
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}
cache-to: ${{ env.CACHE_TO }}
push: ${{ github.event_name != 'pull_request' }}
file: Dockerfile.ubi

- name: "Cleanup old cache images"
uses: actions/delete-package-versions@v5
if: ${{ github.event_name == 'push' }}
with:
package-name: ${{ env.CACHE_PACKAGE_NAME }}
package-type: container
delete-only-untagged-versions: true

- name: "List docker images"
run: docker images

- name: "Check disk usage"
shell: bash
run: |
docker system df
df -h
102 changes: 0 additions & 102 deletions .github/workflows/publish.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/scripts/build.sh

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/scripts/create_release.js

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/scripts/cuda-install.sh

This file was deleted.

56 changes: 0 additions & 56 deletions .github/workflows/scripts/env.sh

This file was deleted.

Loading
Loading