diff --git a/.github/workflows/chart-e2e.yaml b/.github/workflows/chart-e2e.yaml index 0cd5d558..b7566dab 100644 --- a/.github/workflows/chart-e2e.yaml +++ b/.github/workflows/chart-e2e.yaml @@ -34,16 +34,25 @@ jobs: - 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 }} | \ + e2e_charts=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | \ grep "^$CHARTS_DIR/" | \ - grep -vE 'README.md|common|update_dependency.sh' | \ + grep -vE 'README.md|common|*.sh' | \ cut -d'/' -f2 | sort -u ) + common_charts=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | \ + grep "^$CHARTS_DIR/common" | \ + grep -vE 'README.md|*.sh' | \ + cut -d'/' -f3 | sort -u ) run_matrix="{\"include\":[" - for chart in ${changed_charts}; do + for chart in ${e2e_charts}; do #run_matrix="${run_matrix}\"${chart}\"," run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"gaudi\"}," run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"xeon\"}," done + for chart in ${common_charts}; do + #run_matrix="${run_matrix}\"${chart}\"," + run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"gaudi\",\"directory\":\"common\"}," + run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"xeon\",\"directory\":\"common\"}," + done run_matrix=$run_matrix"]}" echo "run_matrix=${run_matrix}" echo "run_matrix=${run_matrix}" >> $GITHUB_OUTPUT @@ -83,23 +92,45 @@ jobs: - name: Initialize chart testing run: | - .github/workflows/scripts/e2e/chart_test.sh init_${{ matrix.example }} + # .github/workflows/scripts/e2e/chart_test.sh init_value + # Replace values for CI test environment + pushd helm-charts + # insert a prefix before opea/.*, the prefix is OPEA_IMAGE_REPO + find . -name '*values.yaml' -type f -exec sed -i "s#repository: opea/*#repository: ${OPEA_IMAGE_REPO}opea/#g" {} \; + # set huggingface token + find . -name '*values.yaml' -type f -exec sed -i "s#insert-your-huggingface-token-here#$(cat /home/$USER_ID/.cache/huggingface/token)#g" {} \; + # replace the mount dir "Volume: *" with "Volume: $CHART_MOUNT" + find . -name '*values.yaml' -type f -exec sed -i "s#modelUseHostPath: .*#modelUseHostPath: $CHART_MOUNT#g" {} \; + # replace the pull policy "IfNotPresent" with "Always" + find . -name '*values.yaml' -type f -exec sed -i "s#pullPolicy: IfNotPresent#pullPolicy: Always#g" {} \; + popd - name: Helm install id: install run: | echo "should_cleanup=true" >> $GITHUB_ENV - helm-charts/update_dependency.sh && helm dependency update helm-charts/${{ matrix.example }} + helm-charts/update_dependency.sh && helm dependency update helm-charts/${{ matrix.directory }}/${{ matrix.example }} value_file="values.yaml" if [ "${{ matrix.hardware }}" == "gaudi" ]; then - value_file="gaudi-values.yaml" + if [ -f helm-charts/${{ matrix.directory }}/${{ matrix.example }}/gaudi-values.yaml ]; then + value_file="gaudi-values.yaml" + else + echo "No Gaudi version for chart ${{ matrix.example }}, skip test" + echo "skip_validate=true" >> $GITHUB_ENV + echo "should_cleanup=false" >> $GITHUB_ENV + exit 0 + fi fi - if ! helm install --create-namespace --namespace $NAMESPACE --wait --timeout "$ROLLOUT_TIMEOUT_SECONDS" --values $CHARTS_DIR/${{ matrix.example }}/${value_file} $RELEASE_NAME $CHARTS_DIR/${{ matrix.example }} ; then + if ! helm install --create-namespace --namespace $NAMESPACE --wait \ + --timeout "$ROLLOUT_TIMEOUT_SECONDS" \ + --set autodependency.enabled=true \ + --values $CHARTS_DIR/${{ matrix.directory }}/${{ matrix.example }}/${value_file} \ + $RELEASE_NAME $CHARTS_DIR/${{ matrix.directory }}/${{ matrix.example }} ; then echo "Failed to install chart ${{ matrix.example }}" echo "skip_validate=true" >> $GITHUB_ENV exit 1 fi - sleep 120 + sleep 10 - name: Validate e2e test if: always() @@ -107,7 +138,32 @@ jobs: if $skip_validate; then echo "Skip validate" else - .github/workflows/scripts/e2e/chart_test.sh validate_${{ matrix.example }} $RELEASE_NAME $NAMESPACE + # .github/workflows/scripts/e2e/chart_test.sh validate_${{ matrix.example }} $RELEASE_NAME $NAMESPACE + LOG_PATH=/home/$(whoami)/logs + chart=${{ matrix.example }} + helm test -n $NAMESPACE $RELEASE_NAME --logs > ${LOG_PATH}/charts-${chart}.log + exit_code=$? + if [ $exit_code -ne 0 ]; then + echo "Chart ${chart} test failed, please check the logs in ${LOG_PATH}!" + exit 1 + fi + + echo "Checking response results, make sure the output is reasonable. " + teststatus=false + if [[ -f $LOG_PATH/charts-${chart}.log ]] && \ + [[ $(grep -c "Failed" $LOG_PATH/charts-${chart}.log) != 0 ]]; then + teststatus=false + else + teststatus=true + fi + + if [ $teststatus == false ]; then + echo "Response check failed, please check the logs in artifacts!" + exit 1 + else + echo "Response check succeed!" + exit 0 + fi fi - name: Helm uninstall