From 69aa2a0f77f48f8a9f42221e44745b61643b9325 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 23:03:18 +0800 Subject: [PATCH] fix: forcequit for result status --- joj3_config_generator/convert.py | 4 +-- joj3_config_generator/lib/task.py | 27 +++++++++------ joj3_config_generator/models/task.py | 2 ++ tests/convert/basic/task.json | 51 ++++++++++++++++------------ tests/convert/basic/task.toml | 5 +++ 5 files changed, 55 insertions(+), 34 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index c12ff1e..13de522 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -2,8 +2,8 @@ from typing import List from joj3_config_generator.lib.repo import getHealthcheckConfig from joj3_config_generator.lib.task import ( - fix_comment, fix_diff, + fix_dummy, fix_keyword, fix_result_detail, get_conf_stage, @@ -36,7 +36,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: executor_with_config, cached = get_executorWithConfig(task_stage, cached) conf_stage = get_conf_stage(task_stage, executor_with_config) conf_stage = fix_result_detail(task_stage, conf_stage) - conf_stage = fix_comment(task_stage, conf_stage) + conf_stage = fix_dummy(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) conf_stage = fix_diff(task_stage, conf_stage) result_conf.stage.stages.append(conf_stage) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 6e4e06c..f11c1c7 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -107,7 +107,6 @@ def get_executorWithConfig( return (executor_with_config, cached) -# FIXME: fix severity and "keywords" def fix_keyword( task_stage: task.Stage, conf_stage: result.StageDetail ) -> result.StageDetail: @@ -172,21 +171,27 @@ def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultS return conf_stage -def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - comment_parser = [ +def fix_dummy( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: + dummy_parser = [ "dummy", "result-status", "cpplint", - ] # FIXME: determine where cpplint should be + ] if task_stage.parsers is not None: for parser in task_stage.parsers: - if parser in comment_parser: - comment_parser_ = next( - p for p in conf_stage.parsers if p.name == parser - ) - if getattr(task_stage, parser.replace("-", "_"), None) is not None: - comment_parser_.with_.update( - getattr(task_stage, parser.replace("-", "_")) + if parser in dummy_parser: + dummy_parser_ = next(p for p in conf_stage.parsers if p.name == parser) + if ( + getattr(task_stage, parser.replace("-", "_"), None) is not None + ) and (task_stage.result_status is not None): + dummy_parser_.with_.update( + { + "score": task_stage.result_status.score, + "comment": task_stage.result_status.comment, + "forceQuitOnNotAccepted": task_stage.result_status.forcequit, + } ) else: continue diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 775cc1d..e8b28c2 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -14,6 +14,8 @@ class ParserResultDetail(BaseModel): class ParserDummy(BaseModel): comment: Optional[str] = "" + score: Optional[int] = 0 + forcequit: Optional[bool] = True class ParserKeyword(BaseModel): diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index c3227ba..cad6f01 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7fa86726c180>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-d89rnuip/repo-health-checker": { - "src": "//tmp/repo-checker-tk3cqa0k/repo-health-checker", + "//tmp/repo-checker-va9ba49a/repo-health-checker": { + "src": "//tmp/repo-checker-e82nkuo4/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -246,13 +246,17 @@ { "name": "dummy", "with": { - "comment": "\n\n### Details\n" + "score": 1, + "comment": "Congratulations! Your code compiled successfully.", + "forceQuitOnNotAccepted": false } }, { "name": "result-status", "with": { - "comment": "Congratulations! Your code compiled successfully." + "score": 1, + "comment": "Congratulations! Your code compiled successfully.", + "forceQuitOnNotAccepted": false } } ] @@ -367,7 +371,9 @@ { "name": "dummy", "with": { - "comment": "" + "score": 10000, + "comment": "Manuel Charlemagne", + "forceQuitOnNotAccepted": true } }, { @@ -504,7 +510,9 @@ { "name": "dummy", "with": { - "comment": "\n\n### Details\n" + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true } }, { @@ -631,7 +639,9 @@ { "name": "dummy", "with": { - "comment": "\n\n### Details\n" + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true } }, { @@ -727,16 +737,9 @@ { "name": "cpplint", "with": { - "keyword": [ - "runtime", - "readability", - "build" - ], - "weight": [ - 10, - 20, - 15 - ], + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true, "matches": [ { "keywords": [ @@ -762,7 +765,9 @@ { "name": "dummy", "with": { - "comment": "\n\n### Details\n" + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true } }, { @@ -1013,7 +1018,9 @@ { "name": "dummy", "with": { - "comment": "\n\n### Details\n" + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true } }, { @@ -1264,7 +1271,9 @@ { "name": "dummy", "with": { - "comment": "\n\n### Details\n" + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true } }, { diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 12f66f3..b060a9e 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -15,6 +15,8 @@ limit.stderr = 128 # compile parsers parsers = [ "result-detail", "dummy", "result-status" ] result-status.comment = "Congratulations! Your code compiled successfully." +result-status.score = 1 +result-status.forcequit = false dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stderr = true @@ -33,6 +35,9 @@ result-detail.exitstatus = true result-detail.stderr = true result-detail.time = false result-detail.mem = false +result-status.comment = "Manuel Charlemagne" +result-status.score = 10000 +result-status.forcequit = true [[stages]] name = "Clang-tidy checks"