|
| 1 | +# Copyright (C) 2024 Intel Corporation |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +name: Golang E2e Tests |
| 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 | + - microservices-connector/** |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +# If there is a new commit, the previous jobs will be canceled |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +env: |
| 20 | + GOSRC_DIR: "microservices-connector" |
| 21 | + |
| 22 | +jobs: |
| 23 | + go-e2e: |
| 24 | + runs-on: k8s |
| 25 | + steps: |
| 26 | + - name: Checkout out Repo |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Set variables |
| 32 | + run: | |
| 33 | + echo "SYSTEM_NAMESPACE=opea-system-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV |
| 34 | + echo "APP_NAMESPACE=chatqna-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV |
| 35 | + echo "DOCKER_REGISTRY=$OPEA_IMAGE_REPO/opea" >> $GITHUB_ENV |
| 36 | + echo "VERSION=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV |
| 37 | + echo "should_cleanup=false" >> $GITHUB_ENV |
| 38 | + echo "skip_validate=false" >> $GITHUB_ENV |
| 39 | +
|
| 40 | + - name: Build image and push |
| 41 | + run: | |
| 42 | + cd $GOSRC_DIR |
| 43 | + make docker.build |
| 44 | + make docker.push |
| 45 | +
|
| 46 | + - name: Install modules |
| 47 | + run: | |
| 48 | + echo "should_cleanup=true" >> $GITHUB_ENV |
| 49 | + .github/workflows/scripts/e2e/go_test.sh install_gmc |
| 50 | + exit_status=$$?$$ |
| 51 | + if [ $$exit_status -ne 0 ]; then |
| 52 | + echo "Failed to install modules" |
| 53 | + echo "skip_validate=true" >> $GITHUB_ENV |
| 54 | + fi |
| 55 | +
|
| 56 | + - name: Run e2e tests |
| 57 | + run: | |
| 58 | + # export DOCKER_REGISTRY={{ env.DOCKER_REGISTRY }} |
| 59 | + # export VERSION={{ env.VERSION }} |
| 60 | + if $skip_validate; then |
| 61 | + echo "Skip validate" |
| 62 | + else |
| 63 | + .github/workflows/scripts/e2e/go_test.sh validate_gmc |
| 64 | + fi |
| 65 | +
|
| 66 | + - name: Cleanup modules |
| 67 | + if: always() |
| 68 | + run: | |
| 69 | + if $should_cleanup; then |
| 70 | + .github/workflows/scripts/e2e/go_test.sh cleanup_gmc |
| 71 | + fi |
0 commit comments