forked from opea-project/GenAIComps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add workflow test for microservice (opea-project#97)
Signed-off-by: chensuyue <suyue.chen@intel.com> Signed-off-by: Spycsh <sihan.chen@intel.com> Signed-off-by: letonghan <letong.han@intel.com>
- Loading branch information
Showing
16 changed files
with
553 additions
and
216 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,87 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: MicroService-test | ||
|
||
on: | ||
pull_request_target: | ||
branches: [main] | ||
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped | ||
paths: | ||
- comps/** | ||
- "!**.md" | ||
- "!**.txt" | ||
- .github/workflows/microservice.yml | ||
|
||
# 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 | ||
|
||
jobs: | ||
job1: | ||
name: Get-test-matrix | ||
runs-on: ubuntu-latest | ||
outputs: | ||
run_matrix: ${{ steps.get-test-matrix.outputs.run_matrix }} | ||
steps: | ||
- name: Checkout out Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "refs/pull/${{ github.event.number }}/merge" | ||
fetch-depth: 0 | ||
- name: Get test matrix | ||
id: get-test-matrix | ||
run: | | ||
set -xe | ||
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \ | ||
| grep 'comps/' | grep -vE '*.md|*.txt') | ||
services=$(printf '%s\n' "${changed_files[@]}" | grep '/' | cut -d'/' -f2 | sort -u) | ||
run_matrix="{\"include\":[" | ||
for service in ${services}; do | ||
hardware="gaudi" # default hardware, set based on the changed files | ||
run_matrix="${run_matrix}{\"service\":\"${service}\",\"hardware\":\"${hardware}\"}," | ||
done | ||
run_matrix=$run_matrix"]}" | ||
echo "run_matrix=${run_matrix}" >> $GITHUB_OUTPUT | ||
Microservice-test: | ||
needs: job1 | ||
strategy: | ||
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }} | ||
runs-on: ${{ matrix.hardware }} | ||
continue-on-error: true | ||
steps: | ||
- name: Clean Up Working Directory | ||
run: sudo rm -rf ${{github.workspace}}/* | ||
|
||
- name: Checkout out Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "refs/pull/${{ github.event.number }}/merge" | ||
|
||
- name: Run microservice test | ||
env: | ||
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HUGGINGFACEHUB_API_TOKEN }} | ||
service: ${{ matrix.service }} | ||
hardware: ${{ matrix.hardware }} | ||
run: | | ||
cd tests | ||
if [ -f test_${service}.sh ]; then timeout 10m bash test_${service}.sh; else echo "Test script not found, skip test!"; fi | ||
- name: Clean up container | ||
env: | ||
service: ${{ matrix.service }} | ||
hardware: ${{ matrix.hardware }} | ||
if: cancelled() || failure() | ||
run: | | ||
cid=$(docker ps -aq --filter "name=test-comps-*") | ||
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi | ||
echo y | docker system prune | ||
- name: Publish pipeline artifact | ||
if: ${{ !cancelled() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.service }}-${{ matrix.hardware }} | ||
path: ${{ github.workspace }}/tests/*.log |
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
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
Oops, something went wrong.