Skip to content

Commit

Permalink
update GMC image build and test workflow (#303)
Browse files Browse the repository at this point in the history
Signed-off-by: Yingchun Guo <[email protected]>
  • Loading branch information
daisy-ycguo authored Aug 16, 2024
1 parent df5f6f3 commit 3d94844
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 43 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/_gmc-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: GMC E2e Test For Call
on:
workflow_call:
inputs:
tag:
default: "latest"
description: "Tag to apply to images, default is latest"
required: false
type: string
repo:
description: "Repo to apply to images, default is empty string"
required: false
type: string

jobs:
go-e2e:
runs-on: kind-xeon
steps:
- name: Checkout out Repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set variables
env:
imagerepo: ${{ inputs.repo }}
imagetag: ${{ inputs.tag }}
run: |
if [[ -z "$imagerepo" ]]; then
echo "DOCKER_REGISTRY=${OPEA_IMAGE_REPO}" >> $GITHUB_ENV
else
echo "DOCKER_REGISTRY=${imagerepo}" >> $GITHUB_ENV
fi
echo "DOCKER_REGISTRY=$DOCKER_REGISTRY" >> $GITHUB_ENV
echo "VERSION=$imagetag" >> $GITHUB_ENV
echo "SYSTEM_NAMESPACE=opea-system" >> $GITHUB_ENV
echo "APP_NAMESPACE=opea-app" >> $GITHUB_ENV
echo "should_cleanup=false" >> $GITHUB_ENV
echo "skip_validate=false" >> $GITHUB_ENV
echo "KIND_MOUNT_DIR=/mnt/huggingface/hub" >> $GITHUB_ENV
- name: Install GMC
run: |
echo "should_cleanup=true" >> $GITHUB_ENV
.github/workflows/scripts/e2e/gmc_install.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: |
if $skip_validate; then
echo "Skip validate"
else
.github/workflows/scripts/e2e/gmc_xeon_test.sh validate_gmc
fi
- name: Cleanup modules
if: always()
run: |
if $should_cleanup; then
.github/workflows/scripts/e2e/gmc_xeon_test.sh cleanup_apps
.github/workflows/scripts/e2e/gmc_install.sh cleanup_gmc
fi
107 changes: 107 additions & 0 deletions .github/workflows/_infra-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: GenAIInfra GMC Jobs
permissions: read-all
on:
workflow_call:
inputs:
tag:
default: "latest"
required: false
type: string
build:
default: true
required: false
type: boolean
scan:
default: true
required: false
type: boolean
test_gmc:
default: true
required: false
type: boolean
publish:
default: false
required: false
type: boolean
publish_tags:
default: "latest"
required: false
type: string
jobs:
####################################################################################################
# Image Build
####################################################################################################
image-build:
if: ${{ fromJSON(inputs.build) }}
uses: ./.github/workflows/_gmc-image-build.yaml
with:
image_tag: ${{ inputs.tag }}
runner_label: 'docker-build-xeon'

####################################################################################################
# Trivy Scan
####################################################################################################
scan-images:
needs: [image-build]
if: ${{ fromJSON(inputs.scan) }}
strategy:
matrix:
image: ["gmcmanager", "gmcrouter"]
runs-on: 'docker-build-xeon'
steps:
- name: Harden Runner
uses: step-security/[email protected]
with:
egress-policy: audit

- name: Pull Image
run: docker pull ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}

- name: Scan Container
uses: opea-project/validation/actions/trivy-scan@main
with:
image-ref: ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
output: ${{ matrix.image }}-scan.txt

- name: Cleanup
if: always()
run: docker rmi -f ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
- uses: actions/[email protected]
with:
name: gmc-scan
path: ${{ matrix.image }}-scan.txt
overwrite: true

####################################################################################################
# GMC Test
####################################################################################################
test-gmc:
needs: [image-build]
if: ${{ fromJSON(inputs.test_gmc) }}
uses: ./.github/workflows/_gmc-e2e.yaml
with:
repo: ${{ needs.image-build.outputs.image_repo }}
tag: ${{ needs.image-build.outputs.image_tag }}
secrets: inherit


####################################################################################################
# Publish
####################################################################################################
publish:
needs: [image-build, scan-images, test-gmc]
if: ${{ fromJSON(inputs.publish) }}
strategy:
matrix:
image: ["gmcmanager", "gmcrouter"]
runs-on: "docker-build-xeon"
steps:
- name: Image Publish
uses: opea-project/validation/actions/image-publish@main
with:
local_image_ref: ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
image_name: opea/${{ matrix.image }}
publish_tags: ${{ inputs.publish_tags }}
50 changes: 50 additions & 0 deletions .github/workflows/manual-cd-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: GenAIInfra GMC CD workflow on manual event
on:
workflow_dispatch:
inputs:
tag:
default: "latest"
description: "Tag to apply to images"
required: true
type: string
build:
default: true
description: 'Build test required images for Examples'
required: false
type: boolean
scan:
default: true
description: 'Scan all images with Trivy'
required: false
type: boolean
test_gmc:
default: true
description: 'Test GMC on Xeon KIND'
required: false
type: boolean
publish:
default: false
description: 'Publish images to docker hub'
required: false
type: boolean
publish_tags:
default: "latest,v0.9"
description: 'Tag list apply to publish images'
required: false
type: string

permissions: read-all
jobs:
gmc-release:
uses: ./.github/workflows/_infra-workflow.yaml
with:
tag: ${{ inputs.tag }}
build: ${{ fromJSON(inputs.build) }}
scan: ${{ fromJSON(inputs.scan) }}
test_gmc: ${{ fromJSON(inputs.test_gmc) }}
publish: ${{ fromJSON(inputs.publish) }}
publish_tags: ${{ fromJSON(inputs.publish_tags) }}
secrets: inherit
49 changes: 6 additions & 43 deletions .github/workflows/pr-go-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,46 +32,9 @@ jobs:
runner_label: 'docker-build-xeon'

go-e2e:
runs-on: kind-xeon
needs: image-build
steps:
- name: Checkout out Repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set variables
run: |
echo "SYSTEM_NAMESPACE=opea-system" >> $GITHUB_ENV
echo "APP_NAMESPACE=opea-app" >> $GITHUB_ENV
echo "DOCKER_REGISTRY=${{ needs.image-build.outputs.image_repo }}" >> $GITHUB_ENV
echo "VERSION=${{ needs.image-build.outputs.image_tag }}" >> $GITHUB_ENV
echo "should_cleanup=false" >> $GITHUB_ENV
echo "skip_validate=false" >> $GITHUB_ENV
echo "KIND_MOUNT_DIR=/mnt/huggingface/hub" >> $GITHUB_ENV
- name: Install GMC
run: |
echo "should_cleanup=true" >> $GITHUB_ENV
.github/workflows/scripts/e2e/gmc_install.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: |
if $skip_validate; then
echo "Skip validate"
else
.github/workflows/scripts/e2e/gmc_xeon_test.sh validate_gmc
fi
- name: Cleanup modules
if: always()
run: |
if $should_cleanup; then
.github/workflows/scripts/e2e/gmc_xeon_test.sh cleanup_apps
.github/workflows/scripts/e2e/gmc_install.sh cleanup_gmc
fi
needs: [image-build]
uses: ./.github/workflows/_gmc-e2e.yaml
with:
repo: ${{ needs.image-build.outputs.image_repo }}
tag: ${{ needs.image-build.outputs.image_tag }}
secrets: inherit
6 changes: 6 additions & 0 deletions .github/workflows/scripts/e2e/gmc_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ function init_gmc() {
sed -i "s|namespace: system|namespace: $SYSTEM_NAMESPACE|g" $(pwd)/config/rbac/gmc-manager-rbac.yaml
sed -i "s|name: system|name: $SYSTEM_NAMESPACE|g" $(pwd)/config/rbac/gmc-manager-rbac.yaml

# if SET_VERSION=true then replace latest with VERSION
if [ -n "$SET_VERSION" ]; then
# replace the repository "image: opea/*:latest" with "image: ${IMAGE_REPO}opea/"
find . -name '*.yaml' -type f -exec sed -i "s#image: opea/\(.*\):latest#image: opea/\1:$VERSION#g" {} \;
find . -name '*.yaml' -type f -exec sed -i "s#image: \"opea/\(.*\):latest#image: \"opea/\1:$VERSION#g" {} \;
fi
# replace the mount dir "path: /mnt/model" with "path: $CHART_MOUNT"
# find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/models#path: $MOUNT_DIR#g" {} \;
find . -name '*.yaml' -type f -exec sed -i "s#path: /mnt/opea-models#path: $MOUNT_DIR#g" {} \;
Expand Down

0 comments on commit 3d94844

Please sign in to comment.