Skip to content

Commit

Permalink
Merge branch 'main' into openshift
Browse files Browse the repository at this point in the history
  • Loading branch information
Feelas authored Nov 5, 2024
2 parents fcb5f93 + d6e5ad1 commit 60037e7
Show file tree
Hide file tree
Showing 264 changed files with 6,038 additions and 404 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/_helm-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
echo "RELEASE_NAME=${CHART_NAME}$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "NAMESPACE=${CHART_NAME}-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "ROLLOUT_TIMEOUT_SECONDS=600s" >> $GITHUB_ENV
echo "TEST_TIMEOUT_SECONDS=600s" >> $GITHUB_ENV
echo "KUBECTL_TIMEOUT_SECONDS=60s" >> $GITHUB_ENV
echo "should_cleanup=false" >> $GITHUB_ENV
echo "skip_validate=false" >> $GITHUB_ENV
Expand Down Expand Up @@ -110,7 +111,6 @@ jobs:
helm-charts/update_dependency.sh && helm dependency update ${{ env.CHART_FOLDER }}
if ! helm install --create-namespace --namespace $NAMESPACE --wait \
--timeout "$ROLLOUT_TIMEOUT_SECONDS" \
--set autodependency.enabled=true \
--set GOOGLE_API_KEY=${{ env.GOOGLE_API_KEY}} \
--set GOOGLE_CSE_ID=${{ env.GOOGLE_CSE_ID}} \
--values ${{ env.CHART_FOLDER }}/${value_file} \
Expand All @@ -130,7 +130,7 @@ jobs:
else
LOG_PATH=/home/$(whoami)/logs
chart=${{ env.CHART_NAME }}
helm test -n $NAMESPACE $RELEASE_NAME --logs |tee ${LOG_PATH}/charts-${chart}.log
helm test -n $NAMESPACE $RELEASE_NAME --logs --timeout "$TEST_TIMEOUT_SECONDS" | tee ${LOG_PATH}/charts-${chart}.log
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "Chart ${chart} test failed, please check the logs in ${LOG_PATH}!"
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/_mbe-image-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: Memory Bindwidth Exportor Image Build
permissions: read-all
on:
workflow_call:
inputs:
image_repo:
required: false
type: string
image_tag:
required: true
type: string
runner_label:
required: false
type: string
default: 'docker-build-xeon'
outputs:
image_repo:
description: "The image repository used for the image build"
value: ${{ jobs.image-build.outputs.image_repo }}
image_tag:
description: "The image tag used for the image build"
value: ${{ jobs.image-build.outputs.version }}
env:
GOSRC_DIR: "kubernetes-addons/memory-bandwidth-exporter"

jobs:
image-build:
runs-on: ${{ inputs.runner_label }}
outputs:
image_repo: ${{ steps.set_variables.outputs.IMAGE_REPO }}
version: ${{ steps.set_variables.outputs.VERSION }}
steps:
- name: Clean Up Working Directory
run: sudo rm -rf ${{github.workspace}}/*

- name: Get checkout ref
id: get-checkout-ref
run: |
if [ "${{ github.event_name }}" == "pull_request" ] || [ "${{ github.event_name }}" == "pull_request_target" ]; then
CHECKOUT_REF=refs/pull/${{ github.event.number }}/merge
else
CHECKOUT_REF=${{ github.ref }}
fi
echo "CHECKOUT_REF=${CHECKOUT_REF}" >> $GITHUB_OUTPUT
echo "checkout ref ${CHECKOUT_REF}"
- name: Checkout out Repo
uses: actions/checkout@v4
with:
ref: ${{ steps.get-checkout-ref.outputs.CHECKOUT_REF }}
fetch-depth: 0

- name: Set variables
id: set_variables
env:
imagerepo: ${{ inputs.image_repo }}
run: |
if [[ -z "$imagerepo" ]]; then
echo "DOCKER_REGISTRY=${OPEA_IMAGE_REPO}opea" >> $GITHUB_ENV
echo "IMAGE_REPO=${OPEA_IMAGE_REPO}" >> $GITHUB_OUTPUT
else
echo "DOCKER_REGISTRY=${imagerepo}/opea" >> $GITHUB_ENV
echo "IMAGE_REPO=${imagerepo}/" >> $GITHUB_OUTPUT
fi
echo "VERSION=${{ inputs.image_tag }}" >> $GITHUB_ENV
echo "VERSION=${{ inputs.image_tag }}" >> $GITHUB_OUTPUT
- name: Build image and push
run: |
cd $GOSRC_DIR
make docker.build
make docker.push
- name: Clean up images
if: always()
run: |
# clean up the images
docker rmi ${{ env.DOCKER_REGISTRY }}/memory-bandwidth-exporter:${{ env.VERSION }}
echo y | docker image prune
13 changes: 3 additions & 10 deletions .github/workflows/pr-chart-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
paths:
- helm-charts/**
- .github/workflows/chart-e2e.yaml
workflow_dispatch:

concurrency:
Expand Down Expand Up @@ -39,19 +38,16 @@ jobs:
merged_commit=$(git log -1 --format='%H')
e2e_charts=$(git diff --name-only ${base_commit} ${merged_commit} | \
grep "^$CHARTS_DIR/" | \
grep -vE 'README.md|common|*.sh' | \
grep -vE 'README.md|CI.md|common|*.sh' | \
cut -d'/' -f2 | sort -u )
common_charts=$(git diff --name-only ${base_commit} ${merged_commit} | \
grep "^$CHARTS_DIR/common" | \
grep -vE 'README.md|*.sh' | \
cut -d'/' -f3 | sort -u )
run_matrix="{\"include\":["
for chart in ${e2e_charts}; do
for file in "$CHARTS_DIR/$chart"/*values.yaml; do
for file in "$CHARTS_DIR/$chart"/ci-*values.yaml; do
if [ -f "$file" ]; then
if [[ "$file" == *"nv-values.yaml" ]] || [[ "$file" == *"hpa-values.yaml" ]]; then
continue
fi
filename=$(basename "$file" .yaml)
if [[ "$filename" == *"gaudi"* ]]; then
run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\"},"
Expand All @@ -62,11 +58,8 @@ jobs:
done
done
for chart in ${common_charts}; do
for file in "$CHARTS_DIR/common/$chart"/*values.yaml; do
for file in "$CHARTS_DIR/common/$chart"/ci-*values.yaml; do
if [ -f "$file" ]; then
if [[ "$file" == *"nv-values.yaml" ]] || [[ "$file" == *"hpa-values.yaml" ]]; then
continue
fi
filename=$(basename "$file" .yaml)
if [[ "$filename" == *"gaudi"* ]]; then
run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\",\"directory\":\"common\"},"
Expand Down
138 changes: 138 additions & 0 deletions .github/workflows/pr-path-detection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: Check Paths and Hyperlinks

on:
pull_request:
branches: [main]
types: [opened, reopened, ready_for_review, synchronize]

jobs:
check-the-validity-of-hyperlinks-in-README:
runs-on: ubuntu-latest
steps:
- name: Clean Up Working Directory
run: sudo rm -rf ${{github.workspace}}/*

- name: Checkout Repo GenAIInfra
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check the Validity of Hyperlinks
run: |
cd ${{github.workspace}}
fail="FALSE"
merged_commit=$(git log -1 --format='%H')
changed_files="$(git diff --name-status --diff-filter=ARM ${{ github.event.pull_request.base.sha }} ${merged_commit} | awk '/\.md$/ {print $NF}')"
if [ -n "$changed_files" ]; then
for changed_file in $changed_files; do
url_lines=$(grep -H -Eo '\]\(http[s]?://[^)]+\)' "$changed_file" | grep -Ev 'GenAIEval/blob/main') || true
if [ -n "$url_lines" ]; then
for url_line in $url_lines; do
url=$(echo "$url_line"|cut -d '(' -f2 | cut -d ')' -f1|sed 's/\.git$//')
path=$(echo "$url_line"|cut -d':' -f1 | cut -d'/' -f2-)
response=$(curl -L -s -o /dev/null -w "%{http_code}" "$url")
if [ "$response" -ne 200 ]; then
echo "**********Validation failed, try again**********"
response_retry=$(curl -s -o /dev/null -w "%{http_code}" "$url")
if [ "$response_retry" -eq 200 ]; then
echo "*****Retry successful*****"
else
echo "Invalid link from ${{github.workspace}}/$path: $url"
fail="TRUE"
fi
fi
done
fi
done
else
echo "No changed .md file."
fi
if [[ "$fail" == "TRUE" ]]; then
exit 1
else
echo "All hyperlinks are valid."
fi
shell: bash

check-the-validity-of-relative-path:
runs-on: ubuntu-latest
steps:
- name: Clean up Working Directory
run: sudo rm -rf ${{github.workspace}}/*

- name: Checkout Repo GenAIInfra
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Checking Relative Path Validity
run: |
cd ${{github.workspace}}
fail="FALSE"
repo_name=${{ github.event.pull_request.head.repo.full_name }}
if [ "$(echo "$repo_name"|cut -d'/' -f1)" != "opea-project" ]; then
owner=$(echo "${{ github.event.pull_request.head.repo.full_name }}" |cut -d'/' -f1)
branch="https://github.com/$owner/GenAIInfra/tree/${{ github.event.pull_request.head.ref }}"
else
branch="https://github.com/opea-project/GenAIInfra/blob/${{ github.event.pull_request.head.ref }}"
fi
link_head="https://github.com/opea-project/GenAIInfra/blob/main"
merged_commit=$(git log -1 --format='%H')
changed_files="$(git diff --name-status --diff-filter=ARM ${{ github.event.pull_request.base.sha }} ${merged_commit} | awk '/\.md$/ {print $NF}')"
png_lines=$(grep -Eo '\]\([^)]+\)' --include='*.md' -r .|grep -Ev 'http')
if [ -n "$png_lines" ]; then
for png_line in $png_lines; do
refer_path=$(echo "$png_line"|cut -d':' -f1 | cut -d'/' -f2-)
png_path=$(echo "$png_line"|cut -d '(' -f2 | cut -d ')' -f1)
if [[ "${png_path:0:1}" == "/" ]]; then
check_path=$png_path
elif [[ "$png_path" == *#* ]]; then
relative_path=$(echo "$png_path" | cut -d '#' -f1)
if [ -n "$relative_path" ]; then
check_path=$(dirname "$refer_path")/$relative_path
png_path=$(echo "$png_path" | awk -F'#' '{print "#" $2}')
else
check_path=$refer_path
fi
else
check_path=$(dirname "$refer_path")/$png_path
fi
if [ -e "$check_path" ]; then
real_path=$(realpath $check_path)
if [[ "$png_line" == *#* ]]; then
if [ -n "changed_files" ] && echo "$changed_files" | grep -q "^${refer_path}$"; then
url_dev=$branch$(echo "$real_path" | sed 's|.*/GenAIInfra||')$png_path
response=$(curl -I -L -s -o /dev/null -w "%{http_code}" "$url_dev")
if [ "$response" -ne 200 ]; then
echo "**********Validation failed, try again**********"
response_retry=$(curl -s -o /dev/null -w "%{http_code}" "$url_dev")
if [ "$response_retry" -eq 200 ]; then
echo "*****Retry successfully*****"
else
echo "Invalid path from ${{github.workspace}}/$refer_path: $png_path, link: $url_dev"
fail="TRUE"
fi
else
echo "Validation succeed $png_line"
fi
fi
fi
else
echo "$check_path does not exist"
fail="TRUE"
fi
done
fi
if [[ "$fail" == "TRUE" ]]; then
exit 1
else
echo "All hyperlinks are valid."
fi
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- "!**.txt"
- "!**.png"
- "!.**"
- .github/workflows/gmc-on-push.yaml
- .github/workflows/push-gmc-image-build.yaml
workflow_dispatch:

concurrency:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/push-mbe-image-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: Upgrade memory bandwidth exporter on push event

on:
push:
branches: ["main"]
paths:
- kubernetes-addons/memory-bandwidth-exporter/**
- "!**.md"
- "!**.txt"
- "!**.png"
- "!.**"
- .github/workflows/push-mbe-image-build.yaml
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-on-push
cancel-in-progress: true

env:
GOSRC_DIR: "kubernetes-addons/memory-bandwidth-exporter"

jobs:
image-build:
strategy:
matrix:
platform: [xeon, gaudi]
uses: ./.github/workflows/_mbe-image-build.yaml
with:
image_tag: 'latest'
runner_label: 'docker-build-${{ matrix.platform }}'
2 changes: 1 addition & 1 deletion .github/workflows/scripts/codeScan/bandit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0

source /GenAIInfra/.github/workflows/scripts/change_color
pip install bandit==1.7.8
pip install --no-cache-dir bandit==1.7.8
log_dir=/GenAIInfra/.github/workflows/scripts/codeScan
python -m bandit -r -lll -iii /GenAIInfra 2>&1 | tee ${log_dir}/bandit.log
exit_code=$?
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/scripts/e2e/chart_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ function dump_failed_pod_logs() {

function dump_all_pod_logs() {
namespace=$1
echo "-----DUMP POD STATUS AND LOG in NS $namespace------"
echo "-----DUMP POD STATUS AND LOG in NS $namespace-----"
echo "------SUMMARY of POD STATUS in NS $namespace------"
kubectl get pods -n $namespace -o wide
echo "--------------------------------------------------"

pods=$(kubectl get pods -n $namespace -o jsonpath='{.items[*].metadata.name}')
for pod_name in $pods
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/scripts/e2e/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

saved_errexit=False

function turnoff_and_save_errexit() {
if [[ "$-" =~ e ]]; then
saved_errexit=True
set +e
fi
}


function resume_errexit() {
if [ "$saved_errexit" = "True" ]; then
saved_errexit=False
set -e
fi
}


function wait_until_pod_ready() {
echo "Waiting for the $1 to be ready..."
max_retries=60
Expand Down Expand Up @@ -53,6 +71,7 @@ function wait_until_all_pod_ready() {
namespace=$1
timeout=$2

turnoff_and_save_errexit
echo "Wait for all pods in NS $namespace to be ready..."
pods=$(kubectl get pods -n $namespace --no-headers | grep -v "Terminating" | awk '{print $1}')
# Loop through each pod
Expand All @@ -68,6 +87,7 @@ function wait_until_all_pod_ready() {
exit 1
fi
done
resume_errexit
}

function check_gmc_status() {
Expand Down
Loading

0 comments on commit 60037e7

Please sign in to comment.