WIP: dev #4
| 
						 | 
				
			
			@ -2,6 +2,7 @@ from typing import List
 | 
			
		|||
 | 
			
		||||
from joj3_config_generator.models import joj1, repo, result, task
 | 
			
		||||
from joj3_config_generator.lib.repo import getHealthcheckConfig, getTeapotConfig
 | 
			
		||||
from joj3_config_generator.lib.task import fix_keyword
 | 
			
		||||
from joj3_config_generator.models import (
 | 
			
		||||
    Cmd,
 | 
			
		||||
    CmdFile,
 | 
			
		||||
| 
						 | 
				
			
			@ -62,6 +63,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config:
 | 
			
		|||
                result.Parser(name=parser, with_={}) for parser in task_stage.parsers
 | 
			
		||||
            ],
 | 
			
		||||
        )
 | 
			
		||||
        # TODO: fix all parser here
 | 
			
		||||
        if "result-detail" in task_stage.parsers:
 | 
			
		||||
            result_detail_parser = next(
 | 
			
		||||
                p for p in conf_stage.parsers if p.name == "result-detail"
 | 
			
		||||
| 
						 | 
				
			
			@ -69,6 +71,20 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config:
 | 
			
		|||
            if task_stage.result_detail is not None:
 | 
			
		||||
                result_detail_parser.with_.update(task_stage.result_detail)
 | 
			
		||||
 | 
			
		||||
        if "dummy" in task_stage.parsers:
 | 
			
		||||
            dummy_parser = next(p for p in conf_stage.parsers if p.name == "dummy")
 | 
			
		||||
            if task_stage.dummy is not None:
 | 
			
		||||
                dummy_parser.with_.update(task_stage.dummy)
 | 
			
		||||
 | 
			
		||||
        if "result-status" in task_stage.parsers:
 | 
			
		||||
            result_status_parser = next(
 | 
			
		||||
                p for p in conf_stage.parsers if p.name == "result-status"
 | 
			
		||||
            )
 | 
			
		||||
            if task_stage.result_status is not None:
 | 
			
		||||
                result_status_parser.with_.update(task_stage.result_status)
 | 
			
		||||
 | 
			
		||||
        conf_stage = fix_keyword(task_stage, conf_stage)
 | 
			
		||||
 | 
			
		||||
        result_conf.stage.stages.append(conf_stage)
 | 
			
		||||
 | 
			
		||||
    return result_conf
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										20
									
								
								joj3_config_generator/lib/task.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								joj3_config_generator/lib/task.py
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
from joj3_config_generator.models.result import Stage as ResultStage
 | 
			
		||||
from joj3_config_generator.models.task import Stage as TaskStage
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage:
 | 
			
		||||
    keyword_parser = ["clangtidy", "keyword", "cppcheck"]  # TODO: may add cpplint
 | 
			
		||||
    for parser in task_stage.parsers:
 | 
			
		||||
        if parser in keyword_parser:
 | 
			
		||||
            keyword_parser_ = next(p for p in conf_stage.parsers if p.name == parser)
 | 
			
		||||
            keyword_weight = []
 | 
			
		||||
            if getattr(task_stage, parser, None) is not None:
 | 
			
		||||
                for _, keyword in enumerate(getattr(task_stage, parser).keyword):
 | 
			
		||||
                    keyword_weight.append({"keyword": [keyword], "score": 0})
 | 
			
		||||
                for idx, weight in enumerate(getattr(task_stage, parser).weight):
 | 
			
		||||
                    keyword_weight[idx]["score"] = weight
 | 
			
		||||
 | 
			
		||||
            keyword_parser_.with_.update({"match": keyword_weight})
 | 
			
		||||
        else:
 | 
			
		||||
            continue
 | 
			
		||||
    return conf_stage
 | 
			
		||||
| 
						 | 
				
			
			@ -17,8 +17,8 @@ class ParserDummy(BaseModel):
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
class ParserKeyword(BaseModel):
 | 
			
		||||
    keyword: Optional[list[str]] = None
 | 
			
		||||
    weight: Optional[list[int]] = None
 | 
			
		||||
    keyword: Optional[list[str]] = []
 | 
			
		||||
    weight: Optional[list[int]] = []
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Files(BaseModel):
 | 
			
		||||
| 
						 | 
				
			
			@ -42,6 +42,7 @@ class Stage(BaseModel):
 | 
			
		|||
    parsers: list[str]  # list of parsers
 | 
			
		||||
    limit: Optional[Limit] = None
 | 
			
		||||
    dummy: Optional[ParserDummy] = ParserDummy()
 | 
			
		||||
    result_status: Optional[ParserDummy] = Field(ParserDummy(), alias="result-status")
 | 
			
		||||
    keyword: Optional[ParserKeyword] = ParserKeyword()
 | 
			
		||||
    clangtidy: Optional[ParserKeyword] = ParserKeyword()
 | 
			
		||||
    cppcheck: Optional[ParserKeyword] = ParserKeyword()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,12 +15,15 @@
 | 
			
		|||
                    "with": {
 | 
			
		||||
                        "default": {
 | 
			
		||||
                            "args": [
 | 
			
		||||
                                "/tmp/repo-health-checker",
 | 
			
		||||
                                "/<function",
 | 
			
		||||
                                "get_temp_directory",
 | 
			
		||||
                                "at",
 | 
			
		||||
                                "0x7f1db69b71a0>/repo-health-checker",
 | 
			
		||||
                                "-root=.",
 | 
			
		||||
                                "-repoSize=50.5",
 | 
			
		||||
                                "-meta=main.py",
 | 
			
		||||
                                "-meta=README.md",
 | 
			
		||||
                                "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,8d1229900c6fc6711b5cc141d1ab5ea7f5b7b7a4b921d9cfa3957408b43ae723,eb857bcd94857cedc4045cb2d6ba04cb5bbb3daf188abc95fb9478db823ef47e",
 | 
			
		||||
                                "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28",
 | 
			
		||||
                                "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml"
 | 
			
		||||
                            ],
 | 
			
		||||
                            "env": [
 | 
			
		||||
| 
						 | 
				
			
			@ -68,8 +71,8 @@
 | 
			
		|||
                            "cpuRateLimit": 0,
 | 
			
		||||
                            "cpuSetLimit": "",
 | 
			
		||||
                            "copyIn": {
 | 
			
		||||
                                "/tmp/repo-health-checker": {
 | 
			
		||||
                                    "src": "/tmp/repo-health-checker",
 | 
			
		||||
                                "//tmp/repo-checker-90ztqsoq/repo-health-checker": {
 | 
			
		||||
                                    "src": "//tmp/repo-checker-41mcx5_x/repo-health-checker",
 | 
			
		||||
                                    "content": null,
 | 
			
		||||
                                    "fileId": null,
 | 
			
		||||
                                    "name": null,
 | 
			
		||||
| 
						 | 
				
			
			@ -240,11 +243,15 @@
 | 
			
		|||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "dummy",
 | 
			
		||||
                        "with": {}
 | 
			
		||||
                        "with": {
 | 
			
		||||
                            "comment": "\n\n### Details\n"
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "result-status",
 | 
			
		||||
                        "with": {}
 | 
			
		||||
                        "with": {
 | 
			
		||||
                            "comment": "Congratulations! Your code compiled successfully."
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
| 
						 | 
				
			
			@ -338,11 +345,28 @@
 | 
			
		|||
                "parsers": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "keyword",
 | 
			
		||||
                        "with": {}
 | 
			
		||||
                        "with": {
 | 
			
		||||
                            "match": [
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "max"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 50
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "recommend"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 20
 | 
			
		||||
                                }
 | 
			
		||||
                            ]
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "dummy",
 | 
			
		||||
                        "with": {}
 | 
			
		||||
                        "with": {
 | 
			
		||||
                            "comment": ""
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "result-detail",
 | 
			
		||||
| 
						 | 
				
			
			@ -433,11 +457,100 @@
 | 
			
		|||
                "parsers": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "clangtidy",
 | 
			
		||||
                        "with": {}
 | 
			
		||||
                        "with": {
 | 
			
		||||
                            "match": [
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "codequality-no-global-variables"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 10
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "codequality-no-header-guard"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 10
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "readability-function-size"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 50
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "readability-duplicate-include"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 10
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "readability-identifier-naming"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 5
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "readability-redundant"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 5
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "readability-misleading-indentation"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 10
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "readability-misplaced-array-index"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 5
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "cppcoreguidelines-init-variables"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 5
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "bugprone-suspicious-string-compare"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 8
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "google-global-names-in-headers"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 5
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "clang-diagnostic"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 5
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "clang-analyzer"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 5
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "misc performance"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 5
 | 
			
		||||
                                }
 | 
			
		||||
                            ]
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "dummy",
 | 
			
		||||
                        "with": {}
 | 
			
		||||
                        "with": {
 | 
			
		||||
                            "comment": "\n\n### Details\n"
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "result-detail",
 | 
			
		||||
| 
						 | 
				
			
			@ -532,11 +645,46 @@
 | 
			
		|||
                "parsers": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "cppcheck",
 | 
			
		||||
                        "with": {}
 | 
			
		||||
                        "with": {
 | 
			
		||||
                            "match": [
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "error"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 20
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "warning"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 10
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "portability"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 15
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "performance"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 15
 | 
			
		||||
                                },
 | 
			
		||||
                                {
 | 
			
		||||
                                    "keyword": [
 | 
			
		||||
                                        "style"
 | 
			
		||||
                                    ],
 | 
			
		||||
                                    "score": 10
 | 
			
		||||
                                }
 | 
			
		||||
                            ]
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "dummy",
 | 
			
		||||
                        "with": {}
 | 
			
		||||
                        "with": {
 | 
			
		||||
                            "comment": "\n\n### Details\n"
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "result-detail",
 | 
			
		||||
| 
						 | 
				
			
			@ -631,7 +779,9 @@
 | 
			
		|||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "dummy",
 | 
			
		||||
                        "with": {}
 | 
			
		||||
                        "with": {
 | 
			
		||||
                            "comment": "\n\n### Details\n"
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "result-detail",
 | 
			
		||||
| 
						 | 
				
			
			@ -722,7 +872,9 @@
 | 
			
		|||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "dummy",
 | 
			
		||||
                        "with": {}
 | 
			
		||||
                        "with": {
 | 
			
		||||
                            "comment": "\n\n### Details\n"
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "result-detail",
 | 
			
		||||
| 
						 | 
				
			
			@ -813,7 +965,9 @@
 | 
			
		|||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "dummy",
 | 
			
		||||
                        "with": {}
 | 
			
		||||
                        "with": {
 | 
			
		||||
                            "comment": "\n\n### Details\n"
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "name": "result-detail",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,7 +41,7 @@ limit.stdout = 65
 | 
			
		|||
 | 
			
		||||
parsers = [ "clangtidy", "dummy", "result-detail" ]
 | 
			
		||||
clangtidy.keyword = [ "codequality-no-global-variables", "codequality-no-header-guard", "readability-function-size", "readability-duplicate-include", "readability-identifier-naming", "readability-redundant", "readability-misleading-indentation", "readability-misplaced-array-index", "cppcoreguidelines-init-variables", "bugprone-suspicious-string-compare", "google-global-names-in-headers", "clang-diagnostic", "clang-analyzer", "misc performance" ]
 | 
			
		||||
clangtidy.weight = [10, 10, 50, 10, 5, 5, 10, 5, 5, 8, 5, 5, 5, 5, 8]
 | 
			
		||||
clangtidy.weight = [10, 10, 50, 10, 5, 5, 10, 5, 5, 8, 5, 5, 5, 5]
 | 
			
		||||
dummy.comment = "\n\n### Details\n"
 | 
			
		||||
result-detail.exitstatus = true
 | 
			
		||||
result-detail.stdout = true
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user