Skip to content

Commit

Permalink
use matrix to loop charts test
Browse files Browse the repository at this point in the history
Signed-off-by: Yingchun Guo <[email protected]>
  • Loading branch information
daisy-ycguo committed May 28, 2024
1 parent ae24e81 commit d67201f
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/chart-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ on:
branches: [main]
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
paths:
- helm-charts/**
- .github/workflows/scripts/chart-integration/**
#- helm-charts/**
#- .github/workflows/scripts/chart-integration/**
- scripts
workflow_dispatch:

# If there is a new commit, the previous jobs will be canceled
Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/helmcharts-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: E2E test with helm charts

on:
pull_request:
branches: [main]
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
paths:
- helm-charts/**
- .github/workflows/scripts/chart-integration/**
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
CHARTS_DIR: "helm-charts"

jobs:
job1:
name: Get-test-matrix
runs-on: ubuntu-latest
outputs:
run_matrix: ${{ steps.get-test-matrix.outputs.run_matrix }}
steps:
- name: Checkout out Repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get test matrix
id: get-test-matrix
run: |
changed_charts=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | \
grep '^helm-charts/' | \
grep -vE 'README.md|common' | \
cut -d'/' -f2 | sort -u )
# set run_matrix to be "{"chart":["chart1","chart2",...]}"
run_matrix="{\"chart\":["
for chart in ${changed_charts}; do
run_matrix="${run_matrix}\"${chart}\","
done
run_matrix=$run_matrix"]}"
echo "run_matrix=${run_matrix}"
echo "run_matrix=${run_matrix}" >> $GITHUB_OUTPUT
Chart-test:
needs: job1
strategy:
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
runs-on: inspur-icx-1
continue-on-error: true
steps:
- name: E2e test chart
run: |
echo "Matrix - chart: ${{ matrix.chart }}"
- name: Clean Up Working Directory
run: sudo rm -rf ${{github.workspace}}/*

- name: Checkout out Repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set variables
run: |
echo "RELEASE_NAME=${{ matrix.chart }}$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "NAMESPACE=${{ matrix.chart }}-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "ROLLOUT_TIMEOUT_SECONDS=300" >> $GITHUB_ENV
echo "KUBECTL_TIMEOUT_SECONDS=60" >> $GITHUB_ENV
- name: Initialize chart testing
run: |
.github/workflows/scripts/chart-integration/lib init_codegen
- name: Helm install
run: |
helm install --create-namespace --namespace $NAMESPACE --wait --timeout "$ROLLOUT_TIMEOUT_SECONDS" $RELEASE_NAME helm-charts/${{ matrix.chart }}/
- name: Validate e2e test
run: |
.github/workflows/scripts/chart-integration/lib validate_codegen $RELEASE_NAME $NAMESPACE
- name: Helm uninstall
run: |
helm uninstall $RELEASE_NAME --namespace $NAMESPACE
if ! kubectl delete ns $NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then
kubectl delete pods --namespace $NAMESPACE --force --grace-period=0 --all
kubectl delete ns $NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS
fi
27 changes: 27 additions & 0 deletions .github/workflows/scripts/chart-integration/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,30 @@ function validate_chatqna() {
echo "Response check succeed!"
fi
}

if [ $# -eq 0 ]; then
echo "Usage: $0 <function_name>"
exit 1
fi

case "$1" in
init_codegen)
init_codegen
;;
validate_codegen)
RELEASE_NAME=$2
NAMESPACE=$3
validate_codegen
;;
init_chatqna)
init_chatqna
;;
validate_chatqna)
RELEASE_NAME=$2
NAMESPACE=$3
validate_chatqna
;;
*)
echo "Unknown function: $1"
;;
esac
2 changes: 1 addition & 1 deletion helm-charts/codegen/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ type: application
dependencies:
- name: llm-uservice
version: "0.1.0"
version: 0.1.0
version: 0.1.1
appVersion: "1.0.0"

0 comments on commit d67201f

Please sign in to comment.