Skip to content

Commit d8c81a3

Browse files
Merge pull request IBM#58 from opendatahub-io/main
Sync main and release branches
2 parents 5ea1f15 + 6256dd3 commit d8c81a3

File tree

17 files changed

+256
-216
lines changed

17 files changed

+256
-216
lines changed

.dockerignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
# exclude any files inside the .git folder to not invalidate docker layer caches
2+
.git
3+
4+
# exclude build artifacts
15
target
2-
server/transformers
6+
server/transformers

.github/workflows/build.yml

Lines changed: 78 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ name: "Build"
22

33
on:
44
workflow_dispatch:
5+
56
push:
67
branches:
7-
- "main"
8+
- main
89
paths-ignore:
910
- "**.md"
1011
- "proto/**"
12+
1113
pull_request:
1214
branches:
13-
- "main"
15+
- main
1416
paths-ignore:
1517
- "**.md"
1618
- "proto/**"
@@ -21,102 +23,84 @@ defaults:
2123

2224
env:
2325
CI: true
24-
DOCKER_BUILDKIT: 1
2526
SERVER_IMAGE_NAME: "text-gen-server:0"
27+
SERVER_IMAGE: "ghcr.io/ibm/text-gen-server:latest" # TODO: consider publishing to quay.io or icr.io instead
2628

2729
jobs:
2830
build:
2931
runs-on: ubuntu-latest
32+
permissions:
33+
packages: write
34+
contents: read
3035
env:
31-
BUILDKIT_INLINE_CACHE: 1
32-
36+
CACHE_IMAGE: "ghcr.io/ibm/text-gen-server:build-cache"
37+
CACHE_REGISTRY: "ghcr.io"
38+
CACHE_PACKAGE_NAME: "text-gen-server"
39+
3340
steps:
34-
- name: "Checkout"
35-
uses: actions/checkout@v4
36-
37-
- name: "Free up disk space"
38-
uses: ./.github/actions/free-up-disk-space
39-
40-
- name: "Set up QEMU"
41-
uses: docker/setup-qemu-action@v3
42-
43-
- name: "Set up Docker Buildx"
44-
uses: docker/setup-buildx-action@v3
45-
46-
- name: "Generate job steps to build stages sequentially"
47-
run: |
48-
build_targets=$(grep -iE "^FROM .+ as .*$" Dockerfile | grep -E -o "[^ ]+$")
49-
for t in $build_targets; do
50-
echo
51-
echo " - name: \"Docker build ${t}\""
52-
echo " run: docker build --target=$t -t $t ."
53-
done
54-
55-
- name: "Docker build base"
56-
run: docker build --target=base -t base .
57-
58-
- name: "Docker build cuda-base"
59-
run: docker build --target=cuda-base -t cuda-base .
60-
61-
- name: "Docker build cuda-devel"
62-
run: docker build --target=cuda-devel -t cuda-devel .
63-
64-
- name: "Docker build python-builder"
65-
run: docker build --target=python-builder -t python-builder .
66-
67-
- name: "Docker build flash-att-v2-builder"
68-
run: docker build --target=flash-att-v2-builder -t flash-att-v2-builder .
69-
70-
- name: "Docker build flash-att-builder"
71-
run: docker build --target=flash-att-builder -t flash-att-builder .
72-
73-
- name: "Docker build flash-att-cache"
74-
run: docker build --target=flash-att-cache -t flash-att-cache .
75-
76-
- name: "Docker build flash-att-v2-cache"
77-
run: docker build --target=flash-att-v2-cache -t flash-att-v2-cache .
78-
79-
- name: "Docker build auto-gptq-installer"
80-
run: docker build --target=auto-gptq-installer -t auto-gptq-installer .
81-
82-
- name: "Docker build auto-gptq-cache"
83-
run: docker build --target=auto-gptq-cache -t auto-gptq-cache .
84-
85-
- name: "Docker build cuda-runtime"
86-
run: docker build --target=cuda-runtime -t cuda-runtime .
87-
88-
- name: "Docker build rust-builder"
89-
run: docker build --target=rust-builder -t rust-builder .
90-
91-
- name: "Docker build router-builder"
92-
run: docker build --target=router-builder -t router-builder .
93-
94-
- name: "Docker build launcher-builder"
95-
run: docker build --target=launcher-builder -t launcher-builder .
96-
97-
- name: "Docker build test-base"
98-
run: docker build --target=test-base -t test-base .
99-
100-
- name: "Docker build cpu-tests"
101-
run: docker build --target=cpu-tests -t cpu-tests .
102-
103-
- name: "Docker build build"
104-
run: docker build --target=build -t build .
105-
106-
- name: "Docker build exllama-kernels-builder"
107-
run: docker build --target=exllama-kernels-builder -t exllama-kernels-builder .
108-
109-
- name: "Docker build exllamav2-kernels-builder"
110-
run: docker build --target=exllamav2-kernels-builder -t exllamav2-kernels-builder .
111-
112-
- name: "Docker build server-release"
113-
run: docker build --target=server-release -t server-release .
114-
115-
- name: "List docker images"
116-
run: docker images
117-
118-
- name: "Check disk usage"
119-
shell: bash
120-
run: |
121-
docker system df
122-
df -h
41+
- name: "Checkout"
42+
uses: actions/checkout@v4
43+
44+
- name: "Free up disk space"
45+
uses: ./.github/actions/free-up-disk-space
46+
47+
- name: "Set up QEMU"
48+
uses: docker/setup-qemu-action@v3
49+
50+
- name: "Set up Docker Buildx"
51+
uses: docker/setup-buildx-action@v3
52+
53+
- name: "Log in to cache image container registry"
54+
uses: docker/login-action@v3
55+
with:
56+
registry: ${{ env.CACHE_REGISTRY }}
57+
username: ${{ github.actor }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: "Set build cache target"
61+
run: |
62+
# For push to `main` (PR merged), push a new cache image with all layers (cache-mode=max).
63+
# For PR builds, use GitHub action cache which isolates cached layers by PR/branch.
64+
# to optimize builds for subsequent pushes to the same PR/branch.
65+
# Do not set a cache-to image for PR builds to not overwrite the `main` cache image and
66+
# to not ping-pong cache images for two or more different PRs.
67+
# Do not push cache images for each PR or multiple branches to not exceed GitHub package
68+
# usage and traffic limitations.
69+
# UPDATE 2024/02/26: GHA cache appears to have issues, cannot use `cache-to: gha,mode=min`
70+
# if `cache-from: reg...,mode=max` but `cache-to: gha,mode=max` takes longer than uncached
71+
# build and exhausts GHA cache size limits, so use cache `type=inline` (no external cache).
72+
if [ "${{ github.event_name }}" == "pull_request" ]
73+
then
74+
#CACHE_TO="type=gha,mode=min"
75+
CACHE_TO="type=inline"
76+
else
77+
CACHE_TO="type=registry,ref=${{ env.CACHE_IMAGE }},mode=max"
78+
fi
79+
echo "CACHE_TO=$CACHE_TO" >> $GITHUB_ENV
80+
81+
- name: "Docker build server-release"
82+
uses: docker/build-push-action@v5
83+
with:
84+
context: .
85+
target: server-release
86+
tags: ${{ env.SERVER_IMAGE }}
87+
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}
88+
cache-to: ${{ env.CACHE_TO }}
89+
push: ${{ github.event_name != 'pull_request' }}
90+
91+
- name: "Cleanup old cache images"
92+
uses: actions/delete-package-versions@v5
93+
if: ${{ github.event_name == 'push' }}
94+
with:
95+
package-name: ${{ env.CACHE_PACKAGE_NAME }}
96+
package-type: container
97+
delete-only-untagged-versions: true
98+
99+
- name: "List docker images"
100+
run: docker images
101+
102+
- name: "Check disk usage"
103+
shell: bash
104+
run: |
105+
docker system df
106+
df -h

.github/workflows/test.yml

Lines changed: 72 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ name: "Test"
22

33
on:
44
workflow_dispatch:
5+
6+
push:
7+
branches:
8+
- main
9+
paths-ignore:
10+
- "**.md"
11+
- "proto/**"
12+
513
pull_request:
614
branches:
715
- main
@@ -15,54 +23,82 @@ defaults:
1523

1624
env:
1725
CI: true
18-
DOCKER_BUILDKIT: 1
1926
TEST_IMAGE_NAME: "cpu-tests:0"
2027

2128
jobs:
2229
build:
2330
runs-on: ubuntu-latest
24-
steps:
25-
- name: "Checkout"
26-
uses: actions/checkout@v4
27-
28-
- name: "Free up disk space"
29-
uses: ./.github/actions/free-up-disk-space
30-
31-
- name: "Set up QEMU"
32-
uses: docker/setup-qemu-action@v3
33-
34-
- name: "Setup Docker Buildx"
35-
uses: docker/setup-buildx-action@v3
36-
37-
- name: "Build test image"
38-
uses: docker/build-push-action@v5
39-
with:
40-
context: .
41-
file: ./Dockerfile
42-
target: "cpu-tests"
43-
tags: ${{ env.TEST_IMAGE_NAME }}
44-
outputs: type=docker,dest=/tmp/test_image.tar
45-
46-
- name: "Upload test image"
47-
uses: actions/upload-artifact@v4
48-
with:
49-
name: "test-image"
50-
path: /tmp/test_image.tar
51-
retention-days: 1
31+
permissions:
32+
packages: write
33+
contents: read
34+
env:
35+
CACHE_IMAGE: "ghcr.io/ibm/text-gen-server:test-cache"
36+
CACHE_REGISTRY: "ghcr.io"
5237

53-
test-python:
54-
runs-on: ubuntu-latest
55-
needs: build
5638
steps:
5739
- name: "Checkout"
58-
uses: actions/checkout@v3
40+
uses: actions/checkout@v4
5941

60-
- name: "Free up disk space"
61-
uses: ./.github/actions/free-up-disk-space
42+
- name: "Set up QEMU"
43+
uses: docker/setup-qemu-action@v3
6244

6345
- name: "Setup Docker Buildx"
6446
uses: docker/setup-buildx-action@v3
6547

48+
- name: "Log in to cache image container registry"
49+
uses: docker/login-action@v3
50+
with:
51+
registry: ${{ env.CACHE_REGISTRY }}
52+
username: ${{ github.actor }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: "Set build cache target"
56+
run: |
57+
# For push to `main` (PR merged), push a new cache image with all layers (cache-mode=max).
58+
# For PR builds, use GitHub action cache which isolates cached layers by PR/branch.
59+
# to optimize builds for subsequent pushes to the same PR/branch.
60+
# Do not set a cache-to image for PR builds to not overwrite the `main` cache image and
61+
# to not ping-pong cache images for two or more different PRs.
62+
# Do not push cache images for each PR or multiple branches to not exceed GitHub package
63+
# usage and traffic limitations.
64+
# UPDATE 2024/02/26: GHA cache appears to have issues, cannot use `cache-to: gha,mode=min`
65+
# if `cache-from: reg...,mode=max` but `cache-to: gha,mode=max` takes longer than uncached
66+
# build and exhausts GHA cache size limits, so use cache `type=inline` (no external cache).
67+
if [ "${{ github.event_name }}" == "pull_request" ]
68+
then
69+
#CACHE_TO="type=gha,mode=min"
70+
CACHE_TO="type=inline"
71+
else
72+
CACHE_TO="type=registry,ref=${{ env.CACHE_IMAGE }},mode=max"
73+
fi
74+
echo "CACHE_TO=$CACHE_TO" >> $GITHUB_ENV
75+
76+
- name: "Build test image"
77+
uses: docker/build-push-action@v5
78+
with:
79+
context: .
80+
target: "cpu-tests"
81+
tags: ${{ env.TEST_IMAGE_NAME }}
82+
cache-from: |
83+
type=gha
84+
type=registry,ref=${{ env.CACHE_IMAGE }}
85+
cache-to: ${{ env.CACHE_TO }}
86+
outputs: type=docker,dest=/tmp/test_image.tar
87+
88+
- name: "Upload test image"
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: "test-image"
92+
path: /tmp/test_image.tar
93+
retention-days: 1
94+
95+
test-python:
96+
runs-on: ubuntu-latest
97+
needs: build
98+
steps:
99+
- name: "Checkout"
100+
uses: actions/checkout@v4
101+
66102
- name: "Download test image"
67103
uses: actions/download-artifact@v4
68104
with:
@@ -83,13 +119,7 @@ jobs:
83119
needs: build
84120
steps:
85121
- name: "Checkout"
86-
uses: actions/checkout@v3
87-
88-
- name: "Free up disk space"
89-
uses: ./.github/actions/free-up-disk-space
90-
91-
- name: "Setup Docker Buildx"
92-
uses: docker/setup-buildx-action@v3
122+
uses: actions/checkout@v4
93123

94124
- name: "Download test image"
95125
uses: actions/download-artifact@v4

0 commit comments

Comments
 (0)