Skip to content

Commit f45e4c6

Browse files
authored
Add GMC e2e in CD workflow (#619)
Signed-off-by: Yingchun Guo <yingchun.guo@intel.com>
1 parent 5dcadf3 commit f45e4c6

File tree

3 files changed

+108
-60
lines changed

3 files changed

+108
-60
lines changed

.github/workflows/_example-workflow.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ on:
3232
default: false
3333
required: false
3434
type: boolean
35+
test_gmc:
36+
default: false
37+
required: false
38+
type: boolean
3539
opea_branch:
3640
default: "main"
3741
required: false
@@ -148,3 +152,15 @@ jobs:
148152
tag: ${{ inputs.tag }}
149153
context: "CD"
150154
secrets: inherit
155+
156+
####################################################################################################
157+
# GMC Test
158+
####################################################################################################
159+
test-gmc-pipeline:
160+
needs: [build-images]
161+
if: ${{ fromJSON(inputs.test_gmc) }}
162+
uses: ./.github/workflows/_gmc-e2e.yml
163+
with:
164+
example: ${{ inputs.example }}
165+
hardware: ${{ inputs.node }}
166+
secrets: inherit

.github/workflows/_gmc-e2e.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# This workflow will only test GMC pipeline and will not install GMC any more
5+
name: Single GMC E2e Test For CD Workflow Call
6+
7+
on:
8+
workflow_call:
9+
inputs:
10+
example:
11+
default: "ChatQnA"
12+
description: "The example to test on K8s"
13+
required: true
14+
type: string
15+
hardware:
16+
default: "xeon"
17+
description: "Nodes to run the test, xeon or gaudi"
18+
required: true
19+
type: string
20+
21+
jobs:
22+
gmc-test:
23+
runs-on: "k8s-${{ inputs.hardware }}"
24+
continue-on-error: true
25+
steps:
26+
- name: Clean Up Working Directory
27+
run: sudo rm -rf ${{github.workspace}}/*
28+
29+
- name: Get checkout ref
30+
run: |
31+
if [ "${{ github.event_name }}" == "pull_request" ] || [ "${{ github.event_name }}" == "pull_request_target" ]; then
32+
echo "CHECKOUT_REF=refs/pull/${{ github.event.number }}/merge" >> $GITHUB_ENV
33+
else
34+
echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV
35+
fi
36+
echo "checkout ref ${{ env.CHECKOUT_REF }}"
37+
38+
- name: Checkout out Repo
39+
uses: actions/checkout@v4
40+
with:
41+
ref: ${{ env.CHECKOUT_REF }}
42+
fetch-depth: 0
43+
44+
- name: Set variables
45+
run: |
46+
echo "IMAGE_REPO=$OPEA_IMAGE_REPO" >> $GITHUB_ENV
47+
lower_example=$(echo "${{ inputs.example }}" | tr '[:upper:]' '[:lower:]')
48+
echo "APP_NAMESPACE=$lower_example-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
49+
echo "ROLLOUT_TIMEOUT_SECONDS=1800s" >> $GITHUB_ENV
50+
echo "KUBECTL_TIMEOUT_SECONDS=60s" >> $GITHUB_ENV
51+
echo "continue_test=true" >> $GITHUB_ENV
52+
echo "should_cleanup=false" >> $GITHUB_ENV
53+
echo "APP_NAMESPACE=$APP_NAMESPACE"
54+
55+
- name: Run tests
56+
id: run-test
57+
env:
58+
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HUGGINGFACEHUB_API_TOKEN }}
59+
GOOGLE_CSE_ID: ${{ secrets.GOOGLE_CSE_ID }}
60+
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
61+
run: |
62+
if [[ ! -f ${{ github.workspace }}/${{ inputs.example }}/tests/test_gmc_on_${{ inputs.hardware }}.sh ]]; then
63+
echo "No test script found, exist test!"
64+
exit 0
65+
else
66+
echo "should_cleanup=true" >> $GITHUB_ENV
67+
${{ github.workspace }}/${{ inputs.example }}/tests/test_gmc_on_${{ inputs.hardware }}.sh install_${{ inputs.example }}
68+
echo "Testing ${{ inputs.example }}, waiting for pod ready..."
69+
if kubectl rollout status deployment --namespace "$APP_NAMESPACE" --timeout "$ROLLOUT_TIMEOUT_SECONDS"; then
70+
echo "Testing gmc ${{ inputs.example }}, running validation test..."
71+
${{ github.workspace }}/${{ inputs.example }}/tests/test_gmc_on_${{ inputs.hardware }}.sh validate_${{ inputs.example }}
72+
else
73+
echo "Timeout waiting for pods in namespace $APP_NAMESPACE to be ready!"
74+
exit 1
75+
fi
76+
sleep 60
77+
fi
78+
79+
- name: Kubectl uninstall
80+
if: always()
81+
run: |
82+
if $should_cleanup; then
83+
if ! kubectl delete ns $APP_NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then
84+
kubectl delete pods --namespace $APP_NAMESPACE --force --grace-period=0 --all
85+
kubectl delete ns $APP_NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS
86+
fi
87+
fi

.github/workflows/pr-gmc-e2e.yaml

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -31,63 +31,8 @@ jobs:
3131
needs: [job1]
3232
strategy:
3333
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
34-
runs-on: "k8s-${{ matrix.hardware }}"
35-
continue-on-error: true
36-
steps:
37-
- name: E2e test gmc
38-
run: |
39-
echo "Matrix - gmc: ${{ matrix.example }}"
40-
41-
- name: Clean Up Working Directory
42-
run: sudo rm -rf ${{github.workspace}}/*
43-
44-
- name: Checkout out Repo
45-
uses: actions/checkout@v4
46-
with:
47-
ref: "refs/pull/${{ github.event.number }}/merge"
48-
49-
- name: Set variables
50-
run: |
51-
if [ ${{ matrix.hardware }} == "gaudi" ]; then IMAGE_REPO=${{ vars.IMAGE_REPO_GAUDI }}; else IMAGE_REPO=${{ vars.IMAGE_REPO_XEON }}; fi
52-
echo "IMAGE_REPO=$OPEA_IMAGE_REPO" >> $GITHUB_ENV
53-
lower_example=$(echo "${{ matrix.example }}" | tr '[:upper:]' '[:lower:]')
54-
echo "APP_NAMESPACE=$lower_example-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
55-
echo "ROLLOUT_TIMEOUT_SECONDS=1800s" >> $GITHUB_ENV
56-
echo "KUBECTL_TIMEOUT_SECONDS=60s" >> $GITHUB_ENV
57-
echo "continue_test=true" >> $GITHUB_ENV
58-
echo "should_cleanup=false" >> $GITHUB_ENV
59-
echo "APP_NAMESPACE=$APP_NAMESPACE"
60-
61-
- name: Run tests
62-
id: run-test
63-
env:
64-
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HUGGINGFACEHUB_API_TOKEN }}
65-
GOOGLE_CSE_ID: ${{ secrets.GOOGLE_CSE_ID }}
66-
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
67-
run: |
68-
if [[ ! -f ${{ github.workspace }}/${{ matrix.example }}/tests/test_gmc_on_${{ matrix.hardware }}.sh ]]; then
69-
echo "No test script found, exist test!"
70-
exit 0
71-
else
72-
echo "should_cleanup=true" >> $GITHUB_ENV
73-
${{ github.workspace }}/${{ matrix.example }}/tests/test_gmc_on_${{ matrix.hardware }}.sh install_${{ matrix.example }}
74-
echo "Testing ${{ matrix.example }}, waiting for pod ready..."
75-
if kubectl rollout status deployment --namespace "$APP_NAMESPACE" --timeout "$ROLLOUT_TIMEOUT_SECONDS"; then
76-
echo "Testing gmc ${{ matrix.example }}, running validation test..."
77-
${{ github.workspace }}/${{ matrix.example }}/tests/test_gmc_on_${{ matrix.hardware }}.sh validate_${{ matrix.example }}
78-
else
79-
echo "Timeout waiting for pods in namespace $APP_NAMESPACE to be ready!"
80-
exit 1
81-
fi
82-
sleep 60
83-
fi
84-
85-
- name: Kubectl uninstall
86-
if: always()
87-
run: |
88-
if $should_cleanup; then
89-
if ! kubectl delete ns $APP_NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then
90-
kubectl delete pods --namespace $APP_NAMESPACE --force --grace-period=0 --all
91-
kubectl delete ns $APP_NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS
92-
fi
93-
fi
34+
uses: ./.github/workflows/_gmc-e2e.yml
35+
with:
36+
example: ${{ matrix.example }}
37+
hardware: ${{ matrix.hardware }}
38+
secrets: inherit

0 commit comments

Comments
 (0)