Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(planner): Polish the workflow planner code #3570

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 25 additions & 57 deletions .github/scripts/behavior_test/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
# The project dir for opendal.
PROJECT_DIR = GITHUB_DIR.parent

LANGUAGE_BINDING = ["java", "python", "nodejs"]


def provided_cases() -> list[dict[str, str]]:
root_dir = f"{GITHUB_DIR}/services"
Expand Down Expand Up @@ -99,23 +101,18 @@ def calculate_hint(changed_files: list[str]) -> Hint:
# workflow behavior tests affected
if p == ".github/workflows/behavior_test.yml":
hint.core = True
hint.binding_java = True
hint.binding_python = True
hint.binding_nodejs = True
for language in LANGUAGE_BINDING:
setattr(hint, f"binding_{language}", True)
hint.all_service = True

if p == ".github/workflows/behavior_test_core.yml":
hint.core = True
hint.all_service = True
if p == ".github/workflows/behavior_test_binding_java.yml":
hint.binding_java = True
hint.all_service = True
if p == ".github/workflows/behavior_test_binding_python.yml":
hint.binding_python = True
hint.all_service = True
if p == ".github/workflows/behavior_test_binding_nodejs.yml":
hint.binding_nodejs = True
hint.all_service = True

for language in LANGUAGE_BINDING:
if p == f".github/workflows/behavior_test_binding_{language}.yml":
setattr(hint, f"binding_{language}", True)
hint.all_service = True
# core affected
if (
p.startswith("core/")
Expand All @@ -130,37 +127,26 @@ def calculate_hint(changed_files: list[str]) -> Hint:
hint.binding_nodejs = True
hint.all_service = True

# binding java affected.
if p.startswith("bindings/java/"):
hint.binding_java = True
hint.all_service = True

# binding python affected.
if p.startswith("bindings/python/"):
hint.binding_python = True
hint.all_service = True

# binding nodejs affected.
if p.startswith("bindings/nodejs/"):
hint.binding_nodejs = True
hint.all_service = True
# language binding affected
for language in LANGUAGE_BINDING:
if p.startswith(f"bindings/{language}/"):
setattr(hint, f"binding_{language}", True)
hint.all_service = True

# core service affected
match = re.search(service_pattern, p)
if match:
hint.core = True
hint.binding_java = True
hint.binding_python = True
hint.binding_nodejs = True
for language in LANGUAGE_BINDING:
setattr(hint, f"binding_{language}", True)
hint.services.add(match.group(1))

# core test affected
match = re.search(test_pattern, p)
if match:
hint.core = True
hint.binding_java = True
hint.binding_python = True
hint.binding_nodejs = True
for language in LANGUAGE_BINDING:
setattr(hint, f"binding_{language}", True)
hint.services.add(match.group(1))
return hint

Expand Down Expand Up @@ -228,21 +214,12 @@ def plan(changed_files: list[str]) -> dict[str, Any]:
hint = calculate_hint(changed_files)

core_cases = generate_core_cases(cases, hint)
binding_java_cases = generate_language_binding_cases(cases, hint, "java")
binding_python_cases = generate_language_binding_cases(cases, hint, "python")
binding_nodejs_cases = generate_language_binding_cases(cases, hint, "nodejs")

jobs = {
"components": {
"core": False,
"binding_java": False,
"binding_python": False,
"binding_nodejs": False,
},
"core": [],
"binding_java": [],
"binding_python": [],
"binding_nodejs": [],
}

if len(core_cases) > 0:
Expand All @@ -259,22 +236,13 @@ def plan(changed_files: list[str]) -> dict[str, Any]:
],
}
)

if len(binding_java_cases) > 0:
jobs["components"]["binding_java"] = True
jobs["binding_java"].append(
{"os": "ubuntu-latest", "cases": binding_java_cases}
)
if len(binding_python_cases) > 0:
jobs["components"]["binding_python"] = True
jobs["binding_python"].append(
{"os": "ubuntu-latest", "cases": binding_python_cases}
)
if len(binding_nodejs_cases) > 0:
jobs["components"]["binding_nodejs"] = True
jobs["binding_nodejs"].append(
{"os": "ubuntu-latest", "cases": binding_nodejs_cases}
)
for language in LANGUAGE_BINDING:
jobs[f"binding_{language}"] = []
jobs["components"][f"binding_{language}"] = False
cases = generate_language_binding_cases(cases, hint, language)
if len(cases) > 0:
jobs["components"][f"binding_{language}"] = True
jobs[f"binding_{language}"].append({"os": "ubuntu-latest", "cases": cases})

return jobs

Expand Down