Skip to content

Commit a0b94b5

Browse files
authored
Add image build job in docker compose e2e xeon test in CI (#304)
Signed-off-by: Yingchun Guo <[email protected]>
1 parent a1a384e commit a0b94b5

File tree

9 files changed

+81
-114
lines changed

9 files changed

+81
-114
lines changed

.github/workflows/E2E_test_with_compose.yml renamed to .github/workflows/docker-compose-e2e.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- "**/ui/**"
1414
- "!**.md"
1515
- "!**.txt"
16-
- .github/workflows/E2E_test_with_compose.yml
16+
- .github/workflows/docker-compose-e2e.yml
1717
workflow_dispatch:
1818

1919
# If there is a new commit, the previous jobs will be canceled
@@ -25,10 +25,20 @@ jobs:
2525
job1:
2626
uses: ./.github/workflows/reuse-get-test-matrix.yml
2727
with:
28-
diff-excluded-files: '.github|README.md|*.txt|deprecate|kubernetes|manifest|assets'
28+
diff_excluded_files: '.github|README.md|*.txt|deprecate|kubernetes|manifest|assets'
2929

30-
Example-test:
30+
mega-image-build:
3131
needs: job1
32+
strategy:
33+
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
34+
uses: ./.github/workflows/reuse-image-build.yml
35+
with:
36+
image_tag: ${{ github.event.pull_request.head.sha }}
37+
mega_service: "${{ matrix.example }}"
38+
runner_label: "docker-build-${{ matrix.hardware }}"
39+
40+
Example-test:
41+
needs: [job1, mega-image-build]
3242
strategy:
3343
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
3444
runs-on: ${{ matrix.hardware }}
@@ -51,6 +61,8 @@ jobs:
5161
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HUGGINGFACEHUB_API_TOKEN }}
5262
example: ${{ matrix.example }}
5363
hardware: ${{ matrix.hardware }}
64+
IMAGE_REPO: ${{needs.mega-image-build.outputs.image_repo}}
65+
IMAGE_TAG: ${{needs.mega-image-build.outputs.image_tag}}
5466
run: |
5567
cd ${{ github.workspace }}/$example/tests
5668
example_l=$(echo $example | tr '[:upper:]' '[:lower:]')

.github/workflows/manifest-e2e.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212
- "**/tests/test_manifest**"
1313
- "!**.md"
1414
- "!**.txt"
15-
- .github/workflows/manifest-e2e.yml
1615
workflow_dispatch:
1716

1817
concurrency:
@@ -23,18 +22,18 @@ jobs:
2322
job1:
2423
uses: ./.github/workflows/reuse-get-test-matrix.yml
2524
with:
26-
diff-excluded-files: '.github|deprecated|docker|assets|*.md|*.txt'
27-
xeon-server-lable: 'k8s'
28-
gaudi-server-lable: ""
25+
diff_excluded_files: '.github|deprecated|docker|assets|*.md|*.txt'
26+
xeon_server_label: 'k8s'
27+
gaudi_server_label: ""
2928

3029
mega-image-build:
3130
needs: job1
3231
strategy:
3332
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
3433
uses: ./.github/workflows/reuse-image-build.yml
3534
with:
36-
image-tag: ${{ github.event.pull_request.head.sha }}
37-
mega-service: "${{ matrix.example }}"
35+
image_tag: ${{ github.event.pull_request.head.sha }}
36+
mega_service: "${{ matrix.example }}"
3837

3938
manifest-test:
4039
needs: [job1, mega-image-build]
@@ -57,8 +56,8 @@ jobs:
5756

5857
- name: Set variables
5958
run: |
60-
echo "IMAGE_REPO=${OPEA_IMAGE_REPO}/" >> $GITHUB_ENV
61-
echo "IMAGE_TAG=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
59+
echo "IMAGE_REPO=${{needs.mega-image-build.outputs.image_repo}}" >> $GITHUB_ENV
60+
echo "IMAGE_TAG=${{needs.mega-image-build.outputs.image_tag}}" >> $GITHUB_ENV
6261
lower_example=$(echo "${{ matrix.example }}" | tr '[:upper:]' '[:lower:]')
6362
echo "NAMESPACE=$lower_example-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
6463
echo "ROLLOUT_TIMEOUT_SECONDS=1800s" >> $GITHUB_ENV

.github/workflows/reuse-get-test-matrix.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ permissions: read-all
77
on:
88
workflow_call:
99
inputs:
10-
diff-excluded-files:
10+
diff_excluded_files:
1111
required: false
1212
type: string
1313
default: '.github|README.md|*.txt'
14-
xeon-server-lable:
14+
xeon_server_label:
1515
required: false
1616
type: string
1717
default: 'xeon'
18-
gaudi-server-lable:
18+
gaudi_server_label:
1919
required: false
2020
type: string
2121
default: 'gaudi'
@@ -57,7 +57,7 @@ jobs:
5757
fi
5858
merged_commit=$(git log -1 --format='%H')
5959
changed_files="$(git diff --name-only ${base_commit} ${merged_commit} | \
60-
grep -vE '${{ inputs.diff-excluded-files }}')" || true
60+
grep -vE '${{ inputs.diff_excluded_files }}')" || true
6161
examples=$(printf '%s\n' "${changed_files[@]}" | grep '/' | cut -d'/' -f1 | sort -u)
6262
run_matrix="{\"include\":["
6363
for example in ${examples}; do
@@ -66,10 +66,10 @@ jobs:
6666
if [ $(printf '%s\n' "${changed_files[@]}" | grep ${example} | grep -c xeon) != 0 ]; then run_hardware="xeon ${run_hardware}"; fi
6767
if [ "$run_hardware" == "" ]; then run_hardware="xeon"; fi
6868
for hw in ${run_hardware}; do
69-
if [ "$hw" == "gaudi" ] && [ "${{ inputs.gaudi-server-lable }}" != "" ]; then
70-
run_matrix="${run_matrix}{\"example\":\"${example}\",\"hardware\":\"${{ inputs.gaudi-server-lable }}\"},"
71-
elif [ "${{ inputs.xeon-server-lable }}" != "" ]; then
72-
run_matrix="${run_matrix}{\"example\":\"${example}\",\"hardware\":\"${{ inputs.xeon-server-lable }}\"},"
69+
if [ "$hw" == "gaudi" ] && [ "${{ inputs.gaudi_server_label }}" != "" ]; then
70+
run_matrix="${run_matrix}{\"example\":\"${example}\",\"hardware\":\"${{ inputs.gaudi_server_label }}\"},"
71+
elif [ "${{ inputs.xeon_server_label }}" != "" ]; then
72+
run_matrix="${run_matrix}{\"example\":\"${example}\",\"hardware\":\"${{ inputs.xeon_server_label }}\"},"
7373
fi
7474
done
7575
done

.github/workflows/reuse-image-build.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,33 @@ permissions: read-all
66
on:
77
workflow_call:
88
inputs:
9-
image-repo:
9+
image_repo:
1010
required: false
1111
type: string
12-
image-tag:
12+
image_tag:
1313
required: true
1414
type: string
15-
mega-service:
15+
mega_service:
1616
required: true
1717
type: string
18-
runner_lable:
18+
runner_label:
1919
required: false
2020
type: string
21-
default: 'docker-build'
22-
23-
concurrency:
24-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-image-build
21+
default: 'docker-build-xeon'
22+
outputs:
23+
image_repo:
24+
description: "The image reposity used for the image build"
25+
value: ${{ jobs.mega-image-build.outputs.image_repo }}
26+
image_tag:
27+
description: "The image tag used for the image build"
28+
value: ${{ jobs.mega-image-build.outputs.image_tag }}
2529

2630
jobs:
2731
mega-image-build:
28-
runs-on: ${{ inputs.runner_lable }}
32+
runs-on: ${{ inputs.runner_label }}
33+
outputs:
34+
image_repo: ${{ steps.build-megaservice-image.outputs.image_repo }}
35+
image_tag: ${{ steps.build-megaservice-image.outputs.image_tag }}
2936
steps:
3037
- name: Checkout out Repo
3138
uses: actions/checkout@v4
@@ -35,8 +42,15 @@ jobs:
3542
- name: Building MegaService Docker Image
3643
id: build-megaservice-image
3744
env:
38-
IMAGE_REPO: ${{ inputs.image-repo }}
39-
IMAGE_TAG: ${{ inputs.image-tag }}
40-
mega-service: ${{ inputs.mega-service }}
45+
IMAGE_REPO: ${{ inputs.image_repo }}
46+
IMAGE_TAG: ${{ inputs.image_tag }}
47+
MEGA_SERVICE: ${{ inputs.mega_service }}
4148
run: |
42-
.github/workflows/scripts/build_push.sh ${{ env.mega-service}}
49+
.github/workflows/scripts/build_push.sh ${{ env.MEGA_SERVICE}}
50+
if [ -z "${{ env.IMAGE_REPO }}" ]; then
51+
IMAGE_REPO=$OPEA_IMAGE_REPO
52+
fi
53+
echo "IMAGE_REPO=${IMAGE_REPO}"
54+
echo "IMAGE_TAG=${IMAGE_TAG}"
55+
echo "image_repo=$IMAGE_REPO" >> $GITHUB_OUTPUT
56+
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT

.github/workflows/scripts/build_push.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function checkExist() {
2222

2323
function docker_build() {
2424
# check if if IMAGE_TAG is not "latest" and the image exists in the registry
25-
if [ $IMAGE_TAG != "latest" && $(checkExist $1) == "true" ]; then
25+
if [ "$IMAGE_TAG" != "latest" ] && [ "$(checkExist $1)" == "true" ]; then
2626
echo "Image ${IMAGE_REPO}opea/$1:$IMAGE_TAG already exists in the registry"
2727
return
2828
fi
@@ -35,7 +35,8 @@ function docker_build() {
3535
echo "Building ${IMAGE_REPO}opea/$1:$IMAGE_TAG using Dockerfile $DOCKERFILE_PATH"
3636
# if https_proxy and http_proxy are set, pass them to docker build
3737
if [ -z "$https_proxy" ]; then
38-
docker build --no-cache -t ${IMAGE_REPO}opea/$1:$IMAGE_TAG -f $DOCKERFILE_PATH .
38+
#docker build --no-cache -t ${IMAGE_REPO}opea/$1:$IMAGE_TAG -f $DOCKERFILE_PATH .
39+
docker build -t ${IMAGE_REPO}opea/$1:$IMAGE_TAG -f $DOCKERFILE_PATH .
3940
else
4041
docker build --no-cache -t ${IMAGE_REPO}opea/$1:$IMAGE_TAG --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f $DOCKERFILE_PATH .
4142
fi

ChatQnA/tests/test_chatqna_on_xeon.sh

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,6 @@ WORKPATH=$(dirname "$PWD")
88
LOG_PATH="$WORKPATH/tests"
99
ip_address=$(hostname -I | awk '{print $1}')
1010

11-
function build_docker_images() {
12-
cd $WORKPATH
13-
git clone https://github.com/opea-project/GenAIComps.git
14-
cd GenAIComps
15-
16-
docker build -t opea/embedding-tei:latest -f comps/embeddings/langchain/docker/Dockerfile .
17-
docker build -t opea/retriever-redis:latest -f comps/retrievers/langchain/redis/docker/Dockerfile .
18-
docker build -t opea/reranking-tei:latest -f comps/reranks/langchain/docker/Dockerfile .
19-
docker build -t opea/llm-tgi:latest -f comps/llms/text-generation/tgi/Dockerfile .
20-
docker build -t opea/dataprep-redis:latest -f comps/dataprep/redis/langchain/docker/Dockerfile .
21-
22-
cd $WORKPATH/docker
23-
docker build --no-cache -t opea/chatqna:latest -f Dockerfile .
24-
25-
cd $WORKPATH/docker/ui
26-
docker build --no-cache -t opea/chatqna-ui:latest -f docker/Dockerfile .
27-
28-
docker images
29-
}
30-
3111
function start_services() {
3212
cd $WORKPATH/docker/xeon
3313

@@ -50,9 +30,12 @@ function start_services() {
5030

5131
sed -i "s/backend_address/$ip_address/g" $WORKPATH/docker/ui/svelte/.env
5232

33+
# Replace the container name with a test-specific name
34+
echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG"
35+
sed -i "s#image: opea/chatqna:latest#image: opea/chatqna:${IMAGE_TAG}#g" docker_compose.yaml
36+
sed -i "s#image: opea/chatqna-ui:latest#image: opea/chatqna-ui:${IMAGE_TAG}#g" docker_compose.yaml
37+
sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" docker_compose.yaml
5338
# Start Docker Containers
54-
# TODO: Replace the container name with a test-specific name
55-
5639
docker compose -f docker_compose.yaml up -d
5740
n=0
5841
until [[ "$n" -ge 200 ]]; do
@@ -207,13 +190,10 @@ function main() {
207190
stop_docker
208191

209192
begin_time=$(date +%s)
210-
build_docker_images
211-
start_time=$(date +%s)
212193
start_services
213194
end_time=$(date +%s)
214-
minimal_duration=$((end_time-start_time))
215195
maximal_duration=$((end_time-begin_time))
216-
echo "Mega service start minimal duration is "$minimal_duration"s, maximal duration(including docker image build) is "$maximal_duration"s" && sleep 1s
196+
echo "Mega service start duration is "$maximal_duration"s" && sleep 1s
217197

218198
validate_microservices
219199
validate_megaservice

CodeGen/tests/test_codegen_on_xeon.sh

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,6 @@ WORKPATH=$(dirname "$PWD")
88
LOG_PATH="$WORKPATH/tests"
99
ip_address=$(hostname -I | awk '{print $1}')
1010

11-
function build_docker_images() {
12-
cd $WORKPATH
13-
git clone https://github.com/opea-project/GenAIComps.git
14-
cd GenAIComps
15-
16-
docker build -t opea/llm-tgi:latest -f comps/llms/text-generation/tgi/Dockerfile .
17-
18-
cd $WORKPATH/docker
19-
docker build --no-cache -t opea/codegen:latest -f Dockerfile .
20-
21-
cd $WORKPATH/docker/ui
22-
docker build --no-cache -t opea/codegen-ui:latest -f docker/Dockerfile .
23-
24-
docker images
25-
}
26-
2711
function start_services() {
2812
cd $WORKPATH/docker/xeon
2913

@@ -36,8 +20,12 @@ function start_services() {
3620

3721
sed -i "s/backend_address/$ip_address/g" $WORKPATH/docker/ui/svelte/.env
3822

23+
# Replace the container name with a test-specific name
24+
echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG"
25+
sed -i "s#image: opea/codegen:latest#image: opea/codegen:${IMAGE_TAG}#g" docker_compose.yaml
26+
sed -i "s#image: opea/codegen-ui:latest#image: opea/codegen-ui:${IMAGE_TAG}#g" docker_compose.yaml
27+
sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" docker_compose.yaml
3928
# Start Docker Containers
40-
# TODO: Replace the container name with a test-specific name
4129
docker compose -f docker_compose.yaml up -d
4230

4331
sleep 2m # Waits 2 minutes
@@ -140,7 +128,6 @@ function main() {
140128

141129
stop_docker
142130

143-
build_docker_images
144131
start_services
145132

146133
validate_microservices

CodeTrans/tests/test_codetrans_on_xeon.sh

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,6 @@ WORKPATH=$(dirname "$PWD")
88
LOG_PATH="$WORKPATH/tests"
99
ip_address=$(hostname -I | awk '{print $1}')
1010

11-
function build_docker_images() {
12-
cd $WORKPATH
13-
git clone https://github.com/opea-project/GenAIComps.git
14-
cd GenAIComps
15-
16-
docker build -t opea/llm-tgi:latest -f comps/llms/text-generation/tgi/Dockerfile .
17-
18-
cd $WORKPATH/docker
19-
docker build --no-cache -t opea/codetrans:latest -f Dockerfile .
20-
21-
cd $WORKPATH/docker/ui
22-
docker build --no-cache -t opea/codetrans-ui:latest -f docker/Dockerfile .
23-
24-
docker images
25-
}
26-
2711
function start_services() {
2812
cd $WORKPATH/docker/xeon
2913
export http_proxy=${http_proxy}
@@ -37,8 +21,12 @@ function start_services() {
3721

3822
sed -i "s/backend_address/$ip_address/g" $WORKPATH/docker/ui/svelte/.env
3923

24+
# Replace the container name with a test-specific name
25+
echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG"
26+
sed -i "s#image: opea/codetrans:latest#image: opea/codetrans:${IMAGE_TAG}#g" docker_compose.yaml
27+
sed -i "s#image: opea/codetrans-ui:latest#image: opea/codetrans-ui:${IMAGE_TAG}#g" docker_compose.yaml
28+
sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" docker_compose.yaml
4029
# Start Docker Containers
41-
# TODO: Replace the container name with a test-specific name
4230
docker compose -f docker_compose.yaml up -d
4331

4432
sleep 2m
@@ -140,7 +128,6 @@ function main() {
140128

141129
stop_docker
142130

143-
build_docker_images
144131
start_services
145132

146133
validate_microservices

0 commit comments

Comments
 (0)