Skip to content

Commit c26d0f6

Browse files
authored
Enhance CI/CD infrastructure (#593)
Signed-off-by: chensuyue <suyue.chen@intel.com> Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com>
1 parent e71aba0 commit c26d0f6

File tree

61 files changed

+987
-954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+987
-954
lines changed

.github/workflows/_example-workflow.yml

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ permissions: read-all
66
on:
77
workflow_call:
88
inputs:
9+
node:
10+
required: true
11+
type: string
912
example:
1013
required: true
1114
type: string
@@ -37,48 +40,56 @@ on:
3740
default: "latest"
3841
required: false
3942
type: string
43+
GenAIComps_branch:
44+
default: "main"
45+
required: false
46+
type: string
4047
jobs:
4148
####################################################################################################
4249
# Image Build
4350
####################################################################################################
4451
build-images:
45-
if: ${{ fromJSON(inputs.build) }}
46-
strategy:
47-
matrix:
48-
node: ["docker-build-xeon", "docker-build-gaudi"]
49-
runs-on: ${{ matrix.node }}
52+
runs-on: "docker-build-${{ inputs.node }}"
5053
continue-on-error: true
5154
steps:
5255
- name: Clean Up Working Directory
53-
run: |
54-
sudo rm -rf ${{github.workspace}}/*
56+
run: sudo rm -rf ${{github.workspace}}/*
5557

5658
- name: Checkout out Repo
5759
uses: actions/checkout@v4
5860

61+
- name: Clone required Repo
62+
run: |
63+
cd ${{ github.workspace }}/${{ inputs.example }}/docker
64+
build_compose_path=${{ github.workspace }}/${{ inputs.example }}/docker/docker_build_compose.yaml
65+
if [[ $(grep -c "tei-gaudi:" ${docker_compose_path}) != 0 ]]; then
66+
git clone https://github.com/huggingface/tei-gaudi.git
67+
fi
68+
if [[ $(grep -c "vllm:" ${docker_compose_path}) != 0 ]]; then
69+
git clone https://github.com/huggingface/tei-gaudi.git
70+
fi
71+
git clone https://github.com/opea-project/GenAIComps.git
72+
cd GenAIComps && checkout ${{ inputs.GenAIComps_branch }} && cd ../
73+
5974
- name: Build Image
75+
if: ${{ fromJSON(inputs.build) }}
6076
uses: opea-project/validation/actions/image-build@main
6177
with:
62-
work_dir: ${{ github.workspace }}/${{ inputs.example }}
63-
docker_compose_path: ${{ github.workspace }}/.github/workflows/docker/compose/${{ inputs.example }}-compose.yaml
78+
work_dir: ${{ github.workspace }}/${{ inputs.example }}/docker
79+
docker_compose_path: ${{ github.workspace }}/${{ inputs.example }}/docker/docker_build_compose.yaml
6480
registry: ${OPEA_IMAGE_REPO}opea
6581
tag: ${{ inputs.tag }}
6682

6783
####################################################################################################
6884
# Trivy Scan
6985
####################################################################################################
7086
image-list:
71-
needs: [ build-images ]
72-
if: ${{ fromJSON(inputs.scan) }}
87+
needs: [build-images]
88+
if: ${{ fromJSON(inputs.scan) && inputs.node == 'gaudi' }}
7389
runs-on: ubuntu-latest
7490
outputs:
7591
matrix: ${{ steps.scan-matrix.outputs.matrix }}
7692
steps:
77-
- name: Harden Runner
78-
uses: step-security/harden-runner@v2.8.1
79-
with:
80-
egress-policy: audit
81-
8293
- name: Checkout out Repo
8394
uses: actions/checkout@v4
8495

@@ -90,34 +101,32 @@ jobs:
90101
echo "matrix=$(cat ${compose_path} | yq -r '.[]' | jq 'keys' | jq -c '.')" >> $GITHUB_OUTPUT
91102
92103
scan-images:
93-
needs: [image-list]
94-
if: ${{ fromJSON(inputs.scan) }}
95-
runs-on: "docker-build-gaudi"
104+
needs: [image-list, build-images]
105+
if: ${{ fromJSON(inputs.scan) && inputs.node == 'gaudi'}}
106+
runs-on: "docker-build-${{ inputs.node }}"
96107
strategy:
97108
matrix:
98109
image: ${{ fromJSON(needs.image-list.outputs.matrix) }}
99110
fail-fast: false
100111
steps:
101-
- name: Harden Runner
102-
uses: step-security/harden-runner@v2.8.1
103-
with:
104-
egress-policy: audit
105-
106112
- name: Pull Image
107-
run: docker pull ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
113+
run: |
114+
docker pull ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
115+
echo "OPEA_IMAGE_REPO=${OPEA_IMAGE_REPO}" >> $GITHUB_ENV
108116
109117
- name: Scan Container
110118
uses: opea-project/validation/actions/trivy-scan@main
111119
with:
112-
image-ref: ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
120+
image-ref: ${{ env.OPEA_IMAGE_REPO }}opea/${{ matrix.image }}:${{ inputs.tag }}
113121
output: ${{ inputs.example }}-${{ matrix.image }}-scan.txt
114122

115123
- name: Cleanup
116124
if: always()
117125
run: docker rmi -f ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
126+
118127
- uses: actions/upload-artifact@v4.3.4
119128
with:
120-
name: ${{ inputs.example }}-scan
129+
name: ${{ inputs.example }}-${{ matrix.image }}-scan
121130
path: ${{ inputs.example }}-${{ matrix.image }}-scan.txt
122131
overwrite: true
123132

@@ -127,15 +136,11 @@ jobs:
127136
test-example-compose:
128137
needs: [build-images]
129138
if: ${{ fromJSON(inputs.test_compose) }}
130-
strategy:
131-
matrix:
132-
hardware: ["xeon", "gaudi"]
133-
fail-fast: false
134139
uses: ./.github/workflows/_run-docker-compose.yml
135140
with:
136141
tag: ${{ inputs.tag }}
137142
example: ${{ inputs.example }}
138-
hardware: ${{ matrix.hardware }}
143+
hardware: ${{ inputs.node }}
139144
secrets: inherit
140145

141146

@@ -145,14 +150,10 @@ jobs:
145150
test-k8s-manifest:
146151
needs: [build-images]
147152
if: ${{ fromJSON(inputs.test_k8s) }}
148-
strategy:
149-
matrix:
150-
hardware: ["xeon", "gaudi"]
151-
fail-fast: false
152153
uses: ./.github/workflows/_manifest-e2e.yml
153154
with:
154155
example: ${{ inputs.example }}
155-
hardware: ${{ matrix.hardware }}
156+
hardware: ${{ inputs.node }}
156157
tag: ${{ inputs.tag }}
157158
secrets: inherit
158159

@@ -162,7 +163,7 @@ jobs:
162163
####################################################################################################
163164
publish:
164165
needs: [image-list, build-images, scan-images, test-example-compose]
165-
if: ${{ fromJSON(inputs.publish) }}
166+
if: ${{ fromJSON(inputs.publish) && inputs.node == 'gaudi' }}
166167
strategy:
167168
matrix:
168169
image: ${{ fromJSON(needs.image-list.outputs.matrix) }}

.github/workflows/_run-docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ jobs:
7272
sudo rm -rf ${{github.workspace}}/* || true
7373
docker system prune -f
7474
docker rmi $(docker images --filter reference="*/*/*:latest" -q) || true
75+
docker rmi $(docker images --filter reference="*/*:ci" -q) || true
7576
7677
- name: Checkout out Repo
7778
uses: actions/checkout@v4
@@ -93,7 +94,7 @@ jobs:
9394
test_case: ${{ matrix.test_case }}
9495
run: |
9596
cd ${{ github.workspace }}/$example/tests
96-
export IMAGE_REPO=${OPEA_IMAGE_REPO}
97+
if [[ "$IMAGE_REPO" == "" ]]; then export IMAGE_REPO="${OPEA_IMAGE_REPO}opea"; fi
9798
if [ -f ${test_case} ]; then timeout 30m bash ${test_case}; else echo "Test script {${test_case}} not found, skip test!"; fi
9899
99100
- name: Clean up container

.github/workflows/manual-cd-workflow.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ name: Examples CD workflow on manual event
55
on:
66
workflow_dispatch:
77
inputs:
8+
nodes:
9+
default: "gaudi,xeon"
10+
description: "Hardware to run test"
11+
required: true
12+
type: string
813
examples:
9-
default: "AudioQnA,ChatQnA,CodeGen,CodeTrans,DocSum,FaqGen,SearchQnA,Translation"
10-
description: 'List of examples to test'
14+
default: "ChatQnA"
15+
description: 'List of examples to test [AudioQnA,ChatQnA,CodeGen,CodeTrans,DocSum,FaqGen,SearchQnA,Translation]'
1116
required: true
1217
type: string
1318
tag:
@@ -41,39 +46,51 @@ on:
4146
required: false
4247
type: boolean
4348
publish_tags:
44-
default: "latest,v0.9"
49+
default: "latest,v1.0"
4550
description: 'Tag list apply to publish images'
4651
required: false
4752
type: string
53+
GenAIComps_branch:
54+
default: "main"
55+
description: 'GenAIComps branch for image build'
56+
required: false
57+
type: string
4858

4959
permissions: read-all
5060
jobs:
5161
get-test-matrix:
5262
runs-on: ubuntu-latest
5363
outputs:
54-
matrix: ${{ steps.get-matrix.outputs.matrix }}
64+
examples: ${{ steps.get-matrix.outputs.examples }}
65+
nodes: ${{ steps.get-matrix.outputs.nodes }}
5566
steps:
5667
- name: Create Matrix
5768
id: get-matrix
5869
run: |
5970
examples=($(echo ${{ github.event.inputs.examples }} | tr ',' ' '))
6071
examples_json=$(printf '%s\n' "${examples[@]}" | sort -u | jq -R '.' | jq -sc '.')
61-
echo "matrix=$examples_json" >> $GITHUB_OUTPUT
72+
echo "examples=$examples_json" >> $GITHUB_OUTPUT
73+
nodes=($(echo ${{ github.event.inputs.nodes }} | tr ',' ' '))
74+
nodes_json=$(printf '%s\n' "${nodes[@]}" | sort -u | jq -R '.' | jq -sc '.')
75+
echo "nodes=$nodes_json" >> $GITHUB_OUTPUT
6276
6377
run-examples:
6478
needs: [get-test-matrix]
6579
strategy:
6680
matrix:
67-
example: ${{ fromJson(needs.get-test-matrix.outputs.matrix) }}
81+
example: ${{ fromJson(needs.get-test-matrix.outputs.examples) }}
82+
node: ${{ fromJson(needs.get-test-matrix.outputs.nodes) }}
6883
fail-fast: false
6984
uses: ./.github/workflows/_example-workflow.yml
7085
with:
86+
node: ${{ matrix.node }}
7187
example: ${{ matrix.example }}
7288
tag: ${{ inputs.tag }}
7389
build: ${{ fromJSON(inputs.build) }}
7490
scan: ${{ fromJSON(inputs.scan) }}
7591
test_compose: ${{ fromJSON(inputs.test_compose) }}
7692
test_k8s: ${{ fromJSON(inputs.test_k8s) }}
7793
publish: ${{ fromJSON(inputs.publish) }}
78-
publish_tags: ${{ fromJSON(inputs.publish_tags) }}
94+
publish_tags: ${{ inputs.publish_tags }}
95+
GenAIComps_branch: ${{ inputs.GenAIComps_branch }}
7996
secrets: inherit

.github/workflows/pr-docker-compose-e2e.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
name: E2E test with docker compose
55

66
on:
7-
pull_request_target:
7+
pull_request:
88
branches: [main]
99
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
1010
paths:
@@ -21,29 +21,20 @@ concurrency:
2121
cancel-in-progress: true
2222

2323
jobs:
24-
job1:
24+
get-test-matrix:
2525
uses: ./.github/workflows/_get-test-matrix.yml
2626
with:
2727
diff_excluded_files: '.github|README.md|*.txt|deprecate|kubernetes|manifest|gmc|assets'
2828

29-
mega-image-build:
30-
needs: job1
31-
strategy:
32-
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
33-
uses: ./.github/workflows/_image-build.yml
34-
with:
35-
image_tag: ${{ github.event.pull_request.head.sha }}
36-
mega_service: "${{ matrix.example }}"
37-
runner_label: "docker-build-${{ matrix.hardware }}"
38-
3929
example-test:
40-
needs: [job1, mega-image-build]
30+
needs: [get-test-matrix]
4131
strategy:
42-
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
32+
matrix: ${{ fromJSON(needs.get-test-matrix.outputs.run_matrix) }}
4333
fail-fast: false
4434
uses: ./.github/workflows/_run-docker-compose.yml
4535
with:
46-
tag: ${{ needs.mega-image-build.outputs.image_tag }}
36+
registry: "opea"
37+
tag: "ci"
4738
example: ${{ matrix.example }}
4839
hardware: ${{ matrix.hardware }}
4940
secrets: inherit
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
services:
5+
audioqna:
6+
build:
7+
args:
8+
http_proxy: ${http_proxy}
9+
https_proxy: ${https_proxy}
10+
no_proxy: ${no_proxy}
11+
dockerfile: ./Dockerfile
12+
image: ${REGISTRY:-opea}/audioqna:${TAG:-latest}
13+
whisper-gaudi:
14+
build:
15+
context: GenAIComps
16+
dockerfile: comps/asr/whisper/Dockerfile_hpu
17+
extends: audioqna
18+
image: ${REGISTRY:-opea}/whisper-gaudi:${TAG:-latest}
19+
whisper:
20+
build:
21+
context: GenAIComps
22+
dockerfile: comps/asr/whisper/Dockerfile
23+
extends: audioqna
24+
image: ${REGISTRY:-opea}/whisper:${TAG:-latest}
25+
asr:
26+
build:
27+
context: GenAIComps
28+
dockerfile: comps/asr/Dockerfile
29+
extends: audioqna
30+
image: ${REGISTRY:-opea}/asr:${TAG:-latest}
31+
llm-tgi:
32+
build:
33+
context: GenAIComps
34+
dockerfile: comps/llms/text-generation/tgi/Dockerfile
35+
extends: audioqna
36+
image: ${REGISTRY:-opea}/llm-tgi:${TAG:-latest}
37+
speecht5-gaudi:
38+
build:
39+
context: GenAIComps
40+
dockerfile: comps/tts/speecht5/Dockerfile_hpu
41+
extends: audioqna
42+
image: ${REGISTRY:-opea}/speecht5-gaudi:${TAG:-latest}
43+
speecht5:
44+
build:
45+
context: GenAIComps
46+
dockerfile: comps/tts/speecht5/Dockerfile
47+
extends: audioqna
48+
image: ${REGISTRY:-opea}/speecht5:${TAG:-latest}
49+
tts:
50+
build:
51+
context: GenAIComps
52+
dockerfile: comps/tts/Dockerfile
53+
extends: audioqna
54+
image: ${REGISTRY:-opea}/tts:${TAG:-latest}

0 commit comments

Comments
 (0)