|
| 1 | +# Copyright (C) 2024 Intel Corporation |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +name: E2E test with GMC |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + branches: [main] |
| 9 | + types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped |
| 10 | + paths: |
| 11 | + - "**/kubernetes/**" |
| 12 | + - "**/tests/test_gmc**" |
| 13 | + - "!**.md" |
| 14 | + - "!**.txt" |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +jobs: |
| 22 | + job1: |
| 23 | + uses: ./.github/workflows/reuse-get-test-matrix.yml |
| 24 | + with: |
| 25 | + diff_excluded_files: '.github|deprecated|docker|assets|*.md|*.txt' |
| 26 | + xeon_server_label: 'xeon' |
| 27 | + gaudi_server_label: 'gaudi' |
| 28 | + |
| 29 | + gmc-test: |
| 30 | + needs: [job1] |
| 31 | + strategy: |
| 32 | + matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }} |
| 33 | + runs-on: "k8s-${{ matrix.hardware }}" |
| 34 | + continue-on-error: true |
| 35 | + steps: |
| 36 | + - name: E2e test gmc |
| 37 | + run: | |
| 38 | + echo "Matrix - gmc: ${{ matrix.example }}" |
| 39 | +
|
| 40 | + - name: Clean Up Working Directory |
| 41 | + run: sudo rm -rf ${{github.workspace}}/* |
| 42 | + |
| 43 | + - name: Checkout out Repo |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + fetch-depth: 0 |
| 47 | + |
| 48 | + - name: Set variables |
| 49 | + run: | |
| 50 | + if [ ${{ matrix.hardware }} == "gaudi" ]; then IMAGE_REPO=${{ vars.IMAGE_REPO_GAUDI }}; else IMAGE_REPO=${{ vars.IMAGE_REPO_XEON }}; fi |
| 51 | + echo "IMAGE_REPO=$OPEA_IMAGE_REPO" >> $GITHUB_ENV |
| 52 | + lower_example=$(echo "${{ matrix.example }}" | tr '[:upper:]' '[:lower:]') |
| 53 | + echo "SYSTEM_NAMESPACE=opea-system-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV |
| 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 "skip_validate=true" >> $GITHUB_ENV |
| 60 | + echo "APP_NAMESPACE=$APP_NAMESPACE" |
| 61 | +
|
| 62 | + - name: Kubectl install |
| 63 | + id: install |
| 64 | + run: | |
| 65 | + if [[ ! -f ${{ github.workspace }}/${{ matrix.example }}/tests/test_gmc_on_${{ matrix.hardware }}.sh ]]; then |
| 66 | + echo "No test script found, exist test!" |
| 67 | + exit 0 |
| 68 | + else |
| 69 | + ${{ github.workspace }}/${{ matrix.example }}/tests/test_gmc_on_${{ matrix.hardware }}.sh init_${{ matrix.example }} |
| 70 | + echo "should_cleanup=true" >> $GITHUB_ENV |
| 71 | + ${{ github.workspace }}/${{ matrix.example }}/tests/test_gmc_on_${{ matrix.hardware }}.sh install_${{ matrix.example }} |
| 72 | + echo "Testing ${{ matrix.example }}, waiting for pod ready..." |
| 73 | + if kubectl rollout status deployment --namespace "$APP_NAMESPACE" --timeout "$ROLLOUT_TIMEOUT_SECONDS"; then |
| 74 | + echo "Testing gmc ${{ matrix.example }}, waiting for pod ready done!" |
| 75 | + echo "skip_validate=false" >> $GITHUB_ENV |
| 76 | + else |
| 77 | + echo "Timeout waiting for pods in namespace $APP_NAMESPACE to be ready!" |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | + sleep 60 |
| 81 | + fi |
| 82 | +
|
| 83 | + - name: Validate e2e test |
| 84 | + if: always() |
| 85 | + run: | |
| 86 | + if $skip_validate; then |
| 87 | + echo "Skip validate" |
| 88 | + else |
| 89 | + ${{ github.workspace }}/${{ matrix.example }}/tests/test_gmc_on_${{ matrix.hardware }}.sh validate_${{ matrix.example }} |
| 90 | + fi |
| 91 | +
|
| 92 | + - name: Kubectl uninstall |
| 93 | + if: always() |
| 94 | + run: | |
| 95 | + if $should_cleanup; then |
| 96 | + if ! kubectl delete ns $APP_NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then |
| 97 | + kubectl delete pods --namespace $APP_NAMESPACE --force --grace-period=0 --all |
| 98 | + kubectl delete ns $APP_NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS |
| 99 | + fi |
| 100 | + if ! kubectl delete ns $SYSTEM_NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then |
| 101 | + kubectl delete pods --namespace $SYSTEM_NAMESPACE --force --grace-period=0 --all |
| 102 | + kubectl delete ns $SYSTEM_NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS |
| 103 | + fi |
| 104 | + fi |
0 commit comments