This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 0721a6e59 refactor(ci): Polish the test planner code (#3457)
0721a6e59 is described below
commit 0721a6e5950064bb39c2f4dfb116a410d546e958
Author: Nadeshiko Manju <[email protected]>
AuthorDate: Wed Nov 1 19:48:14 2023 +0800
refactor(ci): Polish the test planner code (#3457)
* refactor(ci): Polish the test planner code
Signed-off-by: Manjusaka <[email protected]>
* update code
Signed-off-by: Manjusaka <[email protected]>
---------
Signed-off-by: Manjusaka <[email protected]>
---
.github/scripts/behavior_test/plan.py | 61 +++++-------------------------
.github/scripts/behavior_test/test_plan.py | 1 +
2 files changed, 10 insertions(+), 52 deletions(-)
diff --git a/.github/scripts/behavior_test/plan.py
b/.github/scripts/behavior_test/plan.py
index 1df6d0846..d417a25d8 100755
--- a/.github/scripts/behavior_test/plan.py
+++ b/.github/scripts/behavior_test/plan.py
@@ -16,12 +16,12 @@
# specific language governing permissions and limitations
# under the License.
-import sys
import json
import os
import re
-from pathlib import Path
+import sys
from dataclasses import dataclass, field
+from pathlib import Path
from typing import Any
# The path for current script.
@@ -141,7 +141,7 @@ def calculate_hint(changed_files: list[str]) -> Hint:
hint.all_service = True
# binding nodejs affected.
- if p.startswith("bindings/python/"):
+ if p.startswith("bindings/nodejs/"):
hint.binding_nodejs = True
hint.all_service = True
@@ -203,51 +203,8 @@ def generate_core_cases(
return cases
-def generate_binding_java_cases(
- cases: list[dict[str, str]], hint: Hint
-) -> list[dict[str, str]]:
- cases = unique_cases(cases)
-
- # Always run all tests if it is a push event.
- if os.getenv("GITHUB_IS_PUSH") == "true":
- return cases
-
- # Return empty if core is False
- if not hint.binding_java:
- return []
-
- # Return all services if all_service is True
- if hint.all_service:
- return cases
-
- # Filter all cases that not shown un in changed files
- cases = [v for v in cases if v["service"] in hint.services]
- return cases
-
-
-def generate_binding_python_cases(
- cases: list[dict[str, str]], hint: Hint
-) -> list[dict[str, str]]:
- cases = unique_cases(cases)
-
- if os.getenv("GITHUB_IS_PUSH") == "true":
- return cases
-
- # Return empty if core is False
- if not hint.binding_python:
- return []
-
- # Return all services if all_service is True
- if hint.all_service:
- return cases
-
- # Filter all cases that not shown un in changed files
- cases = [v for v in cases if v["service"] in hint.services]
- return cases
-
-
-def generate_binding_nodejs_cases(
- cases: list[dict[str, str]], hint: Hint
+def generate_language_binding_cases(
+ cases: list[dict[str, str]], hint: Hint, language: str
) -> list[dict[str, str]]:
cases = unique_cases(cases)
@@ -255,7 +212,7 @@ def generate_binding_nodejs_cases(
return cases
# Return empty if core is False
- if not hint.binding_nodejs:
+ if not getattr(hint, f"binding_{language}"):
return []
# Return all services if all_service is True
@@ -272,9 +229,9 @@ 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_binding_java_cases(cases, hint)
- binding_python_cases = generate_binding_python_cases(cases, hint)
- binding_nodejs_cases = generate_binding_nodejs_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": {
diff --git a/.github/scripts/behavior_test/test_plan.py
b/.github/scripts/behavior_test/test_plan.py
index 021001e44..f3da678e9 100644
--- a/.github/scripts/behavior_test/test_plan.py
+++ b/.github/scripts/behavior_test/test_plan.py
@@ -16,6 +16,7 @@
# under the License.
import unittest
+
from plan import plan