Compare commits
3 Commits
a0c6bfd63c
...
3b40bee13c
Author | SHA1 | Date | |
---|---|---|---|
3b40bee13c | |||
56ecd35e46 | |||
e0da740871 |
|
@ -1,5 +1,5 @@
|
||||||
import os
|
import os
|
||||||
from typing import Set
|
from typing import Dict
|
||||||
|
|
||||||
from joj3_config_generator.models import joj1, repo, result, task
|
from joj3_config_generator.models import joj1, repo, result, task
|
||||||
from joj3_config_generator.models.const import CACHE_ROOT, JOJ3_CONFIG_ROOT
|
from joj3_config_generator.models.const import CACHE_ROOT, JOJ3_CONFIG_ROOT
|
||||||
|
@ -27,7 +27,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config:
|
||||||
# Construct health check stage
|
# Construct health check stage
|
||||||
if not repo_conf.force_skip_health_check_on_test or not current_test:
|
if not repo_conf.force_skip_health_check_on_test or not current_test:
|
||||||
result_conf.stage.stages.append(get_health_check_stage(repo_conf))
|
result_conf.stage.stages.append(get_health_check_stage(repo_conf))
|
||||||
cached: Set[str] = set()
|
cached: Dict[str, None] = {}
|
||||||
# Convert each stage in the task configuration
|
# Convert each stage in the task configuration
|
||||||
for task_stage in task_conf.stages:
|
for task_stage in task_conf.stages:
|
||||||
result_conf.stage.stages.append(get_conf_stage(task_conf, task_stage, cached))
|
result_conf.stage.stages.append(get_conf_stage(task_conf, task_stage, cached))
|
||||||
|
|
|
@ -114,7 +114,7 @@ class Executor(BaseModel):
|
||||||
with_: ExecutorWith = Field(..., serialization_alias="with")
|
with_: ExecutorWith = Field(..., serialization_alias="with")
|
||||||
|
|
||||||
|
|
||||||
class ParserConfig(BaseModel):
|
class Parser(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
with_: Dict[str, Any] = Field(..., serialization_alias="with")
|
with_: Dict[str, Any] = Field(..., serialization_alias="with")
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ class StageDetail(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
group: Optional[str] = ""
|
group: Optional[str] = ""
|
||||||
executor: Executor
|
executor: Executor
|
||||||
parsers: List[ParserConfig]
|
parsers: List[Parser]
|
||||||
|
|
||||||
|
|
||||||
class Stage(BaseModel):
|
class Stage(BaseModel):
|
||||||
|
|
|
@ -29,7 +29,7 @@ def get_teapot_stage(repo_conf: repo.Config) -> result.StageDetail:
|
||||||
cases=[],
|
cases=[],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
parsers=[result.ParserConfig(name="log", with_={"msg": "joj3 summary"})],
|
parsers=[result.Parser(name="log", with_={"msg": "joj3 summary"})],
|
||||||
)
|
)
|
||||||
return stage_conf
|
return stage_conf
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ def get_health_check_stage(repo_conf: repo.Config) -> result.StageDetail:
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
parsers=[
|
parsers=[
|
||||||
result.ParserConfig(name="healthcheck", with_={"score": 1}),
|
result.Parser(name="healthcheck", with_={"score": 1}),
|
||||||
result.ParserConfig(name="debug", with_={"score": 0}),
|
result.Parser(name="debug", with_={"score": 0}),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
return health_check_stage
|
return health_check_stage
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
from typing import Any, Callable, Dict, List, Set, Tuple
|
from typing import Any, Callable, Dict, List, Tuple
|
||||||
|
|
||||||
from joj3_config_generator.models import result, task
|
from joj3_config_generator.models import result, task
|
||||||
from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT
|
from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT
|
||||||
|
@ -9,7 +9,7 @@ from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT
|
||||||
def get_conf_stage(
|
def get_conf_stage(
|
||||||
task_conf: task.Config,
|
task_conf: task.Config,
|
||||||
task_stage: task.Stage,
|
task_stage: task.Stage,
|
||||||
cached: Set[str],
|
cached: Dict[str, None],
|
||||||
) -> result.StageDetail:
|
) -> result.StageDetail:
|
||||||
conf_stage = result.StageDetail(
|
conf_stage = result.StageDetail(
|
||||||
name=task_stage.name,
|
name=task_stage.name,
|
||||||
|
@ -24,10 +24,7 @@ def get_conf_stage(
|
||||||
with_=get_executor_with(task_stage, cached),
|
with_=get_executor_with(task_stage, cached),
|
||||||
),
|
),
|
||||||
parsers=(
|
parsers=(
|
||||||
[
|
[result.Parser(name=parser, with_={}) for parser in task_stage.parsers]
|
||||||
result.ParserConfig(name=parser, with_={})
|
|
||||||
for parser in task_stage.parsers
|
|
||||||
]
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
processed_dict = get_processed_dict(task_stage)
|
processed_dict = get_processed_dict(task_stage)
|
||||||
|
@ -44,10 +41,8 @@ def get_conf_stage(
|
||||||
|
|
||||||
def get_processed_dict(
|
def get_processed_dict(
|
||||||
task_stage: task.Stage,
|
task_stage: task.Stage,
|
||||||
) -> Dict[str, Tuple[Callable[[Any, result.ParserConfig], None], Any]]:
|
) -> Dict[str, Tuple[Callable[[Any, result.Parser], None], Any]]:
|
||||||
processed_dict: Dict[
|
processed_dict: Dict[str, Tuple[Callable[[Any, result.Parser], None], Any]] = {
|
||||||
str, Tuple[Callable[[Any, result.ParserConfig], None], Any]
|
|
||||||
] = {
|
|
||||||
"clangtidy": (fix_keyword, task_stage.clangtidy),
|
"clangtidy": (fix_keyword, task_stage.clangtidy),
|
||||||
"keyword": (fix_keyword, task_stage.keyword),
|
"keyword": (fix_keyword, task_stage.keyword),
|
||||||
"cppcheck": (fix_keyword, task_stage.cppcheck),
|
"cppcheck": (fix_keyword, task_stage.cppcheck),
|
||||||
|
@ -60,7 +55,9 @@ def get_processed_dict(
|
||||||
return processed_dict
|
return processed_dict
|
||||||
|
|
||||||
|
|
||||||
def get_executor_with(task_stage: task.Stage, cached: Set[str]) -> result.ExecutorWith:
|
def get_executor_with(
|
||||||
|
task_stage: task.Stage, cached: Dict[str, None]
|
||||||
|
) -> result.ExecutorWith:
|
||||||
file_import = task_stage.files.import_
|
file_import = task_stage.files.import_
|
||||||
copy_in_files = [file for file in file_import if file not in cached]
|
copy_in_files = [file for file in file_import if file not in cached]
|
||||||
file_export = task_stage.files.export
|
file_export = task_stage.files.export
|
||||||
|
@ -86,12 +83,12 @@ def get_executor_with(task_stage: task.Stage, cached: Set[str]) -> result.Execut
|
||||||
cases=[],
|
cases=[],
|
||||||
)
|
)
|
||||||
for file in file_export:
|
for file in file_export:
|
||||||
cached.add(file)
|
cached[file] = None
|
||||||
return executor_with_config
|
return executor_with_config
|
||||||
|
|
||||||
|
|
||||||
def fix_keyword(
|
def fix_keyword(
|
||||||
keyword_config: task.ParserKeyword, keyword_parser_: result.ParserConfig
|
keyword_config: task.ParserKeyword, keyword_parser_: result.Parser
|
||||||
) -> None:
|
) -> None:
|
||||||
keyword_weight: List[result.KeywordConfig] = []
|
keyword_weight: List[result.KeywordConfig] = []
|
||||||
unique_weight = list(set(keyword_config.weight))
|
unique_weight = list(set(keyword_config.weight))
|
||||||
|
@ -114,7 +111,7 @@ def fix_keyword(
|
||||||
|
|
||||||
def fix_result_detail(
|
def fix_result_detail(
|
||||||
result_detail_parser_config: task.ParserResultDetail,
|
result_detail_parser_config: task.ParserResultDetail,
|
||||||
result_detail_parser: result.ParserConfig,
|
result_detail_parser: result.Parser,
|
||||||
) -> None:
|
) -> None:
|
||||||
show_files = []
|
show_files = []
|
||||||
if result_detail_parser_config.stdout:
|
if result_detail_parser_config.stdout:
|
||||||
|
@ -134,7 +131,7 @@ def fix_result_detail(
|
||||||
|
|
||||||
|
|
||||||
def fix_dummy(
|
def fix_dummy(
|
||||||
dummy_parser_config: task.ParserDummy, dummy_parser: result.ParserConfig
|
dummy_parser_config: task.ParserDummy, dummy_parser: result.Parser
|
||||||
) -> None:
|
) -> None:
|
||||||
# we don't use dummy parser in real application
|
# we don't use dummy parser in real application
|
||||||
if dummy_parser_config is None:
|
if dummy_parser_config is None:
|
||||||
|
@ -149,9 +146,7 @@ def fix_dummy(
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def fix_file(
|
def fix_file(file_parser_config: task.ParserFile, file_parser: result.Parser) -> None:
|
||||||
file_parser_config: task.ParserFile, file_parser: result.ParserConfig
|
|
||||||
) -> None:
|
|
||||||
file_parser.with_.update(
|
file_parser.with_.update(
|
||||||
result.FileConfig(name=file_parser_config.name).model_dump(by_alias=True)
|
result.FileConfig(name=file_parser_config.name).model_dump(by_alias=True)
|
||||||
)
|
)
|
||||||
|
@ -160,7 +155,7 @@ def fix_file(
|
||||||
def fix_diff(
|
def fix_diff(
|
||||||
task_stage: task.Stage,
|
task_stage: task.Stage,
|
||||||
task_conf: task.Config,
|
task_conf: task.Config,
|
||||||
diff_parser_config: result.ParserConfig,
|
diff_parser_config: result.Parser,
|
||||||
conf_stage: result.StageDetail,
|
conf_stage: result.StageDetail,
|
||||||
) -> None:
|
) -> None:
|
||||||
diff_parser = diff_parser_config
|
diff_parser = diff_parser_config
|
||||||
|
|
|
@ -222,11 +222,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"copyInCached": {
|
"copyInCached": {
|
||||||
"h7/build/ex2-msan": "h7/build/ex2-msan",
|
"h7/build/ex2": "h7/build/ex2",
|
||||||
"h7/build/ex2-asan": "h7/build/ex2-asan",
|
"h7/build/ex2-asan": "h7/build/ex2-asan",
|
||||||
"h7/build/compile_commands.json": "h7/build/compile_commands.json",
|
|
||||||
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
|
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
|
||||||
"h7/build/ex2": "h7/build/ex2"
|
"h7/build/ex2-msan": "h7/build/ex2-msan",
|
||||||
|
"h7/build/compile_commands.json": "h7/build/compile_commands.json"
|
||||||
},
|
},
|
||||||
"copyInDir": ".",
|
"copyInDir": ".",
|
||||||
"copyOut": [
|
"copyOut": [
|
||||||
|
@ -322,11 +322,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"copyInCached": {
|
"copyInCached": {
|
||||||
"h7/build/ex2-msan": "h7/build/ex2-msan",
|
"h7/build/ex2": "h7/build/ex2",
|
||||||
"h7/build/ex2-asan": "h7/build/ex2-asan",
|
"h7/build/ex2-asan": "h7/build/ex2-asan",
|
||||||
"h7/build/compile_commands.json": "h7/build/compile_commands.json",
|
|
||||||
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
|
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
|
||||||
"h7/build/ex2": "h7/build/ex2"
|
"h7/build/ex2-msan": "h7/build/ex2-msan",
|
||||||
|
"h7/build/compile_commands.json": "h7/build/compile_commands.json"
|
||||||
},
|
},
|
||||||
"copyInDir": ".",
|
"copyInDir": ".",
|
||||||
"copyOut": [
|
"copyOut": [
|
||||||
|
@ -444,11 +444,11 @@
|
||||||
"cpuSetLimit": "",
|
"cpuSetLimit": "",
|
||||||
"copyIn": {},
|
"copyIn": {},
|
||||||
"copyInCached": {
|
"copyInCached": {
|
||||||
"h7/build/ex2-msan": "h7/build/ex2-msan",
|
"h7/build/ex2": "h7/build/ex2",
|
||||||
"h7/build/ex2-asan": "h7/build/ex2-asan",
|
"h7/build/ex2-asan": "h7/build/ex2-asan",
|
||||||
"h7/build/compile_commands.json": "h7/build/compile_commands.json",
|
|
||||||
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
|
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
|
||||||
"h7/build/ex2": "h7/build/ex2"
|
"h7/build/ex2-msan": "h7/build/ex2-msan",
|
||||||
|
"h7/build/compile_commands.json": "h7/build/compile_commands.json"
|
||||||
},
|
},
|
||||||
"copyInDir": ".",
|
"copyInDir": ".",
|
||||||
"copyOut": [
|
"copyOut": [
|
||||||
|
@ -587,11 +587,11 @@
|
||||||
"cpuSetLimit": "",
|
"cpuSetLimit": "",
|
||||||
"copyIn": {},
|
"copyIn": {},
|
||||||
"copyInCached": {
|
"copyInCached": {
|
||||||
"h7/build/ex2-msan": "h7/build/ex2-msan",
|
"h7/build/ex2": "h7/build/ex2",
|
||||||
"h7/build/ex2-asan": "h7/build/ex2-asan",
|
"h7/build/ex2-asan": "h7/build/ex2-asan",
|
||||||
"h7/build/compile_commands.json": "h7/build/compile_commands.json",
|
|
||||||
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
|
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
|
||||||
"h7/build/ex2": "h7/build/ex2"
|
"h7/build/ex2-msan": "h7/build/ex2-msan",
|
||||||
|
"h7/build/compile_commands.json": "h7/build/compile_commands.json"
|
||||||
},
|
},
|
||||||
"copyInDir": ".",
|
"copyInDir": ".",
|
||||||
"copyOut": [
|
"copyOut": [
|
||||||
|
@ -684,11 +684,11 @@
|
||||||
"cpuSetLimit": "",
|
"cpuSetLimit": "",
|
||||||
"copyIn": {},
|
"copyIn": {},
|
||||||
"copyInCached": {
|
"copyInCached": {
|
||||||
"h7/build/ex2-msan": "h7/build/ex2-msan",
|
"h7/build/ex2": "h7/build/ex2",
|
||||||
"h7/build/ex2-asan": "h7/build/ex2-asan",
|
"h7/build/ex2-asan": "h7/build/ex2-asan",
|
||||||
"h7/build/compile_commands.json": "h7/build/compile_commands.json",
|
|
||||||
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
|
"h7/build/ex2-ubsan": "h7/build/ex2-ubsan",
|
||||||
"h7/build/ex2": "h7/build/ex2"
|
"h7/build/ex2-msan": "h7/build/ex2-msan",
|
||||||
|
"h7/build/compile_commands.json": "h7/build/compile_commands.json"
|
||||||
},
|
},
|
||||||
"copyInDir": ".",
|
"copyInDir": ".",
|
||||||
"copyOut": [
|
"copyOut": [
|
||||||
|
@ -706,7 +706,7 @@
|
||||||
"cases": [
|
"cases": [
|
||||||
{
|
{
|
||||||
"stdin": {
|
"stdin": {
|
||||||
"src": "/home/tt/.config/joj/case0.in"
|
"src": "/home/tt/.config/joj/basic/case0.in"
|
||||||
},
|
},
|
||||||
"cpuLimit": 500000000,
|
"cpuLimit": 500000000,
|
||||||
"clockLimit": 1000000000,
|
"clockLimit": 1000000000,
|
||||||
|
@ -715,7 +715,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"stdin": {
|
"stdin": {
|
||||||
"src": "/home/tt/.config/joj/case1.in"
|
"src": "/home/tt/.config/joj/basic/case1.in"
|
||||||
},
|
},
|
||||||
"cpuLimit": 1234567890,
|
"cpuLimit": 1234567890,
|
||||||
"clockLimit": 2469135780,
|
"clockLimit": 2469135780,
|
||||||
|
@ -736,7 +736,7 @@
|
||||||
{
|
{
|
||||||
"score": 5,
|
"score": 5,
|
||||||
"fileName": "stdout",
|
"fileName": "stdout",
|
||||||
"answerPath": "/home/tt/.config/joj/case0.out",
|
"answerPath": "/home/tt/.config/joj/basic/case0.out",
|
||||||
"forceQuitOnDiff": false,
|
"forceQuitOnDiff": false,
|
||||||
"alwaysHide": false,
|
"alwaysHide": false,
|
||||||
"compareSpace": false
|
"compareSpace": false
|
||||||
|
@ -748,7 +748,7 @@
|
||||||
{
|
{
|
||||||
"score": 5,
|
"score": 5,
|
||||||
"fileName": "stdout",
|
"fileName": "stdout",
|
||||||
"answerPath": "/home/tt/.config/joj/case1.out",
|
"answerPath": "/home/tt/.config/joj/basic/case1.out",
|
||||||
"forceQuitOnDiff": false,
|
"forceQuitOnDiff": false,
|
||||||
"alwaysHide": false,
|
"alwaysHide": false,
|
||||||
"compareSpace": false
|
"compareSpace": false
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
"cases": [
|
"cases": [
|
||||||
{
|
{
|
||||||
"stdin": {
|
"stdin": {
|
||||||
"src": "/home/tt/.config/joj/case0.in"
|
"src": "/home/tt/.config/joj/diff/case0.in"
|
||||||
},
|
},
|
||||||
"cpuLimit": 1000000000,
|
"cpuLimit": 1000000000,
|
||||||
"clockLimit": 2000000000,
|
"clockLimit": 2000000000,
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"stdin": {
|
"stdin": {
|
||||||
"src": "/home/tt/.config/joj/case1.in"
|
"src": "/home/tt/.config/joj/diff/case1.in"
|
||||||
},
|
},
|
||||||
"cpuLimit": 2000000000,
|
"cpuLimit": 2000000000,
|
||||||
"clockLimit": 4000000000,
|
"clockLimit": 4000000000,
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
{
|
{
|
||||||
"score": 5,
|
"score": 5,
|
||||||
"fileName": "stdout",
|
"fileName": "stdout",
|
||||||
"answerPath": "/home/tt/.config/joj/case0.out",
|
"answerPath": "/home/tt/.config/joj/diff/case0.out",
|
||||||
"forceQuitOnDiff": false,
|
"forceQuitOnDiff": false,
|
||||||
"alwaysHide": false,
|
"alwaysHide": false,
|
||||||
"compareSpace": false
|
"compareSpace": false
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
{
|
{
|
||||||
"score": 5,
|
"score": 5,
|
||||||
"fileName": "stdout",
|
"fileName": "stdout",
|
||||||
"answerPath": "/home/tt/.config/joj/case1.out",
|
"answerPath": "/home/tt/.config/joj/diff/case1.out",
|
||||||
"forceQuitOnDiff": false,
|
"forceQuitOnDiff": false,
|
||||||
"alwaysHide": false,
|
"alwaysHide": false,
|
||||||
"compareSpace": false
|
"compareSpace": false
|
||||||
|
|
|
@ -11,15 +11,19 @@ from joj3_config_generator.models import repo, task
|
||||||
def read_convert_files(
|
def read_convert_files(
|
||||||
case_name: str,
|
case_name: str,
|
||||||
) -> Tuple[repo.Config, task.Config, Dict[str, Any]]:
|
) -> Tuple[repo.Config, task.Config, Dict[str, Any]]:
|
||||||
root = Path(__file__).resolve().parent / case_name
|
root = Path(__file__).resolve().parent
|
||||||
repo_toml_path = root / "repo.toml"
|
repo_toml_path = root / case_name / "repo.toml"
|
||||||
repo_toml = repo_toml_path.read_text() if repo_toml_path.exists() else ""
|
repo_toml = repo_toml_path.read_text() if repo_toml_path.exists() else ""
|
||||||
task_toml_path = root / "task.toml"
|
task_toml_path = root / case_name / "task.toml"
|
||||||
task_toml = task_toml_path.read_text() if task_toml_path.exists() else ""
|
task_toml = task_toml_path.read_text() if task_toml_path.exists() else ""
|
||||||
result = json.loads((root / "task.json").read_text())
|
result = json.loads((root / case_name / "task.json").read_text())
|
||||||
return (
|
return (
|
||||||
repo.Config(root=root, **rtoml.loads(repo_toml)),
|
repo.Config(
|
||||||
task.Config(root=root, **rtoml.loads(task_toml)),
|
root=root, path=repo_toml_path.relative_to(root), **rtoml.loads(repo_toml)
|
||||||
|
),
|
||||||
|
task.Config(
|
||||||
|
root=root, path=task_toml_path.relative_to(root), **rtoml.loads(task_toml)
|
||||||
|
),
|
||||||
result,
|
result,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user