|
| 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 |
0 commit comments