diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index dd95c74..9d1a886 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -146,7 +146,7 @@ class Parser(BaseModel): class StageDetail(BaseModel): name: str - group: str = "" + groups: List[str] = [] executor: Executor parsers: List[Parser] diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 4991351..8fdebea 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -191,6 +191,7 @@ class Case(StrictBaseModel): class Stage(Case): name: str = "" # stage name + groups: List[str] = [] # list of groups parsers: List[Parser] = [] # list of parsers dummy: ParserDummy = ParserDummy() diff --git a/joj3_config_generator/transformers/task.py b/joj3_config_generator/transformers/task.py index df5c722..1306b6e 100644 --- a/joj3_config_generator/transformers/task.py +++ b/joj3_config_generator/transformers/task.py @@ -14,14 +14,17 @@ def get_conf_stage( task_stage: task.Stage, cached: Dict[str, None], ) -> result.StageDetail: + if task_stage.groups: + groups = task_stage.groups + else: + # single group is determined by adding between "[]" in the name of the task + if match := re.search(r"\[([^\[\]]+)\]", task_stage.name): + groups = [match.group(1)] + else: + groups = [] conf_stage = result.StageDetail( name=task_stage.name, - # group is determined by adding between "[]" in the name of the task - group=( - match.group(1) - if (match := re.search(r"\[([^\[\]]+)\]", task_stage.name or "")) - else "" - ), + groups=groups, executor=result.Executor( name="sandbox", with_=get_executor_with(task_stage, cached), diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 9fd830e..87a509e 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -10,7 +10,7 @@ "stages": [ { "name": "Health Check", - "group": "", + "groups": [], "executor": { "name": "local", "with": { @@ -107,7 +107,7 @@ }, { "name": "Compilation", - "group": "", + "groups": [], "executor": { "name": "sandbox", "with": { @@ -203,7 +203,9 @@ }, { "name": "[cq] Filelength", - "group": "cq", + "groups": [ + "cq" + ], "executor": { "name": "sandbox", "with": { @@ -310,7 +312,9 @@ }, { "name": "[cq] Clang-tidy", - "group": "cq", + "groups": [ + "cq" + ], "executor": { "name": "sandbox", "with": { @@ -445,7 +449,9 @@ }, { "name": "[cq] Cppcheck", - "group": "cq", + "groups": [ + "cq" + ], "executor": { "name": "sandbox", "with": { @@ -603,7 +609,9 @@ }, { "name": "[cq] Cpplint", - "group": "cq", + "groups": [ + "cq" + ], "executor": { "name": "sandbox", "with": { @@ -713,7 +721,9 @@ }, { "name": "[joj] ex2-asan", - "group": "joj", + "groups": [ + "joj" + ], "executor": { "name": "sandbox", "with": { @@ -869,7 +879,7 @@ "postStages": [ { "name": "teapot", - "group": "", + "groups": [], "executor": { "name": "local", "with": { diff --git a/tests/convert/clang-tidy/task.json b/tests/convert/clang-tidy/task.json index 628ebc5..e7bac27 100644 --- a/tests/convert/clang-tidy/task.json +++ b/tests/convert/clang-tidy/task.json @@ -10,7 +10,9 @@ "stages": [ { "name": "[cq] Clang-tidy", - "group": "cq", + "groups": [ + "cq" + ], "executor": { "name": "sandbox", "with": { diff --git a/tests/convert/cppcheck/task.json b/tests/convert/cppcheck/task.json index f09d5ca..5c6936f 100644 --- a/tests/convert/cppcheck/task.json +++ b/tests/convert/cppcheck/task.json @@ -10,7 +10,9 @@ "stages": [ { "name": "[cq] Cppcheck", - "group": "cq", + "groups": [ + "cq" + ], "executor": { "name": "sandbox", "with": { diff --git a/tests/convert/cpplint/task.json b/tests/convert/cpplint/task.json index 8bbc948..403c1ae 100644 --- a/tests/convert/cpplint/task.json +++ b/tests/convert/cpplint/task.json @@ -10,7 +10,9 @@ "stages": [ { "name": "[cq] Cpplint", - "group": "cq", + "groups": [ + "cq" + ], "executor": { "name": "sandbox", "with": { diff --git a/tests/convert/diff/task.json b/tests/convert/diff/task.json index 9688e5b..7095b8d 100644 --- a/tests/convert/diff/task.json +++ b/tests/convert/diff/task.json @@ -10,7 +10,9 @@ "stages": [ { "name": "[joj] ex2-asan", - "group": "joj", + "groups": [ + "joj" + ], "executor": { "name": "sandbox", "with": { diff --git a/tests/convert/elf/task.json b/tests/convert/elf/task.json index af459ab..7f3f15b 100644 --- a/tests/convert/elf/task.json +++ b/tests/convert/elf/task.json @@ -10,7 +10,9 @@ "stages": [ { "name": "[cq] elf", - "group": "cq", + "groups": [ + "cq" + ], "executor": { "name": "sandbox", "with": { diff --git a/tests/convert/empty/task.json b/tests/convert/empty/task.json index 7d478d0..7c4ab96 100644 --- a/tests/convert/empty/task.json +++ b/tests/convert/empty/task.json @@ -10,7 +10,7 @@ "stages": [ { "name": "Health Check", - "group": "", + "groups": [], "executor": { "name": "local", "with": { @@ -100,7 +100,7 @@ "postStages": [ { "name": "teapot", - "group": "", + "groups": [], "executor": { "name": "local", "with": { diff --git a/tests/convert/full/task.json b/tests/convert/full/task.json index 18d41cf..a2928bd 100644 --- a/tests/convert/full/task.json +++ b/tests/convert/full/task.json @@ -10,7 +10,7 @@ "stages": [ { "name": "Health Check", - "group": "", + "groups": [], "executor": { "name": "local", "with": { @@ -107,7 +107,10 @@ }, { "name": "Generate yes.txt [no]", - "group": "no", + "groups": [ + "run", + "no" + ], "executor": { "name": "sandbox", "with": { @@ -425,7 +428,7 @@ "postStages": [ { "name": "teapot", - "group": "", + "groups": [], "executor": { "name": "local", "with": { diff --git a/tests/convert/full/task.toml b/tests/convert/full/task.toml index 6668a76..4846e9b 100644 --- a/tests/convert/full/task.toml +++ b/tests/convert/full/task.toml @@ -33,6 +33,8 @@ groups.time-period-hour = [24, 1] # e.g. commit msg "test(hw7): run yes" will not run this stage # commit msg "test(hw7): run yes [no]" will run this stage name = "Generate yes.txt [no]" +# you can also use this fields to override the above groups +groups = ["run", "no"] # =================================================== # ========== executor related config start ========== diff --git a/tests/convert/keyword/task.json b/tests/convert/keyword/task.json index 0291136..aba53b5 100644 --- a/tests/convert/keyword/task.json +++ b/tests/convert/keyword/task.json @@ -10,7 +10,9 @@ "stages": [ { "name": "[cq] Filelength", - "group": "cq", + "groups": [ + "cq" + ], "executor": { "name": "sandbox", "with": { diff --git a/tests/convert/result-detail/task.json b/tests/convert/result-detail/task.json index 4846b19..c00ba50 100644 --- a/tests/convert/result-detail/task.json +++ b/tests/convert/result-detail/task.json @@ -10,7 +10,9 @@ "stages": [ { "name": "[cq] Filelength", - "group": "cq", + "groups": [ + "cq" + ], "executor": { "name": "sandbox", "with": { diff --git a/tests/convert/unnecessary/task.json b/tests/convert/unnecessary/task.json index 242e797..892281a 100644 --- a/tests/convert/unnecessary/task.json +++ b/tests/convert/unnecessary/task.json @@ -10,7 +10,9 @@ "stages": [ { "name": "[cq] Filelength", - "group": "cq", + "groups": [ + "cq" + ], "executor": { "name": "sandbox", "with": {