Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite integration test to use matrix strategy to loop charts test #43

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/chart-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# 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/chart-e2e.yaml
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 "^$CHARTS_DIR/" | \
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
if: always() && ${{ needs.job1.outputs.run_matrix.chart.length }} > 0
strategy:
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
runs-on: inspur-icx-1
continue-on-error: true
outputs:
should_cleanup: ${{ steps.set_boolean.outputs.should_cleanup }}
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=600s" >> $GITHUB_ENV
echo "KUBECTL_TIMEOUT_SECONDS=60s" >> $GITHUB_ENV
echo "should_cleanup=false" >> $GITHUB_ENV
echo "skip_validate=false" >> $GITHUB_ENV
echo "RELEASENAME=$RELEASE_NAME"
echo "NAMESPACE=$NAMESPACE"

- name: Initialize chart testing
run: |
.github/workflows/scripts/e2e/chart_test.sh init_codegen

- name: Helm install
id: install
run: |
echo "should_cleanup=true" >> $GITHUB_ENV
if ! helm install --create-namespace --namespace $NAMESPACE --wait --timeout "$ROLLOUT_TIMEOUT_SECONDS" $RELEASE_NAME $CHARTS_DIR/${{ matrix.chart }} ; then
echo "Failed to install chart ${{ matrix.chart }}"
echo "skip_validate=true" >> $GITHUB_ENV
exit 1
fi

- name: Validate e2e test
if: always()
run: |
if $skip_validate; then
echo "Skip validate"
else
.github/workflows/scripts/e2e/chart_test.sh validate_codegen $RELEASE_NAME $NAMESPACE
fi

- name: Helm uninstall
if: always()
run: |
if $should_cleanup; then
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
fi
48 changes: 0 additions & 48 deletions .github/workflows/chart-integration.yaml

This file was deleted.

62 changes: 0 additions & 62 deletions .github/workflows/scripts/chart-integration/chart-test.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
LOG_PATH=.

function init_codegen() {
# executed under path helm-charts/codegen
# init var
CHART_MOUNT=/home/$USER_ID/charts-mnt/codegen
USER_ID=$(whoami)
CHART_MOUNT=/home/$USER_ID/charts-mnt
MODELREPO=m-a-p
MODELNAME=OpenCodeInterpreter-DS-6.7B
MODELID=$MODELREPO/$MODELNAME
Expand Down Expand Up @@ -95,3 +97,34 @@ 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)
pushd helm-charts/codegen
init_codegen
popd
;;
validate_codegen)
RELEASE_NAME=$2
NAMESPACE=$3
validate_codegen
;;
init_chatqna)
pushd helm-charts/chatqna
init_chatqna
popd
;;
validate_chatqna)
RELEASE_NAME=$2
NAMESPACE=$3
validate_chatqna
;;
*)
echo "Unknown function: $1"
;;
esac