Check image and service names and Dockerfile in build.yaml (#1209)
Signed-off-by: ZePan110 <ze.pan@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
109
.github/workflows/pr-dockerfile-path-and-build-yaml-scan.yml
vendored
Normal file
109
.github/workflows/pr-dockerfile-path-and-build-yaml-scan.yml
vendored
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
# Copyright (C) 2024 Intel Corporation
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
name: Compose file and dockerfile path checking
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
types: [opened, reopened, ready_for_review, synchronize]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-dockerfile-paths-in-README:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Clean Up Working Directory
|
||||||
|
run: sudo rm -rf ${{github.workspace}}/*
|
||||||
|
|
||||||
|
- name: Checkout Repo GenAIExamples
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Clone Repo GenAIComps
|
||||||
|
run: |
|
||||||
|
cd ..
|
||||||
|
git clone https://github.com/opea-project/GenAIComps.git
|
||||||
|
|
||||||
|
- name: Check for Missing Dockerfile Paths in GenAIComps
|
||||||
|
run: |
|
||||||
|
cd ${{github.workspace}}
|
||||||
|
miss="FALSE"
|
||||||
|
while IFS=: read -r file line content; do
|
||||||
|
dockerfile_path=$(echo "$content" | awk -F '-f ' '{print $2}' | awk '{print $1}')
|
||||||
|
if [[ ! -f "../GenAIComps/${dockerfile_path}" ]]; then
|
||||||
|
miss="TRUE"
|
||||||
|
echo "Missing Dockerfile: GenAIComps/${dockerfile_path} (Referenced in GenAIExamples/${file}:${line})"
|
||||||
|
fi
|
||||||
|
done < <(grep -Ern 'docker build .* -f comps/.+/Dockerfile' --include='*.md' .)
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$miss" == "TRUE" ]]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
check-Dockerfile-in-build-yamls:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Clean Up Working Directory
|
||||||
|
run: sudo rm -rf ${{github.workspace}}/*
|
||||||
|
|
||||||
|
- name: Checkout Repo GenAIExamples
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Check Dockerfile path included in image build yaml
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
shopt -s globstar
|
||||||
|
no_add="FALSE"
|
||||||
|
cd ${{github.workspace}}
|
||||||
|
Dockerfiles=$(realpath $(find ./ -name '*Dockerfile*'))
|
||||||
|
if [ -n "$Dockerfiles" ]; then
|
||||||
|
for dockerfile in $Dockerfiles; do
|
||||||
|
service=$(echo "$dockerfile" | awk -F '/GenAIExamples/' '{print $2}' | awk -F '/' '{print $2}')
|
||||||
|
cd ${{github.workspace}}/$service/docker_image_build
|
||||||
|
all_paths=$(realpath $(awk ' /context:/ { context = $2 } /dockerfile:/ { dockerfile = $2; combined = context "/" dockerfile; gsub(/\/+/, "/", combined); if (index(context, ".") > 0) {print combined}}' build.yaml) 2> /dev/null || true )
|
||||||
|
if ! echo "$all_paths" | grep -q "$dockerfile"; then
|
||||||
|
echo "AR: Update $dockerfile to GenAIExamples/$service/docker_image_build/build.yaml. The yaml is used for release images build."
|
||||||
|
no_add="TRUE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$no_add" == "TRUE" ]]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
check-image-and-service-names-in-build-yaml:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Clean Up Working Directory
|
||||||
|
run: sudo rm -rf ${{github.workspace}}/*
|
||||||
|
|
||||||
|
- name: Checkout Repo GenAIExamples
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check name agreement in build.yaml
|
||||||
|
run: |
|
||||||
|
pip install ruamel.yaml
|
||||||
|
cd ${{github.workspace}}
|
||||||
|
consistency="TRUE"
|
||||||
|
build_yamls=$(find . -name 'build.yaml')
|
||||||
|
for build_yaml in $build_yamls; do
|
||||||
|
message=$(python3 .github/workflows/scripts/check-name-agreement.py "$build_yaml")
|
||||||
|
if [[ "$message" != *"consistent"* ]]; then
|
||||||
|
consistency="FALSE"
|
||||||
|
echo "Inconsistent service name and image name found in file $build_yaml."
|
||||||
|
echo "$message"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$consistency" == "FALSE" ]]; then
|
||||||
|
echo "Please ensure that the service and image names are consistent in build.yaml, otherwise we cannot guarantee that your image will be published correctly."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
shell: bash
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (C) 2024 Intel Corporation
|
# Copyright (C) 2024 Intel Corporation
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
name: Check Paths and Hyperlinks
|
name: Check hyperlinks and relative path validity
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
@@ -9,39 +9,6 @@ on:
|
|||||||
types: [opened, reopened, ready_for_review, synchronize]
|
types: [opened, reopened, ready_for_review, synchronize]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-dockerfile-paths:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Clean Up Working Directory
|
|
||||||
run: sudo rm -rf ${{github.workspace}}/*
|
|
||||||
|
|
||||||
- name: Checkout Repo GenAIExamples
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Clone Repo GenAIComps
|
|
||||||
run: |
|
|
||||||
cd ..
|
|
||||||
git clone https://github.com/opea-project/GenAIComps.git
|
|
||||||
|
|
||||||
- name: Check for Missing Dockerfile Paths in GenAIComps
|
|
||||||
run: |
|
|
||||||
cd ${{github.workspace}}
|
|
||||||
miss="FALSE"
|
|
||||||
while IFS=: read -r file line content; do
|
|
||||||
dockerfile_path=$(echo "$content" | awk -F '-f ' '{print $2}' | awk '{print $1}')
|
|
||||||
if [[ ! -f "../GenAIComps/${dockerfile_path}" ]]; then
|
|
||||||
miss="TRUE"
|
|
||||||
echo "Missing Dockerfile: GenAIComps/${dockerfile_path} (Referenced in GenAIExamples/${file}:${line})"
|
|
||||||
fi
|
|
||||||
done < <(grep -Ern 'docker build .* -f comps/.+/Dockerfile' --include='*.md' .)
|
|
||||||
|
|
||||||
|
|
||||||
if [[ "$miss" == "TRUE" ]]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
check-the-validity-of-hyperlinks-in-README:
|
check-the-validity-of-hyperlinks-in-README:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
46
.github/workflows/scripts/check-name-agreement.py
vendored
Normal file
46
.github/workflows/scripts/check-name-agreement.py
vendored
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Copyright (C) 2024 Intel Corporation
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from ruamel.yaml import YAML
|
||||||
|
|
||||||
|
|
||||||
|
def parse_yaml_file(file_path):
|
||||||
|
yaml = YAML()
|
||||||
|
with open(file_path, "r") as file:
|
||||||
|
data = yaml.load(file)
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def check_service_image_consistency(data):
|
||||||
|
inconsistencies = []
|
||||||
|
for service_name, service_details in data.get("services", {}).items():
|
||||||
|
image_name = service_details.get("image", "")
|
||||||
|
# Extract the image name part after the last '/'
|
||||||
|
image_name_part = image_name.split("/")[-1].split(":")[0]
|
||||||
|
# Check if the service name is a substring of the image name part
|
||||||
|
if service_name not in image_name_part:
|
||||||
|
# Get the line number of the service name
|
||||||
|
line_number = service_details.lc.line + 1
|
||||||
|
inconsistencies.append((service_name, image_name, line_number))
|
||||||
|
return inconsistencies
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description="Check service name and image name consistency in a YAML file.")
|
||||||
|
parser.add_argument("file_path", type=str, help="The path to the YAML file.")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
data = parse_yaml_file(args.file_path)
|
||||||
|
|
||||||
|
inconsistencies = check_service_image_consistency(data)
|
||||||
|
if inconsistencies:
|
||||||
|
for service_name, image_name, line_number in inconsistencies:
|
||||||
|
print(f"Service name: {service_name}, Image name: {image_name}, Line number: {line_number}")
|
||||||
|
else:
|
||||||
|
print("All consistent")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -11,6 +11,18 @@ services:
|
|||||||
context: ../
|
context: ../
|
||||||
dockerfile: ./Dockerfile
|
dockerfile: ./Dockerfile
|
||||||
image: ${REGISTRY:-opea}/audioqna:${TAG:-latest}
|
image: ${REGISTRY:-opea}/audioqna:${TAG:-latest}
|
||||||
|
audioqna-ui:
|
||||||
|
build:
|
||||||
|
context: ../ui
|
||||||
|
dockerfile: ./docker/Dockerfile
|
||||||
|
extends: audioqna
|
||||||
|
image: ${REGISTRY:-opea}/audioqna-ui:${TAG:-latest}
|
||||||
|
audioqna-multilang:
|
||||||
|
build:
|
||||||
|
context: ../
|
||||||
|
dockerfile: ./Dockerfile.multilang
|
||||||
|
extends: audioqna
|
||||||
|
image: ${REGISTRY:-opea}/audioqna-multilang:${TAG:-latest}
|
||||||
whisper-gaudi:
|
whisper-gaudi:
|
||||||
build:
|
build:
|
||||||
context: GenAIComps
|
context: GenAIComps
|
||||||
|
|||||||
@@ -47,3 +47,12 @@ services:
|
|||||||
context: ../ui
|
context: ../ui
|
||||||
dockerfile: ./docker/Dockerfile
|
dockerfile: ./docker/Dockerfile
|
||||||
image: ${REGISTRY:-opea}/graphrag-ui:${TAG:-latest}
|
image: ${REGISTRY:-opea}/graphrag-ui:${TAG:-latest}
|
||||||
|
graphrag-react-ui:
|
||||||
|
build:
|
||||||
|
args:
|
||||||
|
http_proxy: ${http_proxy}
|
||||||
|
https_proxy: ${https_proxy}
|
||||||
|
no_proxy: ${no_proxy}
|
||||||
|
context: ../ui
|
||||||
|
dockerfile: ./docker/Dockerfile.react
|
||||||
|
image: ${REGISTRY:-opea}/graphrag-react-ui:${TAG:-latest}
|
||||||
|
|||||||
@@ -11,3 +11,8 @@ services:
|
|||||||
context: GenAIComps
|
context: GenAIComps
|
||||||
dockerfile: comps/text2image/Dockerfile
|
dockerfile: comps/text2image/Dockerfile
|
||||||
image: ${REGISTRY:-opea}/text2image:${TAG:-latest}
|
image: ${REGISTRY:-opea}/text2image:${TAG:-latest}
|
||||||
|
text2image-ui:
|
||||||
|
build:
|
||||||
|
context: ../ui
|
||||||
|
dockerfile: ./docker/Dockerfile
|
||||||
|
image: ${REGISTRY:-opea}/text2image-ui:${TAG:-latest}
|
||||||
|
|||||||
@@ -13,10 +13,9 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fortawesome/free-solid-svg-icons": "6.2.0",
|
"@fortawesome/free-solid-svg-icons": "6.2.0",
|
||||||
"@playwright/test": "^1.48.0",
|
"@playwright/test": "^1.33.0",
|
||||||
"@sveltejs/adapter-auto": "1.0.0-next.75",
|
"@sveltejs/adapter-auto": "1.0.0-next.75",
|
||||||
"@sveltejs/adapter-static": "^3.0.0",
|
"@sveltejs/kit": "^1.30.4",
|
||||||
"@sveltejs/kit": "^2.0.0",
|
|
||||||
"@tailwindcss/typography": "0.5.7",
|
"@tailwindcss/typography": "0.5.7",
|
||||||
"@types/debug": "4.1.7",
|
"@types/debug": "4.1.7",
|
||||||
"@types/node": "^20.12.13",
|
"@types/node": "^20.12.13",
|
||||||
@@ -29,20 +28,21 @@
|
|||||||
"eslint": "^8.16.0",
|
"eslint": "^8.16.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-neverthrow": "1.1.4",
|
"eslint-plugin-neverthrow": "1.1.4",
|
||||||
|
"eslint-plugin-svelte3": "^4.0.0",
|
||||||
"postcss": "^8.4.31",
|
"postcss": "^8.4.31",
|
||||||
"postcss-load-config": "^4.0.1",
|
"postcss-load-config": "^4.0.1",
|
||||||
"postcss-preset-env": "^8.3.2",
|
"postcss-preset-env": "^8.3.2",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^2.8.8",
|
||||||
"prettier-plugin-svelte": "^2.7.0",
|
"prettier-plugin-svelte": "^2.7.0",
|
||||||
"prettier-plugin-tailwindcss": "^0.3.0",
|
"prettier-plugin-tailwindcss": "^0.3.0",
|
||||||
"svelte": "^4.0.0",
|
"svelte": "^3.59.1",
|
||||||
"svelte-check": "^3.0.0",
|
"svelte-check": "^2.7.1",
|
||||||
"svelte-fa": "3.0.3",
|
"svelte-fa": "3.0.3",
|
||||||
"svelte-preprocess": "^6.0.2",
|
"svelte-preprocess": "^4.10.7",
|
||||||
"tailwindcss": "^3.1.5",
|
"tailwindcss": "^3.1.5",
|
||||||
"tslib": "^2.3.1",
|
"tslib": "^2.3.1",
|
||||||
"typescript": "^5.0.0",
|
"typescript": "^4.7.4",
|
||||||
"vite": "^5.0.0"
|
"vite": "^4.5.2"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user