-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yingchun Guo <[email protected]>
- Loading branch information
1 parent
04d7f24
commit bc9abac
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Golang E2e Tests | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped | ||
paths: | ||
- microservices-connector/** | ||
workflow_dispatch: | ||
|
||
# If there is a new commit, the previous jobs will be canceled | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
GOSRC_DIR: "microservices-connector" | ||
|
||
jobs: | ||
go-e2e: | ||
runs-on: k8s | ||
steps: | ||
- name: Checkout out Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set variables | ||
run: | | ||
echo "SYSTEM_NAMESPACE=opea-system-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV | ||
echo "APP_NAMESPACE=chatqna-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV | ||
echo "DOCKER_REGISTRY=$OPEA_IMAGE_REPO/opea" >> $GITHUB_ENV | ||
echo "VERSION=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV | ||
echo "should_cleanup=false" >> $GITHUB_ENV | ||
echo "skip_validate=false" >> $GITHUB_ENV | ||
- name: Build image and push | ||
run: | | ||
cd $GOSRC_DIR | ||
make docker.build | ||
make docker.push | ||
- name: Install modules | ||
run: | | ||
echo "should_cleanup=true" >> $GITHUB_ENV | ||
.github/workflows/scripts/e2e/go_test.sh install_gmc | ||
exit_status=$$?$$ | ||
if [ $$exit_status -ne 0 ]; then | ||
echo "Failed to install modules" | ||
echo "skip_validate=true" >> $GITHUB_ENV | ||
fi | ||
- name: Run e2e tests | ||
run: | | ||
# export DOCKER_REGISTRY={{ env.DOCKER_REGISTRY }} | ||
# export VERSION={{ env.VERSION }} | ||
if $skip_validate; then | ||
echo "Skip validate" | ||
else | ||
.github/workflows/scripts/e2e/go_test.sh validate_gmc | ||
fi | ||
- name: Cleanup modules | ||
if: always() | ||
run: | | ||
if $should_cleanup; then | ||
.github/workflows/scripts/e2e/go_test.sh cleanup_gmc | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -xe | ||
USER_ID=$(whoami) | ||
LOG_PATH=/home/$(whoami)/logs | ||
MOUNT_DIR=/home/$USER_ID/charts-mnt | ||
IMAGE_REPO=${OPEA_IMAGE_REPO:-docker.io} | ||
|
||
function install_gmc() { | ||
# Make sure you have to use image tag $VERSION for microservice-connector installation | ||
echo "install microservice-connector, using repo $DOCKER_REGISTRY and tag $VERSION" | ||
echo "using namespace $SYSTEM_NAMESPACE and $APP_NAMESPACE" | ||
} | ||
|
||
function validate_gmc() { | ||
echo "validate microservice-connector" | ||
} | ||
|
||
function cleanup_gmc() { | ||
echo "clean up microservice-connector" | ||
# clean up the images | ||
docker rmi $DOCKER_REGISTRY/gmcrouter:$VERSION | ||
docker rmi $DOCKER_REGISTRY/gmcmanager:$VERSION | ||
} | ||
|
||
if [ $# -eq 0 ]; then | ||
echo "Usage: $0 <function_name>" | ||
exit 1 | ||
fi | ||
|
||
case "$1" in | ||
install_gmc) | ||
install_gmc | ||
;; | ||
validate_gmc) | ||
validate_gmc | ||
;; | ||
cleanup_gmc) | ||
cleanup_gmc | ||
;; | ||
*) | ||
echo "Unknown function: $1" | ||
;; | ||
esac |