Skip to content

Commit e8cffc6

Browse files
Check image and service names and Dockerfile in build.yaml (opea-project#1209)
Signed-off-by: ZePan110 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 907b30b commit e8cffc6

File tree

7 files changed

+190
-42
lines changed

7 files changed

+190
-42
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Compose file and dockerfile path checking
5+
6+
on:
7+
pull_request:
8+
branches: [main]
9+
types: [opened, reopened, ready_for_review, synchronize]
10+
11+
jobs:
12+
check-dockerfile-paths-in-README:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Clean Up Working Directory
16+
run: sudo rm -rf ${{github.workspace}}/*
17+
18+
- name: Checkout Repo GenAIExamples
19+
uses: actions/checkout@v4
20+
21+
- name: Clone Repo GenAIComps
22+
run: |
23+
cd ..
24+
git clone https://github.com/opea-project/GenAIComps.git
25+
26+
- name: Check for Missing Dockerfile Paths in GenAIComps
27+
run: |
28+
cd ${{github.workspace}}
29+
miss="FALSE"
30+
while IFS=: read -r file line content; do
31+
dockerfile_path=$(echo "$content" | awk -F '-f ' '{print $2}' | awk '{print $1}')
32+
if [[ ! -f "../GenAIComps/${dockerfile_path}" ]]; then
33+
miss="TRUE"
34+
echo "Missing Dockerfile: GenAIComps/${dockerfile_path} (Referenced in GenAIExamples/${file}:${line})"
35+
fi
36+
done < <(grep -Ern 'docker build .* -f comps/.+/Dockerfile' --include='*.md' .)
37+
38+
39+
if [[ "$miss" == "TRUE" ]]; then
40+
exit 1
41+
fi
42+
43+
shell: bash
44+
45+
check-Dockerfile-in-build-yamls:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Clean Up Working Directory
49+
run: sudo rm -rf ${{github.workspace}}/*
50+
51+
- name: Checkout Repo GenAIExamples
52+
uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
56+
- name: Check Dockerfile path included in image build yaml
57+
if: always()
58+
run: |
59+
set -e
60+
shopt -s globstar
61+
no_add="FALSE"
62+
cd ${{github.workspace}}
63+
Dockerfiles=$(realpath $(find ./ -name '*Dockerfile*'))
64+
if [ -n "$Dockerfiles" ]; then
65+
for dockerfile in $Dockerfiles; do
66+
service=$(echo "$dockerfile" | awk -F '/GenAIExamples/' '{print $2}' | awk -F '/' '{print $2}')
67+
cd ${{github.workspace}}/$service/docker_image_build
68+
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 )
69+
if ! echo "$all_paths" | grep -q "$dockerfile"; then
70+
echo "AR: Update $dockerfile to GenAIExamples/$service/docker_image_build/build.yaml. The yaml is used for release images build."
71+
no_add="TRUE"
72+
fi
73+
done
74+
fi
75+
76+
if [[ "$no_add" == "TRUE" ]]; then
77+
exit 1
78+
fi
79+
80+
check-image-and-service-names-in-build-yaml:
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Clean Up Working Directory
84+
run: sudo rm -rf ${{github.workspace}}/*
85+
86+
- name: Checkout Repo GenAIExamples
87+
uses: actions/checkout@v4
88+
89+
- name: Check name agreement in build.yaml
90+
run: |
91+
pip install ruamel.yaml
92+
cd ${{github.workspace}}
93+
consistency="TRUE"
94+
build_yamls=$(find . -name 'build.yaml')
95+
for build_yaml in $build_yamls; do
96+
message=$(python3 .github/workflows/scripts/check-name-agreement.py "$build_yaml")
97+
if [[ "$message" != *"consistent"* ]]; then
98+
consistency="FALSE"
99+
echo "Inconsistent service name and image name found in file $build_yaml."
100+
echo "$message"
101+
fi
102+
done
103+
104+
if [[ "$consistency" == "FALSE" ]]; then
105+
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."
106+
exit 1
107+
fi
108+
109+
shell: bash
Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,14 @@
11
# Copyright (C) 2024 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
33

4-
name: Check Paths and Hyperlinks
4+
name: Check hyperlinks and relative path validity
55

66
on:
77
pull_request:
88
branches: [main]
99
types: [opened, reopened, ready_for_review, synchronize]
1010

1111
jobs:
12-
check-dockerfile-paths:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- name: Clean Up Working Directory
16-
run: sudo rm -rf ${{github.workspace}}/*
17-
18-
- name: Checkout Repo GenAIExamples
19-
uses: actions/checkout@v4
20-
21-
- name: Clone Repo GenAIComps
22-
run: |
23-
cd ..
24-
git clone https://github.com/opea-project/GenAIComps.git
25-
26-
- name: Check for Missing Dockerfile Paths in GenAIComps
27-
run: |
28-
cd ${{github.workspace}}
29-
miss="FALSE"
30-
while IFS=: read -r file line content; do
31-
dockerfile_path=$(echo "$content" | awk -F '-f ' '{print $2}' | awk '{print $1}')
32-
if [[ ! -f "../GenAIComps/${dockerfile_path}" ]]; then
33-
miss="TRUE"
34-
echo "Missing Dockerfile: GenAIComps/${dockerfile_path} (Referenced in GenAIExamples/${file}:${line})"
35-
fi
36-
done < <(grep -Ern 'docker build .* -f comps/.+/Dockerfile' --include='*.md' .)
37-
38-
39-
if [[ "$miss" == "TRUE" ]]; then
40-
exit 1
41-
fi
42-
43-
shell: bash
44-
4512
check-the-validity-of-hyperlinks-in-README:
4613
runs-on: ubuntu-latest
4714
steps:
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
import argparse
5+
6+
from ruamel.yaml import YAML
7+
8+
9+
def parse_yaml_file(file_path):
10+
yaml = YAML()
11+
with open(file_path, "r") as file:
12+
data = yaml.load(file)
13+
return data
14+
15+
16+
def check_service_image_consistency(data):
17+
inconsistencies = []
18+
for service_name, service_details in data.get("services", {}).items():
19+
image_name = service_details.get("image", "")
20+
# Extract the image name part after the last '/'
21+
image_name_part = image_name.split("/")[-1].split(":")[0]
22+
# Check if the service name is a substring of the image name part
23+
if service_name not in image_name_part:
24+
# Get the line number of the service name
25+
line_number = service_details.lc.line + 1
26+
inconsistencies.append((service_name, image_name, line_number))
27+
return inconsistencies
28+
29+
30+
def main():
31+
parser = argparse.ArgumentParser(description="Check service name and image name consistency in a YAML file.")
32+
parser.add_argument("file_path", type=str, help="The path to the YAML file.")
33+
args = parser.parse_args()
34+
35+
data = parse_yaml_file(args.file_path)
36+
37+
inconsistencies = check_service_image_consistency(data)
38+
if inconsistencies:
39+
for service_name, image_name, line_number in inconsistencies:
40+
print(f"Service name: {service_name}, Image name: {image_name}, Line number: {line_number}")
41+
else:
42+
print("All consistent")
43+
44+
45+
if __name__ == "__main__":
46+
main()

AudioQnA/docker_image_build/build.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ services:
1111
context: ../
1212
dockerfile: ./Dockerfile
1313
image: ${REGISTRY:-opea}/audioqna:${TAG:-latest}
14+
audioqna-ui:
15+
build:
16+
context: ../ui
17+
dockerfile: ./docker/Dockerfile
18+
extends: audioqna
19+
image: ${REGISTRY:-opea}/audioqna-ui:${TAG:-latest}
20+
audioqna-multilang:
21+
build:
22+
context: ../
23+
dockerfile: ./Dockerfile.multilang
24+
extends: audioqna
25+
image: ${REGISTRY:-opea}/audioqna-multilang:${TAG:-latest}
1426
whisper-gaudi:
1527
build:
1628
context: GenAIComps

GraphRAG/docker_image_build/build.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,12 @@ services:
4747
context: ../ui
4848
dockerfile: ./docker/Dockerfile
4949
image: ${REGISTRY:-opea}/graphrag-ui:${TAG:-latest}
50+
graphrag-react-ui:
51+
build:
52+
args:
53+
http_proxy: ${http_proxy}
54+
https_proxy: ${https_proxy}
55+
no_proxy: ${no_proxy}
56+
context: ../ui
57+
dockerfile: ./docker/Dockerfile.react
58+
image: ${REGISTRY:-opea}/graphrag-react-ui:${TAG:-latest}

Text2Image/docker_image_build/build.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ services:
1111
context: GenAIComps
1212
dockerfile: comps/text2image/Dockerfile
1313
image: ${REGISTRY:-opea}/text2image:${TAG:-latest}
14+
text2image-ui:
15+
build:
16+
context: ../ui
17+
dockerfile: ./docker/Dockerfile
18+
image: ${REGISTRY:-opea}/text2image-ui:${TAG:-latest}

Text2Image/ui/svelte/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
},
1414
"devDependencies": {
1515
"@fortawesome/free-solid-svg-icons": "6.2.0",
16-
"@playwright/test": "^1.48.0",
16+
"@playwright/test": "^1.33.0",
1717
"@sveltejs/adapter-auto": "1.0.0-next.75",
18-
"@sveltejs/adapter-static": "^3.0.0",
19-
"@sveltejs/kit": "^2.0.0",
18+
"@sveltejs/kit": "^1.30.4",
2019
"@tailwindcss/typography": "0.5.7",
2120
"@types/debug": "4.1.7",
2221
"@types/node": "^20.12.13",
@@ -29,20 +28,21 @@
2928
"eslint": "^8.16.0",
3029
"eslint-config-prettier": "^8.3.0",
3130
"eslint-plugin-neverthrow": "1.1.4",
31+
"eslint-plugin-svelte3": "^4.0.0",
3232
"postcss": "^8.4.31",
3333
"postcss-load-config": "^4.0.1",
3434
"postcss-preset-env": "^8.3.2",
3535
"prettier": "^2.8.8",
3636
"prettier-plugin-svelte": "^2.7.0",
3737
"prettier-plugin-tailwindcss": "^0.3.0",
38-
"svelte": "^4.0.0",
39-
"svelte-check": "^3.0.0",
38+
"svelte": "^3.59.1",
39+
"svelte-check": "^2.7.1",
4040
"svelte-fa": "3.0.3",
41-
"svelte-preprocess": "^6.0.2",
41+
"svelte-preprocess": "^4.10.7",
4242
"tailwindcss": "^3.1.5",
4343
"tslib": "^2.3.1",
44-
"typescript": "^5.0.0",
45-
"vite": "^5.0.0"
44+
"typescript": "^4.7.4",
45+
"vite": "^4.5.2"
4646
},
4747
"type": "module",
4848
"dependencies": {

0 commit comments

Comments
 (0)