From fe620d710e76151273cebd6d4e6a608586be3206 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 18:53:41 +0800 Subject: [PATCH 001/131] feat: migrate repo & init classes --- .gitignore | 2 +- joj3_config_generator/convert.py | 27 +- joj3_config_generator/lib/__init__.py | 11 + joj3_config_generator/lib/repo.py | 123 ++++ joj3_config_generator/models/result.py | 34 +- joj3_config_generator/models/task.py | 48 +- tests/convert/basic/repo.toml | 2 +- tests/convert/basic/task.json | 814 ++++++++++++++++++++++--- tests/convert/basic/task.toml | 133 +++- tests/immutable_file/.gitattributes | 33 + tests/immutable_file/.gitignore | 23 + tests/immutable_file/push.yaml | 18 + tests/immutable_file/release.yaml | 20 + 13 files changed, 1156 insertions(+), 132 deletions(-) create mode 100644 joj3_config_generator/lib/__init__.py create mode 100644 joj3_config_generator/lib/repo.py create mode 100644 tests/immutable_file/.gitattributes create mode 100644 tests/immutable_file/.gitignore create mode 100644 tests/immutable_file/push.yaml create mode 100644 tests/immutable_file/release.yaml diff --git a/.gitignore b/.gitignore index 6a5b3ae..b832e0e 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ dist/ downloads/ eggs/ .eggs/ -lib/ +# lib/ lib64/ parts/ sdist/ diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 9badd5f..96a329a 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,6 +1,20 @@ 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.models import ( + Cmd, + CmdFile, + ExecutorConfig, + ExecutorWithConfig, + ParserConfig, + Repo, + ResultConfig, + Stage, + StageConfig, + Task, + TeapotConfig, +) # FIXME: LLM generated convert function, only for demostration @@ -8,7 +22,8 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Create the base ResultConf object result_conf = result.Config( name=task_conf.task, - log_path=f"{task_conf.task.replace(' ', '_')}.log", + # TODO: specify the exact folder difference + log_path=f"{task_conf.task.replace(' ', '-')}.log", expire_unix_timestamp=( int(task_conf.release.deadline.timestamp()) if task_conf.release.deadline @@ -16,8 +31,14 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: ), stage=result.Stage(stages=[], sandbox_token=repo_conf.sandbox_token), teapot=result.Teapot(), + stage=StageConfig(stages=[], sandbox_token=repo_conf.sandbox_token), + teapot=getTeapotConfig(repo_conf, task_conf), ) + # Construct healthcheck stage + healthcheck_stage = getHealthcheckConfig(repo_conf, task_conf) + result_conf.stage.stages.append(healthcheck_stage) + cached = [] # Convert each stage in the task configuration for task_stage in task_conf.stages: executor_with_config = result.ExecutorWith( @@ -41,12 +62,12 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: result.Parser(name=parser, with_={}) for parser in task_stage.parsers ], ) - if "result-detail" in task_stage.parsers: result_detail_parser = next( p for p in conf_stage.parsers if p.name == "result-detail" ) - result_detail_parser.with_.update(task_stage.result_detail) + if task_stage.result_detail is not None: + result_detail_parser.with_.update(task_stage.result_detail) result_conf.stage.stages.append(conf_stage) diff --git a/joj3_config_generator/lib/__init__.py b/joj3_config_generator/lib/__init__.py new file mode 100644 index 0000000..68802d4 --- /dev/null +++ b/joj3_config_generator/lib/__init__.py @@ -0,0 +1,11 @@ +from joj3_config_generator.models.repo import Repo as Repo +from joj3_config_generator.models.result import Cmd as Cmd +from joj3_config_generator.models.result import CmdFile as CmdFile +from joj3_config_generator.models.result import ExecutorConfig as ExecutorConfig +from joj3_config_generator.models.result import ExecutorWithConfig as ExecutorWithConfig +from joj3_config_generator.models.result import ParserConfig as ParserConfig +from joj3_config_generator.models.result import ResultConfig as ResultConfig +from joj3_config_generator.models.result import Stage as Stage +from joj3_config_generator.models.result import StageConfig as StageConfig +from joj3_config_generator.models.result import TeapotConfig as TeapotConfig +from joj3_config_generator.models.task import Task as Task diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py new file mode 100644 index 0000000..e9a8d33 --- /dev/null +++ b/joj3_config_generator/lib/repo.py @@ -0,0 +1,123 @@ +import hashlib +import os +import tempfile + +from dotenv import load_dotenv + +from joj3_config_generator.models import ( + Cmd, + CmdFile, + ExecutorConfig, + ExecutorWithConfig, + ParserConfig, + Repo, + ResultConfig, + Stage, + StageConfig, + Task, + TeapotConfig, +) + + +def get_temp_directory() -> str: + return tempfile.mkdtemp(prefix="repo-checker-") + + +def getGradingRepoName() -> str: + path = os.path.expanduser("~/.config/teapot/teapot.env") + if os.path.exists(path): + load_dotenv(path) + repo_name = os.environ.get("GITEA_ORG_NAME") + if repo_name is not None: + return f"{repo_name.split('-')[0]}-joj" + return "ece482-joj" + + +def getTeapotConfig(repo_conf: Repo, task_conf: Task) -> TeapotConfig: + teapot = TeapotConfig( + # TODO: fix the log path + log_path=f"{task_conf.task.replace(' ', '-')}-joint-teapot-debug.log", + scoreboard_path=f"{task_conf.task.replace(' ', '-')}-scoreboard.csv", + failed_table_path=f"{task_conf.task.replace(' ', '-')}-failed-table.md", + grading_repo_name=getGradingRepoName(), + ) + return teapot + + +def getHealthcheckCmd(repo_conf: Repo) -> Cmd: + repoSize = repo_conf.max_size + immutable = repo_conf.files.immutable + repo_size = f"-repoSize={str(repoSize)} " + required_files = repo_conf.files.required + + for i, meta in enumerate(required_files): + required_files[i] = f"-meta={meta} " + + immutable_files = f"-checkFileNameList=" + for i, name in enumerate(immutable): + if i == len(immutable) - 1: + immutable_files = immutable_files + name + " " + else: + immutable_files = immutable_files + name + "," + # FIXME: need to make solution and make things easier to edit with global scope + chore = f"/{get_temp_directory}/repo-health-checker -root=. " + args = "" + args = args + chore + args = args + repo_size + for meta in required_files: + args = args + meta + + args = args + get_hash(immutable) + + args = args + immutable_files + + cmd = Cmd( + args=args.split(), + # FIXME: easier to edit within global scope + copy_in={ + f"/{get_temp_directory()}/repo-health-checker": CmdFile( + src=f"/{get_temp_directory()}/repo-health-checker" + ) + }, + ) + return cmd + + +def getHealthcheckConfig(repo_conf: Repo, task_conf: Task) -> Stage: + healthcheck_stage = Stage( + name="healthcheck", + group="", + executor=ExecutorConfig( + name="sandbox", + with_=ExecutorWithConfig(default=getHealthcheckCmd(repo_conf), cases=[]), + ), + parsers=[ParserConfig(name="healthcheck", with_={"score": 0, "comment": ""})], + ) + return healthcheck_stage + + +def calc_sha256sum(file_path: str) -> str: + sha256_hash = hashlib.sha256() + with open(file_path, "rb") as f: + for byte_block in iter(lambda: f.read(65536 * 2), b""): + sha256_hash.update(byte_block) + return sha256_hash.hexdigest() + + +def get_hash(immutable_files: list[str]) -> str: # input should be a list + file_path = "../immutable_file/" # TODO: change this when things are on the server + immutable_hash = [] + for i, file in enumerate(immutable_files): + immutable_files[i] = file_path + file.rsplit("/", 1)[-1] + + for i, file in enumerate(immutable_files): + immutable_hash.append(calc_sha256sum(file)) + + hash_check = "-checkFileSumList=" + + for i, file in enumerate(immutable_hash): + if i == len(immutable_hash) - 1: + hash_check = hash_check + file + " " + else: + hash_check = hash_check + file + "," + return hash_check diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index bb5440c..1f4579e 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -8,7 +8,7 @@ class CmdFile(BaseModel): content: Optional[str] = None file_id: Optional[str] = Field(None, serialization_alias="fileId") name: Optional[str] = None - max: Optional[int] = None + max: Optional[int] = 4 * 1024 * 1024 symlink: Optional[str] = None stream_in: bool = Field(False, serialization_alias="streamIn") stream_out: bool = Field(False, serialization_alias="streamOut") @@ -16,17 +16,17 @@ class CmdFile(BaseModel): class Cmd(BaseModel): - args: List[str] - env: List[str] = [] - stdin: Optional[CmdFile] = None - stdout: Optional[CmdFile] = None - stderr: Optional[CmdFile] = None - cpu_limit: int = Field(0, serialization_alias="cpuLimit") + args: list[str] + env: list[str] = ["PATH=/usr/bin:/bin:/usr/local/bin"] + stdin: Optional[CmdFile] = CmdFile(content="") + stdout: Optional[CmdFile] = CmdFile(name="stdout", max=4 * 1024) + stderr: Optional[CmdFile] = CmdFile(name="stderr", max=4 * 1024) + cpu_limit: int = Field(4 * 1000000000, serialization_alias="cpuLimit") real_cpu_limit: int = Field(0, serialization_alias="realCpuLimit") - clock_limit: int = Field(0, serialization_alias="clockLimit") - memory_limit: int = Field(0, serialization_alias="memoryLimit") + clock_limit: int = Field(8 * 1000000000, serialization_alias="clockLimit") + memory_limit: int = Field(4 * 1024 * 1024, serialization_alias="memoryLimit") stack_limit: int = Field(0, serialization_alias="stackLimit") - proc_limit: int = Field(0, serialization_alias="procLimit") + proc_limit: int = Field(50, serialization_alias="procLimit") cpu_rate_limit: int = Field(0, serialization_alias="cpuRateLimit") cpu_set_limit: str = Field("", serialization_alias="cpuSetLimit") copy_in: Dict[str, CmdFile] = Field({}, serialization_alias="copyIn") @@ -43,17 +43,19 @@ class Cmd(BaseModel): class OptionalCmd(BaseModel): - args: Optional[List[str]] = None - env: Optional[List[str]] = None + args: Optional[list[str]] = None + env: Optional[list[str]] = ["PATH=/usr/bin:/bin:/usr/local/bin"] stdin: Optional[CmdFile] = None stdout: Optional[CmdFile] = None stderr: Optional[CmdFile] = None - cpu_limit: Optional[int] = Field(None, serialization_alias="cpuLimit") + cpu_limit: Optional[int] = Field(4 * 1000000000, serialization_alias="cpuLimit") real_cpu_limit: Optional[int] = Field(None, serialization_alias="realCpuLimit") - clock_limit: Optional[int] = Field(None, serialization_alias="clockLimit") - memory_limit: Optional[int] = Field(None, serialization_alias="memoryLimit") + clock_limit: Optional[int] = Field(8 * 1000000000, serialization_alias="clockLimit") + memory_limit: Optional[int] = Field( + 4 * 1024 * 1024, serialization_alias="memoryLimit" + ) stack_limit: Optional[int] = Field(None, serialization_alias="stackLimit") - proc_limit: Optional[int] = Field(None, serialization_alias="procLimit") + proc_limit: Optional[int] = Field(50, serialization_alias="procLimit") cpu_rate_limit: Optional[int] = Field(None, serialization_alias="cpuRateLimit") cpu_set_limit: Optional[str] = Field(None, serialization_alias="cpuSetLimit") copy_in: Optional[Dict[str, CmdFile]] = Field(None, serialization_alias="copyIn") diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 09a37fc..cf2628f 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -5,26 +5,50 @@ from pydantic import BaseModel, Field class ParserResultDetail(BaseModel): - time: bool = True # Display run time - mem: bool = True # Display memory usage - stdout: bool = False # Display stdout messages - stderr: bool = False # Display stderr messages + time: Optional[bool] = True # Display run time + mem: Optional[bool] = True # Display memory usage + stdout: Optional[bool] = False # Display stdout messages + stderr: Optional[bool] = False # Display stderr messages + exitstatus: Optional[bool] = False + + +class ParserDummy(BaseModel): + comment: Optional[str] = "" + + +class ParserKeyword(BaseModel): + keyword: Optional[list[str]] = None + weight: Optional[list[int]] = None class Files(BaseModel): - import_: List[str] = Field(serialization_alias="import", validation_alias="import") - export: List[str] + import_: Optional[List[str]] = Field(serialization_alias="import", validation_alias="import") + export: Optional[List[str]] + + + +class Limit(BaseModel): + mem: Optional[int] = 4 + cpu: Optional[int] = 4 + stderr: Optional[int] = 4 + stdout: Optional[int] = 4 class Stage(BaseModel): name: str # Stage name command: str # Command to run - files: Files # Files to import and export - score: int # Score for the task - parsers: List[str] # list of parsers - result_detail: ParserResultDetail = ( - ParserResultDetail() - ) # for result-detail parser + files: Optional[Files] = None + score: Optional[int] = 0 + parsers: list[str] # list of parsers + limit: Optional[Limit] = None + dummy: Optional[ParserDummy] = ParserDummy() + keyword: Optional[ParserKeyword] = ParserKeyword() + clangtidy: Optional[ParserKeyword] = ParserKeyword() + cppcheck: Optional[ParserKeyword] = ParserKeyword() + cpplint: Optional[ParserKeyword] = ParserKeyword() + result_detail: Optional[ParserResultDetail] = Field( + ParserResultDetail(), alias="result-detail" + ) class Release(BaseModel): diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index f9012cc..c77b9f7 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -7,4 +7,4 @@ sandbox_token = "test" whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" required = ["main.py", "README.md"] -immutable = ["config.yaml", "setup.py"] +immutable = [".gitignore", ".gitattributes", "push.yaml", "release.yaml"] diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 294d15c..ae81205 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,53 +1,79 @@ { - "name": "hw3 ex5", - "logPath": "hw3_ex5.log", - "expireUnixTimestamp": 1729267140, + "name": "Homework 1 exercise 2", + "logPath": "Homework-1-exercise-2.log", + "expireUnixTimestamp": 1728748740, "stage": { "sandboxExecServer": "172.17.0.1:5051", "sandboxToken": "test", "outputPath": "/tmp/joj3_result.json", "stages": [ { - "name": "judge_base", - "group": "hw3 ex5", + "name": "healthcheck", + "group": "", "executor": { "name": "sandbox", "with": { "default": { "args": [ - "./matlab-joj", - "./h3/ex5.m" + "/tmp/repo-health-checker", + "-root=.", + "-repoSize=50.5", + "-meta=main.py", + "-meta=README.md", + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,8d1229900c6fc6711b5cc141d1ab5ea7f5b7b7a4b921d9cfa3957408b43ae723,eb857bcd94857cedc4045cb2d6ba04cb5bbb3daf188abc95fb9478db823ef47e", + "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" ], - "env": [], - "stdin": null, - "stdout": null, - "stderr": null, - "cpuLimit": 0, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, "realCpuLimit": 0, - "clockLimit": 0, - "memoryLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, "stackLimit": 0, - "procLimit": 0, + "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "tools/matlab-joj": { - "src": "tools/matlab-joj", + "/tmp/repo-health-checker": { + "src": "/tmp/repo-health-checker", "content": null, "fileId": null, "name": null, - "max": null, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "tools/matlab_formatter.py": { - "src": "tools/matlab_formatter.py", - "content": null, - "fileId": null, - "name": null, - "max": null, + "max": 4194304, "symlink": null, "streamIn": false, "streamOut": false, @@ -57,9 +83,139 @@ "copyInCached": {}, "copyInDir": ".", "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 0, + "comment": "" + } + } + ] + }, + { + "name": "Compilation", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "make.sh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/make.sh": { + "src": "/home/tt/.config/joj/tools/make.sh", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/main.c": { + "src": "/home/tt/.config/joj/src/main.c", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/task.h": { + "src": "/home/tt/.config/joj/src/task.h", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "srcCMakelist.txt": { + "src": "/home/tt/.config/joj/srcCMakelist.txt", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/make.sh": "tools/make.sh", + "src/main.c": "src/main.c", + "src/task.h": "src/task.h", + "srcCMakelist.txt": "srcCMakelist.txt" + }, + "copyInDir": ".", + "copyOut": [], "copyOutCached": [ - "output/ex5_results.txt", - "output/ex5_logs.txt" + "driver", + "p2", + "p2-msan" ], "copyOutMax": 0, "copyOutDir": "", @@ -73,7 +229,119 @@ }, "parsers": [ { - "name": "diff", + "name": "result-detail", + "with": { + "time": false, + "mem": false, + "stdout": false, + "stderr": true, + "exitstatus": true + } + }, + { + "name": "dummy", + "with": {} + }, + { + "name": "result-status", + "with": {} + } + ] + }, + { + "name": "File length check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./file-length", + "500", + "400", + "*.c", + "*.h" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/file-length": { + "src": "/home/tt/.config/joj/tools/file-length", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/file-length": "tools/file-length" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "keyword", + "with": {} + }, + { + "name": "dummy", "with": {} }, { @@ -82,65 +350,361 @@ "time": false, "mem": false, "stdout": false, - "stderr": true + "stderr": true, + "exitstatus": false } } ] }, { - "name": "judge_base2", - "group": "hw3 ex5", + "name": "Clang-tidy checks", + "group": null, "executor": { "name": "sandbox", "with": { "default": { "args": [ - "./matlab-joj", - "./h3/ex5.m" + "run-clang-tidy-18", + "-header-filter=.*", + "-quiet", + "-load=/usr/local/lib/libcodequality.so", + "-p", + "build" ], - "env": [], - "stdin": null, - "stdout": null, - "stderr": null, - "cpuLimit": 0, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, "realCpuLimit": 0, - "clockLimit": 0, - "memoryLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, "stackLimit": 0, - "procLimit": 0, + "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", - "copyIn": { - "tools/matlab-joj": { - "src": "tools/matlab-joj", - "content": null, - "fileId": null, - "name": null, - "max": null, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "tools/matlab_formatter.py": { - "src": "tools/matlab_formatter.py", - "content": null, - "fileId": null, - "name": null, - "max": null, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, + "copyIn": {}, "copyInCached": {}, "copyInDir": ".", "copyOut": [], - "copyOutCached": [ - "output/ex5_results2.txt", - "output/ex5_logs2.txt" + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "clangtidy", + "with": {} + }, + { + "name": "dummy", + "with": {} + }, + { + "name": "result-detail", + "with": { + "time": false, + "mem": false, + "stdout": true, + "stderr": false, + "exitstatus": true + } + } + ] + }, + { + "name": "Cppcheck check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cppcheck", + "--template='{\"file\":\"{file}\",\"line\":{line},", + "\"column\":{column},", + "\"severity\":\"{severity}\",", + "\"message\":\"{message}\",", + "\"id\":\"{id}\"}'", + "--force", + "--enable=all", + "--quiet", + "./" ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cppcheck", + "with": {} + }, + { + "name": "dummy", + "with": {} + }, + { + "name": "result-detail", + "with": { + "time": false, + "mem": false, + "stdout": false, + "stderr": true, + "exitstatus": true + } + } + ] + }, + { + "name": "Cpplint check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cpplint", + "--linelength=120", + "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", + "--recursive", + "--exclude=build", + "." + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cpplint", + "with": {} + }, + { + "name": "dummy", + "with": {} + }, + { + "name": "result-detail", + "with": { + "time": false, + "mem": false, + "stdout": true, + "stderr": false, + "exitstatus": true + } + } + ] + }, + { + "name": "judge-base", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], "copyOutMax": 0, "copyOutDir": "", "tty": false, @@ -156,13 +720,109 @@ "name": "diff", "with": {} }, + { + "name": "dummy", + "with": {} + }, { "name": "result-detail", "with": { "time": true, "mem": true, "stdout": false, - "stderr": false + "stderr": true, + "exitstatus": true + } + } + ] + }, + { + "name": "judge-msan", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh-msan" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "diff", + "with": {} + }, + { + "name": "dummy", + "with": {} + }, + { + "name": "result-detail", + "with": { + "time": true, + "mem": true, + "stdout": false, + "stderr": true, + "exitstatus": true } } ] @@ -170,10 +830,10 @@ ] }, "teapot": { - "logPath": "/home/tt/.cache/joint-teapot-debug.log", - "scoreboardPath": "scoreboard.csv", - "failedTablePath": "failed-table.md", - "gradingRepoName": "", + "logPath": "Homework-1-exercise-2-joint-teapot-debug.log", + "scoreboardPath": "Homework-1-exercise-2-scoreboard.csv", + "failedTablePath": "Homework-1-exercise-2-failed-table.md", + "gradingRepoName": "engr151-joj", "skipIssue": false, "skipScoreboard": false, "skipFailedTable": false diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 0872079..ef299a4 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,30 +1,119 @@ -task = "hw3 ex5" +# general task configuration +task="Homework 1 exercise 2" # task name -[release] -deadline = "2024-10-18T23:59:00+08:00" +release.deadline = 2024-10-12 23:59:00+08:00 +release.stages = [ "compile" ] [[stages]] -name = "judge_base" -command = "./matlab-joj ./h3/ex5.m" -score = 100 -parsers = ["diff", "result-detail"] +name = "Compilation" +command = "make.sh" # eg. script running cmake commands +files.import = [ "tools/make.sh", "src/main.c", "src/task.h", "srcCMakelist.txt" ] +files.export = [ "driver", "p2", "p2-msan" ] +limit.cpu = 180 # p2 takes long to compile +limit.stderr = 128 -files.import = ["tools/matlab-joj", "tools/matlab_formatter.py"] -files.export = ["output/ex5_results.txt", "output/ex5_logs.txt"] - -result_detail.time = false -result_detail.mem = false -result_detail.stderr = true +# compile parsers +parsers = [ "result-detail", "dummy", "result-status" ] +result-status.comment = "Congratulations! Your code compiled successfully." +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stderr = true +result-detail.time = false +result-detail.mem = false [[stages]] -name = "judge_base2" -command = "./matlab-joj ./h3/ex5.m" -score = 80 -parsers = ["diff", "result-detail"] +name = "File length check" +command = "./file-length 500 400 *.c *.h" # command to run +files.import = [ "tools/file-length" ] -files.import = ["tools/matlab-joj", "tools/matlab_formatter.py"] -files.export = ["output/ex5_results2.txt", "output/ex5_logs2.txt"] +parsers = [ "keyword", "dummy", "result-detail" ] +keyword.keyword = [ "max", "recommend"] # keywords caught by corresponding JOJ plugin +keyword.weight = [ 50, 20 ] # weight of each keyword +result-detail.exitstatus = false +result-detail.stderr = true +result-detail.time = false +result-detail.mem = false -result_detail.time = true -result_detail.mem = true -result_detail.stderr = false +[[stages]] +name = "Clang-tidy checks" +command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" +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] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stdout = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "Cppcheck check" +command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --quiet ./" +limit.stderr = 65 + +parsers = [ "cppcheck", "dummy", "result-detail" ] +cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] +cppcheck.weight = [20, 10, 15, 15, 10] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stderr = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "Cpplint check" +command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard --recursive --exclude=build ." +limit.stdout = 65 + +parsers = [ "cpplint", "dummy", "result-detail" ] +cpplint.keyword = [ "runtime", "readability", "build" ] +cpplint.weight = [ 10, 20, 15] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stdout = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "judge-base" +command="./driver ./mumsh" +limit.cpu = 3 +limit.mem = 75 +score = 10 + +parsers = ["diff", "dummy", "result-detail"] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stderr = true + +case4.score = 15 +case4.limit.cpu = 30 +case4.limit.mem = 10 +case4.limit.stdout = 8 + +case5.score = 25 + +case8.limit.stderr = 128 + +[[stages]] +name = "judge-msan" +command="./driver ./mumsh-msan" +limit.cpu = 10 # default cpu limit (in sec) for each test case +limit.mem = 500 # set default mem limit (in MB) for all OJ test cases +score = 10 +skip = ["case0", "case11"] + +parsers = ["diff", "dummy", "result-detail"] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stderr = true + +case4.score = 15 +case4.limit.cpu = 30 +case4.limit.mem = 10 + +case5.diff.output.ignorespaces = false + +case6.diff.output.hide = true diff --git a/tests/immutable_file/.gitattributes b/tests/immutable_file/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/immutable_file/.gitattributes @@ -0,0 +1,33 @@ +*.avi filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.djvu filter=lfs diff=lfs merge=lfs -text +*.doc filter=lfs diff=lfs merge=lfs -text +*.docx filter=lfs diff=lfs merge=lfs -text +*.epub filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.ipynb filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.JPEG filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.JPG filter=lfs diff=lfs merge=lfs -text +*.mkv filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.ods filter=lfs diff=lfs merge=lfs -text +*.odt filter=lfs diff=lfs merge=lfs -text +*.otf filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.PDF filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.PNG filter=lfs diff=lfs merge=lfs -text +*.ppt filter=lfs diff=lfs merge=lfs -text +*.pptx filter=lfs diff=lfs merge=lfs -text +*.ps filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text +*.xls filter=lfs diff=lfs merge=lfs -text +*.xlsx filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_file/.gitignore b/tests/immutable_file/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/immutable_file/.gitignore @@ -0,0 +1,23 @@ +################################ +## White list based gitignore ## +################################ + +# forbidden +* +.* + +# allowed +!.gitignore +!.gitattributes +!.gitea/ +!.gitea/issue_template/ +!.gitea/workflows/ +!*.yaml +!Makefile +!CMakeLists.txt +!h[0-8]/ +!*.m +!*.c +!*.cpp +!*.h +!*.md diff --git a/tests/immutable_file/push.yaml b/tests/immutable_file/push.yaml new file mode 100644 index 0000000..2f890b6 --- /dev/null +++ b/tests/immutable_file/push.yaml @@ -0,0 +1,18 @@ +name: Run JOJ3 on Push +on: [push] +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml new file mode 100644 index 0000000..afd2838 --- /dev/null +++ b/tests/immutable_file/release.yaml @@ -0,0 +1,20 @@ +name: Run JOJ3 on Release +on: + release: + types: [published] +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj -msg "feat(h1-release): joj on ${{ github.ref }}" -- 2.30.2 From 3ebeabc205fe19a63ceeb5b4ab49e027809aec0e Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:37:52 +0800 Subject: [PATCH 002/131] feat: finish keyword related --- joj3_config_generator/convert.py | 16 +++ joj3_config_generator/lib/task.py | 20 +++ joj3_config_generator/models/task.py | 5 +- tests/convert/basic/task.json | 184 ++++++++++++++++++++++++--- tests/convert/basic/task.toml | 2 +- 5 files changed, 209 insertions(+), 18 deletions(-) create mode 100644 joj3_config_generator/lib/task.py diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 96a329a..367ed57 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -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 diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py new file mode 100644 index 0000000..c8bffeb --- /dev/null +++ b/joj3_config_generator/lib/task.py @@ -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 diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index cf2628f..97000a8 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -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() diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index ae81205..dcf13ea 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -15,12 +15,15 @@ "with": { "default": { "args": [ - "/tmp/repo-health-checker", + "//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", diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index ef299a4..48dfd07 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -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 -- 2.30.2 From f99fa2d7f6bda972d70995bbe5bd89a3e531e74a Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:45:25 +0800 Subject: [PATCH 003/131] feat: combine dummy & result-staus --- joj3_config_generator/convert.py | 15 ++------------- joj3_config_generator/lib/task.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 367ed57..e6210df 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -2,7 +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.lib.task import fix_comment, fix_keyword from joj3_config_generator.models import ( Cmd, CmdFile, @@ -71,18 +71,7 @@ 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_comment(task_stage, conf_stage) conf_stage = fix_keyword(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 c8bffeb..3b8208c 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -18,3 +18,15 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: else: continue return conf_stage + + +def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + comment_parser = ["dummy", "result-status"] + 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, None) is not None: + comment_parser_.with_.update(getattr(task_stage, parser)) + else: + continue + return conf_stage -- 2.30.2 From c58b53a34983b89e31a2c01fa9a16335a1778043 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:55:31 +0800 Subject: [PATCH 004/131] fix: result-status --- joj3_config_generator/convert.py | 12 ++++++++++++ joj3_config_generator/lib/task.py | 6 ++++-- tests/convert/basic/task.json | 6 +++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index e6210df..bb5dfbb 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -71,6 +71,18 @@ 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_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 3b8208c..a5b0d36 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -25,8 +25,10 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: 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, None) is not None: - comment_parser_.with_.update(getattr(task_stage, parser)) + if getattr(task_stage, parser.replace("-", "_"), None) is not None: + comment_parser_.with_.update( + getattr(task_stage, parser.replace("-", "_")) + ) else: continue return conf_stage diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index dcf13ea..83c624a 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7fbd328431a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-90ztqsoq/repo-health-checker": { - "src": "//tmp/repo-checker-41mcx5_x/repo-health-checker", + "//tmp/repo-checker-04l9les6/repo-health-checker": { + "src": "//tmp/repo-checker-_34sofm5/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From 8f099d8a3307ab551b348fa8eb0af7dc1342c8c4 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:55:55 +0800 Subject: [PATCH 005/131] chore: trim old code --- joj3_config_generator/convert.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index bb5dfbb..e6210df 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -71,18 +71,6 @@ 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_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) -- 2.30.2 From 72f09e7e4b65600e261195b5553f50549af65856 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:56:50 +0800 Subject: [PATCH 006/131] chore: trim old code --- joj3_config_generator/lib/task.py | 6 +++++- tests/convert/basic/task.json | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index a5b0d36..deb3c27 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -21,7 +21,11 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - comment_parser = ["dummy", "result-status"] + comment_parser = [ + "dummy", + "result-status", + "cpplint", + ] # FIXME: determine where cpplint should be 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) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 83c624a..a42375b 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7ff2358271a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-04l9les6/repo-health-checker": { - "src": "//tmp/repo-checker-_34sofm5/repo-health-checker", + "//tmp/repo-checker-3qi07atp/repo-health-checker": { + "src": "//tmp/repo-checker-ebujap5a/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -775,7 +775,18 @@ "parsers": [ { "name": "cpplint", - "with": {} + "with": { + "keyword": [ + "runtime", + "readability", + "build" + ], + "weight": [ + 10, + 20, + 15 + ] + } }, { "name": "dummy", -- 2.30.2 From e5c7d7aad263acbee30c12934051b6cb5de5869d Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 23:30:41 +0800 Subject: [PATCH 007/131] fix: result_detail parser --- joj3_config_generator/convert.py | 12 +--- joj3_config_generator/lib/task.py | 31 ++++++++++ joj3_config_generator/models/task.py | 4 +- tests/convert/basic/task.json | 87 +++++++++++++++++++++------- 4 files changed, 104 insertions(+), 30 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index e6210df..4b4d325 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -2,7 +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_comment, fix_keyword +from joj3_config_generator.lib.task import fix_comment, fix_keyword, fix_result_detail from joj3_config_generator.models import ( Cmd, CmdFile, @@ -63,16 +63,10 @@ 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" - ) - if task_stage.result_detail is not None: - result_detail_parser.with_.update(task_stage.result_detail) - + conf_stage = fix_result_detail(task_stage, conf_stage) conf_stage = fix_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) + # TODO: fix diff parser here result_conf.stage.stages.append(conf_stage) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index deb3c27..900749b 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -20,6 +20,37 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: return conf_stage +def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + if "result-detail" in task_stage.parsers: + result_detail_parser = next( + p for p in conf_stage.parsers if p.name == "result-detail" + ) + if task_stage.result_detail is not None: + show_files = [] + if ( + task_stage.result_detail.stdout + and task_stage.result_detail.stdout is not None + ): + show_files.append("stdout") + if ( + task_stage.result_detail.stderr + and task_stage.result_detail.stderr is not None + ): + show_files.append("stderr") + result_detail_parser.with_.update( + { + "score": 0, + "comment": "", + "showFiles": show_files, + "showExitStatus": task_stage.result_detail.exitstatus, + "showRuntime": task_stage.result_detail.time, + "showMemory": task_stage.result_detail.mem, + } + ) + + return conf_stage + + def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: comment_parser = [ "dummy", diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 97000a8..ac4bd28 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -46,7 +46,9 @@ class Stage(BaseModel): keyword: Optional[ParserKeyword] = ParserKeyword() clangtidy: Optional[ParserKeyword] = ParserKeyword() cppcheck: Optional[ParserKeyword] = ParserKeyword() - cpplint: Optional[ParserKeyword] = ParserKeyword() + # FIXME: determine cpplint type + # cpplint: Optional[ParserKeyword] = ParserKeyword() + cpplint: Optional[ParserDummy] = ParserDummy() result_detail: Optional[ParserResultDetail] = Field( ParserResultDetail(), alias="result-detail" ) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index a42375b..f6f5ea7 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7fd3bed4f1a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-3qi07atp/repo-health-checker": { - "src": "//tmp/repo-checker-ebujap5a/repo-health-checker", + "//tmp/repo-checker-9z61g608/repo-health-checker": { + "src": "//tmp/repo-checker-19d98f6u/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -238,7 +238,15 @@ "mem": false, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } }, { @@ -375,7 +383,15 @@ "mem": false, "stdout": false, "stderr": true, - "exitstatus": false + "exitstatus": false, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": false, + "showRuntime": false, + "showMemory": false } } ] @@ -559,7 +575,15 @@ "mem": false, "stdout": true, "stderr": false, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } } ] @@ -693,7 +717,15 @@ "mem": false, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } } ] @@ -776,16 +808,7 @@ { "name": "cpplint", "with": { - "keyword": [ - "runtime", - "readability", - "build" - ], - "weight": [ - 10, - 20, - 15 - ] + "comment": "" } }, { @@ -801,7 +824,15 @@ "mem": false, "stdout": true, "stderr": false, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } } ] @@ -894,7 +925,15 @@ "mem": true, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true } } ] @@ -987,7 +1026,15 @@ "mem": true, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true } } ] -- 2.30.2 From 3adf645edaa4bc27ef5c4f9d6d167aa0fedc8880 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 13:49:07 +0800 Subject: [PATCH 008/131] feat: cases data reading for diff --- joj3_config_generator/convert.py | 9 ++++- joj3_config_generator/lib/task.py | 55 +++++++++++++++++----------- joj3_config_generator/models/task.py | 35 +++++++++++++++--- tests/convert/basic/task.json | 51 ++++---------------------- tests/convert/basic/task.toml | 2 +- 5 files changed, 80 insertions(+), 72 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 4b4d325..b4b1ebc 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -2,7 +2,12 @@ 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_comment, fix_keyword, fix_result_detail +from joj3_config_generator.lib.task import ( + fix_comment, + fix_diff, + fix_keyword, + fix_result_detail, +) from joj3_config_generator.models import ( Cmd, CmdFile, @@ -67,7 +72,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: conf_stage = fix_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) # TODO: fix diff parser here - + conf_stage = fix_diff(task_stage, conf_stage) result_conf.stage.stages.append(conf_stage) return result_conf diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 900749b..d8d2f78 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,27 +1,32 @@ +import rtoml + 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 + if task_stage.parsers is not None: + 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 + keyword_parser_.with_.update({"match": keyword_weight}) + else: + continue return conf_stage def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - if "result-detail" in task_stage.parsers: + if (task_stage.parsers is not None) and ("result-detail" in task_stage.parsers): result_detail_parser = next( p for p in conf_stage.parsers if p.name == "result-detail" ) @@ -57,13 +62,21 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: "result-status", "cpplint", ] # FIXME: determine where cpplint should be - 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 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 ) - else: - continue + if getattr(task_stage, parser.replace("-", "_"), None) is not None: + comment_parser_.with_.update( + getattr(task_stage, parser.replace("-", "_")) + ) + else: + continue + return conf_stage + + +def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + return conf_stage diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index ac4bd28..d5eefac 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -1,7 +1,7 @@ from datetime import datetime -from typing import List, Optional +from typing import Any, Dict, Optional, Type, List -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, root_validator class ParserResultDetail(BaseModel): @@ -21,6 +21,17 @@ class ParserKeyword(BaseModel): weight: Optional[list[int]] = [] +class Outputs(BaseModel): + score: Optional[int] = 0 + ignorespaces: Optional[bool] = False + hide: Optional[bool] = False + forcequit: Optional[bool] = True + + +class ParserDiff(BaseModel): + output: Optional[Outputs] = Outputs() + + class Files(BaseModel): import_: Optional[List[str]] = Field(serialization_alias="import", validation_alias="import") export: Optional[List[str]] @@ -35,11 +46,11 @@ class Limit(BaseModel): class Stage(BaseModel): - name: str # Stage name - command: str # Command to run + name: Optional[str] = None # Stage name + command: Optional[str] = None # Command to run files: Optional[Files] = None score: Optional[int] = 0 - parsers: list[str] # list of parsers + parsers: Optional[list[str]] = [] # list of parsers limit: Optional[Limit] = None dummy: Optional[ParserDummy] = ParserDummy() result_status: Optional[ParserDummy] = Field(ParserDummy(), alias="result-status") @@ -52,6 +63,20 @@ class Stage(BaseModel): result_detail: Optional[ParserResultDetail] = Field( ParserResultDetail(), alias="result-detail" ) + skip: Optional[list[str]] = [] + diff: Optional[ParserDiff] = ParserDiff() + cases: Optional[Dict[str, "Stage"]] = {} + + class Config: + extra = "allow" + + @root_validator(pre=True) + def gather_cases(cls: Type["Stage"], values: Dict[str, Any]) -> Dict[str, Any]: + cases = {k: v for k, v in values.items() if k.startswith("case")} + for key in cases: + values.pop(key) + values["cases"] = {k: Stage(**v) for k, v in cases.items()} + return values class Release(BaseModel): diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index f6f5ea7..d80e014 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "Homework 1 exercise 2", - "logPath": "Homework-1-exercise-2.log", + "name": "h4 ex1", + "logPath": "h4-ex1.log", "expireUnixTimestamp": 1728748740, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f932c5e31a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-9z61g608/repo-health-checker": { - "src": "//tmp/repo-checker-19d98f6u/repo-health-checker", + "//tmp/repo-checker-tw0902sa/repo-health-checker": { + "src": "//tmp/repo-checker-4sy3g0ro/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -234,11 +234,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -379,11 +374,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": false, - "stderr": true, - "exitstatus": false, "score": 0, "comment": "", "showFiles": [ @@ -571,11 +561,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": true, - "stderr": false, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -713,11 +698,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -820,11 +800,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": true, - "stderr": false, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -921,11 +896,6 @@ { "name": "result-detail", "with": { - "time": true, - "mem": true, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -1022,11 +992,6 @@ { "name": "result-detail", "with": { - "time": true, - "mem": true, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -1042,9 +1007,9 @@ ] }, "teapot": { - "logPath": "Homework-1-exercise-2-joint-teapot-debug.log", - "scoreboardPath": "Homework-1-exercise-2-scoreboard.csv", - "failedTablePath": "Homework-1-exercise-2-failed-table.md", + "logPath": "h4-ex1-joint-teapot-debug.log", + "scoreboardPath": "h4-ex1-scoreboard.csv", + "failedTablePath": "h4-ex1-failed-table.md", "gradingRepoName": "engr151-joj", "skipIssue": false, "skipScoreboard": false, diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 48dfd07..ec4cdfc 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,5 +1,5 @@ # general task configuration -task="Homework 1 exercise 2" # task name +task="h4 ex1" # task name release.deadline = 2024-10-12 23:59:00+08:00 release.stages = [ "compile" ] -- 2.30.2 From eefb687c91830d8d4924ffb4a2c78d01b3bbbc68 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:00:46 +0800 Subject: [PATCH 009/131] ffeat: diff finish --- joj3_config_generator/convert.py | 1 - joj3_config_generator/lib/task.py | 69 ++++++ joj3_config_generator/models/task.py | 2 +- tests/convert/basic/task.json | 324 ++++++++++++++++++++++++++- 4 files changed, 387 insertions(+), 9 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index b4b1ebc..fafe2bc 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -71,7 +71,6 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: conf_stage = fix_result_detail(task_stage, conf_stage) conf_stage = fix_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) - # TODO: fix diff parser here 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 d8d2f78..35aa92b 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,5 +1,6 @@ import rtoml +from joj3_config_generator.models.result import CmdFile, OptionalCmd from joj3_config_generator.models.result import Stage as ResultStage from joj3_config_generator.models.task import Stage as TaskStage @@ -78,5 +79,73 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + if task_stage.parsers is not None and "diff" in task_stage.parsers: + diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) + skip = task_stage.skip or [] + cases = task_stage.cases or {} + finalized_cases = [case for case in cases if case not in skip] + + stage_cases = [] + parser_cases = [] + + for case in finalized_cases: + case_stage = task_stage.cases.get(case) if task_stage.cases else None + if not case_stage: + continue + + # Ensure case_stage.limit is defined before accessing .cpu and .mem + cpu_limit = ( + case_stage.limit.cpu * 1_000_000_000 + if case_stage.limit and case_stage.limit.cpu is not None + else 0 + ) + clock_limit = ( + 2 * case_stage.limit.cpu * 1_000_000_000 + if case_stage.limit and case_stage.limit.cpu is not None + else 0 + ) + memory_limit = ( + case_stage.limit.mem * 1_024 * 1_024 + if case_stage.limit and case_stage.limit.mem is not None + else 0 + ) + + stage_cases.append( + OptionalCmd( + stdin=CmdFile( + src=f"/home/tt/.config/joj/{conf_stage.name}/{case}.in" + ), + cpu_limit=cpu_limit, + clock_limit=clock_limit, + memory_limit=memory_limit, + proc_limit=50, + ) + ) + + # Ensure case_stage.diff and case_stage.diff.output are defined + diff_output = ( + case_stage.diff.output + if case_stage.diff and case_stage.diff.output + else None + ) + if diff_output: + parser_cases.append( + { + "outputs": [ + { + "score": diff_output.score, + "fileName": "stdout", + "answerPath": f"/home/tt/.config/joj/{conf_stage.name}/{case}.out", + "forceQuitOnDiff": diff_output.forcequit, + "alwaysHide": diff_output.hide, + "compareSpace": not diff_output.ignorespaces, + } + ] + } + ) + + if diff_parser and task_stage.diff is not None: + diff_parser.with_.update({"name": "diff", "cases": parser_cases}) + conf_stage.executor.with_.cases = stage_cases return conf_stage diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index d5eefac..cccad8d 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -51,7 +51,7 @@ class Stage(BaseModel): files: Optional[Files] = None score: Optional[int] = 0 parsers: Optional[list[str]] = [] # list of parsers - limit: Optional[Limit] = None + limit: Optional[Limit] = Limit() dummy: Optional[ParserDummy] = ParserDummy() result_status: Optional[ParserDummy] = Field(ParserDummy(), alias="result-status") keyword: Optional[ParserKeyword] = ParserKeyword() diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index d80e014..793bc48 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f67094f3240>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-tw0902sa/repo-health-checker": { - "src": "//tmp/repo-checker-4sy3g0ro/repo-health-checker", + "//tmp/repo-checker-9gy9931v/repo-health-checker": { + "src": "//tmp/repo-checker-kjnt9uw0/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -879,13 +879,168 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [] + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case8.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] } }, "parsers": [ { "name": "diff", - "with": {} + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case8.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + } + ] + } }, { "name": "dummy", @@ -975,13 +1130,168 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [] + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case6.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] } }, "parsers": [ { "name": "diff", - "with": {} + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", + "forceQuitOnDiff": true, + "alwaysHide": true, + "compareSpace": true + } + ] + } + ] + } }, { "name": "dummy", -- 2.30.2 From 1ada79695450b10aef115f7d76bbdccfaeda636b Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:28:29 +0800 Subject: [PATCH 010/131] chore: more compact code --- joj3_config_generator/convert.py | 27 ++------ joj3_config_generator/lib/task.py | 104 +++++++++++++++++++++++++++++- tests/convert/basic/task.json | 50 +++++++------- 3 files changed, 133 insertions(+), 48 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index fafe2bc..10f7e84 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -7,6 +7,8 @@ from joj3_config_generator.lib.task import ( fix_diff, fix_keyword, fix_result_detail, + get_conf_stage, + get_executorWithConfig, ) from joj3_config_generator.models import ( Cmd, @@ -44,30 +46,11 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Construct healthcheck stage healthcheck_stage = getHealthcheckConfig(repo_conf, task_conf) result_conf.stage.stages.append(healthcheck_stage) - cached = [] + cached: list[str] = [] # Convert each stage in the task configuration for task_stage in task_conf.stages: - executor_with_config = result.ExecutorWith( - default=result.Cmd( - args=task_stage.command.split(), - copy_in={ - file: result.CmdFile(src=file) for file in task_stage.files.import_ - }, - copy_out_cached=task_stage.files.export, - ), - cases=[], # You can add cases if needed - ) - conf_stage = result.StageDetail( - name=task_stage.name, - group=task_conf.task, - executor=result.Executor( - name="sandbox", - with_=executor_with_config, - ), - parsers=[ - result.Parser(name=parser, with_={}) for parser in task_stage.parsers - ], - ) + 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_keyword(task_stage, conf_stage) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 35aa92b..6ff56d7 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,10 +1,112 @@ +from typing import Tuple + import rtoml -from joj3_config_generator.models.result import CmdFile, OptionalCmd +from joj3_config_generator.models import ( + ExecutorConfig, + ExecutorWithConfig, + ParserConfig, +) +from joj3_config_generator.models.result import Cmd, CmdFile, OptionalCmd from joj3_config_generator.models.result import Stage as ResultStage from joj3_config_generator.models.task import Stage as TaskStage +def get_conf_stage( + task_stage: TaskStage, executor_with_config: ExecutorWithConfig +) -> ResultStage: + conf_stage = ResultStage( + name=task_stage.name if task_stage.name is not None else "", + # TODO: we may have cq in future + group=( + "joj" + if (task_stage.name is not None) and ("judge" in task_stage.name) + else None + ), + executor=ExecutorConfig( + name="sandbox", + with_=executor_with_config, + ), + parsers=( + [ParserConfig(name=parser, with_={}) for parser in task_stage.parsers] + if task_stage.parsers is not None + else [] + ), + ) + return conf_stage + + +def get_executorWithConfig( + task_stage: TaskStage, cached: list[str] +) -> Tuple[ExecutorWithConfig, list[str]]: + file_import = ( + task_stage.files.import_ + if hasattr(task_stage, "files") + and hasattr(task_stage.files, "import_") + and (task_stage.files is not None) + and (task_stage.files.import_ is not None) + else [] + ) + copy_in_files = [file for file in file_import if (file not in cached)] + file_export = ( + task_stage.files.export + if hasattr(task_stage, "files") + and hasattr(task_stage.files, "export") + and (task_stage.files is not None) + else [] + ) + executor_with_config = ExecutorWithConfig( + default=Cmd( + args=(task_stage.command.split() if task_stage.command is not None else []), + copy_in={ + file: CmdFile(src=f"/home/tt/.config/joj/{file}") + for file in copy_in_files + }, + copy_in_cached={file: file for file in copy_in_files}, + copy_out_cached=file_export if file_export is not None else [], + cpu_limit=( + task_stage.limit.cpu * 1_000_000_000 + if task_stage.limit is not None and task_stage.limit.cpu is not None + else 4 * 1_000_000_000 + ), + clock_limit=( + 2 * task_stage.limit.cpu * 1_000_000_000 + if task_stage.limit is not None and task_stage.limit.cpu is not None + else 8 * 1_000_000_000 + ), + memory_limit=( + task_stage.limit.mem * 1_024 * 1_024 + if task_stage.limit is not None and task_stage.limit.mem is not None + else 4 * 1_024 * 1_024 + ), + stderr=CmdFile( + name="stderr", + max=( + task_stage.limit.stderr * 1_000_000_000 + if task_stage.limit is not None + and task_stage.limit.stderr is not None + else 4 * 1_024 * 1_024 + ), + ), + stdout=CmdFile( + name="stdout", + max=( + task_stage.limit.stdout * 1_000_000_000 + if task_stage.limit is not None + and task_stage.limit.stdout is not None + else 4 * 1_024 * 1_024 + ), + ), + ), + cases=[], # You can add cases if needed + ) + if file_export is not None: + for file in file_export: + if file not in cached: + cached.append(file) + return (executor_with_config, cached) + + def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: keyword_parser = ["clangtidy", "keyword", "cppcheck"] # TODO: may add cpplint if task_stage.parsers is not None: diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 793bc48..0cc5ccf 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7fc2485231a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-9gy9931v/repo-health-checker": { - "src": "//tmp/repo-checker-kjnt9uw0/repo-health-checker", + "//tmp/repo-checker-5xkj4dm4/repo-health-checker": { + "src": "//tmp/repo-checker-k3fmck15/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -136,7 +136,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -147,15 +147,15 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 128000000000, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 180000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, + "clockLimit": 360000000000, "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, @@ -291,7 +291,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -302,7 +302,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -420,7 +420,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 65000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -431,7 +431,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -611,7 +611,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -622,7 +622,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 65000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -744,7 +744,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 65000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -755,7 +755,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -842,7 +842,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -853,16 +853,16 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 3000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 6000000000, + "memoryLimit": 78643200, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -1093,7 +1093,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -1104,16 +1104,16 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 10000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 20000000000, + "memoryLimit": 524288000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, -- 2.30.2 From 17697d7e353b28b73378438c85dd15214f52c630 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:43:43 +0800 Subject: [PATCH 011/131] fix: gradingreponame schema --- joj3_config_generator/lib/repo.py | 11 +++-------- tests/convert/basic/task.json | 8 ++++---- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index e9a8d33..1c39a0c 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -1,5 +1,5 @@ import hashlib -import os +import socket import tempfile from dotenv import load_dotenv @@ -24,13 +24,8 @@ def get_temp_directory() -> str: def getGradingRepoName() -> str: - path = os.path.expanduser("~/.config/teapot/teapot.env") - if os.path.exists(path): - load_dotenv(path) - repo_name = os.environ.get("GITEA_ORG_NAME") - if repo_name is not None: - return f"{repo_name.split('-')[0]}-joj" - return "ece482-joj" + host_name = socket.gethostname() + return f"{host_name.split('-')[0]}-joj" def getTeapotConfig(repo_conf: Repo, task_conf: Task) -> TeapotConfig: diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 0cc5ccf..4ffc375 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7fc3921ab1a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-5xkj4dm4/repo-health-checker": { - "src": "//tmp/repo-checker-k3fmck15/repo-health-checker", + "//tmp/repo-checker-u3awlhwg/repo-health-checker": { + "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -1320,7 +1320,7 @@ "logPath": "h4-ex1-joint-teapot-debug.log", "scoreboardPath": "h4-ex1-scoreboard.csv", "failedTablePath": "h4-ex1-failed-table.md", - "gradingRepoName": "engr151-joj", + "gradingRepoName": "Nuvole-joj", "skipIssue": false, "skipScoreboard": false, "skipFailedTable": false -- 2.30.2 From d62511b3c2193eb341926cf17e043227b67291a7 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:46:30 +0800 Subject: [PATCH 012/131] fix: remove dotenv --- joj3_config_generator/lib/repo.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index 1c39a0c..cb679c4 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -2,8 +2,6 @@ import hashlib import socket import tempfile -from dotenv import load_dotenv - from joj3_config_generator.models import ( Cmd, CmdFile, -- 2.30.2 From 9cb1839e913650f286b0225f88d4b84c5bfdfcac Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:53:42 +0800 Subject: [PATCH 013/131] fix: immutable_file --- tests/immutable_file/.gitattributes | 33 ----------------------------- tests/immutable_file/.gitignore | 23 -------------------- tests/immutable_file/push.yaml | 18 ---------------- tests/immutable_file/release.yaml | 20 ----------------- 4 files changed, 94 deletions(-) delete mode 100644 tests/immutable_file/.gitattributes delete mode 100644 tests/immutable_file/.gitignore delete mode 100644 tests/immutable_file/push.yaml delete mode 100644 tests/immutable_file/release.yaml diff --git a/tests/immutable_file/.gitattributes b/tests/immutable_file/.gitattributes deleted file mode 100644 index b910c4a..0000000 --- a/tests/immutable_file/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -*.avi filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.djvu filter=lfs diff=lfs merge=lfs -text -*.doc filter=lfs diff=lfs merge=lfs -text -*.docx filter=lfs diff=lfs merge=lfs -text -*.epub filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.ipynb filter=lfs diff=lfs merge=lfs -text -*.jpeg filter=lfs diff=lfs merge=lfs -text -*.JPEG filter=lfs diff=lfs merge=lfs -text -*.jpg filter=lfs diff=lfs merge=lfs -text -*.JPG filter=lfs diff=lfs merge=lfs -text -*.mkv filter=lfs diff=lfs merge=lfs -text -*.mp4 filter=lfs diff=lfs merge=lfs -text -*.ods filter=lfs diff=lfs merge=lfs -text -*.odt filter=lfs diff=lfs merge=lfs -text -*.otf filter=lfs diff=lfs merge=lfs -text -*.pdf filter=lfs diff=lfs merge=lfs -text -*.PDF filter=lfs diff=lfs merge=lfs -text -*.png filter=lfs diff=lfs merge=lfs -text -*.PNG filter=lfs diff=lfs merge=lfs -text -*.ppt filter=lfs diff=lfs merge=lfs -text -*.pptx filter=lfs diff=lfs merge=lfs -text -*.ps filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text -*.tar filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.ttf filter=lfs diff=lfs merge=lfs -text -*.webm filter=lfs diff=lfs merge=lfs -text -*.xls filter=lfs diff=lfs merge=lfs -text -*.xlsx filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_file/.gitignore b/tests/immutable_file/.gitignore deleted file mode 100644 index 754f776..0000000 --- a/tests/immutable_file/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -################################ -## White list based gitignore ## -################################ - -# forbidden -* -.* - -# allowed -!.gitignore -!.gitattributes -!.gitea/ -!.gitea/issue_template/ -!.gitea/workflows/ -!*.yaml -!Makefile -!CMakeLists.txt -!h[0-8]/ -!*.m -!*.c -!*.cpp -!*.h -!*.md diff --git a/tests/immutable_file/push.yaml b/tests/immutable_file/push.yaml deleted file mode 100644 index 2f890b6..0000000 --- a/tests/immutable_file/push.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: Run JOJ3 on Push -on: [push] -jobs: - run: - container: - image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim - volumes: - - /home/tt/.config:/home/tt/.config - - /home/tt/.cache:/home/tt/.cache - - /home/tt/.ssh:/home/tt/.ssh - steps: - - name: Check out repository code - uses: https://gitea.com/BoYanZh/checkout@focs - with: - fetch-depth: 0 - - name: run joj3 - run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml deleted file mode 100644 index afd2838..0000000 --- a/tests/immutable_file/release.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: Run JOJ3 on Release -on: - release: - types: [published] -jobs: - run: - container: - image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim - volumes: - - /home/tt/.config:/home/tt/.config - - /home/tt/.cache:/home/tt/.cache - - /home/tt/.ssh:/home/tt/.ssh - steps: - - name: Check out repository code - uses: https://gitea.com/BoYanZh/checkout@focs - with: - fetch-depth: 0 - - name: run joj3 - run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj -msg "feat(h1-release): joj on ${{ github.ref }}" -- 2.30.2 From dcb15ef92c0a432783d082539c871aeb2904243b Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:56:11 +0800 Subject: [PATCH 014/131] fix: immutable repo tom --- tests/convert/basic/repo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index c77b9f7..28b5c05 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -7,4 +7,4 @@ sandbox_token = "test" whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" required = ["main.py", "README.md"] -immutable = [".gitignore", ".gitattributes", "push.yaml", "release.yaml"] +immutable = [] -- 2.30.2 From 4a08eb6a51d268d899e43263348aec835420fae2 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:59:25 +0800 Subject: [PATCH 015/131] feat: rebuild json --- tests/convert/basic/task.json | 1328 --------------------------------- 1 file changed, 1328 deletions(-) delete mode 100644 tests/convert/basic/task.json diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json deleted file mode 100644 index 4ffc375..0000000 --- a/tests/convert/basic/task.json +++ /dev/null @@ -1,1328 +0,0 @@ -{ - "name": "h4 ex1", - "logPath": "h4-ex1.log", - "expireUnixTimestamp": 1728748740, - "stage": { - "sandboxExecServer": "172.17.0.1:5051", - "sandboxToken": "test", - "outputPath": "/tmp/joj3_result.json", - "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "//repo-health-checker", - "-root=.", - "-repoSize=50.5", - "-meta=main.py", - "-meta=README.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", - "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4096, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4096, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "//tmp/repo-checker-u3awlhwg/repo-health-checker": { - "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "healthcheck", - "with": { - "score": 0, - "comment": "" - } - } - ] - }, - { - "name": "Compilation", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "make.sh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 128000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 180000000000, - "realCpuLimit": 0, - "clockLimit": 360000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/make.sh": { - "src": "/home/tt/.config/joj/tools/make.sh", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/main.c": { - "src": "/home/tt/.config/joj/src/main.c", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/task.h": { - "src": "/home/tt/.config/joj/src/task.h", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "srcCMakelist.txt": { - "src": "/home/tt/.config/joj/srcCMakelist.txt", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/make.sh": "tools/make.sh", - "src/main.c": "src/main.c", - "src/task.h": "src/task.h", - "srcCMakelist.txt": "srcCMakelist.txt" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [ - "driver", - "p2", - "p2-msan" - ], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-status", - "with": { - "comment": "Congratulations! Your code compiled successfully." - } - } - ] - }, - { - "name": "File length check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./file-length", - "500", - "400", - "*.c", - "*.h" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/file-length": { - "src": "/home/tt/.config/joj/tools/file-length", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/file-length": "tools/file-length" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "keyword", - "with": { - "match": [ - { - "keyword": [ - "max" - ], - "score": 50 - }, - { - "keyword": [ - "recommend" - ], - "score": 20 - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": false, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Clang-tidy checks", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "run-clang-tidy-18", - "-header-filter=.*", - "-quiet", - "-load=/usr/local/lib/libcodequality.so", - "-p", - "build" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "clangtidy", - "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": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Cppcheck check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cppcheck", - "--template='{\"file\":\"{file}\",\"line\":{line},", - "\"column\":{column},", - "\"severity\":\"{severity}\",", - "\"message\":\"{message}\",", - "\"id\":\"{id}\"}'", - "--force", - "--enable=all", - "--quiet", - "./" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cppcheck", - "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": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Cpplint check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cpplint", - "--linelength=120", - "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", - "--recursive", - "--exclude=build", - "." - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cpplint", - "with": { - "comment": "" - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "judge-base", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 3000000000, - "realCpuLimit": 0, - "clockLimit": 6000000000, - "memoryLimit": 78643200, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case8.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case8.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "judge-msan", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh-msan" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 10000000000, - "realCpuLimit": 0, - "clockLimit": 20000000000, - "memoryLimit": 524288000, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case6.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", - "forceQuitOnDiff": true, - "alwaysHide": true, - "compareSpace": true - } - ] - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - } - ] - }, - "teapot": { - "logPath": "h4-ex1-joint-teapot-debug.log", - "scoreboardPath": "h4-ex1-scoreboard.csv", - "failedTablePath": "h4-ex1-failed-table.md", - "gradingRepoName": "Nuvole-joj", - "skipIssue": false, - "skipScoreboard": false, - "skipFailedTable": false - } -} -- 2.30.2 From 9c853ac35424e795c24ad0175831d35f1d30714c Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 16:01:38 +0800 Subject: [PATCH 016/131] feat: sync --- tests/convert/basic/task.json | 1328 +++++++++++++++++++++++++++ tests/immutable_file/.gitattributes | 33 + tests/immutable_file/.gitignore | 23 + tests/immutable_file/push.yaml | 18 + tests/immutable_file/release.yaml | 20 + 5 files changed, 1422 insertions(+) create mode 100644 tests/convert/basic/task.json create mode 100644 tests/immutable_file/.gitattributes create mode 100644 tests/immutable_file/.gitignore create mode 100644 tests/immutable_file/push.yaml create mode 100644 tests/immutable_file/release.yaml diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json new file mode 100644 index 0000000..4ffc375 --- /dev/null +++ b/tests/convert/basic/task.json @@ -0,0 +1,1328 @@ +{ + "name": "h4 ex1", + "logPath": "h4-ex1.log", + "expireUnixTimestamp": 1728748740, + "stage": { + "sandboxExecServer": "172.17.0.1:5051", + "sandboxToken": "test", + "outputPath": "/tmp/joj3_result.json", + "stages": [ + { + "name": "healthcheck", + "group": "", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "//repo-health-checker", + "-root=.", + "-repoSize=50.5", + "-meta=main.py", + "-meta=README.md", + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", + "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "//tmp/repo-checker-u3awlhwg/repo-health-checker": { + "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 0, + "comment": "" + } + } + ] + }, + { + "name": "Compilation", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "make.sh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 128000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 180000000000, + "realCpuLimit": 0, + "clockLimit": 360000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/make.sh": { + "src": "/home/tt/.config/joj/tools/make.sh", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/main.c": { + "src": "/home/tt/.config/joj/src/main.c", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/task.h": { + "src": "/home/tt/.config/joj/src/task.h", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "srcCMakelist.txt": { + "src": "/home/tt/.config/joj/srcCMakelist.txt", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/make.sh": "tools/make.sh", + "src/main.c": "src/main.c", + "src/task.h": "src/task.h", + "srcCMakelist.txt": "srcCMakelist.txt" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [ + "driver", + "p2", + "p2-msan" + ], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-status", + "with": { + "comment": "Congratulations! Your code compiled successfully." + } + } + ] + }, + { + "name": "File length check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./file-length", + "500", + "400", + "*.c", + "*.h" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/file-length": { + "src": "/home/tt/.config/joj/tools/file-length", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/file-length": "tools/file-length" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "keyword", + "with": { + "match": [ + { + "keyword": [ + "max" + ], + "score": 50 + }, + { + "keyword": [ + "recommend" + ], + "score": 20 + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": false, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Clang-tidy checks", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "run-clang-tidy-18", + "-header-filter=.*", + "-quiet", + "-load=/usr/local/lib/libcodequality.so", + "-p", + "build" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "clangtidy", + "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": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Cppcheck check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cppcheck", + "--template='{\"file\":\"{file}\",\"line\":{line},", + "\"column\":{column},", + "\"severity\":\"{severity}\",", + "\"message\":\"{message}\",", + "\"id\":\"{id}\"}'", + "--force", + "--enable=all", + "--quiet", + "./" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cppcheck", + "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": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Cpplint check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cpplint", + "--linelength=120", + "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", + "--recursive", + "--exclude=build", + "." + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cpplint", + "with": { + "comment": "" + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "judge-base", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 3000000000, + "realCpuLimit": 0, + "clockLimit": 6000000000, + "memoryLimit": 78643200, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case8.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case8.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "judge-msan", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh-msan" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 10000000000, + "realCpuLimit": 0, + "clockLimit": 20000000000, + "memoryLimit": 524288000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case6.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", + "forceQuitOnDiff": true, + "alwaysHide": true, + "compareSpace": true + } + ] + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + } + ] + }, + "teapot": { + "logPath": "h4-ex1-joint-teapot-debug.log", + "scoreboardPath": "h4-ex1-scoreboard.csv", + "failedTablePath": "h4-ex1-failed-table.md", + "gradingRepoName": "Nuvole-joj", + "skipIssue": false, + "skipScoreboard": false, + "skipFailedTable": false + } +} diff --git a/tests/immutable_file/.gitattributes b/tests/immutable_file/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/immutable_file/.gitattributes @@ -0,0 +1,33 @@ +*.avi filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.djvu filter=lfs diff=lfs merge=lfs -text +*.doc filter=lfs diff=lfs merge=lfs -text +*.docx filter=lfs diff=lfs merge=lfs -text +*.epub filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.ipynb filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.JPEG filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.JPG filter=lfs diff=lfs merge=lfs -text +*.mkv filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.ods filter=lfs diff=lfs merge=lfs -text +*.odt filter=lfs diff=lfs merge=lfs -text +*.otf filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.PDF filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.PNG filter=lfs diff=lfs merge=lfs -text +*.ppt filter=lfs diff=lfs merge=lfs -text +*.pptx filter=lfs diff=lfs merge=lfs -text +*.ps filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text +*.xls filter=lfs diff=lfs merge=lfs -text +*.xlsx filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_file/.gitignore b/tests/immutable_file/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/immutable_file/.gitignore @@ -0,0 +1,23 @@ +################################ +## White list based gitignore ## +################################ + +# forbidden +* +.* + +# allowed +!.gitignore +!.gitattributes +!.gitea/ +!.gitea/issue_template/ +!.gitea/workflows/ +!*.yaml +!Makefile +!CMakeLists.txt +!h[0-8]/ +!*.m +!*.c +!*.cpp +!*.h +!*.md diff --git a/tests/immutable_file/push.yaml b/tests/immutable_file/push.yaml new file mode 100644 index 0000000..2f890b6 --- /dev/null +++ b/tests/immutable_file/push.yaml @@ -0,0 +1,18 @@ +name: Run JOJ3 on Push +on: [push] +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml new file mode 100644 index 0000000..afd2838 --- /dev/null +++ b/tests/immutable_file/release.yaml @@ -0,0 +1,20 @@ +name: Run JOJ3 on Release +on: + release: + types: [published] +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj -msg "feat(h1-release): joj on ${{ github.ref }}" -- 2.30.2 From 5fc617e797033ea3cf58b7e2ed4d754040d11443 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 11:13:56 +0800 Subject: [PATCH 017/131] feat: sync --- tests/convert/basic/task.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 4ffc375..c15b691 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,13 +18,12 @@ "//repo-health-checker", + "0x7f64f5d532e0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", "-meta=README.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", - "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" + "-checkFileSumList=-checkFileNameList=" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -71,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-u3awlhwg/repo-health-checker": { - "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", + "//tmp/repo-checker-lf3ranpy/repo-health-checker": { + "src": "//tmp/repo-checker-gd58j2qv/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From f0f1a485b7ade5cee05841e30a650a5c9eab80a5 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 22:46:46 +0800 Subject: [PATCH 018/131] feat: rebase with master --- joj3_config_generator/convert.py | 18 +-------- joj3_config_generator/lib/__init__.py | 11 ------ joj3_config_generator/lib/repo.py | 36 +++++++---------- joj3_config_generator/lib/task.py | 53 +++++++++++++------------- joj3_config_generator/models/result.py | 2 +- joj3_config_generator/models/task.py | 9 +++-- tests/convert/basic/task.json | 6 +-- 7 files changed, 50 insertions(+), 85 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 10f7e84..ce0677f 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,6 +1,5 @@ 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_comment, @@ -10,19 +9,7 @@ from joj3_config_generator.lib.task import ( get_conf_stage, get_executorWithConfig, ) -from joj3_config_generator.models import ( - Cmd, - CmdFile, - ExecutorConfig, - ExecutorWithConfig, - ParserConfig, - Repo, - ResultConfig, - Stage, - StageConfig, - Task, - TeapotConfig, -) +from joj3_config_generator.models import joj1, repo, result, task # FIXME: LLM generated convert function, only for demostration @@ -38,8 +25,6 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: else -1 ), stage=result.Stage(stages=[], sandbox_token=repo_conf.sandbox_token), - teapot=result.Teapot(), - stage=StageConfig(stages=[], sandbox_token=repo_conf.sandbox_token), teapot=getTeapotConfig(repo_conf, task_conf), ) @@ -84,7 +69,6 @@ def convert_joj1(joj1_conf: joj1.Config) -> task.Config: files=files, score=score, parsers=parsers, - result_detail=task.ParserResultDetail(), # You can customize this further if needed ) ) # Assuming no deadline is provided in `joj1`, you can set it accordingly diff --git a/joj3_config_generator/lib/__init__.py b/joj3_config_generator/lib/__init__.py index 68802d4..e69de29 100644 --- a/joj3_config_generator/lib/__init__.py +++ b/joj3_config_generator/lib/__init__.py @@ -1,11 +0,0 @@ -from joj3_config_generator.models.repo import Repo as Repo -from joj3_config_generator.models.result import Cmd as Cmd -from joj3_config_generator.models.result import CmdFile as CmdFile -from joj3_config_generator.models.result import ExecutorConfig as ExecutorConfig -from joj3_config_generator.models.result import ExecutorWithConfig as ExecutorWithConfig -from joj3_config_generator.models.result import ParserConfig as ParserConfig -from joj3_config_generator.models.result import ResultConfig as ResultConfig -from joj3_config_generator.models.result import Stage as Stage -from joj3_config_generator.models.result import StageConfig as StageConfig -from joj3_config_generator.models.result import TeapotConfig as TeapotConfig -from joj3_config_generator.models.task import Task as Task diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index cb679c4..8c17ee1 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -2,19 +2,7 @@ import hashlib import socket import tempfile -from joj3_config_generator.models import ( - Cmd, - CmdFile, - ExecutorConfig, - ExecutorWithConfig, - ParserConfig, - Repo, - ResultConfig, - Stage, - StageConfig, - Task, - TeapotConfig, -) +from joj3_config_generator.models import joj1, repo, result, task def get_temp_directory() -> str: @@ -26,8 +14,8 @@ def getGradingRepoName() -> str: return f"{host_name.split('-')[0]}-joj" -def getTeapotConfig(repo_conf: Repo, task_conf: Task) -> TeapotConfig: - teapot = TeapotConfig( +def getTeapotConfig(repo_conf: repo.Config, task_conf: task.Config) -> result.Teapot: + teapot = result.Teapot( # TODO: fix the log path log_path=f"{task_conf.task.replace(' ', '-')}-joint-teapot-debug.log", scoreboard_path=f"{task_conf.task.replace(' ', '-')}-scoreboard.csv", @@ -37,7 +25,7 @@ def getTeapotConfig(repo_conf: Repo, task_conf: Task) -> TeapotConfig: return teapot -def getHealthcheckCmd(repo_conf: Repo) -> Cmd: +def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: repoSize = repo_conf.max_size immutable = repo_conf.files.immutable repo_size = f"-repoSize={str(repoSize)} " @@ -64,11 +52,11 @@ def getHealthcheckCmd(repo_conf: Repo) -> Cmd: args = args + immutable_files - cmd = Cmd( + cmd = result.Cmd( args=args.split(), # FIXME: easier to edit within global scope copy_in={ - f"/{get_temp_directory()}/repo-health-checker": CmdFile( + f"/{get_temp_directory()}/repo-health-checker": result.CmdFile( src=f"/{get_temp_directory()}/repo-health-checker" ) }, @@ -76,15 +64,17 @@ def getHealthcheckCmd(repo_conf: Repo) -> Cmd: return cmd -def getHealthcheckConfig(repo_conf: Repo, task_conf: Task) -> Stage: - healthcheck_stage = Stage( +def getHealthcheckConfig( + repo_conf: repo.Config, task_conf: task.Config +) -> result.StageDetail: + healthcheck_stage = result.StageDetail( name="healthcheck", group="", - executor=ExecutorConfig( + executor=result.Executor( name="sandbox", - with_=ExecutorWithConfig(default=getHealthcheckCmd(repo_conf), cases=[]), + with_=result.ExecutorWith(default=getHealthcheckCmd(repo_conf), cases=[]), ), - parsers=[ParserConfig(name="healthcheck", with_={"score": 0, "comment": ""})], + parsers=[result.Parser(name="healthcheck", with_={"score": 0, "comment": ""})], ) return healthcheck_stage diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 6ff56d7..7a29cf7 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -2,20 +2,13 @@ from typing import Tuple import rtoml -from joj3_config_generator.models import ( - ExecutorConfig, - ExecutorWithConfig, - ParserConfig, -) -from joj3_config_generator.models.result import Cmd, CmdFile, OptionalCmd -from joj3_config_generator.models.result import Stage as ResultStage -from joj3_config_generator.models.task import Stage as TaskStage +from joj3_config_generator.models import joj1, repo, result, task def get_conf_stage( - task_stage: TaskStage, executor_with_config: ExecutorWithConfig -) -> ResultStage: - conf_stage = ResultStage( + task_stage: task.Stage, executor_with_config: result.ExecutorWith +) -> result.StageDetail: + conf_stage = result.StageDetail( name=task_stage.name if task_stage.name is not None else "", # TODO: we may have cq in future group=( @@ -23,12 +16,12 @@ def get_conf_stage( if (task_stage.name is not None) and ("judge" in task_stage.name) else None ), - executor=ExecutorConfig( + executor=result.Executor( name="sandbox", with_=executor_with_config, ), parsers=( - [ParserConfig(name=parser, with_={}) for parser in task_stage.parsers] + [result.Parser(name=parser, with_={}) for parser in task_stage.parsers] if task_stage.parsers is not None else [] ), @@ -37,8 +30,8 @@ def get_conf_stage( def get_executorWithConfig( - task_stage: TaskStage, cached: list[str] -) -> Tuple[ExecutorWithConfig, list[str]]: + task_stage: task.Stage, cached: list[str] +) -> Tuple[result.ExecutorWith, list[str]]: file_import = ( task_stage.files.import_ if hasattr(task_stage, "files") @@ -55,11 +48,11 @@ def get_executorWithConfig( and (task_stage.files is not None) else [] ) - executor_with_config = ExecutorWithConfig( - default=Cmd( + executor_with_config = result.ExecutorWith( + default=result.Cmd( args=(task_stage.command.split() if task_stage.command is not None else []), copy_in={ - file: CmdFile(src=f"/home/tt/.config/joj/{file}") + file: result.CmdFile(src=f"/home/tt/.config/joj/{file}") for file in copy_in_files }, copy_in_cached={file: file for file in copy_in_files}, @@ -79,7 +72,7 @@ def get_executorWithConfig( if task_stage.limit is not None and task_stage.limit.mem is not None else 4 * 1_024 * 1_024 ), - stderr=CmdFile( + stderr=result.CmdFile( name="stderr", max=( task_stage.limit.stderr * 1_000_000_000 @@ -88,7 +81,7 @@ def get_executorWithConfig( else 4 * 1_024 * 1_024 ), ), - stdout=CmdFile( + stdout=result.CmdFile( name="stdout", max=( task_stage.limit.stdout * 1_000_000_000 @@ -107,7 +100,9 @@ def get_executorWithConfig( return (executor_with_config, cached) -def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: +def fix_keyword( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: keyword_parser = ["clangtidy", "keyword", "cppcheck"] # TODO: may add cpplint if task_stage.parsers is not None: for parser in task_stage.parsers: @@ -128,7 +123,9 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: return conf_stage -def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: +def fix_result_detail( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: if (task_stage.parsers is not None) and ("result-detail" in task_stage.parsers): result_detail_parser = next( p for p in conf_stage.parsers if p.name == "result-detail" @@ -159,7 +156,9 @@ def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultS return conf_stage -def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: +def fix_comment( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: comment_parser = [ "dummy", "result-status", @@ -180,7 +179,9 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: return conf_stage -def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: +def fix_diff( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: if task_stage.parsers is not None and "diff" in task_stage.parsers: diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) skip = task_stage.skip or [] @@ -213,8 +214,8 @@ def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: ) stage_cases.append( - OptionalCmd( - stdin=CmdFile( + result.OptionalCmd( + stdin=result.CmdFile( src=f"/home/tt/.config/joj/{conf_stage.name}/{case}.in" ), cpu_limit=cpu_limit, diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index 1f4579e..42c3b15 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -98,7 +98,7 @@ class Parser(BaseModel): class StageDetail(BaseModel): name: str - group: str + group: Optional[str] = "" executor: Executor parsers: List[Parser] diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index cccad8d..077991a 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Dict, Optional, Type, List +from typing import Any, Dict, List, Optional, Type from pydantic import BaseModel, Field, root_validator @@ -33,9 +33,10 @@ class ParserDiff(BaseModel): class Files(BaseModel): - import_: Optional[List[str]] = Field(serialization_alias="import", validation_alias="import") - export: Optional[List[str]] - + import_: Optional[List[str]] = Field( + [], serialization_alias="import", validation_alias="import" + ) + export: Optional[List[str]] = [] class Limit(BaseModel): diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index c15b691..9ac998d 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f19f8920180>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-lf3ranpy/repo-health-checker": { - "src": "//tmp/repo-checker-gd58j2qv/repo-health-checker", + "//tmp/repo-checker-5txkd_qm/repo-health-checker": { + "src": "//tmp/repo-checker-i9n16_cy/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From a4b32a53cb3d20d5bc31038d7e35c68c5ce37de0 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 18:53:41 +0800 Subject: [PATCH 019/131] feat: migrate repo & init classes --- joj3_config_generator/lib/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/joj3_config_generator/lib/__init__.py b/joj3_config_generator/lib/__init__.py index e69de29..68802d4 100644 --- a/joj3_config_generator/lib/__init__.py +++ b/joj3_config_generator/lib/__init__.py @@ -0,0 +1,11 @@ +from joj3_config_generator.models.repo import Repo as Repo +from joj3_config_generator.models.result import Cmd as Cmd +from joj3_config_generator.models.result import CmdFile as CmdFile +from joj3_config_generator.models.result import ExecutorConfig as ExecutorConfig +from joj3_config_generator.models.result import ExecutorWithConfig as ExecutorWithConfig +from joj3_config_generator.models.result import ParserConfig as ParserConfig +from joj3_config_generator.models.result import ResultConfig as ResultConfig +from joj3_config_generator.models.result import Stage as Stage +from joj3_config_generator.models.result import StageConfig as StageConfig +from joj3_config_generator.models.result import TeapotConfig as TeapotConfig +from joj3_config_generator.models.task import Task as Task -- 2.30.2 From bea8a2e0b4df9f0c3f5acce8bd379539ee59011d Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:37:52 +0800 Subject: [PATCH 020/131] feat: finish keyword related --- tests/convert/basic/repo.toml.bak | 10 +++ tests/convert/basic/task.toml.bak | 137 ++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 tests/convert/basic/repo.toml.bak create mode 100644 tests/convert/basic/task.toml.bak diff --git a/tests/convert/basic/repo.toml.bak b/tests/convert/basic/repo.toml.bak new file mode 100644 index 0000000..bb9818b --- /dev/null +++ b/tests/convert/basic/repo.toml.bak @@ -0,0 +1,10 @@ +teaching_team = ["prof_john", "ta_alice", "ta_bob"] +max_size = 50.5 +release_tags = ["v1.0", "v2.0", "final"] +sandbox_token = "test" + +[files] +whitelist_patterns = ["*.py", "*.txt", "*.md"] +whitelist_file = ".whitelist" +required = [ "Changelog.md", "Readme.md" ] +immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] diff --git a/tests/convert/basic/task.toml.bak b/tests/convert/basic/task.toml.bak new file mode 100644 index 0000000..118247d --- /dev/null +++ b/tests/convert/basic/task.toml.bak @@ -0,0 +1,137 @@ +# p2 repo config + +task="p2 m3" # task name + +release.deadline = 2024-10-12 23:59:00+08:00 +release.stages = [ "compile" ] + +[files] +immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] +required = [ "Changelog.md", "Readme.md" ] + +[[stages]] +name = "Abuse of strings detected" +command = "./strdetect src/" +files.import = [ "tools/strdetec" ] + +parsers = [ "result-status" ] + + +[[stages]] +name = "Compilation" +command = "compile" +files.import = [ "tools/compile" ] +files.export = [ "build/onecard", "build/asan", "build/ubsan", "build/msan", "build/compile_commands.json" ] + +parsers = [ "result-detail", "dummy", "result-status" ] +result-status.comment = "Congratulations! Your code compiled successfully." +result-status.score = 1 +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stderr = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[cq] Filelength" +command = "./file-length 400 300 *.c *.h" +files.import = [ "tools/filelength" ] + +parsers = [ "keyword", "dummy", "result-detail" ] +keyword.keyword = [ "max", "recommended"] +keyword.weight = [ 20, 10 ] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stdout = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[cq] Clang-tidy" +command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" +files.import = [ "projects/p2/.clang-tidy", "build/compile_commands.json" ] +limit.stdout = 65 + +parsers = [ "clangtidy", "dummy", "result-detail" ] +clangtidy.keyword = [ "codequality-unchecked-malloc-result", "codequality-no-global-variables", "codequality-no-header-guard", "codequality-no-fflush-stdin", "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", "portability" ] +clangtidy.weight = [ 5, 20, 20, 20, 10, 5, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stdout = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[cq] Cppcheck" +command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --suppress=missingIncludeSystem --quiet ./" +limit.stderr = 65 + +parsers = [ "cppcheck", "dummy", "result-detail" ] +cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] +cppcheck.weight = [15, 5, 5, 5, 5] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stderr = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[cq] Cpplint" +command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard --recursive --exclude=build ." +limit.stdout = 65 + +parsers = [ "cpplint", "dummy", "result-detail" ] +cpplint.keyword = [ "runtime", "readability", "build" ] +cpplint.weight = [ 5, 20, 10] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stderr = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[run] onecard" +group = "run" +command="./onecard -a" +files.import = [ "build/onecard" ] + +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true + +[[stages]] +name = "[run] address sanitizer" +group = "run" +command="./asan -a" +files.import = [ "build/asan" ] + +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true + +[[stages]] +name = "[run] memory sanitizer" +group = "run" +command="./msan -a" +files.import = [ "build/msan" ] + +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true + +[[stages]] +name = "[run] undefined behavior sanitizer" +command="./ubsan -a" +files.import = [ "build/ubsan" ] + +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true -- 2.30.2 From f06bc21eeb2f744460c22dbd231560544b0d77c1 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:45:25 +0800 Subject: [PATCH 021/131] feat: combine dummy & result-staus --- joj3_config_generator/lib/task.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 7a29cf7..caa45ff 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -252,3 +252,15 @@ def fix_diff( conf_stage.executor.with_.cases = stage_cases return conf_stage + + +def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + comment_parser = ["dummy", "result-status"] + 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, None) is not None: + comment_parser_.with_.update(getattr(task_stage, parser)) + else: + continue + return conf_stage -- 2.30.2 From 5f51232cb076dc8e45be95fa0807a8b95d8f0b54 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:55:31 +0800 Subject: [PATCH 022/131] fix: result-status --- joj3_config_generator/lib/task.py | 6 +- tests/convert/basic/task.json | 478 +++++------------------------- 2 files changed, 77 insertions(+), 407 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index caa45ff..e8544c3 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -259,8 +259,10 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: 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, None) is not None: - comment_parser_.with_.update(getattr(task_stage, parser)) + if getattr(task_stage, parser.replace("-", "_"), None) is not None: + comment_parser_.with_.update( + getattr(task_stage, parser.replace("-", "_")) + ) else: continue return conf_stage diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 9ac998d..dcf13ea 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "h4 ex1", - "logPath": "h4-ex1.log", + "name": "Homework 1 exercise 2", + "logPath": "Homework-1-exercise-2.log", "expireUnixTimestamp": 1728748740, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -18,12 +18,13 @@ "//repo-health-checker", + "0x7f1db69b71a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", "-meta=README.md", - "-checkFileSumList=-checkFileNameList=" + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", + "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -70,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-5txkd_qm/repo-health-checker": { - "src": "//tmp/repo-checker-i9n16_cy/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, @@ -135,7 +136,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -146,15 +147,15 @@ "content": null, "fileId": null, "name": "stderr", - "max": 128000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 180000000000, + "cpuLimit": 4000000000, "realCpuLimit": 0, - "clockLimit": 360000000000, + "clockLimit": 8000000000, "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, @@ -233,14 +234,11 @@ { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false + "time": false, + "mem": false, + "stdout": false, + "stderr": true, + "exitstatus": true } }, { @@ -290,7 +288,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -301,7 +299,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -373,14 +371,11 @@ { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": false, - "showRuntime": false, - "showMemory": false + "time": false, + "mem": false, + "stdout": false, + "stderr": true, + "exitstatus": false } } ] @@ -419,7 +414,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 65000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -430,7 +425,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -560,14 +555,11 @@ { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false + "time": false, + "mem": false, + "stdout": true, + "stderr": false, + "exitstatus": true } } ] @@ -610,7 +602,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -621,7 +613,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 65000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -697,14 +689,11 @@ { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false + "time": false, + "mem": false, + "stdout": false, + "stderr": true, + "exitstatus": true } } ] @@ -743,7 +732,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 65000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -754,7 +743,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -786,9 +775,7 @@ "parsers": [ { "name": "cpplint", - "with": { - "comment": "" - } + "with": {} }, { "name": "dummy", @@ -799,14 +786,11 @@ { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false + "time": false, + "mem": false, + "stdout": true, + "stderr": false, + "exitstatus": true } } ] @@ -841,7 +825,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -852,16 +836,16 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 3000000000, + "cpuLimit": 4000000000, "realCpuLimit": 0, - "clockLimit": 6000000000, - "memoryLimit": 78643200, + "clockLimit": 8000000000, + "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -878,168 +862,13 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case8.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] + "cases": [] } }, "parsers": [ { "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case8.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - } - ] - } + "with": {} }, { "name": "dummy", @@ -1050,14 +879,11 @@ { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true + "time": true, + "mem": true, + "stdout": false, + "stderr": true, + "exitstatus": true } } ] @@ -1092,7 +918,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -1103,16 +929,16 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 10000000000, + "cpuLimit": 4000000000, "realCpuLimit": 0, - "clockLimit": 20000000000, - "memoryLimit": 524288000, + "clockLimit": 8000000000, + "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -1129,168 +955,13 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case6.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] + "cases": [] } }, "parsers": [ { "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", - "forceQuitOnDiff": true, - "alwaysHide": true, - "compareSpace": true - } - ] - } - ] - } + "with": {} }, { "name": "dummy", @@ -1301,14 +972,11 @@ { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true + "time": true, + "mem": true, + "stdout": false, + "stderr": true, + "exitstatus": true } } ] @@ -1316,10 +984,10 @@ ] }, "teapot": { - "logPath": "h4-ex1-joint-teapot-debug.log", - "scoreboardPath": "h4-ex1-scoreboard.csv", - "failedTablePath": "h4-ex1-failed-table.md", - "gradingRepoName": "Nuvole-joj", + "logPath": "Homework-1-exercise-2-joint-teapot-debug.log", + "scoreboardPath": "Homework-1-exercise-2-scoreboard.csv", + "failedTablePath": "Homework-1-exercise-2-failed-table.md", + "gradingRepoName": "engr151-joj", "skipIssue": false, "skipScoreboard": false, "skipFailedTable": false -- 2.30.2 From 78dc81b864184974201eb045c54e15c6b160c856 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:56:50 +0800 Subject: [PATCH 023/131] chore: trim old code --- joj3_config_generator/lib/task.py | 6 +++++- tests/convert/basic/task.json | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index e8544c3..f42ac8b 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -255,7 +255,11 @@ def fix_diff( def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - comment_parser = ["dummy", "result-status"] + comment_parser = [ + "dummy", + "result-status", + "cpplint", + ] # FIXME: determine where cpplint should be 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) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index dcf13ea..6dde2a2 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -775,7 +775,18 @@ "parsers": [ { "name": "cpplint", - "with": {} + "with": { + "keyword": [ + "runtime", + "readability", + "build" + ], + "weight": [ + 10, + 20, + 15 + ] + } }, { "name": "dummy", -- 2.30.2 From 8d5932801d37cb2c787e03098d7024d33668a599 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 23:30:41 +0800 Subject: [PATCH 024/131] fix: result_detail parser --- joj3_config_generator/lib/task.py | 31 ++++++++++++ tests/convert/basic/task.json | 81 ++++++++++++++++++++++++------- 2 files changed, 95 insertions(+), 17 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index f42ac8b..de9f7fb 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -254,6 +254,37 @@ def fix_diff( return conf_stage +def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + if "result-detail" in task_stage.parsers: + result_detail_parser = next( + p for p in conf_stage.parsers if p.name == "result-detail" + ) + if task_stage.result_detail is not None: + show_files = [] + if ( + task_stage.result_detail.stdout + and task_stage.result_detail.stdout is not None + ): + show_files.append("stdout") + if ( + task_stage.result_detail.stderr + and task_stage.result_detail.stderr is not None + ): + show_files.append("stderr") + result_detail_parser.with_.update( + { + "score": 0, + "comment": "", + "showFiles": show_files, + "showExitStatus": task_stage.result_detail.exitstatus, + "showRuntime": task_stage.result_detail.time, + "showMemory": task_stage.result_detail.mem, + } + ) + + return conf_stage + + def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: comment_parser = [ "dummy", diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 6dde2a2..333cc48 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -238,7 +238,15 @@ "mem": false, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } }, { @@ -375,7 +383,15 @@ "mem": false, "stdout": false, "stderr": true, - "exitstatus": false + "exitstatus": false, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": false, + "showRuntime": false, + "showMemory": false } } ] @@ -559,7 +575,15 @@ "mem": false, "stdout": true, "stderr": false, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } } ] @@ -693,7 +717,15 @@ "mem": false, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } } ] @@ -776,16 +808,7 @@ { "name": "cpplint", "with": { - "keyword": [ - "runtime", - "readability", - "build" - ], - "weight": [ - 10, - 20, - 15 - ] + "comment": "" } }, { @@ -801,7 +824,15 @@ "mem": false, "stdout": true, "stderr": false, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } } ] @@ -894,7 +925,15 @@ "mem": true, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true } } ] @@ -987,7 +1026,15 @@ "mem": true, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true } } ] -- 2.30.2 From ad35dffbaf7c7de96d340bdd2751121daa0b26c8 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 13:49:07 +0800 Subject: [PATCH 025/131] feat: cases data reading for diff --- joj3_config_generator/lib/task.py | 26 +++++++++++------- tests/convert/basic/task.json | 45 ++++--------------------------- 2 files changed, 22 insertions(+), 49 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index de9f7fb..765ecb1 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -255,7 +255,7 @@ def fix_diff( def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - if "result-detail" in task_stage.parsers: + if (task_stage.parsers is not None) and ("result-detail" in task_stage.parsers): result_detail_parser = next( p for p in conf_stage.parsers if p.name == "result-detail" ) @@ -291,13 +291,21 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: "result-status", "cpplint", ] # FIXME: determine where cpplint should be - 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 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 ) - else: - continue + if getattr(task_stage, parser.replace("-", "_"), None) is not None: + comment_parser_.with_.update( + getattr(task_stage, parser.replace("-", "_")) + ) + else: + continue + return conf_stage + + +def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + return conf_stage diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 333cc48..9a71599 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "Homework 1 exercise 2", - "logPath": "Homework-1-exercise-2.log", + "name": "h4 ex1", + "logPath": "h4-ex1.log", "expireUnixTimestamp": 1728748740, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -234,11 +234,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -379,11 +374,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": false, - "stderr": true, - "exitstatus": false, "score": 0, "comment": "", "showFiles": [ @@ -571,11 +561,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": true, - "stderr": false, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -713,11 +698,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -820,11 +800,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": true, - "stderr": false, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -921,11 +896,6 @@ { "name": "result-detail", "with": { - "time": true, - "mem": true, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -1022,11 +992,6 @@ { "name": "result-detail", "with": { - "time": true, - "mem": true, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -1042,9 +1007,9 @@ ] }, "teapot": { - "logPath": "Homework-1-exercise-2-joint-teapot-debug.log", - "scoreboardPath": "Homework-1-exercise-2-scoreboard.csv", - "failedTablePath": "Homework-1-exercise-2-failed-table.md", + "logPath": "h4-ex1-joint-teapot-debug.log", + "scoreboardPath": "h4-ex1-scoreboard.csv", + "failedTablePath": "h4-ex1-failed-table.md", "gradingRepoName": "engr151-joj", "skipIssue": false, "skipScoreboard": false, -- 2.30.2 From ac3e656ec166bc4d205e9a91f81a9d5fd98e9808 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:00:46 +0800 Subject: [PATCH 026/131] ffeat: diff finish --- joj3_config_generator/lib/task.py | 68 +++++++ tests/convert/basic/task.json | 318 +++++++++++++++++++++++++++++- 2 files changed, 382 insertions(+), 4 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 765ecb1..d500c45 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -307,5 +307,73 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + if task_stage.parsers is not None and "diff" in task_stage.parsers: + diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) + skip = task_stage.skip or [] + cases = task_stage.cases or {} + finalized_cases = [case for case in cases if case not in skip] + + stage_cases = [] + parser_cases = [] + + for case in finalized_cases: + case_stage = task_stage.cases.get(case) if task_stage.cases else None + if not case_stage: + continue + + # Ensure case_stage.limit is defined before accessing .cpu and .mem + cpu_limit = ( + case_stage.limit.cpu * 1_000_000_000 + if case_stage.limit and case_stage.limit.cpu is not None + else 0 + ) + clock_limit = ( + 2 * case_stage.limit.cpu * 1_000_000_000 + if case_stage.limit and case_stage.limit.cpu is not None + else 0 + ) + memory_limit = ( + case_stage.limit.mem * 1_024 * 1_024 + if case_stage.limit and case_stage.limit.mem is not None + else 0 + ) + + stage_cases.append( + OptionalCmd( + stdin=CmdFile( + src=f"/home/tt/.config/joj/{conf_stage.name}/{case}.in" + ), + cpu_limit=cpu_limit, + clock_limit=clock_limit, + memory_limit=memory_limit, + proc_limit=50, + ) + ) + + # Ensure case_stage.diff and case_stage.diff.output are defined + diff_output = ( + case_stage.diff.output + if case_stage.diff and case_stage.diff.output + else None + ) + if diff_output: + parser_cases.append( + { + "outputs": [ + { + "score": diff_output.score, + "fileName": "stdout", + "answerPath": f"/home/tt/.config/joj/{conf_stage.name}/{case}.out", + "forceQuitOnDiff": diff_output.forcequit, + "alwaysHide": diff_output.hide, + "compareSpace": not diff_output.ignorespaces, + } + ] + } + ) + + if diff_parser and task_stage.diff is not None: + diff_parser.with_.update({"name": "diff", "cases": parser_cases}) + conf_stage.executor.with_.cases = stage_cases return conf_stage diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 9a71599..a1dd5cc 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -879,13 +879,168 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [] + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case8.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] } }, "parsers": [ { "name": "diff", - "with": {} + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case8.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + } + ] + } }, { "name": "dummy", @@ -975,13 +1130,168 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [] + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case6.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] } }, "parsers": [ { "name": "diff", - "with": {} + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", + "forceQuitOnDiff": true, + "alwaysHide": true, + "compareSpace": true + } + ] + } + ] + } }, { "name": "dummy", -- 2.30.2 From 6e4c56a9cfc3163b790f009e5a8dea11c005dcc1 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:28:29 +0800 Subject: [PATCH 027/131] chore: more compact code --- tests/convert/basic/task.json | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index a1dd5cc..bb0703d 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -136,7 +136,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -147,15 +147,15 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 128000000000, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 180000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, + "clockLimit": 360000000000, "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, @@ -291,7 +291,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -302,7 +302,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -420,7 +420,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 65000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -431,7 +431,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -611,7 +611,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -622,7 +622,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 65000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -744,7 +744,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 65000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -755,7 +755,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -842,7 +842,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -853,16 +853,16 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 3000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 6000000000, + "memoryLimit": 78643200, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -1093,7 +1093,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -1104,16 +1104,16 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 10000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 20000000000, + "memoryLimit": 524288000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, -- 2.30.2 From 26baf756d0234252eec5b2085f030f87570de856 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:43:43 +0800 Subject: [PATCH 028/131] fix: gradingreponame schema --- tests/convert/basic/task.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index bb0703d..c96efcd 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-90ztqsoq/repo-health-checker": { - "src": "//tmp/repo-checker-41mcx5_x/repo-health-checker", + "//tmp/repo-checker-u3awlhwg/repo-health-checker": { + "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -1320,7 +1320,7 @@ "logPath": "h4-ex1-joint-teapot-debug.log", "scoreboardPath": "h4-ex1-scoreboard.csv", "failedTablePath": "h4-ex1-failed-table.md", - "gradingRepoName": "engr151-joj", + "gradingRepoName": "Nuvole-joj", "skipIssue": false, "skipScoreboard": false, "skipFailedTable": false -- 2.30.2 From 14e96bd5f4019087f227d6804a8ced52473ea0ce Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:53:42 +0800 Subject: [PATCH 029/131] fix: immutable_file --- tests/immutable_file/.gitattributes | 33 ----------------------------- tests/immutable_file/.gitignore | 23 -------------------- tests/immutable_file/push.yaml | 18 ---------------- tests/immutable_file/release.yaml | 20 ----------------- 4 files changed, 94 deletions(-) delete mode 100644 tests/immutable_file/.gitattributes delete mode 100644 tests/immutable_file/.gitignore delete mode 100644 tests/immutable_file/push.yaml delete mode 100644 tests/immutable_file/release.yaml diff --git a/tests/immutable_file/.gitattributes b/tests/immutable_file/.gitattributes deleted file mode 100644 index b910c4a..0000000 --- a/tests/immutable_file/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -*.avi filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.djvu filter=lfs diff=lfs merge=lfs -text -*.doc filter=lfs diff=lfs merge=lfs -text -*.docx filter=lfs diff=lfs merge=lfs -text -*.epub filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.ipynb filter=lfs diff=lfs merge=lfs -text -*.jpeg filter=lfs diff=lfs merge=lfs -text -*.JPEG filter=lfs diff=lfs merge=lfs -text -*.jpg filter=lfs diff=lfs merge=lfs -text -*.JPG filter=lfs diff=lfs merge=lfs -text -*.mkv filter=lfs diff=lfs merge=lfs -text -*.mp4 filter=lfs diff=lfs merge=lfs -text -*.ods filter=lfs diff=lfs merge=lfs -text -*.odt filter=lfs diff=lfs merge=lfs -text -*.otf filter=lfs diff=lfs merge=lfs -text -*.pdf filter=lfs diff=lfs merge=lfs -text -*.PDF filter=lfs diff=lfs merge=lfs -text -*.png filter=lfs diff=lfs merge=lfs -text -*.PNG filter=lfs diff=lfs merge=lfs -text -*.ppt filter=lfs diff=lfs merge=lfs -text -*.pptx filter=lfs diff=lfs merge=lfs -text -*.ps filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text -*.tar filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.ttf filter=lfs diff=lfs merge=lfs -text -*.webm filter=lfs diff=lfs merge=lfs -text -*.xls filter=lfs diff=lfs merge=lfs -text -*.xlsx filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_file/.gitignore b/tests/immutable_file/.gitignore deleted file mode 100644 index 754f776..0000000 --- a/tests/immutable_file/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -################################ -## White list based gitignore ## -################################ - -# forbidden -* -.* - -# allowed -!.gitignore -!.gitattributes -!.gitea/ -!.gitea/issue_template/ -!.gitea/workflows/ -!*.yaml -!Makefile -!CMakeLists.txt -!h[0-8]/ -!*.m -!*.c -!*.cpp -!*.h -!*.md diff --git a/tests/immutable_file/push.yaml b/tests/immutable_file/push.yaml deleted file mode 100644 index 2f890b6..0000000 --- a/tests/immutable_file/push.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: Run JOJ3 on Push -on: [push] -jobs: - run: - container: - image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim - volumes: - - /home/tt/.config:/home/tt/.config - - /home/tt/.cache:/home/tt/.cache - - /home/tt/.ssh:/home/tt/.ssh - steps: - - name: Check out repository code - uses: https://gitea.com/BoYanZh/checkout@focs - with: - fetch-depth: 0 - - name: run joj3 - run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml deleted file mode 100644 index afd2838..0000000 --- a/tests/immutable_file/release.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: Run JOJ3 on Release -on: - release: - types: [published] -jobs: - run: - container: - image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim - volumes: - - /home/tt/.config:/home/tt/.config - - /home/tt/.cache:/home/tt/.cache - - /home/tt/.ssh:/home/tt/.ssh - steps: - - name: Check out repository code - uses: https://gitea.com/BoYanZh/checkout@focs - with: - fetch-depth: 0 - - name: run joj3 - run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj -msg "feat(h1-release): joj on ${{ github.ref }}" -- 2.30.2 From 0ef0ec177b6e9cef38406d169a9f2aec00dff397 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:59:25 +0800 Subject: [PATCH 030/131] feat: rebuild json --- tests/convert/basic/task.json | 1328 --------------------------------- 1 file changed, 1328 deletions(-) delete mode 100644 tests/convert/basic/task.json diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json deleted file mode 100644 index c96efcd..0000000 --- a/tests/convert/basic/task.json +++ /dev/null @@ -1,1328 +0,0 @@ -{ - "name": "h4 ex1", - "logPath": "h4-ex1.log", - "expireUnixTimestamp": 1728748740, - "stage": { - "sandboxExecServer": "172.17.0.1:5051", - "sandboxToken": "test", - "outputPath": "/tmp/joj3_result.json", - "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "//repo-health-checker", - "-root=.", - "-repoSize=50.5", - "-meta=main.py", - "-meta=README.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", - "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4096, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4096, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "//tmp/repo-checker-u3awlhwg/repo-health-checker": { - "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "healthcheck", - "with": { - "score": 0, - "comment": "" - } - } - ] - }, - { - "name": "Compilation", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "make.sh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 128000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 180000000000, - "realCpuLimit": 0, - "clockLimit": 360000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/make.sh": { - "src": "/home/tt/.config/joj/tools/make.sh", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/main.c": { - "src": "/home/tt/.config/joj/src/main.c", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/task.h": { - "src": "/home/tt/.config/joj/src/task.h", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "srcCMakelist.txt": { - "src": "/home/tt/.config/joj/srcCMakelist.txt", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/make.sh": "tools/make.sh", - "src/main.c": "src/main.c", - "src/task.h": "src/task.h", - "srcCMakelist.txt": "srcCMakelist.txt" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [ - "driver", - "p2", - "p2-msan" - ], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-status", - "with": { - "comment": "Congratulations! Your code compiled successfully." - } - } - ] - }, - { - "name": "File length check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./file-length", - "500", - "400", - "*.c", - "*.h" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/file-length": { - "src": "/home/tt/.config/joj/tools/file-length", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/file-length": "tools/file-length" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "keyword", - "with": { - "match": [ - { - "keyword": [ - "max" - ], - "score": 50 - }, - { - "keyword": [ - "recommend" - ], - "score": 20 - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": false, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Clang-tidy checks", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "run-clang-tidy-18", - "-header-filter=.*", - "-quiet", - "-load=/usr/local/lib/libcodequality.so", - "-p", - "build" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "clangtidy", - "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": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Cppcheck check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cppcheck", - "--template='{\"file\":\"{file}\",\"line\":{line},", - "\"column\":{column},", - "\"severity\":\"{severity}\",", - "\"message\":\"{message}\",", - "\"id\":\"{id}\"}'", - "--force", - "--enable=all", - "--quiet", - "./" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cppcheck", - "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": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Cpplint check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cpplint", - "--linelength=120", - "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", - "--recursive", - "--exclude=build", - "." - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cpplint", - "with": { - "comment": "" - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "judge-base", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 3000000000, - "realCpuLimit": 0, - "clockLimit": 6000000000, - "memoryLimit": 78643200, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case8.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case8.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "judge-msan", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh-msan" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 10000000000, - "realCpuLimit": 0, - "clockLimit": 20000000000, - "memoryLimit": 524288000, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case6.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", - "forceQuitOnDiff": true, - "alwaysHide": true, - "compareSpace": true - } - ] - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - } - ] - }, - "teapot": { - "logPath": "h4-ex1-joint-teapot-debug.log", - "scoreboardPath": "h4-ex1-scoreboard.csv", - "failedTablePath": "h4-ex1-failed-table.md", - "gradingRepoName": "Nuvole-joj", - "skipIssue": false, - "skipScoreboard": false, - "skipFailedTable": false - } -} -- 2.30.2 From e093305bed6d7198a558a7f2dded51bbfdb93498 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 16:01:38 +0800 Subject: [PATCH 031/131] feat: sync --- tests/convert/basic/task.json | 1328 +++++++++++++++++++++++++++ tests/immutable_file/.gitattributes | 33 + tests/immutable_file/.gitignore | 23 + tests/immutable_file/push.yaml | 18 + tests/immutable_file/release.yaml | 20 + 5 files changed, 1422 insertions(+) create mode 100644 tests/convert/basic/task.json create mode 100644 tests/immutable_file/.gitattributes create mode 100644 tests/immutable_file/.gitignore create mode 100644 tests/immutable_file/push.yaml create mode 100644 tests/immutable_file/release.yaml diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json new file mode 100644 index 0000000..4ffc375 --- /dev/null +++ b/tests/convert/basic/task.json @@ -0,0 +1,1328 @@ +{ + "name": "h4 ex1", + "logPath": "h4-ex1.log", + "expireUnixTimestamp": 1728748740, + "stage": { + "sandboxExecServer": "172.17.0.1:5051", + "sandboxToken": "test", + "outputPath": "/tmp/joj3_result.json", + "stages": [ + { + "name": "healthcheck", + "group": "", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "//repo-health-checker", + "-root=.", + "-repoSize=50.5", + "-meta=main.py", + "-meta=README.md", + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", + "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "//tmp/repo-checker-u3awlhwg/repo-health-checker": { + "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 0, + "comment": "" + } + } + ] + }, + { + "name": "Compilation", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "make.sh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 128000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 180000000000, + "realCpuLimit": 0, + "clockLimit": 360000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/make.sh": { + "src": "/home/tt/.config/joj/tools/make.sh", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/main.c": { + "src": "/home/tt/.config/joj/src/main.c", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/task.h": { + "src": "/home/tt/.config/joj/src/task.h", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "srcCMakelist.txt": { + "src": "/home/tt/.config/joj/srcCMakelist.txt", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/make.sh": "tools/make.sh", + "src/main.c": "src/main.c", + "src/task.h": "src/task.h", + "srcCMakelist.txt": "srcCMakelist.txt" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [ + "driver", + "p2", + "p2-msan" + ], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-status", + "with": { + "comment": "Congratulations! Your code compiled successfully." + } + } + ] + }, + { + "name": "File length check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./file-length", + "500", + "400", + "*.c", + "*.h" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/file-length": { + "src": "/home/tt/.config/joj/tools/file-length", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/file-length": "tools/file-length" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "keyword", + "with": { + "match": [ + { + "keyword": [ + "max" + ], + "score": 50 + }, + { + "keyword": [ + "recommend" + ], + "score": 20 + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": false, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Clang-tidy checks", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "run-clang-tidy-18", + "-header-filter=.*", + "-quiet", + "-load=/usr/local/lib/libcodequality.so", + "-p", + "build" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "clangtidy", + "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": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Cppcheck check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cppcheck", + "--template='{\"file\":\"{file}\",\"line\":{line},", + "\"column\":{column},", + "\"severity\":\"{severity}\",", + "\"message\":\"{message}\",", + "\"id\":\"{id}\"}'", + "--force", + "--enable=all", + "--quiet", + "./" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cppcheck", + "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": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Cpplint check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cpplint", + "--linelength=120", + "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", + "--recursive", + "--exclude=build", + "." + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cpplint", + "with": { + "comment": "" + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "judge-base", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 3000000000, + "realCpuLimit": 0, + "clockLimit": 6000000000, + "memoryLimit": 78643200, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case8.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case8.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "judge-msan", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh-msan" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 10000000000, + "realCpuLimit": 0, + "clockLimit": 20000000000, + "memoryLimit": 524288000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case6.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", + "forceQuitOnDiff": true, + "alwaysHide": true, + "compareSpace": true + } + ] + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + } + ] + }, + "teapot": { + "logPath": "h4-ex1-joint-teapot-debug.log", + "scoreboardPath": "h4-ex1-scoreboard.csv", + "failedTablePath": "h4-ex1-failed-table.md", + "gradingRepoName": "Nuvole-joj", + "skipIssue": false, + "skipScoreboard": false, + "skipFailedTable": false + } +} diff --git a/tests/immutable_file/.gitattributes b/tests/immutable_file/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/immutable_file/.gitattributes @@ -0,0 +1,33 @@ +*.avi filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.djvu filter=lfs diff=lfs merge=lfs -text +*.doc filter=lfs diff=lfs merge=lfs -text +*.docx filter=lfs diff=lfs merge=lfs -text +*.epub filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.ipynb filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.JPEG filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.JPG filter=lfs diff=lfs merge=lfs -text +*.mkv filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.ods filter=lfs diff=lfs merge=lfs -text +*.odt filter=lfs diff=lfs merge=lfs -text +*.otf filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.PDF filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.PNG filter=lfs diff=lfs merge=lfs -text +*.ppt filter=lfs diff=lfs merge=lfs -text +*.pptx filter=lfs diff=lfs merge=lfs -text +*.ps filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text +*.xls filter=lfs diff=lfs merge=lfs -text +*.xlsx filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_file/.gitignore b/tests/immutable_file/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/immutable_file/.gitignore @@ -0,0 +1,23 @@ +################################ +## White list based gitignore ## +################################ + +# forbidden +* +.* + +# allowed +!.gitignore +!.gitattributes +!.gitea/ +!.gitea/issue_template/ +!.gitea/workflows/ +!*.yaml +!Makefile +!CMakeLists.txt +!h[0-8]/ +!*.m +!*.c +!*.cpp +!*.h +!*.md diff --git a/tests/immutable_file/push.yaml b/tests/immutable_file/push.yaml new file mode 100644 index 0000000..2f890b6 --- /dev/null +++ b/tests/immutable_file/push.yaml @@ -0,0 +1,18 @@ +name: Run JOJ3 on Push +on: [push] +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml new file mode 100644 index 0000000..afd2838 --- /dev/null +++ b/tests/immutable_file/release.yaml @@ -0,0 +1,20 @@ +name: Run JOJ3 on Release +on: + release: + types: [published] +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj -msg "feat(h1-release): joj on ${{ github.ref }}" -- 2.30.2 From 342570cf3e858a59b7f513d34f02d3a6c9bd6953 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 11:13:56 +0800 Subject: [PATCH 032/131] feat: sync --- tests/convert/basic/task.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 4ffc375..c15b691 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,13 +18,12 @@ "//repo-health-checker", + "0x7f64f5d532e0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", "-meta=README.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", - "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" + "-checkFileSumList=-checkFileNameList=" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -71,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-u3awlhwg/repo-health-checker": { - "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", + "//tmp/repo-checker-lf3ranpy/repo-health-checker": { + "src": "//tmp/repo-checker-gd58j2qv/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From 0507a14f4413a03ea69bf65fa2a4add6ba2034a5 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 22:56:26 +0800 Subject: [PATCH 033/131] feat --- tests/convert/basic/task.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index c15b691..92d475d 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7ff414d38860>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-lf3ranpy/repo-health-checker": { - "src": "//tmp/repo-checker-gd58j2qv/repo-health-checker", + "//tmp/repo-checker-kep8doc0/repo-health-checker": { + "src": "//tmp/repo-checker-7_k9ht77/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -1316,10 +1316,10 @@ ] }, "teapot": { - "logPath": "h4-ex1-joint-teapot-debug.log", - "scoreboardPath": "h4-ex1-scoreboard.csv", - "failedTablePath": "h4-ex1-failed-table.md", - "gradingRepoName": "Nuvole-joj", + "logPath": "/home/tt/.cache/joint-teapot-debug.log", + "scoreboardPath": "scoreboard.csv", + "failedTablePath": "failed-table.md", + "gradingRepoName": "", "skipIssue": false, "skipScoreboard": false, "skipFailedTable": false -- 2.30.2 From 9b36f3022826476e8a1a645616c45610f90bc37c Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 22:56:52 +0800 Subject: [PATCH 034/131] fix: merge conflict --- joj3_config_generator/convert.py | 10 +++++++++- joj3_config_generator/lib/__init__.py | 11 ----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index ce0677f..d6e7c3a 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -10,7 +10,15 @@ from joj3_config_generator.lib.task import ( get_executorWithConfig, ) from joj3_config_generator.models import joj1, repo, result, task - +from joj3_config_generator.lib.task import ( + fix_comment, + fix_diff, + fix_keyword, + fix_result_detail, + get_executorWithConfig, + get_conf_stage, +) +from joj3_config_generator.lib.repo import getHealthcheckConfig # FIXME: LLM generated convert function, only for demostration def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: diff --git a/joj3_config_generator/lib/__init__.py b/joj3_config_generator/lib/__init__.py index 68802d4..e69de29 100644 --- a/joj3_config_generator/lib/__init__.py +++ b/joj3_config_generator/lib/__init__.py @@ -1,11 +0,0 @@ -from joj3_config_generator.models.repo import Repo as Repo -from joj3_config_generator.models.result import Cmd as Cmd -from joj3_config_generator.models.result import CmdFile as CmdFile -from joj3_config_generator.models.result import ExecutorConfig as ExecutorConfig -from joj3_config_generator.models.result import ExecutorWithConfig as ExecutorWithConfig -from joj3_config_generator.models.result import ParserConfig as ParserConfig -from joj3_config_generator.models.result import ResultConfig as ResultConfig -from joj3_config_generator.models.result import Stage as Stage -from joj3_config_generator.models.result import StageConfig as StageConfig -from joj3_config_generator.models.result import TeapotConfig as TeapotConfig -from joj3_config_generator.models.task import Task as Task -- 2.30.2 From c5f14cb6fc65c38dc84d92de5e61d6e2b55b04e9 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 23:06:37 +0800 Subject: [PATCH 035/131] fix: List import --- joj3_config_generator/convert.py | 1 + tests/convert/basic/task.json | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index d6e7c3a..26a9bf0 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -19,6 +19,7 @@ from joj3_config_generator.lib.task import ( get_conf_stage, ) from joj3_config_generator.lib.repo import getHealthcheckConfig +from typing import List # FIXME: LLM generated convert function, only for demostration def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 92d475d..be97d42 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f5f9b524860>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-kep8doc0/repo-health-checker": { - "src": "//tmp/repo-checker-7_k9ht77/repo-health-checker", + "//tmp/repo-checker-h1q4gec9/repo-health-checker": { + "src": "//tmp/repo-checker-nprjqigk/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From de5a4cd9cb8f2d9cbd453b9b4b948328a6919737 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 22:42:53 +0800 Subject: [PATCH 036/131] fix: keywords group score --- joj3_config_generator/convert.py | 9 +- joj3_config_generator/lib/task.py | 23 +++- joj3_config_generator/models/task.py | 3 +- tests/convert/basic/task.json | 169 +++++++++++---------------- tests/convert/basic/task.toml | 4 +- 5 files changed, 93 insertions(+), 115 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 26a9bf0..d7fd728 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -14,14 +14,13 @@ from joj3_config_generator.lib.task import ( fix_comment, fix_diff, fix_keyword, - fix_result_detail, - get_executorWithConfig, + fix_result_detail, get_conf_stage, + get_executorWithConfig, ) -from joj3_config_generator.lib.repo import getHealthcheckConfig -from typing import List +from joj3_config_generator.models import joj1, repo, result, task + -# FIXME: LLM generated convert function, only for demostration def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Create the base ResultConf object result_conf = result.Config( diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index d500c45..9d5a06c 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -100,10 +100,11 @@ 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: - keyword_parser = ["clangtidy", "keyword", "cppcheck"] # TODO: may add cpplint + keyword_parser = ["clangtidy", "keyword", "cppcheck", "cpplint"] if task_stage.parsers is not None: for parser in task_stage.parsers: if parser in keyword_parser: @@ -112,12 +113,22 @@ def fix_keyword( ) 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 + unique_weight = list(set(getattr(task_stage, parser).weight)) + for score in unique_weight: + keyword_weight.append({"keywords": [], "score": score}) - keyword_parser_.with_.update({"match": keyword_weight}) + for idx, score in enumerate(unique_weight): + for idx_, score_ in enumerate( + getattr(task_stage, parser).weight + ): + if score == score_: + keyword_weight[idx]["keywords"].append( + getattr(task_stage, parser).keyword[idx_] + ) + else: + continue + + keyword_parser_.with_.update({"matches": keyword_weight}) else: continue return conf_stage diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 077991a..3ed7c43 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -59,8 +59,7 @@ class Stage(BaseModel): clangtidy: Optional[ParserKeyword] = ParserKeyword() cppcheck: Optional[ParserKeyword] = ParserKeyword() # FIXME: determine cpplint type - # cpplint: Optional[ParserKeyword] = ParserKeyword() - cpplint: Optional[ParserDummy] = ParserDummy() + cpplint: Optional[ParserKeyword] = ParserKeyword() result_detail: Optional[ParserResultDetail] = Field( ParserResultDetail(), alias="result-detail" ) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index be97d42..c3227ba 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "h4 ex1", - "logPath": "h4-ex1.log", + "name": "Homework 1 exercise 2", + "logPath": "Homework-1-exercise-2.log", "expireUnixTimestamp": 1728748740, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7efe709e4180>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-h1q4gec9/repo-health-checker": { - "src": "//tmp/repo-checker-nprjqigk/repo-health-checker", + "//tmp/repo-checker-d89rnuip/repo-health-checker": { + "src": "//tmp/repo-checker-tk3cqa0k/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -348,15 +348,15 @@ { "name": "keyword", "with": { - "match": [ + "matches": [ { - "keyword": [ + "keywords": [ "max" ], "score": 50 }, { - "keyword": [ + "keywords": [ "recommend" ], "score": 20 @@ -378,7 +378,7 @@ "showFiles": [ "stderr" ], - "showExitStatus": false, + "showExitStatus": true, "showRuntime": false, "showMemory": false } @@ -463,87 +463,37 @@ { "name": "clangtidy", "with": { - "match": [ + "matches": [ { - "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": [ + "keywords": [ "bugprone-suspicious-string-compare" ], "score": 8 }, { - "keyword": [ - "google-global-names-in-headers" + "keywords": [ + "codequality-no-global-variables", + "codequality-no-header-guard", + "readability-duplicate-include", + "readability-misleading-indentation" ], - "score": 5 + "score": 10 }, { - "keyword": [ - "clang-diagnostic" + "keywords": [ + "readability-function-size" ], - "score": 5 + "score": 50 }, { - "keyword": [ - "clang-analyzer" - ], - "score": 5 - }, - { - "keyword": [ + "keywords": [ + "readability-identifier-naming", + "readability-redundant", + "readability-misplaced-array-index", + "cppcoreguidelines-init-variables", + "google-global-names-in-headers", + "clang-diagnostic", + "clang-analyzer", "misc performance" ], "score": 5 @@ -654,36 +604,26 @@ { "name": "cppcheck", "with": { - "match": [ + "matches": [ { - "keyword": [ + "keywords": [ + "warning", + "style" + ], + "score": 10 + }, + { + "keywords": [ "error" ], "score": 20 }, { - "keyword": [ - "warning" - ], - "score": 10 - }, - { - "keyword": [ - "portability" - ], - "score": 15 - }, - { - "keyword": [ + "keywords": [ + "portability", "performance" ], "score": 15 - }, - { - "keyword": [ - "style" - ], - "score": 10 } ] } @@ -787,7 +727,36 @@ { "name": "cpplint", "with": { - "comment": "" + "keyword": [ + "runtime", + "readability", + "build" + ], + "weight": [ + 10, + 20, + 15 + ], + "matches": [ + { + "keywords": [ + "runtime" + ], + "score": 10 + }, + { + "keywords": [ + "readability" + ], + "score": 20 + }, + { + "keywords": [ + "build" + ], + "score": 15 + } + ] } }, { diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index ec4cdfc..12f66f3 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,5 +1,5 @@ # general task configuration -task="h4 ex1" # task name +task="Homework 1 exercise 2" # task name release.deadline = 2024-10-12 23:59:00+08:00 release.stages = [ "compile" ] @@ -29,7 +29,7 @@ files.import = [ "tools/file-length" ] parsers = [ "keyword", "dummy", "result-detail" ] keyword.keyword = [ "max", "recommend"] # keywords caught by corresponding JOJ plugin keyword.weight = [ 50, 20 ] # weight of each keyword -result-detail.exitstatus = false +result-detail.exitstatus = true result-detail.stderr = true result-detail.time = false result-detail.mem = false -- 2.30.2 From 9a547d3608e269735d5f51f9e4640c8e135412a7 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 23:03:18 +0800 Subject: [PATCH 037/131] fix: forcequit for result status --- joj3_config_generator/convert.py | 4 +-- joj3_config_generator/lib/task.py | 25 ++++++++------ joj3_config_generator/models/task.py | 2 ++ tests/convert/basic/task.json | 51 ++++++++++++++++------------ tests/convert/basic/task.toml | 5 +++ 5 files changed, 53 insertions(+), 34 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index d7fd728..4fbda28 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -11,8 +11,8 @@ from joj3_config_generator.lib.task import ( ) from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.lib.task import ( - fix_comment, fix_diff, + fix_dummy, fix_keyword, fix_result_detail, get_conf_stage, @@ -45,7 +45,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 9d5a06c..1692f41 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -100,7 +100,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: @@ -167,23 +166,27 @@ def fix_result_detail( return conf_stage -def fix_comment( +def fix_dummy( task_stage: task.Stage, conf_stage: result.StageDetail ) -> result.StageDetail: - comment_parser = [ + 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 3ed7c43..684cdd5 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" -- 2.30.2 From 0324313f92d80413989a7ec1591cc00924ef5bb2 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 23:26:06 +0800 Subject: [PATCH 038/131] feat: newest json --- joj3_config_generator/main.py | 1 + tests/convert/basic/task.json | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index d556071..9b153c3 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -63,6 +63,7 @@ def convert(root: Path = Path(".")) -> None: task_obj = rtoml.loads(task_toml) result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj)) result_dict = result_model.model_dump(by_alias=True) + with open(result_json_path, "w") as result_file: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) result_file.write("\n") diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index cad6f01..fe289a5 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f46eeff8180>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-va9ba49a/repo-health-checker": { - "src": "//tmp/repo-checker-e82nkuo4/repo-health-checker", + "//tmp/repo-checker-l7uddq8e/repo-health-checker": { + "src": "//tmp/repo-checker-s5wx4xg3/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From a7c5e0c925c441dc86bc37101640e9eaa6f9d039 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 23:35:07 +0800 Subject: [PATCH 039/131] fix: path to past test --- joj3_config_generator/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 9b153c3..d91a0a7 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -51,10 +51,10 @@ def convert(root: Path = Path(".")) -> None: Convert given dir of JOJ3 toml config files to JOJ3 json config files """ logger.info(f"Converting files in {root.absolute()}") - repo_toml_path = os.path.join(root, "repo.toml") + repo_toml_path = os.path.join(root, "basic", "repo.toml") # TODO: loop through all dirs to find all task.toml - task_toml_path = os.path.join(root, "task.toml") - result_json_path = os.path.join(root, "task.json") + task_toml_path = os.path.join(root, "basic", "task.toml") + result_json_path = os.path.join(root, "basic", "task.json") with open(repo_toml_path) as repo_file: repo_toml = repo_file.read() with open(task_toml_path) as task_file: -- 2.30.2 From c888f20eaf53e8da20721579731c09528d051c2d Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 23:40:04 +0800 Subject: [PATCH 040/131] fix: path to test --- joj3_config_generator/main.py | 6 +++--- tests/convert/basic/task.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index d91a0a7..1c86df2 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -51,10 +51,10 @@ def convert(root: Path = Path(".")) -> None: Convert given dir of JOJ3 toml config files to JOJ3 json config files """ logger.info(f"Converting files in {root.absolute()}") - repo_toml_path = os.path.join(root, "basic", "repo.toml") + repo_toml_path = os.path.join(root.absolute(), "basic", "repo.toml") # TODO: loop through all dirs to find all task.toml - task_toml_path = os.path.join(root, "basic", "task.toml") - result_json_path = os.path.join(root, "basic", "task.json") + task_toml_path = os.path.join(root.absolute(), "basic", "task.toml") + result_json_path = os.path.join(root.absolute(), "basic", "task.json") with open(repo_toml_path) as repo_file: repo_toml = repo_file.read() with open(task_toml_path) as task_file: diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index fe289a5..4c406f2 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f8686b98180>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-l7uddq8e/repo-health-checker": { - "src": "//tmp/repo-checker-s5wx4xg3/repo-health-checker", + "//tmp/repo-checker-9jj98lrm/repo-health-checker": { + "src": "//tmp/repo-checker-er4az3r2/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From 36b9629ca40cbf20fc5c7dbfaf201297340329e3 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 23:42:35 +0800 Subject: [PATCH 041/131] fix: path to test --- tests/convert/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 5875138..15e8a8c 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -12,13 +12,13 @@ def read_convert_files( case_name: str, ) -> Tuple[repo.Config, task.Config, Dict[str, Any]]: root = os.path.dirname(os.path.realpath(__file__)) - repo_toml_path = os.path.join(root, case_name, "repo.toml") + repo_toml_path = os.path.join(root.absolute(), case_name, "repo.toml") with open(repo_toml_path) as f: repo_toml = f.read() - task_toml_path = os.path.join(root, case_name, "task.toml") + task_toml_path = os.path.join(root.absolute(), case_name, "task.toml") with open(task_toml_path) as f: task_toml = f.read() - result_json_path = os.path.join(root, case_name, "task.json") + result_json_path = os.path.join(root.absolute(), case_name, "task.json") with open(result_json_path) as f: result: Dict[str, Any] = json.load(f) repo_obj = rtoml.loads(repo_toml) -- 2.30.2 From f012d80d1dd8f13174829ae123c5ef00dc9ed53b Mon Sep 17 00:00:00 2001 From: Nuvole Date: Fri, 8 Nov 2024 00:05:22 +0800 Subject: [PATCH 042/131] feat: pass test --- joj3_config_generator/lib/repo.py | 11 ++--------- joj3_config_generator/main.py | 8 +++++--- tests/convert/basic/task.json | 9 +++------ tests/convert/test_convert_cases.py | 3 +++ tests/convert/utils.py | 7 ++++--- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index 8c17ee1..3f1935a 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -1,14 +1,9 @@ import hashlib import socket -import tempfile from joj3_config_generator.models import joj1, repo, result, task -def get_temp_directory() -> str: - return tempfile.mkdtemp(prefix="repo-checker-") - - def getGradingRepoName() -> str: host_name = socket.gethostname() return f"{host_name.split('-')[0]}-joj" @@ -41,7 +36,7 @@ def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: else: immutable_files = immutable_files + name + "," # FIXME: need to make solution and make things easier to edit with global scope - chore = f"/{get_temp_directory}/repo-health-checker -root=. " + chore = f"/tmp/repo-health-checker -root=. " args = "" args = args + chore args = args + repo_size @@ -56,9 +51,7 @@ def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: args=args.split(), # FIXME: easier to edit within global scope copy_in={ - f"/{get_temp_directory()}/repo-health-checker": result.CmdFile( - src=f"/{get_temp_directory()}/repo-health-checker" - ) + f"/tmp/repo-health-checker": result.CmdFile(src=f"/tmp/repo-health-checker") }, ) return cmd diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 1c86df2..0e3f79c 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -9,7 +9,7 @@ import yaml from joj3_config_generator.convert import convert as convert_conf from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf -from joj3_config_generator.models import joj1, repo, task +from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.utils.logger import logger app = typer.Typer(add_completion=False) @@ -46,7 +46,7 @@ def convert_joj1(yaml_file: typer.FileText, toml_file: typer.FileTextWrite) -> N @app.command() -def convert(root: Path = Path(".")) -> None: +def convert(root: Path = Path(".")) -> result.Config: """ Convert given dir of JOJ3 toml config files to JOJ3 json config files """ @@ -63,7 +63,9 @@ def convert(root: Path = Path(".")) -> None: task_obj = rtoml.loads(task_toml) result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj)) result_dict = result_model.model_dump(by_alias=True) - + with open(result_json_path, "w") as result_file: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) result_file.write("\n") + + return result_model diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 4c406f2..1a55fb8 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -15,10 +15,7 @@ "with": { "default": { "args": [ - "//repo-health-checker", + "/tmp/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +67,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-9jj98lrm/repo-health-checker": { - "src": "//tmp/repo-checker-er4az3r2/repo-health-checker", + "/tmp/repo-health-checker": { + "src": "/tmp/repo-health-checker", "content": null, "fileId": null, "name": null, diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index 1a3392a..6aa8a0c 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -3,3 +3,6 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") + + +test_basic() diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 15e8a8c..3144319 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -3,6 +3,7 @@ import os from typing import Any, Dict, Tuple import rtoml +from deepdiff import DeepDiff from joj3_config_generator.convert import convert from joj3_config_generator.models import repo, task @@ -12,13 +13,13 @@ def read_convert_files( case_name: str, ) -> Tuple[repo.Config, task.Config, Dict[str, Any]]: root = os.path.dirname(os.path.realpath(__file__)) - repo_toml_path = os.path.join(root.absolute(), case_name, "repo.toml") + repo_toml_path = os.path.join(root, case_name, "repo.toml") with open(repo_toml_path) as f: repo_toml = f.read() - task_toml_path = os.path.join(root.absolute(), case_name, "task.toml") + task_toml_path = os.path.join(root, case_name, "task.toml") with open(task_toml_path) as f: task_toml = f.read() - result_json_path = os.path.join(root.absolute(), case_name, "task.json") + result_json_path = os.path.join(root, case_name, "task.json") with open(result_json_path) as f: result: Dict[str, Any] = json.load(f) repo_obj = rtoml.loads(repo_toml) -- 2.30.2 From b207fefca3aa237ec22d7bd93f02c6958f826989 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Fri, 8 Nov 2024 00:07:35 +0800 Subject: [PATCH 043/131] feat: pass test --- tests/convert/test_convert_cases.py | 3 --- tests/convert/utils.py | 1 - 2 files changed, 4 deletions(-) diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index 6aa8a0c..1a3392a 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -3,6 +3,3 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") - - -test_basic() diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 3144319..5875138 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -3,7 +3,6 @@ import os from typing import Any, Dict, Tuple import rtoml -from deepdiff import DeepDiff from joj3_config_generator.convert import convert from joj3_config_generator.models import repo, task -- 2.30.2 From d451fed83201fc00cb1782e0c212219aa10f347d Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 10:45:40 +0800 Subject: [PATCH 044/131] feat: remove tmp directory --- joj3_config_generator/convert.py | 2 +- joj3_config_generator/lib/repo.py | 8 +- tests/convert_joj1/basic/task.toml | 118 +++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 6 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 4fbda28..b20807e 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -37,7 +37,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: ) # Construct healthcheck stage - healthcheck_stage = getHealthcheckConfig(repo_conf, task_conf) + healthcheck_stage = getHealthcheckConfig(repo_conf) result_conf.stage.stages.append(healthcheck_stage) cached: list[str] = [] # Convert each stage in the task configuration diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index 3f1935a..ffba830 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -36,7 +36,7 @@ def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: else: immutable_files = immutable_files + name + "," # FIXME: need to make solution and make things easier to edit with global scope - chore = f"/tmp/repo-health-checker -root=. " + chore = f"./repo-health-checker -root=. " args = "" args = args + chore args = args + repo_size @@ -51,15 +51,13 @@ def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: args=args.split(), # FIXME: easier to edit within global scope copy_in={ - f"/tmp/repo-health-checker": result.CmdFile(src=f"/tmp/repo-health-checker") + f"./repo-health-checker": result.CmdFile(src=f"./repo-health-checker") }, ) return cmd -def getHealthcheckConfig( - repo_conf: repo.Config, task_conf: task.Config -) -> result.StageDetail: +def getHealthcheckConfig(repo_conf: repo.Config) -> result.StageDetail: healthcheck_stage = result.StageDetail( name="healthcheck", group="", diff --git a/tests/convert_joj1/basic/task.toml b/tests/convert_joj1/basic/task.toml index e69de29..a58cd74 100644 --- a/tests/convert_joj1/basic/task.toml +++ b/tests/convert_joj1/basic/task.toml @@ -0,0 +1,118 @@ +task = "cc" + +[[stages]] +name = "cc" +command = "run cc" +score = 100 +parsers = [] +skip = [] + +[stages.files] +import = [] +export = [] + +[stages.limit] +mem = 4 +cpu = 4 +stderr = 4 +stdout = 4 + +[stages.dummy] +comment = "" +score = 0 +forcequit = true + +[stages.result-status] +comment = "" +score = 0 +forcequit = true + +[stages.keyword] +keyword = [] +weight = [] + +[stages.clangtidy] +keyword = [] +weight = [] + +[stages.cppcheck] +keyword = [] +weight = [] + +[stages.cpplint] +keyword = [] +weight = [] + +[stages.result-detail] +time = true +mem = true +stdout = false +stderr = false +exitstatus = false +[stages.diff.output] +score = 0 +ignorespaces = false +hide = false +forcequit = true + +[stages.cases] + +[[stages]] +name = "c" +command = "run c" +score = 100 +parsers = [] +skip = [] + +[stages.files] +import = [] +export = [] + +[stages.limit] +mem = 4 +cpu = 4 +stderr = 4 +stdout = 4 + +[stages.dummy] +comment = "" +score = 0 +forcequit = true + +[stages.result-status] +comment = "" +score = 0 +forcequit = true + +[stages.keyword] +keyword = [] +weight = [] + +[stages.clangtidy] +keyword = [] +weight = [] + +[stages.cppcheck] +keyword = [] +weight = [] + +[stages.cpplint] +keyword = [] +weight = [] + +[stages.result-detail] +time = true +mem = true +stdout = false +stderr = false +exitstatus = false +[stages.diff.output] +score = 0 +ignorespaces = false +hide = false +forcequit = true + +[stages.cases] + +[release] +deadline = "null" -- 2.30.2 From 2521d571fd256dddd9bd43597bc2a1ef9ab65ca7 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 10:51:00 +0800 Subject: [PATCH 045/131] fix: task.json --- tests/convert/basic/task.json | 6 +++--- tests/convert/test_convert_cases.py | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 1a55fb8..a49a9d9 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -15,7 +15,7 @@ "with": { "default": { "args": [ - "/tmp/repo-health-checker", + "./repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -67,8 +67,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "/tmp/repo-health-checker": { - "src": "/tmp/repo-health-checker", + "./repo-health-checker": { + "src": "./repo-health-checker", "content": null, "fileId": null, "name": null, diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index 1a3392a..c3ac6cb 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -3,3 +3,5 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") + +test_basic() \ No newline at end of file -- 2.30.2 From c36977c3fa2415985d5baaef3cf5e2ae7dc14c96 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 13:08:08 +0800 Subject: [PATCH 046/131] feat: remove nulls function --- joj3_config_generator/lib/task.py | 11 +- joj3_config_generator/main.py | 2 + tests/convert/basic/repo.toml | 4 +- tests/convert/basic/task.json | 1228 +++++++++++---------------- tests/convert/basic/task.toml | 143 ++-- tests/convert/test_convert_cases.py | 2 - 6 files changed, 598 insertions(+), 792 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 1692f41..8666971 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,10 +1,19 @@ -from typing import Tuple +from typing import Any, Dict, Tuple import rtoml from joj3_config_generator.models import joj1, repo, result, task +def remove_nulls(d: Dict[str, Any]) -> Dict[str, Any]: + if isinstance(d, dict): + return {k: remove_nulls(v) for k, v in d.items() if v is not None} + elif isinstance(d, list): + return [remove_nulls(item) for item in d] + else: + return d + + def get_conf_stage( task_stage: task.Stage, executor_with_config: result.ExecutorWith ) -> result.StageDetail: diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 0e3f79c..d814496 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -9,6 +9,7 @@ import yaml from joj3_config_generator.convert import convert as convert_conf from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf +from joj3_config_generator.lib.task import remove_nulls from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.utils.logger import logger @@ -63,6 +64,7 @@ def convert(root: Path = Path(".")) -> result.Config: task_obj = rtoml.loads(task_toml) result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj)) result_dict = result_model.model_dump(by_alias=True) + result_dict = remove_nulls(result_dict) with open(result_json_path, "w") as result_file: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index 28b5c05..bb9818b 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -6,5 +6,5 @@ sandbox_token = "test" [files] whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" -required = ["main.py", "README.md"] -immutable = [] +required = [ "Changelog.md", "Readme.md" ] +immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index a49a9d9..9277b16 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "Homework 1 exercise 2", - "logPath": "Homework-1-exercise-2.log", + "name": "p2 m3", + "logPath": "p2-m3.log", "expireUnixTimestamp": 1728748740, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -18,42 +18,31 @@ "./repo-health-checker", "-root=.", "-repoSize=50.5", - "-meta=main.py", - "-meta=README.md", - "-checkFileSumList=-checkFileNameList=" + "-meta=Changelog.md", + "-meta=Readme.md", + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", + "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4096, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4096, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -69,11 +58,7 @@ "copyIn": { "./repo-health-checker": { "src": "./repo-health-checker", - "content": null, - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -104,117 +89,144 @@ ] }, { - "name": "Compilation", - "group": null, + "name": "Abuse of strings detected", "executor": { "name": "sandbox", "with": { "default": { "args": [ - "make.sh" + "./strdetect", + "src/" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", - "max": 128000000000, - "symlink": null, + "max": 4000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 180000000000, + "cpuLimit": 4000000000, "realCpuLimit": 0, - "clockLimit": 360000000000, + "clockLimit": 8000000000, "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "tools/make.sh": { - "src": "/home/tt/.config/joj/tools/make.sh", - "content": null, - "fileId": null, - "name": null, + "tools/strdetec": { + "src": "/home/tt/.config/joj/tools/strdetec", "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/main.c": { - "src": "/home/tt/.config/joj/src/main.c", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/task.h": { - "src": "/home/tt/.config/joj/src/task.h", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "srcCMakelist.txt": { - "src": "/home/tt/.config/joj/srcCMakelist.txt", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false } }, "copyInCached": { - "tools/make.sh": "tools/make.sh", - "src/main.c": "src/main.c", - "src/task.h": "src/task.h", - "srcCMakelist.txt": "srcCMakelist.txt" + "tools/strdetec": "tools/strdetec" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true + } + } + ] + }, + { + "name": "Compilation", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "compile" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/compile": { + "src": "/home/tt/.config/joj/tools/compile", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/compile": "tools/compile" }, "copyInDir": ".", "copyOut": [], "copyOutCached": [ - "driver", - "p2", - "p2-msan" + "build/onecard", + "build/asan", + "build/ubsan", + "build/msan", + "build/compile_commands.json" ], "copyOutMax": 0, "copyOutDir": "", @@ -245,7 +257,7 @@ "with": { "score": 1, "comment": "Congratulations! Your code compiled successfully.", - "forceQuitOnNotAccepted": false + "forceQuitOnNotAccepted": true } }, { @@ -253,22 +265,21 @@ "with": { "score": 1, "comment": "Congratulations! Your code compiled successfully.", - "forceQuitOnNotAccepted": false + "forceQuitOnNotAccepted": true } } ] }, { - "name": "File length check", - "group": null, + "name": "[cq] Filelength", "executor": { "name": "sandbox", "with": { "default": { "args": [ "./file-length", - "500", "400", + "300", "*.c", "*.h" ], @@ -276,34 +287,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -317,20 +316,16 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "tools/file-length": { - "src": "/home/tt/.config/joj/tools/file-length", - "content": null, - "fileId": null, - "name": null, + "tools/filelength": { + "src": "/home/tt/.config/joj/tools/filelength", "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false } }, "copyInCached": { - "tools/file-length": "tools/file-length" + "tools/filelength": "tools/filelength" }, "copyInDir": ".", "copyOut": [], @@ -352,154 +347,15 @@ "matches": [ { "keywords": [ - "max" - ], - "score": 50 - }, - { - "keywords": [ - "recommend" - ], - "score": 20 - } - ] - } - }, - { - "name": "dummy", - "with": { - "score": 10000, - "comment": "Manuel Charlemagne", - "forceQuitOnNotAccepted": true - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Clang-tidy checks", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "run-clang-tidy-18", - "-header-filter=.*", - "-quiet", - "-load=/usr/local/lib/libcodequality.so", - "-p", - "build" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "clangtidy", - "with": { - "matches": [ - { - "keywords": [ - "bugprone-suspicious-string-compare" - ], - "score": 8 - }, - { - "keywords": [ - "codequality-no-global-variables", - "codequality-no-header-guard", - "readability-duplicate-include", - "readability-misleading-indentation" + "recommended" ], "score": 10 }, { "keywords": [ - "readability-function-size" + "max" ], - "score": 50 - }, - { - "keywords": [ - "readability-identifier-naming", - "readability-redundant", - "readability-misplaced-array-index", - "cppcoreguidelines-init-variables", - "google-global-names-in-headers", - "clang-diagnostic", - "clang-analyzer", - "misc performance" - ], - "score": 5 + "score": 20 } ] } @@ -528,8 +384,147 @@ ] }, { - "name": "Cppcheck check", - "group": null, + "name": "[cq] Clang-tidy", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "run-clang-tidy-18", + "-header-filter=.*", + "-quiet", + "-load=/usr/local/lib/libcodequality.so", + "-p", + "build" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 65000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "projects/p2/.clang-tidy": { + "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "projects/p2/.clang-tidy": "projects/p2/.clang-tidy" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "clangtidy", + "with": { + "matches": [ + { + "keywords": [ + "readability-function-size" + ], + "score": 10 + }, + { + "keywords": [ + "codequality-no-global-variables", + "codequality-no-header-guard", + "codequality-no-fflush-stdin" + ], + "score": 20 + }, + { + "keywords": [ + "codequality-unchecked-malloc-result", + "readability-duplicate-include", + "readability-identifier-naming", + "readability-redundant", + "readability-misplaced-array-index", + "cppcoreguidelines-init-variables", + "bugprone-suspicious-string-compare", + "google-global-names-in-headers", + "clang-diagnostic", + "clang-analyzer", + "misc", + "performance", + "portability" + ], + "score": 5 + }, + { + "keywords": [ + "readability-misleading-indentation" + ], + "score": 15 + } + ] + } + }, + { + "name": "dummy", + "with": { + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "[cq] Cppcheck", "executor": { "name": "sandbox", "with": { @@ -543,6 +538,7 @@ "\"id\":\"{id}\"}'", "--force", "--enable=all", + "--suppress=missingIncludeSystem", "--quiet", "./" ], @@ -550,34 +546,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 65000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -613,21 +597,16 @@ { "keywords": [ "warning", + "portability", + "performance", "style" ], - "score": 10 + "score": 5 }, { "keywords": [ "error" ], - "score": 20 - }, - { - "keywords": [ - "portability", - "performance" - ], "score": 15 } ] @@ -657,8 +636,7 @@ ] }, { - "name": "Cpplint check", - "group": null, + "name": "[cq] Cpplint", "executor": { "name": "sandbox", "with": { @@ -675,34 +653,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 65000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -740,7 +706,7 @@ "matches": [ { "keywords": [ - "runtime" + "build" ], "score": 10 }, @@ -752,262 +718,9 @@ }, { "keywords": [ - "build" + "runtime" ], - "score": 15 - } - ] - } - }, - { - "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "judge-base", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 3000000000, - "realCpuLimit": 0, - "clockLimit": 6000000000, - "memoryLimit": 78643200, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case8.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case8.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] + "score": 5 } ] } @@ -1029,63 +742,50 @@ "stderr" ], "showExitStatus": true, - "showRuntime": true, - "showMemory": true + "showRuntime": false, + "showMemory": false } } ] }, { - "name": "judge-msan", - "group": "joj", + "name": "[run] onecard", "executor": { "name": "sandbox", "with": { "default": { "args": [ - "./driver", - "./mumsh-msan" + "./onecard", + "-a" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 10000000000, + "cpuLimit": 4000000000, "realCpuLimit": 0, - "clockLimit": 20000000000, - "memoryLimit": 524288000, + "clockLimit": 8000000000, + "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -1102,175 +802,259 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case6.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] + "cases": [] } }, "parsers": [ { - "name": "diff", + "name": "result-status", "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", - "forceQuitOnDiff": true, - "alwaysHide": true, - "compareSpace": true - } - ] - } - ] + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false } }, { - "name": "dummy", + "name": "result-detail", "with": { "score": 0, "comment": "", - "forceQuitOnNotAccepted": true + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[run] address sanitizer", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./asan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[run] memory sanitizer", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./msan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[run] undefined behavior sanitizer", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./ubsan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false } }, { diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index b060a9e..118247d 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,22 +1,31 @@ -# general task configuration -task="Homework 1 exercise 2" # task name +# p2 repo config + +task="p2 m3" # task name release.deadline = 2024-10-12 23:59:00+08:00 release.stages = [ "compile" ] +[files] +immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] +required = [ "Changelog.md", "Readme.md" ] + +[[stages]] +name = "Abuse of strings detected" +command = "./strdetect src/" +files.import = [ "tools/strdetec" ] + +parsers = [ "result-status" ] + + [[stages]] name = "Compilation" -command = "make.sh" # eg. script running cmake commands -files.import = [ "tools/make.sh", "src/main.c", "src/task.h", "srcCMakelist.txt" ] -files.export = [ "driver", "p2", "p2-msan" ] -limit.cpu = 180 # p2 takes long to compile -limit.stderr = 128 +command = "compile" +files.import = [ "tools/compile" ] +files.export = [ "build/onecard", "build/asan", "build/ubsan", "build/msan", "build/compile_commands.json" ] -# 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 @@ -24,29 +33,13 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "File length check" -command = "./file-length 500 400 *.c *.h" # command to run -files.import = [ "tools/file-length" ] +name = "[cq] Filelength" +command = "./file-length 400 300 *.c *.h" +files.import = [ "tools/filelength" ] parsers = [ "keyword", "dummy", "result-detail" ] -keyword.keyword = [ "max", "recommend"] # keywords caught by corresponding JOJ plugin -keyword.weight = [ 50, 20 ] # weight of each keyword -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" -command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" -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] +keyword.keyword = [ "max", "recommended"] +keyword.weight = [ 20, 10 ] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stdout = true @@ -54,13 +47,28 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "Cppcheck check" -command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --quiet ./" +name = "[cq] Clang-tidy" +command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" +files.import = [ "projects/p2/.clang-tidy", "build/compile_commands.json" ] +limit.stdout = 65 + +parsers = [ "clangtidy", "dummy", "result-detail" ] +clangtidy.keyword = [ "codequality-unchecked-malloc-result", "codequality-no-global-variables", "codequality-no-header-guard", "codequality-no-fflush-stdin", "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", "portability" ] +clangtidy.weight = [ 5, 20, 20, 20, 10, 5, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stdout = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[cq] Cppcheck" +command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --suppress=missingIncludeSystem --quiet ./" limit.stderr = 65 parsers = [ "cppcheck", "dummy", "result-detail" ] cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] -cppcheck.weight = [20, 10, 15, 15, 10] +cppcheck.weight = [15, 5, 5, 5, 5] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stderr = true @@ -68,57 +76,62 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "Cpplint check" +name = "[cq] Cpplint" command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard --recursive --exclude=build ." limit.stdout = 65 parsers = [ "cpplint", "dummy", "result-detail" ] cpplint.keyword = [ "runtime", "readability", "build" ] -cpplint.weight = [ 10, 20, 15] +cpplint.weight = [ 5, 20, 10] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true -result-detail.stdout = true +result-detail.stderr = true result-detail.time = false result-detail.mem = false [[stages]] -name = "judge-base" -command="./driver ./mumsh" -limit.cpu = 3 -limit.mem = 75 -score = 10 +name = "[run] onecard" +group = "run" +command="./onecard -a" +files.import = [ "build/onecard" ] -parsers = ["diff", "dummy", "result-detail"] -dummy.comment = "\n\n### Details\n" +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false result-detail.exitstatus = true result-detail.stderr = true -case4.score = 15 -case4.limit.cpu = 30 -case4.limit.mem = 10 -case4.limit.stdout = 8 - -case5.score = 25 - -case8.limit.stderr = 128 - [[stages]] -name = "judge-msan" -command="./driver ./mumsh-msan" -limit.cpu = 10 # default cpu limit (in sec) for each test case -limit.mem = 500 # set default mem limit (in MB) for all OJ test cases -score = 10 -skip = ["case0", "case11"] +name = "[run] address sanitizer" +group = "run" +command="./asan -a" +files.import = [ "build/asan" ] -parsers = ["diff", "dummy", "result-detail"] -dummy.comment = "\n\n### Details\n" +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false result-detail.exitstatus = true result-detail.stderr = true -case4.score = 15 -case4.limit.cpu = 30 -case4.limit.mem = 10 +[[stages]] +name = "[run] memory sanitizer" +group = "run" +command="./msan -a" +files.import = [ "build/msan" ] -case5.diff.output.ignorespaces = false +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true -case6.diff.output.hide = true +[[stages]] +name = "[run] undefined behavior sanitizer" +command="./ubsan -a" +files.import = [ "build/ubsan" ] + +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index c3ac6cb..1a3392a 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -3,5 +3,3 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") - -test_basic() \ No newline at end of file -- 2.30.2 From befcf4931d0d8e35e24bd7c92845f6ee19095019 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 14:05:54 +0800 Subject: [PATCH 047/131] fix: shell split command args --- joj3_config_generator/lib/repo.py | 3 ++- joj3_config_generator/lib/task.py | 7 ++++++- tests/convert/basic/task.json | 6 +----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index ffba830..14bdb79 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -1,4 +1,5 @@ import hashlib +import shlex import socket from joj3_config_generator.models import joj1, repo, result, task @@ -48,7 +49,7 @@ def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: args = args + immutable_files cmd = result.Cmd( - args=args.split(), + args=shlex.split(args), # FIXME: easier to edit within global scope copy_in={ f"./repo-health-checker": result.CmdFile(src=f"./repo-health-checker") diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 8666971..f562b9b 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,3 +1,4 @@ +import shlex from typing import Any, Dict, Tuple import rtoml @@ -59,7 +60,11 @@ def get_executorWithConfig( ) executor_with_config = result.ExecutorWith( default=result.Cmd( - args=(task_stage.command.split() if task_stage.command is not None else []), + args=( + shlex.split(task_stage.command) + if task_stage.command is not None + else [] + ), copy_in={ file: result.CmdFile(src=f"/home/tt/.config/joj/{file}") for file in copy_in_files diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 9277b16..9d67b24 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -531,11 +531,7 @@ "default": { "args": [ "cppcheck", - "--template='{\"file\":\"{file}\",\"line\":{line},", - "\"column\":{column},", - "\"severity\":\"{severity}\",", - "\"message\":\"{message}\",", - "\"id\":\"{id}\"}'", + "--template={\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}", "--force", "--enable=all", "--suppress=missingIncludeSystem", -- 2.30.2 From 6ecfeece62e08ef642f4da8be9498fa15b525ab7 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 14:38:20 +0800 Subject: [PATCH 048/131] fix: file path setting --- joj3_config_generator/lib/repo.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index 14bdb79..c8e1d5b 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -1,6 +1,7 @@ import hashlib import shlex import socket +from pathlib import Path from joj3_config_generator.models import joj1, repo, result, task @@ -80,7 +81,10 @@ def calc_sha256sum(file_path: str) -> str: def get_hash(immutable_files: list[str]) -> str: # input should be a list - file_path = "../immutable_file/" # TODO: change this when things are on the server + # FIXME: should be finalized when get into the server + current_file_path = Path(__file__).resolve() + project_root = current_file_path.parents[2] + file_path = f"{project_root}/tests/immutable_file/" immutable_hash = [] for i, file in enumerate(immutable_files): immutable_files[i] = file_path + file.rsplit("/", 1)[-1] -- 2.30.2 From 76590e6a25f68c8d1c95a2462f7a0fddb1145be4 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 14:48:23 +0800 Subject: [PATCH 049/131] fix: pass test --- joj3_config_generator/main.py | 2 +- tests/convert/basic/task.json | 162 ++++++++++++++++++++++++++++ tests/convert/test_convert_cases.py | 2 + tests/convert/utils.py | 1 + 4 files changed, 166 insertions(+), 1 deletion(-) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index d814496..8a42950 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -63,8 +63,8 @@ def convert(root: Path = Path(".")) -> result.Config: repo_obj = rtoml.loads(repo_toml) task_obj = rtoml.loads(task_toml) result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj)) + result_model = remove_nulls(result_model) result_dict = result_model.model_dump(by_alias=True) - result_dict = remove_nulls(result_dict) with open(result_json_path, "w") as result_file: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 9d67b24..1603820 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -27,22 +27,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4096, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4096, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -58,7 +70,11 @@ "copyIn": { "./repo-health-checker": { "src": "./repo-health-checker", + "content": null, + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -90,6 +106,7 @@ }, { "name": "Abuse of strings detected", + "group": null, "executor": { "name": "sandbox", "with": { @@ -102,22 +119,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -133,7 +162,11 @@ "copyIn": { "tools/strdetec": { "src": "/home/tt/.config/joj/tools/strdetec", + "content": null, + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -168,6 +201,7 @@ }, { "name": "Compilation", + "group": null, "executor": { "name": "sandbox", "with": { @@ -179,22 +213,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -210,7 +256,11 @@ "copyIn": { "tools/compile": { "src": "/home/tt/.config/joj/tools/compile", + "content": null, + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -272,6 +322,7 @@ }, { "name": "[cq] Filelength", + "group": null, "executor": { "name": "sandbox", "with": { @@ -287,22 +338,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -318,7 +381,11 @@ "copyIn": { "tools/filelength": { "src": "/home/tt/.config/joj/tools/filelength", + "content": null, + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -385,6 +452,7 @@ }, { "name": "[cq] Clang-tidy", + "group": null, "executor": { "name": "sandbox", "with": { @@ -401,22 +469,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 65000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -432,7 +512,11 @@ "copyIn": { "projects/p2/.clang-tidy": { "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", + "content": null, + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -525,6 +609,7 @@ }, { "name": "[cq] Cppcheck", + "group": null, "executor": { "name": "sandbox", "with": { @@ -542,22 +627,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 65000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -633,6 +730,7 @@ }, { "name": "[cq] Cpplint", + "group": null, "executor": { "name": "sandbox", "with": { @@ -649,22 +747,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 65000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -746,6 +856,7 @@ }, { "name": "[run] onecard", + "group": null, "executor": { "name": "sandbox", "with": { @@ -758,22 +869,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -827,6 +950,7 @@ }, { "name": "[run] address sanitizer", + "group": null, "executor": { "name": "sandbox", "with": { @@ -839,22 +963,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -908,6 +1044,7 @@ }, { "name": "[run] memory sanitizer", + "group": null, "executor": { "name": "sandbox", "with": { @@ -920,22 +1057,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -989,6 +1138,7 @@ }, { "name": "[run] undefined behavior sanitizer", + "group": null, "executor": { "name": "sandbox", "with": { @@ -1001,22 +1151,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index 1a3392a..c3ac6cb 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -3,3 +3,5 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") + +test_basic() \ No newline at end of file diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 5875138..0d7e395 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -29,4 +29,5 @@ def read_convert_files( def load_case(case_name: str) -> None: repo, task, expected_result = read_convert_files(case_name) result = convert(repo, task).model_dump(mode="json", by_alias=True) + assert result == expected_result -- 2.30.2 From 60668f86df283d3c343812ef8ba473557eef3de8 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 14:54:39 +0800 Subject: [PATCH 050/131] fix: type annotation --- joj3_config_generator/lib/task.py | 4 ++-- tests/convert/test_convert_cases.py | 3 ++- tests/convert/utils.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index f562b9b..fdfab1f 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,12 +1,12 @@ import shlex -from typing import Any, Dict, Tuple +from typing import Tuple import rtoml from joj3_config_generator.models import joj1, repo, result, task -def remove_nulls(d: Dict[str, Any]) -> Dict[str, Any]: +def remove_nulls(d: result.Config) -> result.Config: if isinstance(d, dict): return {k: remove_nulls(v) for k, v in d.items() if v is not None} elif isinstance(d, list): diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index c3ac6cb..6aa8a0c 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -4,4 +4,5 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") -test_basic() \ No newline at end of file + +test_basic() diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 0d7e395..8a2c3f1 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -29,5 +29,5 @@ def read_convert_files( def load_case(case_name: str) -> None: repo, task, expected_result = read_convert_files(case_name) result = convert(repo, task).model_dump(mode="json", by_alias=True) - + assert result == expected_result -- 2.30.2 From b45d65250d2f2aecd31576353a470a78082adde1 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 18:53:41 +0800 Subject: [PATCH 051/131] feat: migrate repo & init classes --- joj3_config_generator/convert.py | 57 ++- joj3_config_generator/lib/__init__.py | 11 + joj3_config_generator/lib/repo.py | 65 ++- joj3_config_generator/models/task.py | 48 +- tests/convert/basic/repo.toml | 4 +- tests/convert/basic/task.json | 712 ++++++-------------------- tests/convert/basic/task.toml | 124 ++--- 7 files changed, 325 insertions(+), 696 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index b20807e..914bef5 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -19,35 +19,76 @@ from joj3_config_generator.lib.task import ( get_executorWithConfig, ) from joj3_config_generator.models import joj1, repo, result, task +from joj3_config_generator.lib.repo import getHealthcheckConfig, getTeapotConfig +from joj3_config_generator.models import ( + Cmd, + CmdFile, + ExecutorConfig, + ExecutorWithConfig, + ParserConfig, + Repo, + ResultConfig, + Stage, + StageConfig, + Task, + TeapotConfig, +) +# FIXME: LLM generated convert function, only for demostration def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Create the base ResultConf object result_conf = result.Config( name=task_conf.task, # TODO: specify the exact folder difference log_path=f"{task_conf.task.replace(' ', '-')}.log", + # TODO: specify the exact folder difference + log_path=f"{task_conf.task.replace(' ', '-')}.log", expire_unix_timestamp=( int(task_conf.release.deadline.timestamp()) if task_conf.release.deadline else -1 ), stage=result.Stage(stages=[], sandbox_token=repo_conf.sandbox_token), + teapot=result.Teapot(), + stage=StageConfig(stages=[], sandbox_token=repo_conf.sandbox_token), teapot=getTeapotConfig(repo_conf, task_conf), ) # Construct healthcheck stage - healthcheck_stage = getHealthcheckConfig(repo_conf) + healthcheck_stage = getHealthcheckConfig(repo_conf, task_conf) result_conf.stage.stages.append(healthcheck_stage) - cached: list[str] = [] + cached = [] # Convert each stage in the task configuration for task_stage in task_conf.stages: - 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_dummy(task_stage, conf_stage) - conf_stage = fix_keyword(task_stage, conf_stage) - conf_stage = fix_diff(task_stage, conf_stage) + executor_with_config = result.ExecutorWith( + default=result.Cmd( + args=task_stage.command.split(), + copy_in={ + file: result.CmdFile(src=file) for file in task_stage.files.import_ + }, + copy_out_cached=task_stage.files.export, + ), + cases=[], # You can add cases if needed + ) + conf_stage = result.StageDetail( + name=task_stage.name, + group=task_conf.task, + executor=result.Executor( + name="sandbox", + with_=executor_with_config, + ), + parsers=[ + result.Parser(name=parser, with_={}) for parser in task_stage.parsers + ], + ) + if "result-detail" in task_stage.parsers: + result_detail_parser = next( + p for p in conf_stage.parsers if p.name == "result-detail" + ) + if task_stage.result_detail is not None: + result_detail_parser.with_.update(task_stage.result_detail) + result_conf.stage.stages.append(conf_stage) return result_conf diff --git a/joj3_config_generator/lib/__init__.py b/joj3_config_generator/lib/__init__.py index e69de29..68802d4 100644 --- a/joj3_config_generator/lib/__init__.py +++ b/joj3_config_generator/lib/__init__.py @@ -0,0 +1,11 @@ +from joj3_config_generator.models.repo import Repo as Repo +from joj3_config_generator.models.result import Cmd as Cmd +from joj3_config_generator.models.result import CmdFile as CmdFile +from joj3_config_generator.models.result import ExecutorConfig as ExecutorConfig +from joj3_config_generator.models.result import ExecutorWithConfig as ExecutorWithConfig +from joj3_config_generator.models.result import ParserConfig as ParserConfig +from joj3_config_generator.models.result import ResultConfig as ResultConfig +from joj3_config_generator.models.result import Stage as Stage +from joj3_config_generator.models.result import StageConfig as StageConfig +from joj3_config_generator.models.result import TeapotConfig as TeapotConfig +from joj3_config_generator.models.task import Task as Task diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index c8e1d5b..e9a8d33 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -1,18 +1,40 @@ import hashlib -import shlex -import socket -from pathlib import Path +import os +import tempfile -from joj3_config_generator.models import joj1, repo, result, task +from dotenv import load_dotenv + +from joj3_config_generator.models import ( + Cmd, + CmdFile, + ExecutorConfig, + ExecutorWithConfig, + ParserConfig, + Repo, + ResultConfig, + Stage, + StageConfig, + Task, + TeapotConfig, +) + + +def get_temp_directory() -> str: + return tempfile.mkdtemp(prefix="repo-checker-") def getGradingRepoName() -> str: - host_name = socket.gethostname() - return f"{host_name.split('-')[0]}-joj" + path = os.path.expanduser("~/.config/teapot/teapot.env") + if os.path.exists(path): + load_dotenv(path) + repo_name = os.environ.get("GITEA_ORG_NAME") + if repo_name is not None: + return f"{repo_name.split('-')[0]}-joj" + return "ece482-joj" -def getTeapotConfig(repo_conf: repo.Config, task_conf: task.Config) -> result.Teapot: - teapot = result.Teapot( +def getTeapotConfig(repo_conf: Repo, task_conf: Task) -> TeapotConfig: + teapot = TeapotConfig( # TODO: fix the log path log_path=f"{task_conf.task.replace(' ', '-')}-joint-teapot-debug.log", scoreboard_path=f"{task_conf.task.replace(' ', '-')}-scoreboard.csv", @@ -22,7 +44,7 @@ def getTeapotConfig(repo_conf: repo.Config, task_conf: task.Config) -> result.Te return teapot -def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: +def getHealthcheckCmd(repo_conf: Repo) -> Cmd: repoSize = repo_conf.max_size immutable = repo_conf.files.immutable repo_size = f"-repoSize={str(repoSize)} " @@ -38,7 +60,7 @@ def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: else: immutable_files = immutable_files + name + "," # FIXME: need to make solution and make things easier to edit with global scope - chore = f"./repo-health-checker -root=. " + chore = f"/{get_temp_directory}/repo-health-checker -root=. " args = "" args = args + chore args = args + repo_size @@ -49,25 +71,27 @@ def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: args = args + immutable_files - cmd = result.Cmd( - args=shlex.split(args), + cmd = Cmd( + args=args.split(), # FIXME: easier to edit within global scope copy_in={ - f"./repo-health-checker": result.CmdFile(src=f"./repo-health-checker") + f"/{get_temp_directory()}/repo-health-checker": CmdFile( + src=f"/{get_temp_directory()}/repo-health-checker" + ) }, ) return cmd -def getHealthcheckConfig(repo_conf: repo.Config) -> result.StageDetail: - healthcheck_stage = result.StageDetail( +def getHealthcheckConfig(repo_conf: Repo, task_conf: Task) -> Stage: + healthcheck_stage = Stage( name="healthcheck", group="", - executor=result.Executor( + executor=ExecutorConfig( name="sandbox", - with_=result.ExecutorWith(default=getHealthcheckCmd(repo_conf), cases=[]), + with_=ExecutorWithConfig(default=getHealthcheckCmd(repo_conf), cases=[]), ), - parsers=[result.Parser(name="healthcheck", with_={"score": 0, "comment": ""})], + parsers=[ParserConfig(name="healthcheck", with_={"score": 0, "comment": ""})], ) return healthcheck_stage @@ -81,10 +105,7 @@ def calc_sha256sum(file_path: str) -> str: def get_hash(immutable_files: list[str]) -> str: # input should be a list - # FIXME: should be finalized when get into the server - current_file_path = Path(__file__).resolve() - project_root = current_file_path.parents[2] - file_path = f"{project_root}/tests/immutable_file/" + file_path = "../immutable_file/" # TODO: change this when things are on the server immutable_hash = [] for i, file in enumerate(immutable_files): immutable_files[i] = file_path + file.rsplit("/", 1)[-1] diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 684cdd5..85b58fe 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -14,31 +14,17 @@ class ParserResultDetail(BaseModel): class ParserDummy(BaseModel): comment: Optional[str] = "" - score: Optional[int] = 0 - forcequit: Optional[bool] = True class ParserKeyword(BaseModel): - keyword: Optional[list[str]] = [] - weight: Optional[list[int]] = [] - - -class Outputs(BaseModel): - score: Optional[int] = 0 - ignorespaces: Optional[bool] = False - hide: Optional[bool] = False - forcequit: Optional[bool] = True - - -class ParserDiff(BaseModel): - output: Optional[Outputs] = Outputs() + keyword: Optional[list[str]] = None + weight: Optional[list[int]] = None class Files(BaseModel): - import_: Optional[List[str]] = Field( - [], serialization_alias="import", validation_alias="import" - ) - export: Optional[List[str]] = [] + import_: Optional[List[str]] = Field(serialization_alias="import", validation_alias="import") + export: Optional[List[str]] + class Limit(BaseModel): @@ -49,36 +35,20 @@ class Limit(BaseModel): class Stage(BaseModel): - name: Optional[str] = None # Stage name - command: Optional[str] = None # Command to run + name: str # Stage name + command: str # Command to run files: Optional[Files] = None score: Optional[int] = 0 - parsers: Optional[list[str]] = [] # list of parsers - limit: Optional[Limit] = Limit() + 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() - # FIXME: determine cpplint type cpplint: Optional[ParserKeyword] = ParserKeyword() result_detail: Optional[ParserResultDetail] = Field( ParserResultDetail(), alias="result-detail" ) - skip: Optional[list[str]] = [] - diff: Optional[ParserDiff] = ParserDiff() - cases: Optional[Dict[str, "Stage"]] = {} - - class Config: - extra = "allow" - - @root_validator(pre=True) - def gather_cases(cls: Type["Stage"], values: Dict[str, Any]) -> Dict[str, Any]: - cases = {k: v for k, v in values.items() if k.startswith("case")} - for key in cases: - values.pop(key) - values["cases"] = {k: Stage(**v) for k, v in cases.items()} - return values class Release(BaseModel): diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index bb9818b..c77b9f7 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -6,5 +6,5 @@ sandbox_token = "test" [files] whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" -required = [ "Changelog.md", "Readme.md" ] -immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] +required = ["main.py", "README.md"] +immutable = [".gitignore", ".gitattributes", "push.yaml", "release.yaml"] diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 1603820..777e2d7 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "p2 m3", - "logPath": "p2-m3.log", + "name": "Homework 1 exercise 2", + "logPath": "Homework-1-exercise-2.log", "expireUnixTimestamp": 1728748740, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -15,13 +15,13 @@ "with": { "default": { "args": [ - "./repo-health-checker", + "/tmp/repo-health-checker", "-root=.", "-repoSize=50.5", - "-meta=Changelog.md", - "-meta=Readme.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", - "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml" + "-meta=main.py", + "-meta=README.md", + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,8d1229900c6fc6711b5cc141d1ab5ea7f5b7b7a4b921d9cfa3957408b43ae723,eb857bcd94857cedc4045cb2d6ba04cb5bbb3daf188abc95fb9478db823ef47e", + "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -68,8 +68,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "./repo-health-checker": { - "src": "./repo-health-checker", + "/tmp/repo-health-checker": { + "src": "/tmp/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -104,101 +104,6 @@ } ] }, - { - "name": "Abuse of strings detected", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./strdetect", - "src/" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/strdetec": { - "src": "/home/tt/.config/joj/tools/strdetec", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/strdetec": "tools/strdetec" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } - } - ] - }, { "name": "Compilation", "group": null, @@ -207,7 +112,7 @@ "with": { "default": { "args": [ - "compile" + "make.sh" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -228,7 +133,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -239,7 +144,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -249,13 +154,16 @@ "realCpuLimit": 0, "clockLimit": 8000000000, "memoryLimit": 4194304, + "clockLimit": 8000000000, + "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, + "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "tools/compile": { - "src": "/home/tt/.config/joj/tools/compile", + "tools/make.sh": { + "src": "/home/tt/.config/joj/tools/make.sh", "content": null, "fileId": null, "name": null, @@ -264,19 +172,54 @@ "streamIn": false, "streamOut": false, "pipe": false + }, + "src/main.c": { + "src": "/home/tt/.config/joj/src/main.c", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/task.h": { + "src": "/home/tt/.config/joj/src/task.h", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "srcCMakelist.txt": { + "src": "/home/tt/.config/joj/srcCMakelist.txt", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false } }, "copyInCached": { - "tools/compile": "tools/compile" + "tools/make.sh": "tools/make.sh", + "src/main.c": "src/main.c", + "src/task.h": "src/task.h", + "srcCMakelist.txt": "srcCMakelist.txt" }, "copyInDir": ".", "copyOut": [], "copyOutCached": [ - "build/onecard", - "build/asan", - "build/ubsan", - "build/msan", - "build/compile_commands.json" + "driver", + "p2", + "p2-msan" ], "copyOutMax": 0, "copyOutDir": "", @@ -290,38 +233,27 @@ }, "parsers": [ { - "name": "result-detail", + "name": "result-status", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false + "time": false, + "mem": false, + "stdout": false, + "stderr": true, + "exitstatus": true } }, { "name": "dummy", - "with": { - "score": 1, - "comment": "Congratulations! Your code compiled successfully.", - "forceQuitOnNotAccepted": true - } + "with": {} }, { "name": "result-status", - "with": { - "score": 1, - "comment": "Congratulations! Your code compiled successfully.", - "forceQuitOnNotAccepted": true - } + "with": {} } ] }, { - "name": "[cq] Filelength", + "name": "File length check", "group": null, "executor": { "name": "sandbox", @@ -329,8 +261,8 @@ "default": { "args": [ "./file-length", + "500", "400", - "300", "*.c", "*.h" ], @@ -353,7 +285,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -364,7 +296,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -374,13 +306,16 @@ "realCpuLimit": 0, "clockLimit": 8000000000, "memoryLimit": 4194304, + "clockLimit": 8000000000, + "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, + "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "tools/filelength": { - "src": "/home/tt/.config/joj/tools/filelength", + "tools/file-length": { + "src": "/home/tt/.config/joj/tools/file-length", "content": null, "fileId": null, "name": null, @@ -392,7 +327,7 @@ } }, "copyInCached": { - "tools/filelength": "tools/filelength" + "tools/file-length": "tools/file-length" }, "copyInDir": ".", "copyOut": [], @@ -410,48 +345,26 @@ "parsers": [ { "name": "keyword", - "with": { - "matches": [ - { - "keywords": [ - "recommended" - ], - "score": 10 - }, - { - "keywords": [ - "max" - ], - "score": 20 - } - ] - } + "with": {} }, { "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } + "with": {} }, { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false + "time": false, + "mem": false, + "stdout": false, + "stderr": true, + "exitstatus": false } } ] }, { - "name": "[cq] Clang-tidy", + "name": "Clang-tidy checks", "group": null, "executor": { "name": "sandbox", @@ -484,7 +397,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 65000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -495,7 +408,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -509,22 +422,8 @@ "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", - "copyIn": { - "projects/p2/.clang-tidy": { - "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "projects/p2/.clang-tidy": "projects/p2/.clang-tidy" - }, + "copyIn": {}, + "copyInCached": {}, "copyInDir": ".", "copyOut": [], "copyOutCached": [], @@ -541,74 +440,26 @@ "parsers": [ { "name": "clangtidy", - "with": { - "matches": [ - { - "keywords": [ - "readability-function-size" - ], - "score": 10 - }, - { - "keywords": [ - "codequality-no-global-variables", - "codequality-no-header-guard", - "codequality-no-fflush-stdin" - ], - "score": 20 - }, - { - "keywords": [ - "codequality-unchecked-malloc-result", - "readability-duplicate-include", - "readability-identifier-naming", - "readability-redundant", - "readability-misplaced-array-index", - "cppcoreguidelines-init-variables", - "bugprone-suspicious-string-compare", - "google-global-names-in-headers", - "clang-diagnostic", - "clang-analyzer", - "misc", - "performance", - "portability" - ], - "score": 5 - }, - { - "keywords": [ - "readability-misleading-indentation" - ], - "score": 15 - } - ] - } + "with": {} }, { "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } + "with": {} }, { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false + "time": false, + "mem": false, + "stdout": true, + "stderr": false, + "exitstatus": true } } ] }, { - "name": "[cq] Cppcheck", + "name": "Cppcheck check", "group": null, "executor": { "name": "sandbox", @@ -616,10 +467,13 @@ "default": { "args": [ "cppcheck", - "--template={\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}", + "--template='{\"file\":\"{file}\",\"line\":{line},", + "\"column\":{column},", + "\"severity\":\"{severity}\",", + "\"message\":\"{message}\",", + "\"id\":\"{id}\"}'", "--force", "--enable=all", - "--suppress=missingIncludeSystem", "--quiet", "./" ], @@ -642,7 +496,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -653,7 +507,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 65000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -685,51 +539,26 @@ "parsers": [ { "name": "cppcheck", - "with": { - "matches": [ - { - "keywords": [ - "warning", - "portability", - "performance", - "style" - ], - "score": 5 - }, - { - "keywords": [ - "error" - ], - "score": 15 - } - ] - } + "with": {} }, { "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } + "with": {} }, { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false + "time": false, + "mem": false, + "stdout": false, + "stderr": true, + "exitstatus": true } } ] }, { - "name": "[cq] Cpplint", + "name": "Cpplint check", "group": null, "executor": { "name": "sandbox", @@ -762,7 +591,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 65000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -773,7 +602,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -805,65 +634,34 @@ "parsers": [ { "name": "cpplint", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true, - "matches": [ - { - "keywords": [ - "build" - ], - "score": 10 - }, - { - "keywords": [ - "readability" - ], - "score": 20 - }, - { - "keywords": [ - "runtime" - ], - "score": 5 - } - ] - } + "with": {} }, { "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } + "with": {} }, { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false + "time": false, + "mem": false, + "stdout": true, + "stderr": false, + "exitstatus": true } } ] }, { - "name": "[run] onecard", - "group": null, + "name": "judge-base", + "group": "joj", "executor": { "name": "sandbox", "with": { "default": { "args": [ - "./onecard", - "-a" + "./driver", + "./mumsh" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -884,7 +682,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -895,7 +693,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -926,38 +724,35 @@ }, "parsers": [ { - "name": "result-status", - "with": { - "score": 1, - "comment": "", - "forceQuitOnNotAccepted": false - } + "name": "diff", + "with": {} + }, + { + "name": "dummy", + "with": {} }, { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true + "time": true, + "mem": true, + "stdout": false, + "stderr": true, + "exitstatus": true } } ] }, { - "name": "[run] address sanitizer", - "group": null, + "name": "judge-msan", + "group": "joj", "executor": { "name": "sandbox", "with": { "default": { "args": [ - "./asan", - "-a" + "./driver", + "./mumsh-msan" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -978,7 +773,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -989,7 +784,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4000000000, + "max": 4096, "symlink": null, "streamIn": false, "streamOut": false, @@ -1020,212 +815,21 @@ }, "parsers": [ { - "name": "result-status", - "with": { - "score": 1, - "comment": "", - "forceQuitOnNotAccepted": false - } + "name": "diff", + "with": {} + }, + { + "name": "dummy", + "with": {} }, { "name": "result-detail", "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "[run] memory sanitizer", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./msan", - "-a" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 1, - "comment": "", - "forceQuitOnNotAccepted": false - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "[run] undefined behavior sanitizer", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./ubsan", - "-a" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 1, - "comment": "", - "forceQuitOnNotAccepted": false - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true + "time": true, + "mem": true, + "stdout": false, + "stderr": true, + "exitstatus": true } } ] @@ -1233,10 +837,10 @@ ] }, "teapot": { - "logPath": "/home/tt/.cache/joint-teapot-debug.log", - "scoreboardPath": "scoreboard.csv", - "failedTablePath": "failed-table.md", - "gradingRepoName": "", + "logPath": "Homework-1-exercise-2-joint-teapot-debug.log", + "scoreboardPath": "Homework-1-exercise-2-scoreboard.csv", + "failedTablePath": "Homework-1-exercise-2-failed-table.md", + "gradingRepoName": "engr151-joj", "skipIssue": false, "skipScoreboard": false, "skipFailedTable": false diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 118247d..ef299a4 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,31 +1,20 @@ -# p2 repo config - -task="p2 m3" # task name +# general task configuration +task="Homework 1 exercise 2" # task name release.deadline = 2024-10-12 23:59:00+08:00 release.stages = [ "compile" ] -[files] -immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] -required = [ "Changelog.md", "Readme.md" ] - -[[stages]] -name = "Abuse of strings detected" -command = "./strdetect src/" -files.import = [ "tools/strdetec" ] - -parsers = [ "result-status" ] - - [[stages]] name = "Compilation" -command = "compile" -files.import = [ "tools/compile" ] -files.export = [ "build/onecard", "build/asan", "build/ubsan", "build/msan", "build/compile_commands.json" ] +command = "make.sh" # eg. script running cmake commands +files.import = [ "tools/make.sh", "src/main.c", "src/task.h", "srcCMakelist.txt" ] +files.export = [ "driver", "p2", "p2-msan" ] +limit.cpu = 180 # p2 takes long to compile +limit.stderr = 128 +# compile parsers parsers = [ "result-detail", "dummy", "result-status" ] result-status.comment = "Congratulations! Your code compiled successfully." -result-status.score = 1 dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stderr = true @@ -33,28 +22,26 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "[cq] Filelength" -command = "./file-length 400 300 *.c *.h" -files.import = [ "tools/filelength" ] +name = "File length check" +command = "./file-length 500 400 *.c *.h" # command to run +files.import = [ "tools/file-length" ] parsers = [ "keyword", "dummy", "result-detail" ] -keyword.keyword = [ "max", "recommended"] -keyword.weight = [ 20, 10 ] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stdout = true +keyword.keyword = [ "max", "recommend"] # keywords caught by corresponding JOJ plugin +keyword.weight = [ 50, 20 ] # weight of each keyword +result-detail.exitstatus = false +result-detail.stderr = true result-detail.time = false result-detail.mem = false [[stages]] -name = "[cq] Clang-tidy" +name = "Clang-tidy checks" command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" -files.import = [ "projects/p2/.clang-tidy", "build/compile_commands.json" ] limit.stdout = 65 parsers = [ "clangtidy", "dummy", "result-detail" ] -clangtidy.keyword = [ "codequality-unchecked-malloc-result", "codequality-no-global-variables", "codequality-no-header-guard", "codequality-no-fflush-stdin", "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", "portability" ] -clangtidy.weight = [ 5, 20, 20, 20, 10, 5, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5] +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] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stdout = true @@ -62,13 +49,13 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "[cq] Cppcheck" -command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --suppress=missingIncludeSystem --quiet ./" +name = "Cppcheck check" +command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --quiet ./" limit.stderr = 65 parsers = [ "cppcheck", "dummy", "result-detail" ] cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] -cppcheck.weight = [15, 5, 5, 5, 5] +cppcheck.weight = [20, 10, 15, 15, 10] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stderr = true @@ -76,62 +63,57 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "[cq] Cpplint" +name = "Cpplint check" command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard --recursive --exclude=build ." limit.stdout = 65 parsers = [ "cpplint", "dummy", "result-detail" ] cpplint.keyword = [ "runtime", "readability", "build" ] -cpplint.weight = [ 5, 20, 10] +cpplint.weight = [ 10, 20, 15] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true -result-detail.stderr = true +result-detail.stdout = true result-detail.time = false result-detail.mem = false [[stages]] -name = "[run] onecard" -group = "run" -command="./onecard -a" -files.import = [ "build/onecard" ] +name = "judge-base" +command="./driver ./mumsh" +limit.cpu = 3 +limit.mem = 75 +score = 10 -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false +parsers = ["diff", "dummy", "result-detail"] +dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stderr = true +case4.score = 15 +case4.limit.cpu = 30 +case4.limit.mem = 10 +case4.limit.stdout = 8 + +case5.score = 25 + +case8.limit.stderr = 128 + [[stages]] -name = "[run] address sanitizer" -group = "run" -command="./asan -a" -files.import = [ "build/asan" ] +name = "judge-msan" +command="./driver ./mumsh-msan" +limit.cpu = 10 # default cpu limit (in sec) for each test case +limit.mem = 500 # set default mem limit (in MB) for all OJ test cases +score = 10 +skip = ["case0", "case11"] -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false +parsers = ["diff", "dummy", "result-detail"] +dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stderr = true -[[stages]] -name = "[run] memory sanitizer" -group = "run" -command="./msan -a" -files.import = [ "build/msan" ] +case4.score = 15 +case4.limit.cpu = 30 +case4.limit.mem = 10 -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true +case5.diff.output.ignorespaces = false -[[stages]] -name = "[run] undefined behavior sanitizer" -command="./ubsan -a" -files.import = [ "build/ubsan" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true +case6.diff.output.hide = true -- 2.30.2 From d638e20fb039c4c99cf442a3c29d2ae23d5f78a4 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:37:52 +0800 Subject: [PATCH 052/131] feat: finish keyword related --- joj3_config_generator/convert.py | 16 + joj3_config_generator/lib/task.py | 419 +-------------------------- joj3_config_generator/models/task.py | 5 +- tests/convert/basic/task.json | 184 +++++++++++- tests/convert/basic/task.toml | 2 +- 5 files changed, 205 insertions(+), 421 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 914bef5..66da3d4 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -20,6 +20,7 @@ from joj3_config_generator.lib.task import ( ) 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, @@ -82,6 +83,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" @@ -89,6 +91,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 diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index fdfab1f..c8bffeb 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,407 +1,20 @@ -import shlex -from typing import Tuple - -import rtoml - -from joj3_config_generator.models import joj1, repo, result, task +from joj3_config_generator.models.result import Stage as ResultStage +from joj3_config_generator.models.task import Stage as TaskStage -def remove_nulls(d: result.Config) -> result.Config: - if isinstance(d, dict): - return {k: remove_nulls(v) for k, v in d.items() if v is not None} - elif isinstance(d, list): - return [remove_nulls(item) for item in d] - else: - return d - - -def get_conf_stage( - task_stage: task.Stage, executor_with_config: result.ExecutorWith -) -> result.StageDetail: - conf_stage = result.StageDetail( - name=task_stage.name if task_stage.name is not None else "", - # TODO: we may have cq in future - group=( - "joj" - if (task_stage.name is not None) and ("judge" in task_stage.name) - else None - ), - executor=result.Executor( - name="sandbox", - with_=executor_with_config, - ), - parsers=( - [result.Parser(name=parser, with_={}) for parser in task_stage.parsers] - if task_stage.parsers is not None - else [] - ), - ) - return conf_stage - - -def get_executorWithConfig( - task_stage: task.Stage, cached: list[str] -) -> Tuple[result.ExecutorWith, list[str]]: - file_import = ( - task_stage.files.import_ - if hasattr(task_stage, "files") - and hasattr(task_stage.files, "import_") - and (task_stage.files is not None) - and (task_stage.files.import_ is not None) - else [] - ) - copy_in_files = [file for file in file_import if (file not in cached)] - file_export = ( - task_stage.files.export - if hasattr(task_stage, "files") - and hasattr(task_stage.files, "export") - and (task_stage.files is not None) - else [] - ) - executor_with_config = result.ExecutorWith( - default=result.Cmd( - args=( - shlex.split(task_stage.command) - if task_stage.command is not None - else [] - ), - copy_in={ - file: result.CmdFile(src=f"/home/tt/.config/joj/{file}") - for file in copy_in_files - }, - copy_in_cached={file: file for file in copy_in_files}, - copy_out_cached=file_export if file_export is not None else [], - cpu_limit=( - task_stage.limit.cpu * 1_000_000_000 - if task_stage.limit is not None and task_stage.limit.cpu is not None - else 4 * 1_000_000_000 - ), - clock_limit=( - 2 * task_stage.limit.cpu * 1_000_000_000 - if task_stage.limit is not None and task_stage.limit.cpu is not None - else 8 * 1_000_000_000 - ), - memory_limit=( - task_stage.limit.mem * 1_024 * 1_024 - if task_stage.limit is not None and task_stage.limit.mem is not None - else 4 * 1_024 * 1_024 - ), - stderr=result.CmdFile( - name="stderr", - max=( - task_stage.limit.stderr * 1_000_000_000 - if task_stage.limit is not None - and task_stage.limit.stderr is not None - else 4 * 1_024 * 1_024 - ), - ), - stdout=result.CmdFile( - name="stdout", - max=( - task_stage.limit.stdout * 1_000_000_000 - if task_stage.limit is not None - and task_stage.limit.stdout is not None - else 4 * 1_024 * 1_024 - ), - ), - ), - cases=[], # You can add cases if needed - ) - if file_export is not None: - for file in file_export: - if file not in cached: - cached.append(file) - return (executor_with_config, cached) - - -def fix_keyword( - task_stage: task.Stage, conf_stage: result.StageDetail -) -> result.StageDetail: - keyword_parser = ["clangtidy", "keyword", "cppcheck", "cpplint"] - if task_stage.parsers is not None: - 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: - unique_weight = list(set(getattr(task_stage, parser).weight)) - for score in unique_weight: - keyword_weight.append({"keywords": [], "score": score}) - - for idx, score in enumerate(unique_weight): - for idx_, score_ in enumerate( - getattr(task_stage, parser).weight - ): - if score == score_: - keyword_weight[idx]["keywords"].append( - getattr(task_stage, parser).keyword[idx_] - ) - else: - continue - - keyword_parser_.with_.update({"matches": keyword_weight}) - else: - continue - return conf_stage - - -def fix_result_detail( - task_stage: task.Stage, conf_stage: result.StageDetail -) -> result.StageDetail: - if (task_stage.parsers is not None) and ("result-detail" in task_stage.parsers): - result_detail_parser = next( - p for p in conf_stage.parsers if p.name == "result-detail" - ) - if task_stage.result_detail is not None: - show_files = [] - if ( - task_stage.result_detail.stdout - and task_stage.result_detail.stdout is not None - ): - show_files.append("stdout") - if ( - task_stage.result_detail.stderr - and task_stage.result_detail.stderr is not None - ): - show_files.append("stderr") - result_detail_parser.with_.update( - { - "score": 0, - "comment": "", - "showFiles": show_files, - "showExitStatus": task_stage.result_detail.exitstatus, - "showRuntime": task_stage.result_detail.time, - "showMemory": task_stage.result_detail.mem, - } - ) - - return conf_stage - - -def fix_dummy( - task_stage: task.Stage, conf_stage: result.StageDetail -) -> result.StageDetail: - dummy_parser = [ - "dummy", - "result-status", - "cpplint", - ] - if task_stage.parsers is not None: - for parser in task_stage.parsers: - 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 - return conf_stage - - -def fix_diff( - task_stage: task.Stage, conf_stage: result.StageDetail -) -> result.StageDetail: - if task_stage.parsers is not None and "diff" in task_stage.parsers: - diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) - skip = task_stage.skip or [] - cases = task_stage.cases or {} - finalized_cases = [case for case in cases if case not in skip] - - stage_cases = [] - parser_cases = [] - - for case in finalized_cases: - case_stage = task_stage.cases.get(case) if task_stage.cases else None - if not case_stage: - continue - - # Ensure case_stage.limit is defined before accessing .cpu and .mem - cpu_limit = ( - case_stage.limit.cpu * 1_000_000_000 - if case_stage.limit and case_stage.limit.cpu is not None - else 0 - ) - clock_limit = ( - 2 * case_stage.limit.cpu * 1_000_000_000 - if case_stage.limit and case_stage.limit.cpu is not None - else 0 - ) - memory_limit = ( - case_stage.limit.mem * 1_024 * 1_024 - if case_stage.limit and case_stage.limit.mem is not None - else 0 - ) - - stage_cases.append( - result.OptionalCmd( - stdin=result.CmdFile( - src=f"/home/tt/.config/joj/{conf_stage.name}/{case}.in" - ), - cpu_limit=cpu_limit, - clock_limit=clock_limit, - memory_limit=memory_limit, - proc_limit=50, - ) - ) - - # Ensure case_stage.diff and case_stage.diff.output are defined - diff_output = ( - case_stage.diff.output - if case_stage.diff and case_stage.diff.output - else None - ) - if diff_output: - parser_cases.append( - { - "outputs": [ - { - "score": diff_output.score, - "fileName": "stdout", - "answerPath": f"/home/tt/.config/joj/{conf_stage.name}/{case}.out", - "forceQuitOnDiff": diff_output.forcequit, - "alwaysHide": diff_output.hide, - "compareSpace": not diff_output.ignorespaces, - } - ] - } - ) - - if diff_parser and task_stage.diff is not None: - diff_parser.with_.update({"name": "diff", "cases": parser_cases}) - conf_stage.executor.with_.cases = stage_cases - - return conf_stage - - -def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - if (task_stage.parsers is not None) and ("result-detail" in task_stage.parsers): - result_detail_parser = next( - p for p in conf_stage.parsers if p.name == "result-detail" - ) - if task_stage.result_detail is not None: - show_files = [] - if ( - task_stage.result_detail.stdout - and task_stage.result_detail.stdout is not None - ): - show_files.append("stdout") - if ( - task_stage.result_detail.stderr - and task_stage.result_detail.stderr is not None - ): - show_files.append("stderr") - result_detail_parser.with_.update( - { - "score": 0, - "comment": "", - "showFiles": show_files, - "showExitStatus": task_stage.result_detail.exitstatus, - "showRuntime": task_stage.result_detail.time, - "showMemory": task_stage.result_detail.mem, - } - ) - - return conf_stage - - -def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - comment_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("-", "_")) - ) - else: - continue - return conf_stage - - -def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - if task_stage.parsers is not None and "diff" in task_stage.parsers: - diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) - skip = task_stage.skip or [] - cases = task_stage.cases or {} - finalized_cases = [case for case in cases if case not in skip] - - stage_cases = [] - parser_cases = [] - - for case in finalized_cases: - case_stage = task_stage.cases.get(case) if task_stage.cases else None - if not case_stage: - continue - - # Ensure case_stage.limit is defined before accessing .cpu and .mem - cpu_limit = ( - case_stage.limit.cpu * 1_000_000_000 - if case_stage.limit and case_stage.limit.cpu is not None - else 0 - ) - clock_limit = ( - 2 * case_stage.limit.cpu * 1_000_000_000 - if case_stage.limit and case_stage.limit.cpu is not None - else 0 - ) - memory_limit = ( - case_stage.limit.mem * 1_024 * 1_024 - if case_stage.limit and case_stage.limit.mem is not None - else 0 - ) - - stage_cases.append( - OptionalCmd( - stdin=CmdFile( - src=f"/home/tt/.config/joj/{conf_stage.name}/{case}.in" - ), - cpu_limit=cpu_limit, - clock_limit=clock_limit, - memory_limit=memory_limit, - proc_limit=50, - ) - ) - - # Ensure case_stage.diff and case_stage.diff.output are defined - diff_output = ( - case_stage.diff.output - if case_stage.diff and case_stage.diff.output - else None - ) - if diff_output: - parser_cases.append( - { - "outputs": [ - { - "score": diff_output.score, - "fileName": "stdout", - "answerPath": f"/home/tt/.config/joj/{conf_stage.name}/{case}.out", - "forceQuitOnDiff": diff_output.forcequit, - "alwaysHide": diff_output.hide, - "compareSpace": not diff_output.ignorespaces, - } - ] - } - ) - - if diff_parser and task_stage.diff is not None: - diff_parser.with_.update({"name": "diff", "cases": parser_cases}) - conf_stage.executor.with_.cases = stage_cases +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 diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 85b58fe..71922af 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -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() diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 777e2d7..b7bd596 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -15,12 +15,15 @@ "with": { "default": { "args": [ - "/tmp/repo-health-checker", + "//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, @@ -244,11 +247,15 @@ }, { "name": "dummy", - "with": {} + "with": { + "comment": "\n\n### Details\n" + } }, { "name": "result-status", - "with": {} + "with": { + "comment": "Congratulations! Your code compiled successfully." + } } ] }, @@ -345,11 +352,28 @@ "parsers": [ { "name": "keyword", - "with": {} + "with": { + "match": [ + { + "keyword": [ + "max" + ], + "score": 50 + }, + { + "keyword": [ + "recommend" + ], + "score": 20 + } + ] + } }, { "name": "dummy", - "with": {} + "with": { + "comment": "" + } }, { "name": "result-detail", @@ -440,11 +464,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", @@ -539,11 +652,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", @@ -638,7 +786,9 @@ }, { "name": "dummy", - "with": {} + "with": { + "comment": "\n\n### Details\n" + } }, { "name": "result-detail", @@ -729,7 +879,9 @@ }, { "name": "dummy", - "with": {} + "with": { + "comment": "\n\n### Details\n" + } }, { "name": "result-detail", @@ -820,7 +972,9 @@ }, { "name": "dummy", - "with": {} + "with": { + "comment": "\n\n### Details\n" + } }, { "name": "result-detail", diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index ef299a4..48dfd07 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -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 -- 2.30.2 From fae671321004746ed3bdfd6281bac232a9ae3ed3 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:45:25 +0800 Subject: [PATCH 053/131] feat: combine dummy & result-staus --- joj3_config_generator/convert.py | 15 ++------------- joj3_config_generator/lib/task.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 66da3d4..91a27e3 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -20,7 +20,7 @@ from joj3_config_generator.lib.task import ( ) 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.lib.task import fix_comment, fix_keyword from joj3_config_generator.models import ( Cmd, CmdFile, @@ -91,18 +91,7 @@ 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_comment(task_stage, conf_stage) conf_stage = fix_keyword(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 c8bffeb..3b8208c 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -18,3 +18,15 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: else: continue return conf_stage + + +def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + comment_parser = ["dummy", "result-status"] + 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, None) is not None: + comment_parser_.with_.update(getattr(task_stage, parser)) + else: + continue + return conf_stage -- 2.30.2 From 6fd6cecb176a867d5bc4115ea0ef6c59ac51db0e Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:55:31 +0800 Subject: [PATCH 054/131] fix: result-status --- joj3_config_generator/convert.py | 12 ++++++++++++ joj3_config_generator/lib/task.py | 6 ++++-- tests/convert/basic/task.json | 6 +++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 91a27e3..534008c 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -91,6 +91,18 @@ 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_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 3b8208c..a5b0d36 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -25,8 +25,10 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: 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, None) is not None: - comment_parser_.with_.update(getattr(task_stage, parser)) + if getattr(task_stage, parser.replace("-", "_"), None) is not None: + comment_parser_.with_.update( + getattr(task_stage, parser.replace("-", "_")) + ) else: continue return conf_stage diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index b7bd596..9fe0c35 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7fbd328431a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-90ztqsoq/repo-health-checker": { - "src": "//tmp/repo-checker-41mcx5_x/repo-health-checker", + "//tmp/repo-checker-04l9les6/repo-health-checker": { + "src": "//tmp/repo-checker-_34sofm5/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From 4234d9ab2d5d2ab9ed4012e644fc6a036891913e Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:55:55 +0800 Subject: [PATCH 055/131] chore: trim old code --- joj3_config_generator/convert.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 534008c..91a27e3 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -91,18 +91,6 @@ 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_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) -- 2.30.2 From 67f2806c1636ce99e15df5de346782f67308884f Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:56:50 +0800 Subject: [PATCH 056/131] chore: trim old code --- joj3_config_generator/lib/task.py | 6 +++++- tests/convert/basic/task.json | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index a5b0d36..deb3c27 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -21,7 +21,11 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - comment_parser = ["dummy", "result-status"] + comment_parser = [ + "dummy", + "result-status", + "cpplint", + ] # FIXME: determine where cpplint should be 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) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 9fe0c35..10e0b77 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7ff2358271a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-04l9les6/repo-health-checker": { - "src": "//tmp/repo-checker-_34sofm5/repo-health-checker", + "//tmp/repo-checker-3qi07atp/repo-health-checker": { + "src": "//tmp/repo-checker-ebujap5a/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -782,7 +782,18 @@ "parsers": [ { "name": "cpplint", - "with": {} + "with": { + "keyword": [ + "runtime", + "readability", + "build" + ], + "weight": [ + 10, + 20, + 15 + ] + } }, { "name": "dummy", -- 2.30.2 From b1f5d4c9535493c971c4b5f2aabcee0e92731a2a Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 23:30:41 +0800 Subject: [PATCH 057/131] fix: result_detail parser --- joj3_config_generator/convert.py | 12 +--- joj3_config_generator/lib/task.py | 31 ++++++++++ joj3_config_generator/models/task.py | 4 +- tests/convert/basic/task.json | 87 +++++++++++++++++++++------- 4 files changed, 104 insertions(+), 30 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 91a27e3..da2fe49 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -20,7 +20,7 @@ from joj3_config_generator.lib.task import ( ) 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_comment, fix_keyword +from joj3_config_generator.lib.task import fix_comment, fix_keyword, fix_result_detail from joj3_config_generator.models import ( Cmd, CmdFile, @@ -83,16 +83,10 @@ 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" - ) - if task_stage.result_detail is not None: - result_detail_parser.with_.update(task_stage.result_detail) - + conf_stage = fix_result_detail(task_stage, conf_stage) conf_stage = fix_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) + # TODO: fix diff parser here result_conf.stage.stages.append(conf_stage) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index deb3c27..900749b 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -20,6 +20,37 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: return conf_stage +def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + if "result-detail" in task_stage.parsers: + result_detail_parser = next( + p for p in conf_stage.parsers if p.name == "result-detail" + ) + if task_stage.result_detail is not None: + show_files = [] + if ( + task_stage.result_detail.stdout + and task_stage.result_detail.stdout is not None + ): + show_files.append("stdout") + if ( + task_stage.result_detail.stderr + and task_stage.result_detail.stderr is not None + ): + show_files.append("stderr") + result_detail_parser.with_.update( + { + "score": 0, + "comment": "", + "showFiles": show_files, + "showExitStatus": task_stage.result_detail.exitstatus, + "showRuntime": task_stage.result_detail.time, + "showMemory": task_stage.result_detail.mem, + } + ) + + return conf_stage + + def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: comment_parser = [ "dummy", diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 71922af..a32d529 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -46,7 +46,9 @@ class Stage(BaseModel): keyword: Optional[ParserKeyword] = ParserKeyword() clangtidy: Optional[ParserKeyword] = ParserKeyword() cppcheck: Optional[ParserKeyword] = ParserKeyword() - cpplint: Optional[ParserKeyword] = ParserKeyword() + # FIXME: determine cpplint type + # cpplint: Optional[ParserKeyword] = ParserKeyword() + cpplint: Optional[ParserDummy] = ParserDummy() result_detail: Optional[ParserResultDetail] = Field( ParserResultDetail(), alias="result-detail" ) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 10e0b77..60b2c73 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7fd3bed4f1a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-3qi07atp/repo-health-checker": { - "src": "//tmp/repo-checker-ebujap5a/repo-health-checker", + "//tmp/repo-checker-9z61g608/repo-health-checker": { + "src": "//tmp/repo-checker-19d98f6u/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -242,7 +242,15 @@ "mem": false, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } }, { @@ -382,7 +390,15 @@ "mem": false, "stdout": false, "stderr": true, - "exitstatus": false + "exitstatus": false, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": false, + "showRuntime": false, + "showMemory": false } } ] @@ -566,7 +582,15 @@ "mem": false, "stdout": true, "stderr": false, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } } ] @@ -700,7 +724,15 @@ "mem": false, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } } ] @@ -783,16 +815,7 @@ { "name": "cpplint", "with": { - "keyword": [ - "runtime", - "readability", - "build" - ], - "weight": [ - 10, - 20, - 15 - ] + "comment": "" } }, { @@ -808,7 +831,15 @@ "mem": false, "stdout": true, "stderr": false, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false } } ] @@ -901,7 +932,15 @@ "mem": true, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true } } ] @@ -994,7 +1033,15 @@ "mem": true, "stdout": false, "stderr": true, - "exitstatus": true + "exitstatus": true, + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true } } ] -- 2.30.2 From 135c38f83b4a0315eed2fa5466fd2f6895682bc5 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 13:49:07 +0800 Subject: [PATCH 058/131] feat: cases data reading for diff --- joj3_config_generator/convert.py | 9 ++++- joj3_config_generator/lib/task.py | 55 +++++++++++++++++----------- joj3_config_generator/models/task.py | 34 +++++++++++++++-- tests/convert/basic/task.json | 51 ++++---------------------- tests/convert/basic/task.toml | 2 +- 5 files changed, 80 insertions(+), 71 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index da2fe49..84da0bb 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -20,7 +20,12 @@ from joj3_config_generator.lib.task import ( ) 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_comment, fix_keyword, fix_result_detail +from joj3_config_generator.lib.task import ( + fix_comment, + fix_diff, + fix_keyword, + fix_result_detail, +) from joj3_config_generator.models import ( Cmd, CmdFile, @@ -87,7 +92,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: conf_stage = fix_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) # TODO: fix diff parser here - + conf_stage = fix_diff(task_stage, conf_stage) result_conf.stage.stages.append(conf_stage) return result_conf diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 900749b..d8d2f78 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,27 +1,32 @@ +import rtoml + 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 + if task_stage.parsers is not None: + 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 + keyword_parser_.with_.update({"match": keyword_weight}) + else: + continue return conf_stage def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - if "result-detail" in task_stage.parsers: + if (task_stage.parsers is not None) and ("result-detail" in task_stage.parsers): result_detail_parser = next( p for p in conf_stage.parsers if p.name == "result-detail" ) @@ -57,13 +62,21 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: "result-status", "cpplint", ] # FIXME: determine where cpplint should be - 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 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 ) - else: - continue + if getattr(task_stage, parser.replace("-", "_"), None) is not None: + comment_parser_.with_.update( + getattr(task_stage, parser.replace("-", "_")) + ) + else: + continue + return conf_stage + + +def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + return conf_stage diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index a32d529..cef87f1 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -1,7 +1,8 @@ from datetime import datetime -from typing import Any, Dict, List, Optional, Type +from typing import Any, Dict, Optional, Type, List from pydantic import BaseModel, Field, root_validator +from pydantic import BaseModel, Field, root_validator class ParserResultDetail(BaseModel): @@ -21,6 +22,17 @@ class ParserKeyword(BaseModel): weight: Optional[list[int]] = [] +class Outputs(BaseModel): + score: Optional[int] = 0 + ignorespaces: Optional[bool] = False + hide: Optional[bool] = False + forcequit: Optional[bool] = True + + +class ParserDiff(BaseModel): + output: Optional[Outputs] = Outputs() + + class Files(BaseModel): import_: Optional[List[str]] = Field(serialization_alias="import", validation_alias="import") export: Optional[List[str]] @@ -35,11 +47,11 @@ class Limit(BaseModel): class Stage(BaseModel): - name: str # Stage name - command: str # Command to run + name: Optional[str] = None # Stage name + command: Optional[str] = None # Command to run files: Optional[Files] = None score: Optional[int] = 0 - parsers: list[str] # list of parsers + parsers: Optional[list[str]] = [] # list of parsers limit: Optional[Limit] = None dummy: Optional[ParserDummy] = ParserDummy() result_status: Optional[ParserDummy] = Field(ParserDummy(), alias="result-status") @@ -52,6 +64,20 @@ class Stage(BaseModel): result_detail: Optional[ParserResultDetail] = Field( ParserResultDetail(), alias="result-detail" ) + skip: Optional[list[str]] = [] + diff: Optional[ParserDiff] = ParserDiff() + cases: Optional[Dict[str, "Stage"]] = {} + + class Config: + extra = "allow" + + @root_validator(pre=True) + def gather_cases(cls: Type["Stage"], values: Dict[str, Any]) -> Dict[str, Any]: + cases = {k: v for k, v in values.items() if k.startswith("case")} + for key in cases: + values.pop(key) + values["cases"] = {k: Stage(**v) for k, v in cases.items()} + return values class Release(BaseModel): diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 60b2c73..7ce0682 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "Homework 1 exercise 2", - "logPath": "Homework-1-exercise-2.log", + "name": "h4 ex1", + "logPath": "h4-ex1.log", "expireUnixTimestamp": 1728748740, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f932c5e31a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-9z61g608/repo-health-checker": { - "src": "//tmp/repo-checker-19d98f6u/repo-health-checker", + "//tmp/repo-checker-tw0902sa/repo-health-checker": { + "src": "//tmp/repo-checker-4sy3g0ro/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -238,11 +238,6 @@ { "name": "result-status", "with": { - "time": false, - "mem": false, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -386,11 +381,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": false, - "stderr": true, - "exitstatus": false, "score": 0, "comment": "", "showFiles": [ @@ -578,11 +568,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": true, - "stderr": false, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -720,11 +705,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -827,11 +807,6 @@ { "name": "result-detail", "with": { - "time": false, - "mem": false, - "stdout": true, - "stderr": false, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -928,11 +903,6 @@ { "name": "result-detail", "with": { - "time": true, - "mem": true, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -1029,11 +999,6 @@ { "name": "result-detail", "with": { - "time": true, - "mem": true, - "stdout": false, - "stderr": true, - "exitstatus": true, "score": 0, "comment": "", "showFiles": [ @@ -1049,9 +1014,9 @@ ] }, "teapot": { - "logPath": "Homework-1-exercise-2-joint-teapot-debug.log", - "scoreboardPath": "Homework-1-exercise-2-scoreboard.csv", - "failedTablePath": "Homework-1-exercise-2-failed-table.md", + "logPath": "h4-ex1-joint-teapot-debug.log", + "scoreboardPath": "h4-ex1-scoreboard.csv", + "failedTablePath": "h4-ex1-failed-table.md", "gradingRepoName": "engr151-joj", "skipIssue": false, "skipScoreboard": false, diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 48dfd07..ec4cdfc 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,5 +1,5 @@ # general task configuration -task="Homework 1 exercise 2" # task name +task="h4 ex1" # task name release.deadline = 2024-10-12 23:59:00+08:00 release.stages = [ "compile" ] -- 2.30.2 From 70cee6e55a8f3f0de4987e52ccb0e453a707cbdc Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:00:46 +0800 Subject: [PATCH 059/131] ffeat: diff finish --- joj3_config_generator/convert.py | 1 - joj3_config_generator/lib/task.py | 69 ++++++ joj3_config_generator/models/task.py | 2 +- tests/convert/basic/task.json | 324 ++++++++++++++++++++++++++- 4 files changed, 387 insertions(+), 9 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 84da0bb..d522871 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -91,7 +91,6 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: conf_stage = fix_result_detail(task_stage, conf_stage) conf_stage = fix_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) - # TODO: fix diff parser here 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 d8d2f78..35aa92b 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,5 +1,6 @@ import rtoml +from joj3_config_generator.models.result import CmdFile, OptionalCmd from joj3_config_generator.models.result import Stage as ResultStage from joj3_config_generator.models.task import Stage as TaskStage @@ -78,5 +79,73 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + if task_stage.parsers is not None and "diff" in task_stage.parsers: + diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) + skip = task_stage.skip or [] + cases = task_stage.cases or {} + finalized_cases = [case for case in cases if case not in skip] + + stage_cases = [] + parser_cases = [] + + for case in finalized_cases: + case_stage = task_stage.cases.get(case) if task_stage.cases else None + if not case_stage: + continue + + # Ensure case_stage.limit is defined before accessing .cpu and .mem + cpu_limit = ( + case_stage.limit.cpu * 1_000_000_000 + if case_stage.limit and case_stage.limit.cpu is not None + else 0 + ) + clock_limit = ( + 2 * case_stage.limit.cpu * 1_000_000_000 + if case_stage.limit and case_stage.limit.cpu is not None + else 0 + ) + memory_limit = ( + case_stage.limit.mem * 1_024 * 1_024 + if case_stage.limit and case_stage.limit.mem is not None + else 0 + ) + + stage_cases.append( + OptionalCmd( + stdin=CmdFile( + src=f"/home/tt/.config/joj/{conf_stage.name}/{case}.in" + ), + cpu_limit=cpu_limit, + clock_limit=clock_limit, + memory_limit=memory_limit, + proc_limit=50, + ) + ) + + # Ensure case_stage.diff and case_stage.diff.output are defined + diff_output = ( + case_stage.diff.output + if case_stage.diff and case_stage.diff.output + else None + ) + if diff_output: + parser_cases.append( + { + "outputs": [ + { + "score": diff_output.score, + "fileName": "stdout", + "answerPath": f"/home/tt/.config/joj/{conf_stage.name}/{case}.out", + "forceQuitOnDiff": diff_output.forcequit, + "alwaysHide": diff_output.hide, + "compareSpace": not diff_output.ignorespaces, + } + ] + } + ) + + if diff_parser and task_stage.diff is not None: + diff_parser.with_.update({"name": "diff", "cases": parser_cases}) + conf_stage.executor.with_.cases = stage_cases return conf_stage diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index cef87f1..e77b9d8 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -52,7 +52,7 @@ class Stage(BaseModel): files: Optional[Files] = None score: Optional[int] = 0 parsers: Optional[list[str]] = [] # list of parsers - limit: Optional[Limit] = None + limit: Optional[Limit] = Limit() dummy: Optional[ParserDummy] = ParserDummy() result_status: Optional[ParserDummy] = Field(ParserDummy(), alias="result-status") keyword: Optional[ParserKeyword] = ParserKeyword() diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 7ce0682..65a21ff 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f67094f3240>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-tw0902sa/repo-health-checker": { - "src": "//tmp/repo-checker-4sy3g0ro/repo-health-checker", + "//tmp/repo-checker-9gy9931v/repo-health-checker": { + "src": "//tmp/repo-checker-kjnt9uw0/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -886,13 +886,168 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [] + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case8.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] } }, "parsers": [ { "name": "diff", - "with": {} + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case8.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + } + ] + } }, { "name": "dummy", @@ -982,13 +1137,168 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [] + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case6.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] } }, "parsers": [ { "name": "diff", - "with": {} + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", + "forceQuitOnDiff": true, + "alwaysHide": true, + "compareSpace": true + } + ] + } + ] + } }, { "name": "dummy", -- 2.30.2 From 919f3057298f35a02ec55483792238ab7fb3e0a5 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:28:29 +0800 Subject: [PATCH 060/131] chore: more compact code --- joj3_config_generator/convert.py | 27 ++------ joj3_config_generator/lib/task.py | 104 +++++++++++++++++++++++++++++- tests/convert/basic/task.json | 50 +++++++------- 3 files changed, 133 insertions(+), 48 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index d522871..e1ed51e 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -25,6 +25,8 @@ from joj3_config_generator.lib.task import ( fix_diff, fix_keyword, fix_result_detail, + get_conf_stage, + get_executorWithConfig, ) from joj3_config_generator.models import ( Cmd, @@ -64,30 +66,11 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Construct healthcheck stage healthcheck_stage = getHealthcheckConfig(repo_conf, task_conf) result_conf.stage.stages.append(healthcheck_stage) - cached = [] + cached: list[str] = [] # Convert each stage in the task configuration for task_stage in task_conf.stages: - executor_with_config = result.ExecutorWith( - default=result.Cmd( - args=task_stage.command.split(), - copy_in={ - file: result.CmdFile(src=file) for file in task_stage.files.import_ - }, - copy_out_cached=task_stage.files.export, - ), - cases=[], # You can add cases if needed - ) - conf_stage = result.StageDetail( - name=task_stage.name, - group=task_conf.task, - executor=result.Executor( - name="sandbox", - with_=executor_with_config, - ), - parsers=[ - result.Parser(name=parser, with_={}) for parser in task_stage.parsers - ], - ) + 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_keyword(task_stage, conf_stage) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 35aa92b..6ff56d7 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,10 +1,112 @@ +from typing import Tuple + import rtoml -from joj3_config_generator.models.result import CmdFile, OptionalCmd +from joj3_config_generator.models import ( + ExecutorConfig, + ExecutorWithConfig, + ParserConfig, +) +from joj3_config_generator.models.result import Cmd, CmdFile, OptionalCmd from joj3_config_generator.models.result import Stage as ResultStage from joj3_config_generator.models.task import Stage as TaskStage +def get_conf_stage( + task_stage: TaskStage, executor_with_config: ExecutorWithConfig +) -> ResultStage: + conf_stage = ResultStage( + name=task_stage.name if task_stage.name is not None else "", + # TODO: we may have cq in future + group=( + "joj" + if (task_stage.name is not None) and ("judge" in task_stage.name) + else None + ), + executor=ExecutorConfig( + name="sandbox", + with_=executor_with_config, + ), + parsers=( + [ParserConfig(name=parser, with_={}) for parser in task_stage.parsers] + if task_stage.parsers is not None + else [] + ), + ) + return conf_stage + + +def get_executorWithConfig( + task_stage: TaskStage, cached: list[str] +) -> Tuple[ExecutorWithConfig, list[str]]: + file_import = ( + task_stage.files.import_ + if hasattr(task_stage, "files") + and hasattr(task_stage.files, "import_") + and (task_stage.files is not None) + and (task_stage.files.import_ is not None) + else [] + ) + copy_in_files = [file for file in file_import if (file not in cached)] + file_export = ( + task_stage.files.export + if hasattr(task_stage, "files") + and hasattr(task_stage.files, "export") + and (task_stage.files is not None) + else [] + ) + executor_with_config = ExecutorWithConfig( + default=Cmd( + args=(task_stage.command.split() if task_stage.command is not None else []), + copy_in={ + file: CmdFile(src=f"/home/tt/.config/joj/{file}") + for file in copy_in_files + }, + copy_in_cached={file: file for file in copy_in_files}, + copy_out_cached=file_export if file_export is not None else [], + cpu_limit=( + task_stage.limit.cpu * 1_000_000_000 + if task_stage.limit is not None and task_stage.limit.cpu is not None + else 4 * 1_000_000_000 + ), + clock_limit=( + 2 * task_stage.limit.cpu * 1_000_000_000 + if task_stage.limit is not None and task_stage.limit.cpu is not None + else 8 * 1_000_000_000 + ), + memory_limit=( + task_stage.limit.mem * 1_024 * 1_024 + if task_stage.limit is not None and task_stage.limit.mem is not None + else 4 * 1_024 * 1_024 + ), + stderr=CmdFile( + name="stderr", + max=( + task_stage.limit.stderr * 1_000_000_000 + if task_stage.limit is not None + and task_stage.limit.stderr is not None + else 4 * 1_024 * 1_024 + ), + ), + stdout=CmdFile( + name="stdout", + max=( + task_stage.limit.stdout * 1_000_000_000 + if task_stage.limit is not None + and task_stage.limit.stdout is not None + else 4 * 1_024 * 1_024 + ), + ), + ), + cases=[], # You can add cases if needed + ) + if file_export is not None: + for file in file_export: + if file not in cached: + cached.append(file) + return (executor_with_config, cached) + + def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: keyword_parser = ["clangtidy", "keyword", "cppcheck"] # TODO: may add cpplint if task_stage.parsers is not None: diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 65a21ff..70bc593 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7fc2485231a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-9gy9931v/repo-health-checker": { - "src": "//tmp/repo-checker-kjnt9uw0/repo-health-checker", + "//tmp/repo-checker-5xkj4dm4/repo-health-checker": { + "src": "//tmp/repo-checker-k3fmck15/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -136,7 +136,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -147,15 +147,15 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 128000000000, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 180000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, + "clockLimit": 360000000000, "memoryLimit": 4194304, "clockLimit": 8000000000, "memoryLimit": 4194304, @@ -295,7 +295,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -306,7 +306,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -427,7 +427,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 65000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -438,7 +438,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -618,7 +618,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -629,7 +629,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 65000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -751,7 +751,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 65000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -762,7 +762,7 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -849,7 +849,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -860,16 +860,16 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 3000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 6000000000, + "memoryLimit": 78643200, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -1100,7 +1100,7 @@ "content": null, "fileId": null, "name": "stdout", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, @@ -1111,16 +1111,16 @@ "content": null, "fileId": null, "name": "stderr", - "max": 4096, + "max": 4000000000, "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 10000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 20000000000, + "memoryLimit": 524288000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, -- 2.30.2 From ac7a3baefe6ce7ac23366cb4f377739d952aa01f Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:43:43 +0800 Subject: [PATCH 061/131] fix: gradingreponame schema --- joj3_config_generator/lib/repo.py | 11 +++-------- tests/convert/basic/task.json | 8 ++++---- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index e9a8d33..1c39a0c 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -1,5 +1,5 @@ import hashlib -import os +import socket import tempfile from dotenv import load_dotenv @@ -24,13 +24,8 @@ def get_temp_directory() -> str: def getGradingRepoName() -> str: - path = os.path.expanduser("~/.config/teapot/teapot.env") - if os.path.exists(path): - load_dotenv(path) - repo_name = os.environ.get("GITEA_ORG_NAME") - if repo_name is not None: - return f"{repo_name.split('-')[0]}-joj" - return "ece482-joj" + host_name = socket.gethostname() + return f"{host_name.split('-')[0]}-joj" def getTeapotConfig(repo_conf: Repo, task_conf: Task) -> TeapotConfig: diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 70bc593..1573e39 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7fc3921ab1a0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -71,8 +71,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-5xkj4dm4/repo-health-checker": { - "src": "//tmp/repo-checker-k3fmck15/repo-health-checker", + "//tmp/repo-checker-u3awlhwg/repo-health-checker": { + "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -1327,7 +1327,7 @@ "logPath": "h4-ex1-joint-teapot-debug.log", "scoreboardPath": "h4-ex1-scoreboard.csv", "failedTablePath": "h4-ex1-failed-table.md", - "gradingRepoName": "engr151-joj", + "gradingRepoName": "Nuvole-joj", "skipIssue": false, "skipScoreboard": false, "skipFailedTable": false -- 2.30.2 From 908baa17142dd6ccbbe58e406f0ab6b6be3d4fa8 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:46:30 +0800 Subject: [PATCH 062/131] fix: remove dotenv --- joj3_config_generator/lib/repo.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index 1c39a0c..cb679c4 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -2,8 +2,6 @@ import hashlib import socket import tempfile -from dotenv import load_dotenv - from joj3_config_generator.models import ( Cmd, CmdFile, -- 2.30.2 From f678406d94a8b933e4cd78604b8e9d91643900a5 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:53:42 +0800 Subject: [PATCH 063/131] fix: immutable_file --- tests/immutable_file/.gitattributes | 33 ----------------------------- tests/immutable_file/.gitignore | 23 -------------------- tests/immutable_file/push.yaml | 18 ---------------- tests/immutable_file/release.yaml | 20 ----------------- 4 files changed, 94 deletions(-) delete mode 100644 tests/immutable_file/.gitattributes delete mode 100644 tests/immutable_file/.gitignore delete mode 100644 tests/immutable_file/push.yaml delete mode 100644 tests/immutable_file/release.yaml diff --git a/tests/immutable_file/.gitattributes b/tests/immutable_file/.gitattributes deleted file mode 100644 index b910c4a..0000000 --- a/tests/immutable_file/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -*.avi filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.djvu filter=lfs diff=lfs merge=lfs -text -*.doc filter=lfs diff=lfs merge=lfs -text -*.docx filter=lfs diff=lfs merge=lfs -text -*.epub filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.ipynb filter=lfs diff=lfs merge=lfs -text -*.jpeg filter=lfs diff=lfs merge=lfs -text -*.JPEG filter=lfs diff=lfs merge=lfs -text -*.jpg filter=lfs diff=lfs merge=lfs -text -*.JPG filter=lfs diff=lfs merge=lfs -text -*.mkv filter=lfs diff=lfs merge=lfs -text -*.mp4 filter=lfs diff=lfs merge=lfs -text -*.ods filter=lfs diff=lfs merge=lfs -text -*.odt filter=lfs diff=lfs merge=lfs -text -*.otf filter=lfs diff=lfs merge=lfs -text -*.pdf filter=lfs diff=lfs merge=lfs -text -*.PDF filter=lfs diff=lfs merge=lfs -text -*.png filter=lfs diff=lfs merge=lfs -text -*.PNG filter=lfs diff=lfs merge=lfs -text -*.ppt filter=lfs diff=lfs merge=lfs -text -*.pptx filter=lfs diff=lfs merge=lfs -text -*.ps filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text -*.tar filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.ttf filter=lfs diff=lfs merge=lfs -text -*.webm filter=lfs diff=lfs merge=lfs -text -*.xls filter=lfs diff=lfs merge=lfs -text -*.xlsx filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_file/.gitignore b/tests/immutable_file/.gitignore deleted file mode 100644 index 754f776..0000000 --- a/tests/immutable_file/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -################################ -## White list based gitignore ## -################################ - -# forbidden -* -.* - -# allowed -!.gitignore -!.gitattributes -!.gitea/ -!.gitea/issue_template/ -!.gitea/workflows/ -!*.yaml -!Makefile -!CMakeLists.txt -!h[0-8]/ -!*.m -!*.c -!*.cpp -!*.h -!*.md diff --git a/tests/immutable_file/push.yaml b/tests/immutable_file/push.yaml deleted file mode 100644 index 2f890b6..0000000 --- a/tests/immutable_file/push.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: Run JOJ3 on Push -on: [push] -jobs: - run: - container: - image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim - volumes: - - /home/tt/.config:/home/tt/.config - - /home/tt/.cache:/home/tt/.cache - - /home/tt/.ssh:/home/tt/.ssh - steps: - - name: Check out repository code - uses: https://gitea.com/BoYanZh/checkout@focs - with: - fetch-depth: 0 - - name: run joj3 - run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml deleted file mode 100644 index afd2838..0000000 --- a/tests/immutable_file/release.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: Run JOJ3 on Release -on: - release: - types: [published] -jobs: - run: - container: - image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim - volumes: - - /home/tt/.config:/home/tt/.config - - /home/tt/.cache:/home/tt/.cache - - /home/tt/.ssh:/home/tt/.ssh - steps: - - name: Check out repository code - uses: https://gitea.com/BoYanZh/checkout@focs - with: - fetch-depth: 0 - - name: run joj3 - run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj -msg "feat(h1-release): joj on ${{ github.ref }}" -- 2.30.2 From db45d0db3e8ba741bfbc4d5c2096df8f865569b2 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:56:11 +0800 Subject: [PATCH 064/131] fix: immutable repo tom --- tests/convert/basic/repo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index c77b9f7..28b5c05 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -7,4 +7,4 @@ sandbox_token = "test" whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" required = ["main.py", "README.md"] -immutable = [".gitignore", ".gitattributes", "push.yaml", "release.yaml"] +immutable = [] -- 2.30.2 From c738f9b5fcea186dcf9fd8a02282a7a024b3d62b Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:59:25 +0800 Subject: [PATCH 065/131] feat: rebuild json --- tests/convert/basic/task.json | 1335 --------------------------------- 1 file changed, 1335 deletions(-) delete mode 100644 tests/convert/basic/task.json diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json deleted file mode 100644 index 1573e39..0000000 --- a/tests/convert/basic/task.json +++ /dev/null @@ -1,1335 +0,0 @@ -{ - "name": "h4 ex1", - "logPath": "h4-ex1.log", - "expireUnixTimestamp": 1728748740, - "stage": { - "sandboxExecServer": "172.17.0.1:5051", - "sandboxToken": "test", - "outputPath": "/tmp/joj3_result.json", - "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "//repo-health-checker", - "-root=.", - "-repoSize=50.5", - "-meta=main.py", - "-meta=README.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", - "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4096, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4096, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "//tmp/repo-checker-u3awlhwg/repo-health-checker": { - "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "healthcheck", - "with": { - "score": 0, - "comment": "" - } - } - ] - }, - { - "name": "Compilation", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "make.sh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 128000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 180000000000, - "realCpuLimit": 0, - "clockLimit": 360000000000, - "memoryLimit": 4194304, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/make.sh": { - "src": "/home/tt/.config/joj/tools/make.sh", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/main.c": { - "src": "/home/tt/.config/joj/src/main.c", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/task.h": { - "src": "/home/tt/.config/joj/src/task.h", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "srcCMakelist.txt": { - "src": "/home/tt/.config/joj/srcCMakelist.txt", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/make.sh": "tools/make.sh", - "src/main.c": "src/main.c", - "src/task.h": "src/task.h", - "srcCMakelist.txt": "srcCMakelist.txt" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [ - "driver", - "p2", - "p2-msan" - ], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-status", - "with": { - "comment": "Congratulations! Your code compiled successfully." - } - } - ] - }, - { - "name": "File length check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./file-length", - "500", - "400", - "*.c", - "*.h" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/file-length": { - "src": "/home/tt/.config/joj/tools/file-length", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/file-length": "tools/file-length" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "keyword", - "with": { - "match": [ - { - "keyword": [ - "max" - ], - "score": 50 - }, - { - "keyword": [ - "recommend" - ], - "score": 20 - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": false, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Clang-tidy checks", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "run-clang-tidy-18", - "-header-filter=.*", - "-quiet", - "-load=/usr/local/lib/libcodequality.so", - "-p", - "build" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "clangtidy", - "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": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Cppcheck check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cppcheck", - "--template='{\"file\":\"{file}\",\"line\":{line},", - "\"column\":{column},", - "\"severity\":\"{severity}\",", - "\"message\":\"{message}\",", - "\"id\":\"{id}\"}'", - "--force", - "--enable=all", - "--quiet", - "./" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cppcheck", - "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": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Cpplint check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cpplint", - "--linelength=120", - "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", - "--recursive", - "--exclude=build", - "." - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cpplint", - "with": { - "comment": "" - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "judge-base", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 3000000000, - "realCpuLimit": 0, - "clockLimit": 6000000000, - "memoryLimit": 78643200, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case8.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case8.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "judge-msan", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh-msan" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 10000000000, - "realCpuLimit": 0, - "clockLimit": 20000000000, - "memoryLimit": 524288000, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case6.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", - "forceQuitOnDiff": true, - "alwaysHide": true, - "compareSpace": true - } - ] - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - } - ] - }, - "teapot": { - "logPath": "h4-ex1-joint-teapot-debug.log", - "scoreboardPath": "h4-ex1-scoreboard.csv", - "failedTablePath": "h4-ex1-failed-table.md", - "gradingRepoName": "Nuvole-joj", - "skipIssue": false, - "skipScoreboard": false, - "skipFailedTable": false - } -} -- 2.30.2 From 7adea96a21d245d34faaa2ae84c78b212b6bf2dd Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 16:01:38 +0800 Subject: [PATCH 066/131] feat: sync --- tests/convert/basic/task.json | 1328 +++++++++++++++++++++++++++ tests/immutable_file/.gitattributes | 33 + tests/immutable_file/.gitignore | 23 + tests/immutable_file/push.yaml | 18 + tests/immutable_file/release.yaml | 20 + 5 files changed, 1422 insertions(+) create mode 100644 tests/convert/basic/task.json create mode 100644 tests/immutable_file/.gitattributes create mode 100644 tests/immutable_file/.gitignore create mode 100644 tests/immutable_file/push.yaml create mode 100644 tests/immutable_file/release.yaml diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json new file mode 100644 index 0000000..4ffc375 --- /dev/null +++ b/tests/convert/basic/task.json @@ -0,0 +1,1328 @@ +{ + "name": "h4 ex1", + "logPath": "h4-ex1.log", + "expireUnixTimestamp": 1728748740, + "stage": { + "sandboxExecServer": "172.17.0.1:5051", + "sandboxToken": "test", + "outputPath": "/tmp/joj3_result.json", + "stages": [ + { + "name": "healthcheck", + "group": "", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "//repo-health-checker", + "-root=.", + "-repoSize=50.5", + "-meta=main.py", + "-meta=README.md", + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", + "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "//tmp/repo-checker-u3awlhwg/repo-health-checker": { + "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 0, + "comment": "" + } + } + ] + }, + { + "name": "Compilation", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "make.sh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 128000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 180000000000, + "realCpuLimit": 0, + "clockLimit": 360000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/make.sh": { + "src": "/home/tt/.config/joj/tools/make.sh", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/main.c": { + "src": "/home/tt/.config/joj/src/main.c", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/task.h": { + "src": "/home/tt/.config/joj/src/task.h", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "srcCMakelist.txt": { + "src": "/home/tt/.config/joj/srcCMakelist.txt", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/make.sh": "tools/make.sh", + "src/main.c": "src/main.c", + "src/task.h": "src/task.h", + "srcCMakelist.txt": "srcCMakelist.txt" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [ + "driver", + "p2", + "p2-msan" + ], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-status", + "with": { + "comment": "Congratulations! Your code compiled successfully." + } + } + ] + }, + { + "name": "File length check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./file-length", + "500", + "400", + "*.c", + "*.h" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/file-length": { + "src": "/home/tt/.config/joj/tools/file-length", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/file-length": "tools/file-length" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "keyword", + "with": { + "match": [ + { + "keyword": [ + "max" + ], + "score": 50 + }, + { + "keyword": [ + "recommend" + ], + "score": 20 + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": false, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Clang-tidy checks", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "run-clang-tidy-18", + "-header-filter=.*", + "-quiet", + "-load=/usr/local/lib/libcodequality.so", + "-p", + "build" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "clangtidy", + "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": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Cppcheck check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cppcheck", + "--template='{\"file\":\"{file}\",\"line\":{line},", + "\"column\":{column},", + "\"severity\":\"{severity}\",", + "\"message\":\"{message}\",", + "\"id\":\"{id}\"}'", + "--force", + "--enable=all", + "--quiet", + "./" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cppcheck", + "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": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Cpplint check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cpplint", + "--linelength=120", + "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", + "--recursive", + "--exclude=build", + "." + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cpplint", + "with": { + "comment": "" + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "judge-base", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 3000000000, + "realCpuLimit": 0, + "clockLimit": 6000000000, + "memoryLimit": 78643200, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case8.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case8.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "judge-msan", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh-msan" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 10000000000, + "realCpuLimit": 0, + "clockLimit": 20000000000, + "memoryLimit": 524288000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case6.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", + "forceQuitOnDiff": true, + "alwaysHide": true, + "compareSpace": true + } + ] + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + } + ] + }, + "teapot": { + "logPath": "h4-ex1-joint-teapot-debug.log", + "scoreboardPath": "h4-ex1-scoreboard.csv", + "failedTablePath": "h4-ex1-failed-table.md", + "gradingRepoName": "Nuvole-joj", + "skipIssue": false, + "skipScoreboard": false, + "skipFailedTable": false + } +} diff --git a/tests/immutable_file/.gitattributes b/tests/immutable_file/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/immutable_file/.gitattributes @@ -0,0 +1,33 @@ +*.avi filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.djvu filter=lfs diff=lfs merge=lfs -text +*.doc filter=lfs diff=lfs merge=lfs -text +*.docx filter=lfs diff=lfs merge=lfs -text +*.epub filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.ipynb filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.JPEG filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.JPG filter=lfs diff=lfs merge=lfs -text +*.mkv filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.ods filter=lfs diff=lfs merge=lfs -text +*.odt filter=lfs diff=lfs merge=lfs -text +*.otf filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.PDF filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.PNG filter=lfs diff=lfs merge=lfs -text +*.ppt filter=lfs diff=lfs merge=lfs -text +*.pptx filter=lfs diff=lfs merge=lfs -text +*.ps filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text +*.xls filter=lfs diff=lfs merge=lfs -text +*.xlsx filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_file/.gitignore b/tests/immutable_file/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/immutable_file/.gitignore @@ -0,0 +1,23 @@ +################################ +## White list based gitignore ## +################################ + +# forbidden +* +.* + +# allowed +!.gitignore +!.gitattributes +!.gitea/ +!.gitea/issue_template/ +!.gitea/workflows/ +!*.yaml +!Makefile +!CMakeLists.txt +!h[0-8]/ +!*.m +!*.c +!*.cpp +!*.h +!*.md diff --git a/tests/immutable_file/push.yaml b/tests/immutable_file/push.yaml new file mode 100644 index 0000000..2f890b6 --- /dev/null +++ b/tests/immutable_file/push.yaml @@ -0,0 +1,18 @@ +name: Run JOJ3 on Push +on: [push] +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml new file mode 100644 index 0000000..afd2838 --- /dev/null +++ b/tests/immutable_file/release.yaml @@ -0,0 +1,20 @@ +name: Run JOJ3 on Release +on: + release: + types: [published] +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj -msg "feat(h1-release): joj on ${{ github.ref }}" -- 2.30.2 From e837e18db9ddb6bf811e201d00926c558c4d2939 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 11:13:56 +0800 Subject: [PATCH 067/131] feat: sync --- tests/convert/basic/task.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 4ffc375..c15b691 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,13 +18,12 @@ "//repo-health-checker", + "0x7f64f5d532e0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", "-meta=README.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", - "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" + "-checkFileSumList=-checkFileNameList=" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -71,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-u3awlhwg/repo-health-checker": { - "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", + "//tmp/repo-checker-lf3ranpy/repo-health-checker": { + "src": "//tmp/repo-checker-gd58j2qv/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From 16c7cb517a0763efa069f73e14f0fbafd53e442a Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 22:46:46 +0800 Subject: [PATCH 068/131] feat: rebase with master --- joj3_config_generator/convert.py | 33 ----------------- joj3_config_generator/lib/__init__.py | 11 ------ joj3_config_generator/lib/repo.py | 36 +++++++----------- joj3_config_generator/lib/task.py | 53 ++++++++++++++------------- joj3_config_generator/models/task.py | 9 +++-- tests/convert/basic/task.json | 6 +-- 6 files changed, 48 insertions(+), 100 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index e1ed51e..1d014aa 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -10,37 +10,6 @@ from joj3_config_generator.lib.task import ( get_executorWithConfig, ) from joj3_config_generator.models import joj1, repo, result, task -from joj3_config_generator.lib.task import ( - fix_diff, - fix_dummy, - fix_keyword, - fix_result_detail, - get_conf_stage, - get_executorWithConfig, -) -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_comment, - fix_diff, - fix_keyword, - fix_result_detail, - get_conf_stage, - get_executorWithConfig, -) -from joj3_config_generator.models import ( - Cmd, - CmdFile, - ExecutorConfig, - ExecutorWithConfig, - ParserConfig, - Repo, - ResultConfig, - Stage, - StageConfig, - Task, - TeapotConfig, -) # FIXME: LLM generated convert function, only for demostration @@ -58,8 +27,6 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: else -1 ), stage=result.Stage(stages=[], sandbox_token=repo_conf.sandbox_token), - teapot=result.Teapot(), - stage=StageConfig(stages=[], sandbox_token=repo_conf.sandbox_token), teapot=getTeapotConfig(repo_conf, task_conf), ) diff --git a/joj3_config_generator/lib/__init__.py b/joj3_config_generator/lib/__init__.py index 68802d4..e69de29 100644 --- a/joj3_config_generator/lib/__init__.py +++ b/joj3_config_generator/lib/__init__.py @@ -1,11 +0,0 @@ -from joj3_config_generator.models.repo import Repo as Repo -from joj3_config_generator.models.result import Cmd as Cmd -from joj3_config_generator.models.result import CmdFile as CmdFile -from joj3_config_generator.models.result import ExecutorConfig as ExecutorConfig -from joj3_config_generator.models.result import ExecutorWithConfig as ExecutorWithConfig -from joj3_config_generator.models.result import ParserConfig as ParserConfig -from joj3_config_generator.models.result import ResultConfig as ResultConfig -from joj3_config_generator.models.result import Stage as Stage -from joj3_config_generator.models.result import StageConfig as StageConfig -from joj3_config_generator.models.result import TeapotConfig as TeapotConfig -from joj3_config_generator.models.task import Task as Task diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index cb679c4..8c17ee1 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -2,19 +2,7 @@ import hashlib import socket import tempfile -from joj3_config_generator.models import ( - Cmd, - CmdFile, - ExecutorConfig, - ExecutorWithConfig, - ParserConfig, - Repo, - ResultConfig, - Stage, - StageConfig, - Task, - TeapotConfig, -) +from joj3_config_generator.models import joj1, repo, result, task def get_temp_directory() -> str: @@ -26,8 +14,8 @@ def getGradingRepoName() -> str: return f"{host_name.split('-')[0]}-joj" -def getTeapotConfig(repo_conf: Repo, task_conf: Task) -> TeapotConfig: - teapot = TeapotConfig( +def getTeapotConfig(repo_conf: repo.Config, task_conf: task.Config) -> result.Teapot: + teapot = result.Teapot( # TODO: fix the log path log_path=f"{task_conf.task.replace(' ', '-')}-joint-teapot-debug.log", scoreboard_path=f"{task_conf.task.replace(' ', '-')}-scoreboard.csv", @@ -37,7 +25,7 @@ def getTeapotConfig(repo_conf: Repo, task_conf: Task) -> TeapotConfig: return teapot -def getHealthcheckCmd(repo_conf: Repo) -> Cmd: +def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: repoSize = repo_conf.max_size immutable = repo_conf.files.immutable repo_size = f"-repoSize={str(repoSize)} " @@ -64,11 +52,11 @@ def getHealthcheckCmd(repo_conf: Repo) -> Cmd: args = args + immutable_files - cmd = Cmd( + cmd = result.Cmd( args=args.split(), # FIXME: easier to edit within global scope copy_in={ - f"/{get_temp_directory()}/repo-health-checker": CmdFile( + f"/{get_temp_directory()}/repo-health-checker": result.CmdFile( src=f"/{get_temp_directory()}/repo-health-checker" ) }, @@ -76,15 +64,17 @@ def getHealthcheckCmd(repo_conf: Repo) -> Cmd: return cmd -def getHealthcheckConfig(repo_conf: Repo, task_conf: Task) -> Stage: - healthcheck_stage = Stage( +def getHealthcheckConfig( + repo_conf: repo.Config, task_conf: task.Config +) -> result.StageDetail: + healthcheck_stage = result.StageDetail( name="healthcheck", group="", - executor=ExecutorConfig( + executor=result.Executor( name="sandbox", - with_=ExecutorWithConfig(default=getHealthcheckCmd(repo_conf), cases=[]), + with_=result.ExecutorWith(default=getHealthcheckCmd(repo_conf), cases=[]), ), - parsers=[ParserConfig(name="healthcheck", with_={"score": 0, "comment": ""})], + parsers=[result.Parser(name="healthcheck", with_={"score": 0, "comment": ""})], ) return healthcheck_stage diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 6ff56d7..7a29cf7 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -2,20 +2,13 @@ from typing import Tuple import rtoml -from joj3_config_generator.models import ( - ExecutorConfig, - ExecutorWithConfig, - ParserConfig, -) -from joj3_config_generator.models.result import Cmd, CmdFile, OptionalCmd -from joj3_config_generator.models.result import Stage as ResultStage -from joj3_config_generator.models.task import Stage as TaskStage +from joj3_config_generator.models import joj1, repo, result, task def get_conf_stage( - task_stage: TaskStage, executor_with_config: ExecutorWithConfig -) -> ResultStage: - conf_stage = ResultStage( + task_stage: task.Stage, executor_with_config: result.ExecutorWith +) -> result.StageDetail: + conf_stage = result.StageDetail( name=task_stage.name if task_stage.name is not None else "", # TODO: we may have cq in future group=( @@ -23,12 +16,12 @@ def get_conf_stage( if (task_stage.name is not None) and ("judge" in task_stage.name) else None ), - executor=ExecutorConfig( + executor=result.Executor( name="sandbox", with_=executor_with_config, ), parsers=( - [ParserConfig(name=parser, with_={}) for parser in task_stage.parsers] + [result.Parser(name=parser, with_={}) for parser in task_stage.parsers] if task_stage.parsers is not None else [] ), @@ -37,8 +30,8 @@ def get_conf_stage( def get_executorWithConfig( - task_stage: TaskStage, cached: list[str] -) -> Tuple[ExecutorWithConfig, list[str]]: + task_stage: task.Stage, cached: list[str] +) -> Tuple[result.ExecutorWith, list[str]]: file_import = ( task_stage.files.import_ if hasattr(task_stage, "files") @@ -55,11 +48,11 @@ def get_executorWithConfig( and (task_stage.files is not None) else [] ) - executor_with_config = ExecutorWithConfig( - default=Cmd( + executor_with_config = result.ExecutorWith( + default=result.Cmd( args=(task_stage.command.split() if task_stage.command is not None else []), copy_in={ - file: CmdFile(src=f"/home/tt/.config/joj/{file}") + file: result.CmdFile(src=f"/home/tt/.config/joj/{file}") for file in copy_in_files }, copy_in_cached={file: file for file in copy_in_files}, @@ -79,7 +72,7 @@ def get_executorWithConfig( if task_stage.limit is not None and task_stage.limit.mem is not None else 4 * 1_024 * 1_024 ), - stderr=CmdFile( + stderr=result.CmdFile( name="stderr", max=( task_stage.limit.stderr * 1_000_000_000 @@ -88,7 +81,7 @@ def get_executorWithConfig( else 4 * 1_024 * 1_024 ), ), - stdout=CmdFile( + stdout=result.CmdFile( name="stdout", max=( task_stage.limit.stdout * 1_000_000_000 @@ -107,7 +100,9 @@ def get_executorWithConfig( return (executor_with_config, cached) -def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: +def fix_keyword( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: keyword_parser = ["clangtidy", "keyword", "cppcheck"] # TODO: may add cpplint if task_stage.parsers is not None: for parser in task_stage.parsers: @@ -128,7 +123,9 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: return conf_stage -def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: +def fix_result_detail( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: if (task_stage.parsers is not None) and ("result-detail" in task_stage.parsers): result_detail_parser = next( p for p in conf_stage.parsers if p.name == "result-detail" @@ -159,7 +156,9 @@ def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultS return conf_stage -def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: +def fix_comment( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: comment_parser = [ "dummy", "result-status", @@ -180,7 +179,9 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: return conf_stage -def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: +def fix_diff( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: if task_stage.parsers is not None and "diff" in task_stage.parsers: diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) skip = task_stage.skip or [] @@ -213,8 +214,8 @@ def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: ) stage_cases.append( - OptionalCmd( - stdin=CmdFile( + result.OptionalCmd( + stdin=result.CmdFile( src=f"/home/tt/.config/joj/{conf_stage.name}/{case}.in" ), cpu_limit=cpu_limit, diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index e77b9d8..f89fa77 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Dict, Optional, Type, List +from typing import Any, Dict, List, Optional, Type from pydantic import BaseModel, Field, root_validator from pydantic import BaseModel, Field, root_validator @@ -34,9 +34,10 @@ class ParserDiff(BaseModel): class Files(BaseModel): - import_: Optional[List[str]] = Field(serialization_alias="import", validation_alias="import") - export: Optional[List[str]] - + import_: Optional[List[str]] = Field( + [], serialization_alias="import", validation_alias="import" + ) + export: Optional[List[str]] = [] class Limit(BaseModel): diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index c15b691..9ac998d 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f19f8920180>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-lf3ranpy/repo-health-checker": { - "src": "//tmp/repo-checker-gd58j2qv/repo-health-checker", + "//tmp/repo-checker-5txkd_qm/repo-health-checker": { + "src": "//tmp/repo-checker-i9n16_cy/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From 805a79bf106d188b4081a449741956e5f77f8118 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 18:53:41 +0800 Subject: [PATCH 069/131] feat: migrate repo & init classes --- joj3_config_generator/convert.py | 85 ++++++++++++++++++++------ joj3_config_generator/lib/__init__.py | 11 ++++ joj3_config_generator/lib/repo.py | 49 ++++++++++----- joj3_config_generator/main.py | 4 +- joj3_config_generator/models/result.py | 25 +++++++- joj3_config_generator/models/task.py | 48 +++------------ tests/convert/basic/repo.toml | 2 +- 7 files changed, 145 insertions(+), 79 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 1d014aa..d59d076 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,15 +1,17 @@ -from typing import List - from joj3_config_generator.lib.repo import getHealthcheckConfig, getTeapotConfig -from joj3_config_generator.lib.task import ( - fix_comment, - fix_diff, - fix_keyword, - fix_result_detail, - get_conf_stage, - get_executorWithConfig, +from joj3_config_generator.models import ( + Cmd, + CmdFile, + ExecutorConfig, + ExecutorWithConfig, + ParserConfig, + Repo, + ResultConfig, + Stage, + StageConfig, + Task, + TeapotConfig, ) -from joj3_config_generator.models import joj1, repo, result, task # FIXME: LLM generated convert function, only for demostration @@ -19,29 +21,72 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: name=task_conf.task, # TODO: specify the exact folder difference log_path=f"{task_conf.task.replace(' ', '-')}.log", - # TODO: specify the exact folder difference - log_path=f"{task_conf.task.replace(' ', '-')}.log", expire_unix_timestamp=( int(task_conf.release.deadline.timestamp()) if task_conf.release.deadline else -1 ), - stage=result.Stage(stages=[], sandbox_token=repo_conf.sandbox_token), + stage=StageConfig(stages=[], sandbox_token=repo_conf.sandbox_token), teapot=getTeapotConfig(repo_conf, task_conf), ) # Construct healthcheck stage healthcheck_stage = getHealthcheckConfig(repo_conf, task_conf) result_conf.stage.stages.append(healthcheck_stage) - cached: list[str] = [] + cached = [] # Convert each stage in the task configuration for task_stage in task_conf.stages: - 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_keyword(task_stage, conf_stage) - conf_stage = fix_diff(task_stage, conf_stage) + file_import = ( + task_stage.files.import_ + if hasattr(task_stage, "files") + and hasattr(task_stage.files, "import_") + and (task_stage.files is not None) + and (task_stage.files.import_ is not None) + else [] + ) + copy_in_files = [file for file in file_import if (file not in cached)] + file_export = ( + task_stage.files.export + if hasattr(task_stage, "files") + and hasattr(task_stage.files, "export") + and (task_stage.files is not None) + else [] + ) + executor_with_config = ExecutorWithConfig( + default=Cmd( + args=task_stage.command.split(), + copy_in={ + file: CmdFile(src=f"/home/tt/.config/joj/{file}") + for file in copy_in_files + }, + copy_in_cached={file: file for file in copy_in_files}, + copy_out_cached=file_export if file_export is not None else [], + ), + cases=[], # You can add cases if needed + ) + if file_export is not None: + for file in file_export: + if file not in cached: + cached.append(file) + conf_stage = Stage( + name=task_stage.name, + # TODO: we may have cq in future + group="joj" if "judge" in task_stage.name else None, + executor=ExecutorConfig( + name="sandbox", + with_=executor_with_config, + ), + parsers=[ + ParserConfig(name=parser, with_={}) for parser in task_stage.parsers + ], + ) + if "result-detail" in task_stage.parsers: + result_detail_parser = next( + p for p in conf_stage.parsers if p.name == "result-detail" + ) + if task_stage.result_detail is not None: + result_detail_parser.with_.update(task_stage.result_detail) + result_conf.stage.stages.append(conf_stage) return result_conf diff --git a/joj3_config_generator/lib/__init__.py b/joj3_config_generator/lib/__init__.py index e69de29..68802d4 100644 --- a/joj3_config_generator/lib/__init__.py +++ b/joj3_config_generator/lib/__init__.py @@ -0,0 +1,11 @@ +from joj3_config_generator.models.repo import Repo as Repo +from joj3_config_generator.models.result import Cmd as Cmd +from joj3_config_generator.models.result import CmdFile as CmdFile +from joj3_config_generator.models.result import ExecutorConfig as ExecutorConfig +from joj3_config_generator.models.result import ExecutorWithConfig as ExecutorWithConfig +from joj3_config_generator.models.result import ParserConfig as ParserConfig +from joj3_config_generator.models.result import ResultConfig as ResultConfig +from joj3_config_generator.models.result import Stage as Stage +from joj3_config_generator.models.result import StageConfig as StageConfig +from joj3_config_generator.models.result import TeapotConfig as TeapotConfig +from joj3_config_generator.models.task import Task as Task diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index 8c17ee1..e9a8d33 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -1,8 +1,22 @@ import hashlib -import socket +import os import tempfile -from joj3_config_generator.models import joj1, repo, result, task +from dotenv import load_dotenv + +from joj3_config_generator.models import ( + Cmd, + CmdFile, + ExecutorConfig, + ExecutorWithConfig, + ParserConfig, + Repo, + ResultConfig, + Stage, + StageConfig, + Task, + TeapotConfig, +) def get_temp_directory() -> str: @@ -10,12 +24,17 @@ def get_temp_directory() -> str: def getGradingRepoName() -> str: - host_name = socket.gethostname() - return f"{host_name.split('-')[0]}-joj" + path = os.path.expanduser("~/.config/teapot/teapot.env") + if os.path.exists(path): + load_dotenv(path) + repo_name = os.environ.get("GITEA_ORG_NAME") + if repo_name is not None: + return f"{repo_name.split('-')[0]}-joj" + return "ece482-joj" -def getTeapotConfig(repo_conf: repo.Config, task_conf: task.Config) -> result.Teapot: - teapot = result.Teapot( +def getTeapotConfig(repo_conf: Repo, task_conf: Task) -> TeapotConfig: + teapot = TeapotConfig( # TODO: fix the log path log_path=f"{task_conf.task.replace(' ', '-')}-joint-teapot-debug.log", scoreboard_path=f"{task_conf.task.replace(' ', '-')}-scoreboard.csv", @@ -25,7 +44,7 @@ def getTeapotConfig(repo_conf: repo.Config, task_conf: task.Config) -> result.Te return teapot -def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: +def getHealthcheckCmd(repo_conf: Repo) -> Cmd: repoSize = repo_conf.max_size immutable = repo_conf.files.immutable repo_size = f"-repoSize={str(repoSize)} " @@ -52,11 +71,11 @@ def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: args = args + immutable_files - cmd = result.Cmd( + cmd = Cmd( args=args.split(), # FIXME: easier to edit within global scope copy_in={ - f"/{get_temp_directory()}/repo-health-checker": result.CmdFile( + f"/{get_temp_directory()}/repo-health-checker": CmdFile( src=f"/{get_temp_directory()}/repo-health-checker" ) }, @@ -64,17 +83,15 @@ def getHealthcheckCmd(repo_conf: repo.Config) -> result.Cmd: return cmd -def getHealthcheckConfig( - repo_conf: repo.Config, task_conf: task.Config -) -> result.StageDetail: - healthcheck_stage = result.StageDetail( +def getHealthcheckConfig(repo_conf: Repo, task_conf: Task) -> Stage: + healthcheck_stage = Stage( name="healthcheck", group="", - executor=result.Executor( + executor=ExecutorConfig( name="sandbox", - with_=result.ExecutorWith(default=getHealthcheckCmd(repo_conf), cases=[]), + with_=ExecutorWithConfig(default=getHealthcheckCmd(repo_conf), cases=[]), ), - parsers=[result.Parser(name="healthcheck", with_={"score": 0, "comment": ""})], + parsers=[ParserConfig(name="healthcheck", with_={"score": 0, "comment": ""})], ) return healthcheck_stage diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 8a42950..823804c 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -62,8 +62,8 @@ def convert(root: Path = Path(".")) -> result.Config: task_toml = task_file.read() repo_obj = rtoml.loads(repo_toml) task_obj = rtoml.loads(task_toml) - result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj)) - result_model = remove_nulls(result_model) + print(task_obj) + result_model = convert_conf(Repo(**repo_obj), Task(**task_obj)) result_dict = result_model.model_dump(by_alias=True) with open(result_json_path, "w") as result_file: diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index 42c3b15..f2ea268 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -9,6 +9,7 @@ class CmdFile(BaseModel): file_id: Optional[str] = Field(None, serialization_alias="fileId") name: Optional[str] = None max: Optional[int] = 4 * 1024 * 1024 + max: Optional[int] = 4 * 1024 * 1024 symlink: Optional[str] = None stream_in: bool = Field(False, serialization_alias="streamIn") stream_out: bool = Field(False, serialization_alias="streamOut") @@ -22,11 +23,19 @@ class Cmd(BaseModel): stdout: Optional[CmdFile] = CmdFile(name="stdout", max=4 * 1024) stderr: Optional[CmdFile] = CmdFile(name="stderr", max=4 * 1024) cpu_limit: int = Field(4 * 1000000000, serialization_alias="cpuLimit") + env: list[str] = ["PATH=/usr/bin:/bin:/usr/local/bin"] + stdin: Optional[CmdFile] = CmdFile(content="") + stdout: Optional[CmdFile] = CmdFile(name="stdout", max=4 * 1024) + stderr: Optional[CmdFile] = CmdFile(name="stderr", max=4 * 1024) + cpu_limit: int = Field(4 * 1000000000, serialization_alias="cpuLimit") real_cpu_limit: int = Field(0, serialization_alias="realCpuLimit") clock_limit: int = Field(8 * 1000000000, serialization_alias="clockLimit") memory_limit: int = Field(4 * 1024 * 1024, serialization_alias="memoryLimit") + clock_limit: int = Field(8 * 1000000000, serialization_alias="clockLimit") + memory_limit: int = Field(4 * 1024 * 1024, serialization_alias="memoryLimit") stack_limit: int = Field(0, serialization_alias="stackLimit") proc_limit: int = Field(50, serialization_alias="procLimit") + proc_limit: int = Field(50, serialization_alias="procLimit") cpu_rate_limit: int = Field(0, serialization_alias="cpuRateLimit") cpu_set_limit: str = Field("", serialization_alias="cpuSetLimit") copy_in: Dict[str, CmdFile] = Field({}, serialization_alias="copyIn") @@ -45,17 +54,24 @@ class Cmd(BaseModel): class OptionalCmd(BaseModel): args: Optional[list[str]] = None env: Optional[list[str]] = ["PATH=/usr/bin:/bin:/usr/local/bin"] + env: Optional[list[str]] = ["PATH=/usr/bin:/bin:/usr/local/bin"] stdin: Optional[CmdFile] = None stdout: Optional[CmdFile] = None stderr: Optional[CmdFile] = None cpu_limit: Optional[int] = Field(4 * 1000000000, serialization_alias="cpuLimit") + cpu_limit: Optional[int] = Field(4 * 1000000000, serialization_alias="cpuLimit") real_cpu_limit: Optional[int] = Field(None, serialization_alias="realCpuLimit") clock_limit: Optional[int] = Field(8 * 1000000000, serialization_alias="clockLimit") memory_limit: Optional[int] = Field( 4 * 1024 * 1024, serialization_alias="memoryLimit" ) + clock_limit: Optional[int] = Field(8 * 1000000000, serialization_alias="clockLimit") + memory_limit: Optional[int] = Field( + 4 * 1024 * 1024, serialization_alias="memoryLimit" + ) stack_limit: Optional[int] = Field(None, serialization_alias="stackLimit") proc_limit: Optional[int] = Field(50, serialization_alias="procLimit") + proc_limit: Optional[int] = Field(50, serialization_alias="procLimit") cpu_rate_limit: Optional[int] = Field(None, serialization_alias="cpuRateLimit") cpu_set_limit: Optional[str] = Field(None, serialization_alias="cpuSetLimit") copy_in: Optional[Dict[str, CmdFile]] = Field(None, serialization_alias="copyIn") @@ -81,7 +97,14 @@ class OptionalCmd(BaseModel): ) -class ExecutorWith(BaseModel): +class Stage(BaseModel): + name: str + group: Optional[str] = None + executor: "ExecutorConfig" + parsers: list["ParserConfig"] + + +class ExecutorWithConfig(BaseModel): default: Cmd cases: List[OptionalCmd] diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index f89fa77..77fd23d 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -18,26 +18,13 @@ class ParserDummy(BaseModel): class ParserKeyword(BaseModel): - keyword: Optional[list[str]] = [] - weight: Optional[list[int]] = [] - - -class Outputs(BaseModel): - score: Optional[int] = 0 - ignorespaces: Optional[bool] = False - hide: Optional[bool] = False - forcequit: Optional[bool] = True - - -class ParserDiff(BaseModel): - output: Optional[Outputs] = Outputs() + keyword: Optional[list[str]] = None + weight: Optional[list[int]] = None class Files(BaseModel): - import_: Optional[List[str]] = Field( - [], serialization_alias="import", validation_alias="import" - ) - export: Optional[List[str]] = [] + import_: Optional[list[str]] = Field([], alias="import") + export: Optional[list[str]] = [] class Limit(BaseModel): @@ -48,37 +35,20 @@ class Limit(BaseModel): class Stage(BaseModel): - name: Optional[str] = None # Stage name - command: Optional[str] = None # Command to run + name: str # Stage name + command: str # Command to run files: Optional[Files] = None score: Optional[int] = 0 - parsers: Optional[list[str]] = [] # list of parsers - limit: Optional[Limit] = Limit() + 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() - # FIXME: determine cpplint type - # cpplint: Optional[ParserKeyword] = ParserKeyword() - cpplint: Optional[ParserDummy] = ParserDummy() + cpplint: Optional[ParserKeyword] = ParserKeyword() result_detail: Optional[ParserResultDetail] = Field( ParserResultDetail(), alias="result-detail" ) - skip: Optional[list[str]] = [] - diff: Optional[ParserDiff] = ParserDiff() - cases: Optional[Dict[str, "Stage"]] = {} - - class Config: - extra = "allow" - - @root_validator(pre=True) - def gather_cases(cls: Type["Stage"], values: Dict[str, Any]) -> Dict[str, Any]: - cases = {k: v for k, v in values.items() if k.startswith("case")} - for key in cases: - values.pop(key) - values["cases"] = {k: Stage(**v) for k, v in cases.items()} - return values class Release(BaseModel): diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index 28b5c05..c77b9f7 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -7,4 +7,4 @@ sandbox_token = "test" whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" required = ["main.py", "README.md"] -immutable = [] +immutable = [".gitignore", ".gitattributes", "push.yaml", "release.yaml"] -- 2.30.2 From 43b55f77cee73ea1b6aacc98b264553ed648dcc5 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:37:52 +0800 Subject: [PATCH 070/131] feat: finish keyword related --- joj3_config_generator/convert.py | 19 +- joj3_config_generator/lib/task.py | 264 +---- joj3_config_generator/main.py | 1 - joj3_config_generator/models/task.py | 5 +- tests/convert/basic/task.json | 1327 -------------------------- 5 files changed, 36 insertions(+), 1580 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index d59d076..848ad53 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,4 +1,5 @@ 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, @@ -17,7 +18,8 @@ from joj3_config_generator.models import ( # FIXME: LLM generated convert function, only for demostration def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Create the base ResultConf object - result_conf = result.Config( + # FIXME: wrap things in functions + result_conf = ResultConfig( name=task_conf.task, # TODO: specify the exact folder difference log_path=f"{task_conf.task.replace(' ', '-')}.log", @@ -80,6 +82,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: ParserConfig(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" @@ -87,6 +90,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 diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 7a29cf7..c8bffeb 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,254 +1,20 @@ -from typing import Tuple - -import rtoml - -from joj3_config_generator.models import joj1, repo, result, task +from joj3_config_generator.models.result import Stage as ResultStage +from joj3_config_generator.models.task import Stage as TaskStage -def get_conf_stage( - task_stage: task.Stage, executor_with_config: result.ExecutorWith -) -> result.StageDetail: - conf_stage = result.StageDetail( - name=task_stage.name if task_stage.name is not None else "", - # TODO: we may have cq in future - group=( - "joj" - if (task_stage.name is not None) and ("judge" in task_stage.name) - else None - ), - executor=result.Executor( - name="sandbox", - with_=executor_with_config, - ), - parsers=( - [result.Parser(name=parser, with_={}) for parser in task_stage.parsers] - if task_stage.parsers is not None - else [] - ), - ) - return conf_stage - - -def get_executorWithConfig( - task_stage: task.Stage, cached: list[str] -) -> Tuple[result.ExecutorWith, list[str]]: - file_import = ( - task_stage.files.import_ - if hasattr(task_stage, "files") - and hasattr(task_stage.files, "import_") - and (task_stage.files is not None) - and (task_stage.files.import_ is not None) - else [] - ) - copy_in_files = [file for file in file_import if (file not in cached)] - file_export = ( - task_stage.files.export - if hasattr(task_stage, "files") - and hasattr(task_stage.files, "export") - and (task_stage.files is not None) - else [] - ) - executor_with_config = result.ExecutorWith( - default=result.Cmd( - args=(task_stage.command.split() if task_stage.command is not None else []), - copy_in={ - file: result.CmdFile(src=f"/home/tt/.config/joj/{file}") - for file in copy_in_files - }, - copy_in_cached={file: file for file in copy_in_files}, - copy_out_cached=file_export if file_export is not None else [], - cpu_limit=( - task_stage.limit.cpu * 1_000_000_000 - if task_stage.limit is not None and task_stage.limit.cpu is not None - else 4 * 1_000_000_000 - ), - clock_limit=( - 2 * task_stage.limit.cpu * 1_000_000_000 - if task_stage.limit is not None and task_stage.limit.cpu is not None - else 8 * 1_000_000_000 - ), - memory_limit=( - task_stage.limit.mem * 1_024 * 1_024 - if task_stage.limit is not None and task_stage.limit.mem is not None - else 4 * 1_024 * 1_024 - ), - stderr=result.CmdFile( - name="stderr", - max=( - task_stage.limit.stderr * 1_000_000_000 - if task_stage.limit is not None - and task_stage.limit.stderr is not None - else 4 * 1_024 * 1_024 - ), - ), - stdout=result.CmdFile( - name="stdout", - max=( - task_stage.limit.stdout * 1_000_000_000 - if task_stage.limit is not None - and task_stage.limit.stdout is not None - else 4 * 1_024 * 1_024 - ), - ), - ), - cases=[], # You can add cases if needed - ) - if file_export is not None: - for file in file_export: - if file not in cached: - cached.append(file) - return (executor_with_config, cached) - - -def fix_keyword( - task_stage: task.Stage, conf_stage: result.StageDetail -) -> result.StageDetail: +def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: keyword_parser = ["clangtidy", "keyword", "cppcheck"] # TODO: may add cpplint - if task_stage.parsers is not None: - 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 - - -def fix_result_detail( - task_stage: task.Stage, conf_stage: result.StageDetail -) -> result.StageDetail: - if (task_stage.parsers is not None) and ("result-detail" in task_stage.parsers): - result_detail_parser = next( - p for p in conf_stage.parsers if p.name == "result-detail" - ) - if task_stage.result_detail is not None: - show_files = [] - if ( - task_stage.result_detail.stdout - and task_stage.result_detail.stdout is not None - ): - show_files.append("stdout") - if ( - task_stage.result_detail.stderr - and task_stage.result_detail.stderr is not None - ): - show_files.append("stderr") - result_detail_parser.with_.update( - { - "score": 0, - "comment": "", - "showFiles": show_files, - "showExitStatus": task_stage.result_detail.exitstatus, - "showRuntime": task_stage.result_detail.time, - "showMemory": task_stage.result_detail.mem, - } - ) - - return conf_stage - - -def fix_comment( - task_stage: task.Stage, conf_stage: result.StageDetail -) -> result.StageDetail: - comment_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("-", "_")) - ) - else: - continue - return conf_stage - - -def fix_diff( - task_stage: task.Stage, conf_stage: result.StageDetail -) -> result.StageDetail: - if task_stage.parsers is not None and "diff" in task_stage.parsers: - diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) - skip = task_stage.skip or [] - cases = task_stage.cases or {} - finalized_cases = [case for case in cases if case not in skip] - - stage_cases = [] - parser_cases = [] - - for case in finalized_cases: - case_stage = task_stage.cases.get(case) if task_stage.cases else None - if not case_stage: - continue - - # Ensure case_stage.limit is defined before accessing .cpu and .mem - cpu_limit = ( - case_stage.limit.cpu * 1_000_000_000 - if case_stage.limit and case_stage.limit.cpu is not None - else 0 - ) - clock_limit = ( - 2 * case_stage.limit.cpu * 1_000_000_000 - if case_stage.limit and case_stage.limit.cpu is not None - else 0 - ) - memory_limit = ( - case_stage.limit.mem * 1_024 * 1_024 - if case_stage.limit and case_stage.limit.mem is not None - else 0 - ) - - stage_cases.append( - result.OptionalCmd( - stdin=result.CmdFile( - src=f"/home/tt/.config/joj/{conf_stage.name}/{case}.in" - ), - cpu_limit=cpu_limit, - clock_limit=clock_limit, - memory_limit=memory_limit, - proc_limit=50, - ) - ) - - # Ensure case_stage.diff and case_stage.diff.output are defined - diff_output = ( - case_stage.diff.output - if case_stage.diff and case_stage.diff.output - else None - ) - if diff_output: - parser_cases.append( - { - "outputs": [ - { - "score": diff_output.score, - "fileName": "stdout", - "answerPath": f"/home/tt/.config/joj/{conf_stage.name}/{case}.out", - "forceQuitOnDiff": diff_output.forcequit, - "alwaysHide": diff_output.hide, - "compareSpace": not diff_output.ignorespaces, - } - ] - } - ) - - if diff_parser and task_stage.diff is not None: - diff_parser.with_.update({"name": "diff", "cases": parser_cases}) - conf_stage.executor.with_.cases = stage_cases + 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 diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 823804c..9e07455 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -62,7 +62,6 @@ def convert(root: Path = Path(".")) -> result.Config: task_toml = task_file.read() repo_obj = rtoml.loads(repo_toml) task_obj = rtoml.loads(task_toml) - print(task_obj) result_model = convert_conf(Repo(**repo_obj), Task(**task_obj)) result_dict = result_model.model_dump(by_alias=True) diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 77fd23d..2bb15cd 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -18,8 +18,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() diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 9ac998d..e69de29 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,1327 +0,0 @@ -{ - "name": "h4 ex1", - "logPath": "h4-ex1.log", - "expireUnixTimestamp": 1728748740, - "stage": { - "sandboxExecServer": "172.17.0.1:5051", - "sandboxToken": "test", - "outputPath": "/tmp/joj3_result.json", - "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "//repo-health-checker", - "-root=.", - "-repoSize=50.5", - "-meta=main.py", - "-meta=README.md", - "-checkFileSumList=-checkFileNameList=" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4096, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4096, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "//tmp/repo-checker-5txkd_qm/repo-health-checker": { - "src": "//tmp/repo-checker-i9n16_cy/repo-health-checker", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "healthcheck", - "with": { - "score": 0, - "comment": "" - } - } - ] - }, - { - "name": "Compilation", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "make.sh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 128000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 180000000000, - "realCpuLimit": 0, - "clockLimit": 360000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/make.sh": { - "src": "/home/tt/.config/joj/tools/make.sh", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/main.c": { - "src": "/home/tt/.config/joj/src/main.c", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/task.h": { - "src": "/home/tt/.config/joj/src/task.h", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "srcCMakelist.txt": { - "src": "/home/tt/.config/joj/srcCMakelist.txt", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/make.sh": "tools/make.sh", - "src/main.c": "src/main.c", - "src/task.h": "src/task.h", - "srcCMakelist.txt": "srcCMakelist.txt" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [ - "driver", - "p2", - "p2-msan" - ], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-status", - "with": { - "comment": "Congratulations! Your code compiled successfully." - } - } - ] - }, - { - "name": "File length check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./file-length", - "500", - "400", - "*.c", - "*.h" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/file-length": { - "src": "/home/tt/.config/joj/tools/file-length", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/file-length": "tools/file-length" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "keyword", - "with": { - "match": [ - { - "keyword": [ - "max" - ], - "score": 50 - }, - { - "keyword": [ - "recommend" - ], - "score": 20 - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": false, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Clang-tidy checks", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "run-clang-tidy-18", - "-header-filter=.*", - "-quiet", - "-load=/usr/local/lib/libcodequality.so", - "-p", - "build" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "clangtidy", - "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": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Cppcheck check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cppcheck", - "--template='{\"file\":\"{file}\",\"line\":{line},", - "\"column\":{column},", - "\"severity\":\"{severity}\",", - "\"message\":\"{message}\",", - "\"id\":\"{id}\"}'", - "--force", - "--enable=all", - "--quiet", - "./" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cppcheck", - "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": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Cpplint check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cpplint", - "--linelength=120", - "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", - "--recursive", - "--exclude=build", - "." - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cpplint", - "with": { - "comment": "" - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "judge-base", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 3000000000, - "realCpuLimit": 0, - "clockLimit": 6000000000, - "memoryLimit": 78643200, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case8.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case8.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "judge-msan", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh-msan" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 10000000000, - "realCpuLimit": 0, - "clockLimit": 20000000000, - "memoryLimit": 524288000, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case6.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", - "forceQuitOnDiff": true, - "alwaysHide": true, - "compareSpace": true - } - ] - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - } - ] - }, - "teapot": { - "logPath": "h4-ex1-joint-teapot-debug.log", - "scoreboardPath": "h4-ex1-scoreboard.csv", - "failedTablePath": "h4-ex1-failed-table.md", - "gradingRepoName": "Nuvole-joj", - "skipIssue": false, - "skipScoreboard": false, - "skipFailedTable": false - } -} -- 2.30.2 From 08fcba4b2cf3271bb9ce8ddb422cd7720654f4cb Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:45:25 +0800 Subject: [PATCH 071/131] feat: combine dummy & result-staus --- joj3_config_generator/convert.py | 15 ++------------- joj3_config_generator/lib/task.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 848ad53..4db2a23 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,5 +1,5 @@ from joj3_config_generator.lib.repo import getHealthcheckConfig, getTeapotConfig -from joj3_config_generator.lib.task import fix_keyword +from joj3_config_generator.lib.task import fix_comment, fix_keyword from joj3_config_generator.models import ( Cmd, CmdFile, @@ -90,18 +90,7 @@ 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_comment(task_stage, conf_stage) conf_stage = fix_keyword(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 c8bffeb..3b8208c 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -18,3 +18,15 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: else: continue return conf_stage + + +def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + comment_parser = ["dummy", "result-status"] + 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, None) is not None: + comment_parser_.with_.update(getattr(task_stage, parser)) + else: + continue + return conf_stage -- 2.30.2 From b7a3e51d19357d69c009837a99470a97c0786075 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:55:31 +0800 Subject: [PATCH 072/131] fix: result-status --- joj3_config_generator/convert.py | 12 ++++++++++++ joj3_config_generator/lib/task.py | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 4db2a23..da16e50 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -90,6 +90,18 @@ 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_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 3b8208c..a5b0d36 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -25,8 +25,10 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: 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, None) is not None: - comment_parser_.with_.update(getattr(task_stage, parser)) + if getattr(task_stage, parser.replace("-", "_"), None) is not None: + comment_parser_.with_.update( + getattr(task_stage, parser.replace("-", "_")) + ) else: continue return conf_stage -- 2.30.2 From 1075ab5342d9f793ac597339b288a0c2f9c0d98c Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:55:55 +0800 Subject: [PATCH 073/131] chore: trim old code --- joj3_config_generator/convert.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index da16e50..4db2a23 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -90,18 +90,6 @@ 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_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) -- 2.30.2 From 5eff9fca759dcd2546f10919543d5b086af994f8 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 22:56:50 +0800 Subject: [PATCH 074/131] chore: trim old code --- joj3_config_generator/lib/task.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index a5b0d36..deb3c27 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -21,7 +21,11 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - comment_parser = ["dummy", "result-status"] + comment_parser = [ + "dummy", + "result-status", + "cpplint", + ] # FIXME: determine where cpplint should be 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) -- 2.30.2 From 3f8a6e9066713b5d2bebd10a6bad51669cc86c77 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 23 Oct 2024 23:30:41 +0800 Subject: [PATCH 075/131] fix: result_detail parser --- joj3_config_generator/convert.py | 12 +++-------- joj3_config_generator/lib/task.py | 31 ++++++++++++++++++++++++++++ joj3_config_generator/models/task.py | 4 +++- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 4db2a23..f19a42d 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,5 +1,5 @@ from joj3_config_generator.lib.repo import getHealthcheckConfig, getTeapotConfig -from joj3_config_generator.lib.task import fix_comment, fix_keyword +from joj3_config_generator.lib.task import fix_comment, fix_keyword, fix_result_detail from joj3_config_generator.models import ( Cmd, CmdFile, @@ -82,16 +82,10 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: ParserConfig(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" - ) - if task_stage.result_detail is not None: - result_detail_parser.with_.update(task_stage.result_detail) - + conf_stage = fix_result_detail(task_stage, conf_stage) conf_stage = fix_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) + # TODO: fix diff parser here result_conf.stage.stages.append(conf_stage) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index deb3c27..900749b 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -20,6 +20,37 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: return conf_stage +def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + if "result-detail" in task_stage.parsers: + result_detail_parser = next( + p for p in conf_stage.parsers if p.name == "result-detail" + ) + if task_stage.result_detail is not None: + show_files = [] + if ( + task_stage.result_detail.stdout + and task_stage.result_detail.stdout is not None + ): + show_files.append("stdout") + if ( + task_stage.result_detail.stderr + and task_stage.result_detail.stderr is not None + ): + show_files.append("stderr") + result_detail_parser.with_.update( + { + "score": 0, + "comment": "", + "showFiles": show_files, + "showExitStatus": task_stage.result_detail.exitstatus, + "showRuntime": task_stage.result_detail.time, + "showMemory": task_stage.result_detail.mem, + } + ) + + return conf_stage + + def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: comment_parser = [ "dummy", diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 2bb15cd..31fd3f2 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -46,7 +46,9 @@ class Stage(BaseModel): keyword: Optional[ParserKeyword] = ParserKeyword() clangtidy: Optional[ParserKeyword] = ParserKeyword() cppcheck: Optional[ParserKeyword] = ParserKeyword() - cpplint: Optional[ParserKeyword] = ParserKeyword() + # FIXME: determine cpplint type + # cpplint: Optional[ParserKeyword] = ParserKeyword() + cpplint: Optional[ParserDummy] = ParserDummy() result_detail: Optional[ParserResultDetail] = Field( ParserResultDetail(), alias="result-detail" ) -- 2.30.2 From ec8dc49f210009ef8cd37a360bd6a97ac47434bc Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 13:49:07 +0800 Subject: [PATCH 076/131] feat: cases data reading for diff --- joj3_config_generator/convert.py | 33 ++++++++++++----- joj3_config_generator/lib/task.py | 55 +++++++++++++++++----------- joj3_config_generator/main.py | 6 +-- joj3_config_generator/models/task.py | 34 ++++++++++++++--- 4 files changed, 90 insertions(+), 38 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index f19a42d..f884f22 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,5 +1,10 @@ from joj3_config_generator.lib.repo import getHealthcheckConfig, getTeapotConfig -from joj3_config_generator.lib.task import fix_comment, fix_keyword, fix_result_detail +from joj3_config_generator.lib.task import ( + fix_comment, + fix_diff, + fix_keyword, + fix_result_detail, +) from joj3_config_generator.models import ( Cmd, CmdFile, @@ -16,7 +21,8 @@ from joj3_config_generator.models import ( # FIXME: LLM generated convert function, only for demostration -def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: +def convert(repo_conf: Repo, task_conf: Task) -> ResultConfig: + print(task_conf) # Create the base ResultConf object # FIXME: wrap things in functions result_conf = ResultConfig( @@ -54,9 +60,12 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: and (task_stage.files is not None) else [] ) + # TODO: the global limit field executor_with_config = ExecutorWithConfig( default=Cmd( - args=task_stage.command.split(), + args=( + task_stage.command.split() if task_stage.command is not None else [] + ), copy_in={ file: CmdFile(src=f"/home/tt/.config/joj/{file}") for file in copy_in_files @@ -71,22 +80,28 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: if file not in cached: cached.append(file) conf_stage = Stage( - name=task_stage.name, + name=task_stage.name if task_stage.name is not None else "", # TODO: we may have cq in future - group="joj" if "judge" in task_stage.name else None, + group=( + "joj" + if (task_stage.name is not None) and ("judge" in task_stage.name) + else None + ), executor=ExecutorConfig( name="sandbox", with_=executor_with_config, ), - parsers=[ - ParserConfig(name=parser, with_={}) for parser in task_stage.parsers - ], + parsers=( + [ParserConfig(name=parser, with_={}) for parser in task_stage.parsers] + if task_stage.parsers is not None + else [] + ), ) conf_stage = fix_result_detail(task_stage, conf_stage) conf_stage = fix_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) # TODO: fix diff parser here - + conf_stage = fix_diff(task_stage, conf_stage) result_conf.stage.stages.append(conf_stage) return result_conf diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 900749b..d8d2f78 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,27 +1,32 @@ +import rtoml + 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 + if task_stage.parsers is not None: + 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 + keyword_parser_.with_.update({"match": keyword_weight}) + else: + continue return conf_stage def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - if "result-detail" in task_stage.parsers: + if (task_stage.parsers is not None) and ("result-detail" in task_stage.parsers): result_detail_parser = next( p for p in conf_stage.parsers if p.name == "result-detail" ) @@ -57,13 +62,21 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: "result-status", "cpplint", ] # FIXME: determine where cpplint should be - 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 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 ) - else: - continue + if getattr(task_stage, parser.replace("-", "_"), None) is not None: + comment_parser_.with_.update( + getattr(task_stage, parser.replace("-", "_")) + ) + else: + continue + return conf_stage + + +def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + return conf_stage diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 9e07455..3f388ac 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -8,9 +8,9 @@ import typer import yaml from joj3_config_generator.convert import convert as convert_conf -from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf -from joj3_config_generator.lib.task import remove_nulls -from joj3_config_generator.models import joj1, repo, result, task + +# from joj3_config_generator.lib.task import get_processed_task_obj +from joj3_config_generator.models import Repo, Task from joj3_config_generator.utils.logger import logger app = typer.Typer(add_completion=False) diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 31fd3f2..9c4602c 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -1,8 +1,7 @@ from datetime import datetime -from typing import Any, Dict, List, Optional, Type +from typing import Any, Dict, Optional, Type from pydantic import BaseModel, Field, root_validator -from pydantic import BaseModel, Field, root_validator class ParserResultDetail(BaseModel): @@ -22,6 +21,17 @@ class ParserKeyword(BaseModel): weight: Optional[list[int]] = [] +class Outputs(BaseModel): + score: Optional[int] = 0 + ignorespaces: Optional[bool] = False + hide: Optional[bool] = False + forcequit: Optional[bool] = True + + +class ParserDiff(BaseModel): + output: Optional[Outputs] = Outputs() + + class Files(BaseModel): import_: Optional[list[str]] = Field([], alias="import") export: Optional[list[str]] = [] @@ -35,11 +45,11 @@ class Limit(BaseModel): class Stage(BaseModel): - name: str # Stage name - command: str # Command to run + name: Optional[str] = None # Stage name + command: Optional[str] = None # Command to run files: Optional[Files] = None score: Optional[int] = 0 - parsers: list[str] # list of parsers + parsers: Optional[list[str]] = [] # list of parsers limit: Optional[Limit] = None dummy: Optional[ParserDummy] = ParserDummy() result_status: Optional[ParserDummy] = Field(ParserDummy(), alias="result-status") @@ -52,6 +62,20 @@ class Stage(BaseModel): result_detail: Optional[ParserResultDetail] = Field( ParserResultDetail(), alias="result-detail" ) + skip: Optional[list[str]] = [] + diff: Optional[ParserDiff] = ParserDiff() + cases: Optional[Dict[str, "Stage"]] = {} + + class Config: + extra = "allow" + + @root_validator(pre=True) + def gather_cases(cls: Type["Stage"], values: Dict[str, Any]) -> Dict[str, Any]: + cases = {k: v for k, v in values.items() if k.startswith("case")} + for key in cases: + values.pop(key) + values["cases"] = {k: Stage(**v) for k, v in cases.items()} + return values class Release(BaseModel): -- 2.30.2 From 91ad7e88a7e9b82ab89f0fcbb195dad392a39b20 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:00:46 +0800 Subject: [PATCH 077/131] ffeat: diff finish --- joj3_config_generator/convert.py | 3 -- joj3_config_generator/lib/task.py | 69 ++++++++++++++++++++++++++++ joj3_config_generator/models/task.py | 2 +- 3 files changed, 70 insertions(+), 4 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index f884f22..98ea255 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -20,9 +20,7 @@ from joj3_config_generator.models import ( ) -# FIXME: LLM generated convert function, only for demostration def convert(repo_conf: Repo, task_conf: Task) -> ResultConfig: - print(task_conf) # Create the base ResultConf object # FIXME: wrap things in functions result_conf = ResultConfig( @@ -100,7 +98,6 @@ def convert(repo_conf: Repo, task_conf: Task) -> ResultConfig: conf_stage = fix_result_detail(task_stage, conf_stage) conf_stage = fix_comment(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) - # TODO: fix diff parser here 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 d8d2f78..35aa92b 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,5 +1,6 @@ import rtoml +from joj3_config_generator.models.result import CmdFile, OptionalCmd from joj3_config_generator.models.result import Stage as ResultStage from joj3_config_generator.models.task import Stage as TaskStage @@ -78,5 +79,73 @@ def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: + if task_stage.parsers is not None and "diff" in task_stage.parsers: + diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) + skip = task_stage.skip or [] + cases = task_stage.cases or {} + finalized_cases = [case for case in cases if case not in skip] + + stage_cases = [] + parser_cases = [] + + for case in finalized_cases: + case_stage = task_stage.cases.get(case) if task_stage.cases else None + if not case_stage: + continue + + # Ensure case_stage.limit is defined before accessing .cpu and .mem + cpu_limit = ( + case_stage.limit.cpu * 1_000_000_000 + if case_stage.limit and case_stage.limit.cpu is not None + else 0 + ) + clock_limit = ( + 2 * case_stage.limit.cpu * 1_000_000_000 + if case_stage.limit and case_stage.limit.cpu is not None + else 0 + ) + memory_limit = ( + case_stage.limit.mem * 1_024 * 1_024 + if case_stage.limit and case_stage.limit.mem is not None + else 0 + ) + + stage_cases.append( + OptionalCmd( + stdin=CmdFile( + src=f"/home/tt/.config/joj/{conf_stage.name}/{case}.in" + ), + cpu_limit=cpu_limit, + clock_limit=clock_limit, + memory_limit=memory_limit, + proc_limit=50, + ) + ) + + # Ensure case_stage.diff and case_stage.diff.output are defined + diff_output = ( + case_stage.diff.output + if case_stage.diff and case_stage.diff.output + else None + ) + if diff_output: + parser_cases.append( + { + "outputs": [ + { + "score": diff_output.score, + "fileName": "stdout", + "answerPath": f"/home/tt/.config/joj/{conf_stage.name}/{case}.out", + "forceQuitOnDiff": diff_output.forcequit, + "alwaysHide": diff_output.hide, + "compareSpace": not diff_output.ignorespaces, + } + ] + } + ) + + if diff_parser and task_stage.diff is not None: + diff_parser.with_.update({"name": "diff", "cases": parser_cases}) + conf_stage.executor.with_.cases = stage_cases return conf_stage diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 9c4602c..fa15fb8 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -50,7 +50,7 @@ class Stage(BaseModel): files: Optional[Files] = None score: Optional[int] = 0 parsers: Optional[list[str]] = [] # list of parsers - limit: Optional[Limit] = None + limit: Optional[Limit] = Limit() dummy: Optional[ParserDummy] = ParserDummy() result_status: Optional[ParserDummy] = Field(ParserDummy(), alias="result-status") keyword: Optional[ParserKeyword] = ParserKeyword() -- 2.30.2 From 12451eebbe8dc686e24ab0522329f6cd30c214e6 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:28:29 +0800 Subject: [PATCH 078/131] chore: more compact code --- joj3_config_generator/convert.py | 60 ++--------------- joj3_config_generator/lib/task.py | 104 +++++++++++++++++++++++++++++- 2 files changed, 108 insertions(+), 56 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 98ea255..ca222b0 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -4,6 +4,8 @@ from joj3_config_generator.lib.task import ( fix_diff, fix_keyword, fix_result_detail, + get_conf_stage, + get_executorWithConfig, ) from joj3_config_generator.models import ( Cmd, @@ -22,7 +24,6 @@ from joj3_config_generator.models import ( def convert(repo_conf: Repo, task_conf: Task) -> ResultConfig: # Create the base ResultConf object - # FIXME: wrap things in functions result_conf = ResultConfig( name=task_conf.task, # TODO: specify the exact folder difference @@ -39,62 +40,11 @@ def convert(repo_conf: Repo, task_conf: Task) -> ResultConfig: # Construct healthcheck stage healthcheck_stage = getHealthcheckConfig(repo_conf, task_conf) result_conf.stage.stages.append(healthcheck_stage) - cached = [] + cached: list[str] = [] # Convert each stage in the task configuration for task_stage in task_conf.stages: - file_import = ( - task_stage.files.import_ - if hasattr(task_stage, "files") - and hasattr(task_stage.files, "import_") - and (task_stage.files is not None) - and (task_stage.files.import_ is not None) - else [] - ) - copy_in_files = [file for file in file_import if (file not in cached)] - file_export = ( - task_stage.files.export - if hasattr(task_stage, "files") - and hasattr(task_stage.files, "export") - and (task_stage.files is not None) - else [] - ) - # TODO: the global limit field - executor_with_config = ExecutorWithConfig( - default=Cmd( - args=( - task_stage.command.split() if task_stage.command is not None else [] - ), - copy_in={ - file: CmdFile(src=f"/home/tt/.config/joj/{file}") - for file in copy_in_files - }, - copy_in_cached={file: file for file in copy_in_files}, - copy_out_cached=file_export if file_export is not None else [], - ), - cases=[], # You can add cases if needed - ) - if file_export is not None: - for file in file_export: - if file not in cached: - cached.append(file) - conf_stage = Stage( - name=task_stage.name if task_stage.name is not None else "", - # TODO: we may have cq in future - group=( - "joj" - if (task_stage.name is not None) and ("judge" in task_stage.name) - else None - ), - executor=ExecutorConfig( - name="sandbox", - with_=executor_with_config, - ), - parsers=( - [ParserConfig(name=parser, with_={}) for parser in task_stage.parsers] - if task_stage.parsers is not None - else [] - ), - ) + 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_keyword(task_stage, conf_stage) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 35aa92b..6ff56d7 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,10 +1,112 @@ +from typing import Tuple + import rtoml -from joj3_config_generator.models.result import CmdFile, OptionalCmd +from joj3_config_generator.models import ( + ExecutorConfig, + ExecutorWithConfig, + ParserConfig, +) +from joj3_config_generator.models.result import Cmd, CmdFile, OptionalCmd from joj3_config_generator.models.result import Stage as ResultStage from joj3_config_generator.models.task import Stage as TaskStage +def get_conf_stage( + task_stage: TaskStage, executor_with_config: ExecutorWithConfig +) -> ResultStage: + conf_stage = ResultStage( + name=task_stage.name if task_stage.name is not None else "", + # TODO: we may have cq in future + group=( + "joj" + if (task_stage.name is not None) and ("judge" in task_stage.name) + else None + ), + executor=ExecutorConfig( + name="sandbox", + with_=executor_with_config, + ), + parsers=( + [ParserConfig(name=parser, with_={}) for parser in task_stage.parsers] + if task_stage.parsers is not None + else [] + ), + ) + return conf_stage + + +def get_executorWithConfig( + task_stage: TaskStage, cached: list[str] +) -> Tuple[ExecutorWithConfig, list[str]]: + file_import = ( + task_stage.files.import_ + if hasattr(task_stage, "files") + and hasattr(task_stage.files, "import_") + and (task_stage.files is not None) + and (task_stage.files.import_ is not None) + else [] + ) + copy_in_files = [file for file in file_import if (file not in cached)] + file_export = ( + task_stage.files.export + if hasattr(task_stage, "files") + and hasattr(task_stage.files, "export") + and (task_stage.files is not None) + else [] + ) + executor_with_config = ExecutorWithConfig( + default=Cmd( + args=(task_stage.command.split() if task_stage.command is not None else []), + copy_in={ + file: CmdFile(src=f"/home/tt/.config/joj/{file}") + for file in copy_in_files + }, + copy_in_cached={file: file for file in copy_in_files}, + copy_out_cached=file_export if file_export is not None else [], + cpu_limit=( + task_stage.limit.cpu * 1_000_000_000 + if task_stage.limit is not None and task_stage.limit.cpu is not None + else 4 * 1_000_000_000 + ), + clock_limit=( + 2 * task_stage.limit.cpu * 1_000_000_000 + if task_stage.limit is not None and task_stage.limit.cpu is not None + else 8 * 1_000_000_000 + ), + memory_limit=( + task_stage.limit.mem * 1_024 * 1_024 + if task_stage.limit is not None and task_stage.limit.mem is not None + else 4 * 1_024 * 1_024 + ), + stderr=CmdFile( + name="stderr", + max=( + task_stage.limit.stderr * 1_000_000_000 + if task_stage.limit is not None + and task_stage.limit.stderr is not None + else 4 * 1_024 * 1_024 + ), + ), + stdout=CmdFile( + name="stdout", + max=( + task_stage.limit.stdout * 1_000_000_000 + if task_stage.limit is not None + and task_stage.limit.stdout is not None + else 4 * 1_024 * 1_024 + ), + ), + ), + cases=[], # You can add cases if needed + ) + if file_export is not None: + for file in file_export: + if file not in cached: + cached.append(file) + return (executor_with_config, cached) + + def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: keyword_parser = ["clangtidy", "keyword", "cppcheck"] # TODO: may add cpplint if task_stage.parsers is not None: -- 2.30.2 From 922f79071e09ceab0089b3ca1b3bffede659bff6 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:43:43 +0800 Subject: [PATCH 079/131] fix: gradingreponame schema --- joj3_config_generator/lib/repo.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index e9a8d33..1c39a0c 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -1,5 +1,5 @@ import hashlib -import os +import socket import tempfile from dotenv import load_dotenv @@ -24,13 +24,8 @@ def get_temp_directory() -> str: def getGradingRepoName() -> str: - path = os.path.expanduser("~/.config/teapot/teapot.env") - if os.path.exists(path): - load_dotenv(path) - repo_name = os.environ.get("GITEA_ORG_NAME") - if repo_name is not None: - return f"{repo_name.split('-')[0]}-joj" - return "ece482-joj" + host_name = socket.gethostname() + return f"{host_name.split('-')[0]}-joj" def getTeapotConfig(repo_conf: Repo, task_conf: Task) -> TeapotConfig: -- 2.30.2 From fddfe310015b2ceb79815fe079fad7c452f403b2 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:46:30 +0800 Subject: [PATCH 080/131] fix: remove dotenv --- joj3_config_generator/lib/repo.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index 1c39a0c..cb679c4 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -2,8 +2,6 @@ import hashlib import socket import tempfile -from dotenv import load_dotenv - from joj3_config_generator.models import ( Cmd, CmdFile, -- 2.30.2 From 93b873b7312f3ddc68a7aaaa6bec9a1f15467795 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:53:42 +0800 Subject: [PATCH 081/131] fix: immutable_file --- tests/immutable_file/.gitattributes | 33 ----------------------------- tests/immutable_file/.gitignore | 23 -------------------- tests/immutable_file/push.yaml | 18 ---------------- tests/immutable_file/release.yaml | 20 ----------------- 4 files changed, 94 deletions(-) delete mode 100644 tests/immutable_file/.gitattributes delete mode 100644 tests/immutable_file/.gitignore delete mode 100644 tests/immutable_file/push.yaml delete mode 100644 tests/immutable_file/release.yaml diff --git a/tests/immutable_file/.gitattributes b/tests/immutable_file/.gitattributes deleted file mode 100644 index b910c4a..0000000 --- a/tests/immutable_file/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -*.avi filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.djvu filter=lfs diff=lfs merge=lfs -text -*.doc filter=lfs diff=lfs merge=lfs -text -*.docx filter=lfs diff=lfs merge=lfs -text -*.epub filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.ipynb filter=lfs diff=lfs merge=lfs -text -*.jpeg filter=lfs diff=lfs merge=lfs -text -*.JPEG filter=lfs diff=lfs merge=lfs -text -*.jpg filter=lfs diff=lfs merge=lfs -text -*.JPG filter=lfs diff=lfs merge=lfs -text -*.mkv filter=lfs diff=lfs merge=lfs -text -*.mp4 filter=lfs diff=lfs merge=lfs -text -*.ods filter=lfs diff=lfs merge=lfs -text -*.odt filter=lfs diff=lfs merge=lfs -text -*.otf filter=lfs diff=lfs merge=lfs -text -*.pdf filter=lfs diff=lfs merge=lfs -text -*.PDF filter=lfs diff=lfs merge=lfs -text -*.png filter=lfs diff=lfs merge=lfs -text -*.PNG filter=lfs diff=lfs merge=lfs -text -*.ppt filter=lfs diff=lfs merge=lfs -text -*.pptx filter=lfs diff=lfs merge=lfs -text -*.ps filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text -*.tar filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.ttf filter=lfs diff=lfs merge=lfs -text -*.webm filter=lfs diff=lfs merge=lfs -text -*.xls filter=lfs diff=lfs merge=lfs -text -*.xlsx filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_file/.gitignore b/tests/immutable_file/.gitignore deleted file mode 100644 index 754f776..0000000 --- a/tests/immutable_file/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -################################ -## White list based gitignore ## -################################ - -# forbidden -* -.* - -# allowed -!.gitignore -!.gitattributes -!.gitea/ -!.gitea/issue_template/ -!.gitea/workflows/ -!*.yaml -!Makefile -!CMakeLists.txt -!h[0-8]/ -!*.m -!*.c -!*.cpp -!*.h -!*.md diff --git a/tests/immutable_file/push.yaml b/tests/immutable_file/push.yaml deleted file mode 100644 index 2f890b6..0000000 --- a/tests/immutable_file/push.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: Run JOJ3 on Push -on: [push] -jobs: - run: - container: - image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim - volumes: - - /home/tt/.config:/home/tt/.config - - /home/tt/.cache:/home/tt/.cache - - /home/tt/.ssh:/home/tt/.ssh - steps: - - name: Check out repository code - uses: https://gitea.com/BoYanZh/checkout@focs - with: - fetch-depth: 0 - - name: run joj3 - run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml deleted file mode 100644 index afd2838..0000000 --- a/tests/immutable_file/release.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: Run JOJ3 on Release -on: - release: - types: [published] -jobs: - run: - container: - image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim - volumes: - - /home/tt/.config:/home/tt/.config - - /home/tt/.cache:/home/tt/.cache - - /home/tt/.ssh:/home/tt/.ssh - steps: - - name: Check out repository code - uses: https://gitea.com/BoYanZh/checkout@focs - with: - fetch-depth: 0 - - name: run joj3 - run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj -msg "feat(h1-release): joj on ${{ github.ref }}" -- 2.30.2 From d112810f855f301072e246fd84e99234ad4c457c Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 15:56:11 +0800 Subject: [PATCH 082/131] fix: immutable repo tom --- tests/convert/basic/repo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index c77b9f7..28b5c05 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -7,4 +7,4 @@ sandbox_token = "test" whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" required = ["main.py", "README.md"] -immutable = [".gitignore", ".gitattributes", "push.yaml", "release.yaml"] +immutable = [] -- 2.30.2 From 6e6642956193eb2358aa4a3a70a02cc7da2829e4 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 26 Oct 2024 16:01:38 +0800 Subject: [PATCH 083/131] feat: sync --- tests/convert/basic/task.json | 1328 +++++++++++++++++++++++++++ tests/immutable_file/.gitattributes | 33 + tests/immutable_file/.gitignore | 23 + tests/immutable_file/push.yaml | 18 + tests/immutable_file/release.yaml | 20 + 5 files changed, 1422 insertions(+) create mode 100644 tests/immutable_file/.gitattributes create mode 100644 tests/immutable_file/.gitignore create mode 100644 tests/immutable_file/push.yaml create mode 100644 tests/immutable_file/release.yaml diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index e69de29..4ffc375 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -0,0 +1,1328 @@ +{ + "name": "h4 ex1", + "logPath": "h4-ex1.log", + "expireUnixTimestamp": 1728748740, + "stage": { + "sandboxExecServer": "172.17.0.1:5051", + "sandboxToken": "test", + "outputPath": "/tmp/joj3_result.json", + "stages": [ + { + "name": "healthcheck", + "group": "", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "//repo-health-checker", + "-root=.", + "-repoSize=50.5", + "-meta=main.py", + "-meta=README.md", + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", + "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "//tmp/repo-checker-u3awlhwg/repo-health-checker": { + "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 0, + "comment": "" + } + } + ] + }, + { + "name": "Compilation", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "make.sh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 128000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 180000000000, + "realCpuLimit": 0, + "clockLimit": 360000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/make.sh": { + "src": "/home/tt/.config/joj/tools/make.sh", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/main.c": { + "src": "/home/tt/.config/joj/src/main.c", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/task.h": { + "src": "/home/tt/.config/joj/src/task.h", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "srcCMakelist.txt": { + "src": "/home/tt/.config/joj/srcCMakelist.txt", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/make.sh": "tools/make.sh", + "src/main.c": "src/main.c", + "src/task.h": "src/task.h", + "srcCMakelist.txt": "srcCMakelist.txt" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [ + "driver", + "p2", + "p2-msan" + ], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-status", + "with": { + "comment": "Congratulations! Your code compiled successfully." + } + } + ] + }, + { + "name": "File length check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./file-length", + "500", + "400", + "*.c", + "*.h" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/file-length": { + "src": "/home/tt/.config/joj/tools/file-length", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/file-length": "tools/file-length" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "keyword", + "with": { + "match": [ + { + "keyword": [ + "max" + ], + "score": 50 + }, + { + "keyword": [ + "recommend" + ], + "score": 20 + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": false, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Clang-tidy checks", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "run-clang-tidy-18", + "-header-filter=.*", + "-quiet", + "-load=/usr/local/lib/libcodequality.so", + "-p", + "build" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "clangtidy", + "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": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Cppcheck check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cppcheck", + "--template='{\"file\":\"{file}\",\"line\":{line},", + "\"column\":{column},", + "\"severity\":\"{severity}\",", + "\"message\":\"{message}\",", + "\"id\":\"{id}\"}'", + "--force", + "--enable=all", + "--quiet", + "./" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cppcheck", + "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": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Cpplint check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cpplint", + "--linelength=120", + "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", + "--recursive", + "--exclude=build", + "." + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cpplint", + "with": { + "comment": "" + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "judge-base", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 3000000000, + "realCpuLimit": 0, + "clockLimit": 6000000000, + "memoryLimit": 78643200, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case8.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case8.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "judge-msan", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh-msan" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 10000000000, + "realCpuLimit": 0, + "clockLimit": 20000000000, + "memoryLimit": 524288000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case6.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", + "forceQuitOnDiff": true, + "alwaysHide": true, + "compareSpace": true + } + ] + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + } + ] + }, + "teapot": { + "logPath": "h4-ex1-joint-teapot-debug.log", + "scoreboardPath": "h4-ex1-scoreboard.csv", + "failedTablePath": "h4-ex1-failed-table.md", + "gradingRepoName": "Nuvole-joj", + "skipIssue": false, + "skipScoreboard": false, + "skipFailedTable": false + } +} diff --git a/tests/immutable_file/.gitattributes b/tests/immutable_file/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/immutable_file/.gitattributes @@ -0,0 +1,33 @@ +*.avi filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.djvu filter=lfs diff=lfs merge=lfs -text +*.doc filter=lfs diff=lfs merge=lfs -text +*.docx filter=lfs diff=lfs merge=lfs -text +*.epub filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.ipynb filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.JPEG filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.JPG filter=lfs diff=lfs merge=lfs -text +*.mkv filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.ods filter=lfs diff=lfs merge=lfs -text +*.odt filter=lfs diff=lfs merge=lfs -text +*.otf filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.PDF filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.PNG filter=lfs diff=lfs merge=lfs -text +*.ppt filter=lfs diff=lfs merge=lfs -text +*.pptx filter=lfs diff=lfs merge=lfs -text +*.ps filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text +*.xls filter=lfs diff=lfs merge=lfs -text +*.xlsx filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_file/.gitignore b/tests/immutable_file/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/immutable_file/.gitignore @@ -0,0 +1,23 @@ +################################ +## White list based gitignore ## +################################ + +# forbidden +* +.* + +# allowed +!.gitignore +!.gitattributes +!.gitea/ +!.gitea/issue_template/ +!.gitea/workflows/ +!*.yaml +!Makefile +!CMakeLists.txt +!h[0-8]/ +!*.m +!*.c +!*.cpp +!*.h +!*.md diff --git a/tests/immutable_file/push.yaml b/tests/immutable_file/push.yaml new file mode 100644 index 0000000..2f890b6 --- /dev/null +++ b/tests/immutable_file/push.yaml @@ -0,0 +1,18 @@ +name: Run JOJ3 on Push +on: [push] +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml new file mode 100644 index 0000000..afd2838 --- /dev/null +++ b/tests/immutable_file/release.yaml @@ -0,0 +1,20 @@ +name: Run JOJ3 on Release +on: + release: + types: [published] +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj -msg "feat(h1-release): joj on ${{ github.ref }}" -- 2.30.2 From 43083df88b4723d418821212583aa5a8d69df626 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 11:13:56 +0800 Subject: [PATCH 084/131] feat: sync --- tests/convert/basic/task.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 4ffc375..c15b691 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,13 +18,12 @@ "//repo-health-checker", + "0x7f64f5d532e0>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", "-meta=README.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", - "-checkFileNameList=.gitignore,.gitattributes,push.yaml,release.yaml" + "-checkFileSumList=-checkFileNameList=" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -71,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-u3awlhwg/repo-health-checker": { - "src": "//tmp/repo-checker-mc0n0t1l/repo-health-checker", + "//tmp/repo-checker-lf3ranpy/repo-health-checker": { + "src": "//tmp/repo-checker-gd58j2qv/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From 57c7b46c6d70042bf125c04b542d169a46401e82 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 22:51:54 +0800 Subject: [PATCH 085/131] feat: merge conflict --- joj3_config_generator/convert.py | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index ca222b0..ced4596 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,25 +1,4 @@ -from joj3_config_generator.lib.repo import getHealthcheckConfig, getTeapotConfig -from joj3_config_generator.lib.task import ( - fix_comment, - fix_diff, - fix_keyword, - fix_result_detail, - get_conf_stage, - get_executorWithConfig, -) -from joj3_config_generator.models import ( - Cmd, - CmdFile, - ExecutorConfig, - ExecutorWithConfig, - ParserConfig, - Repo, - ResultConfig, - Stage, - StageConfig, - Task, - TeapotConfig, -) +from joj3_config_generator.models import joj1, repo, result, task def convert(repo_conf: Repo, task_conf: Task) -> ResultConfig: -- 2.30.2 From e5eb582f5f1e405f24fe3f827165d5eff1340efa Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 22:56:26 +0800 Subject: [PATCH 086/131] feat --- tests/convert/basic/task.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index c15b691..92d475d 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7ff414d38860>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-lf3ranpy/repo-health-checker": { - "src": "//tmp/repo-checker-gd58j2qv/repo-health-checker", + "//tmp/repo-checker-kep8doc0/repo-health-checker": { + "src": "//tmp/repo-checker-7_k9ht77/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -1316,10 +1316,10 @@ ] }, "teapot": { - "logPath": "h4-ex1-joint-teapot-debug.log", - "scoreboardPath": "h4-ex1-scoreboard.csv", - "failedTablePath": "h4-ex1-failed-table.md", - "gradingRepoName": "Nuvole-joj", + "logPath": "/home/tt/.cache/joint-teapot-debug.log", + "scoreboardPath": "scoreboard.csv", + "failedTablePath": "failed-table.md", + "gradingRepoName": "", "skipIssue": false, "skipScoreboard": false, "skipFailedTable": false -- 2.30.2 From e54d0af8c56a6fb6f51dd9a06d05b4017bc61229 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 22:56:52 +0800 Subject: [PATCH 087/131] fix: merge conflict --- joj3_config_generator/convert.py | 17 +++++++++++++---- joj3_config_generator/lib/__init__.py | 11 ----------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index ced4596..b563646 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,7 +1,16 @@ from joj3_config_generator.models import joj1, repo, result, task +from joj3_config_generator.lib.task import ( + fix_comment, + fix_diff, + fix_keyword, + fix_result_detail, + get_executorWithConfig, + get_conf_stage, +) +from joj3_config_generator.lib.repo import getHealthcheckConfig - -def convert(repo_conf: Repo, task_conf: Task) -> ResultConfig: +# FIXME: LLM generated convert function, only for demostration +def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Create the base ResultConf object result_conf = ResultConfig( name=task_conf.task, @@ -12,8 +21,8 @@ def convert(repo_conf: Repo, task_conf: Task) -> ResultConfig: if task_conf.release.deadline else -1 ), - stage=StageConfig(stages=[], sandbox_token=repo_conf.sandbox_token), - teapot=getTeapotConfig(repo_conf, task_conf), + stage=result.Stage(stages=[], sandbox_token=repo_conf.sandbox_token), + teapot=result.Teapot(), ) # Construct healthcheck stage diff --git a/joj3_config_generator/lib/__init__.py b/joj3_config_generator/lib/__init__.py index 68802d4..e69de29 100644 --- a/joj3_config_generator/lib/__init__.py +++ b/joj3_config_generator/lib/__init__.py @@ -1,11 +0,0 @@ -from joj3_config_generator.models.repo import Repo as Repo -from joj3_config_generator.models.result import Cmd as Cmd -from joj3_config_generator.models.result import CmdFile as CmdFile -from joj3_config_generator.models.result import ExecutorConfig as ExecutorConfig -from joj3_config_generator.models.result import ExecutorWithConfig as ExecutorWithConfig -from joj3_config_generator.models.result import ParserConfig as ParserConfig -from joj3_config_generator.models.result import ResultConfig as ResultConfig -from joj3_config_generator.models.result import Stage as Stage -from joj3_config_generator.models.result import StageConfig as StageConfig -from joj3_config_generator.models.result import TeapotConfig as TeapotConfig -from joj3_config_generator.models.task import Task as Task -- 2.30.2 From 654e94b094687e21a79191ba6d8a1974615ae3cd Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sun, 27 Oct 2024 23:06:37 +0800 Subject: [PATCH 088/131] fix: List import --- joj3_config_generator/convert.py | 1 + tests/convert/basic/task.json | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index b563646..4aa53df 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -8,6 +8,7 @@ from joj3_config_generator.lib.task import ( get_conf_stage, ) from joj3_config_generator.lib.repo import getHealthcheckConfig +from typing import List # FIXME: LLM generated convert function, only for demostration def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 92d475d..be97d42 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f5f9b524860>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-kep8doc0/repo-health-checker": { - "src": "//tmp/repo-checker-7_k9ht77/repo-health-checker", + "//tmp/repo-checker-h1q4gec9/repo-health-checker": { + "src": "//tmp/repo-checker-nprjqigk/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From 4b9e74467cd27d6ed4d6ba784541402b4676736d Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 22:42:53 +0800 Subject: [PATCH 089/131] fix: keywords group score --- joj3_config_generator/convert.py | 13 ++- joj3_config_generator/lib/task.py | 27 +++-- joj3_config_generator/models/task.py | 3 +- tests/convert/basic/task.json | 169 +++++++++++---------------- tests/convert/basic/task.toml | 4 +- 5 files changed, 99 insertions(+), 117 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 4aa53df..c12ff1e 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,16 +1,17 @@ -from joj3_config_generator.models import joj1, repo, result, task +from typing import List + +from joj3_config_generator.lib.repo import getHealthcheckConfig from joj3_config_generator.lib.task import ( fix_comment, fix_diff, fix_keyword, - fix_result_detail, - get_executorWithConfig, + fix_result_detail, get_conf_stage, + get_executorWithConfig, ) -from joj3_config_generator.lib.repo import getHealthcheckConfig -from typing import List +from joj3_config_generator.models import joj1, repo, result, task + -# FIXME: LLM generated convert function, only for demostration def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Create the base ResultConf object result_conf = ResultConfig( diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 6ff56d7..6e4e06c 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -107,8 +107,11 @@ def get_executorWithConfig( return (executor_with_config, cached) -def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: - keyword_parser = ["clangtidy", "keyword", "cppcheck"] # TODO: may add cpplint +# FIXME: fix severity and "keywords" +def fix_keyword( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: + keyword_parser = ["clangtidy", "keyword", "cppcheck", "cpplint"] if task_stage.parsers is not None: for parser in task_stage.parsers: if parser in keyword_parser: @@ -117,12 +120,22 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: ) 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 + unique_weight = list(set(getattr(task_stage, parser).weight)) + for score in unique_weight: + keyword_weight.append({"keywords": [], "score": score}) - keyword_parser_.with_.update({"match": keyword_weight}) + for idx, score in enumerate(unique_weight): + for idx_, score_ in enumerate( + getattr(task_stage, parser).weight + ): + if score == score_: + keyword_weight[idx]["keywords"].append( + getattr(task_stage, parser).keyword[idx_] + ) + else: + continue + + keyword_parser_.with_.update({"matches": keyword_weight}) else: continue return conf_stage diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index fa15fb8..775cc1d 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -57,8 +57,7 @@ class Stage(BaseModel): clangtidy: Optional[ParserKeyword] = ParserKeyword() cppcheck: Optional[ParserKeyword] = ParserKeyword() # FIXME: determine cpplint type - # cpplint: Optional[ParserKeyword] = ParserKeyword() - cpplint: Optional[ParserDummy] = ParserDummy() + cpplint: Optional[ParserKeyword] = ParserKeyword() result_detail: Optional[ParserResultDetail] = Field( ParserResultDetail(), alias="result-detail" ) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index be97d42..c3227ba 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "h4 ex1", - "logPath": "h4-ex1.log", + "name": "Homework 1 exercise 2", + "logPath": "Homework-1-exercise-2.log", "expireUnixTimestamp": 1728748740, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7efe709e4180>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-h1q4gec9/repo-health-checker": { - "src": "//tmp/repo-checker-nprjqigk/repo-health-checker", + "//tmp/repo-checker-d89rnuip/repo-health-checker": { + "src": "//tmp/repo-checker-tk3cqa0k/repo-health-checker", "content": null, "fileId": null, "name": null, @@ -348,15 +348,15 @@ { "name": "keyword", "with": { - "match": [ + "matches": [ { - "keyword": [ + "keywords": [ "max" ], "score": 50 }, { - "keyword": [ + "keywords": [ "recommend" ], "score": 20 @@ -378,7 +378,7 @@ "showFiles": [ "stderr" ], - "showExitStatus": false, + "showExitStatus": true, "showRuntime": false, "showMemory": false } @@ -463,87 +463,37 @@ { "name": "clangtidy", "with": { - "match": [ + "matches": [ { - "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": [ + "keywords": [ "bugprone-suspicious-string-compare" ], "score": 8 }, { - "keyword": [ - "google-global-names-in-headers" + "keywords": [ + "codequality-no-global-variables", + "codequality-no-header-guard", + "readability-duplicate-include", + "readability-misleading-indentation" ], - "score": 5 + "score": 10 }, { - "keyword": [ - "clang-diagnostic" + "keywords": [ + "readability-function-size" ], - "score": 5 + "score": 50 }, { - "keyword": [ - "clang-analyzer" - ], - "score": 5 - }, - { - "keyword": [ + "keywords": [ + "readability-identifier-naming", + "readability-redundant", + "readability-misplaced-array-index", + "cppcoreguidelines-init-variables", + "google-global-names-in-headers", + "clang-diagnostic", + "clang-analyzer", "misc performance" ], "score": 5 @@ -654,36 +604,26 @@ { "name": "cppcheck", "with": { - "match": [ + "matches": [ { - "keyword": [ + "keywords": [ + "warning", + "style" + ], + "score": 10 + }, + { + "keywords": [ "error" ], "score": 20 }, { - "keyword": [ - "warning" - ], - "score": 10 - }, - { - "keyword": [ - "portability" - ], - "score": 15 - }, - { - "keyword": [ + "keywords": [ + "portability", "performance" ], "score": 15 - }, - { - "keyword": [ - "style" - ], - "score": 10 } ] } @@ -787,7 +727,36 @@ { "name": "cpplint", "with": { - "comment": "" + "keyword": [ + "runtime", + "readability", + "build" + ], + "weight": [ + 10, + 20, + 15 + ], + "matches": [ + { + "keywords": [ + "runtime" + ], + "score": 10 + }, + { + "keywords": [ + "readability" + ], + "score": 20 + }, + { + "keywords": [ + "build" + ], + "score": 15 + } + ] } }, { diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index ec4cdfc..12f66f3 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,5 +1,5 @@ # general task configuration -task="h4 ex1" # task name +task="Homework 1 exercise 2" # task name release.deadline = 2024-10-12 23:59:00+08:00 release.stages = [ "compile" ] @@ -29,7 +29,7 @@ files.import = [ "tools/file-length" ] parsers = [ "keyword", "dummy", "result-detail" ] keyword.keyword = [ "max", "recommend"] # keywords caught by corresponding JOJ plugin keyword.weight = [ 50, 20 ] # weight of each keyword -result-detail.exitstatus = false +result-detail.exitstatus = true result-detail.stderr = true result-detail.time = false result-detail.mem = false -- 2.30.2 From 69aa2a0f77f48f8a9f42221e44745b61643b9325 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 23:03:18 +0800 Subject: [PATCH 090/131] 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" -- 2.30.2 From 9001c0db5cd1b4eefbfc18da8c5b4900888a6823 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 23:26:06 +0800 Subject: [PATCH 091/131] feat: newest json --- joj3_config_generator/main.py | 2 +- tests/convert/basic/task.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 3f388ac..3d7e63e 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -64,7 +64,7 @@ def convert(root: Path = Path(".")) -> result.Config: task_obj = rtoml.loads(task_toml) result_model = convert_conf(Repo(**repo_obj), Task(**task_obj)) result_dict = result_model.model_dump(by_alias=True) - + with open(result_json_path, "w") as result_file: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) result_file.write("\n") diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index cad6f01..fe289a5 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f46eeff8180>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-va9ba49a/repo-health-checker": { - "src": "//tmp/repo-checker-e82nkuo4/repo-health-checker", + "//tmp/repo-checker-l7uddq8e/repo-health-checker": { + "src": "//tmp/repo-checker-s5wx4xg3/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From 8af47a34a11346f6544c42fd820a1ded8d030d7d Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 23:35:07 +0800 Subject: [PATCH 092/131] fix: path to past test --- joj3_config_generator/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 3d7e63e..39e2d7e 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -52,10 +52,10 @@ def convert(root: Path = Path(".")) -> result.Config: Convert given dir of JOJ3 toml config files to JOJ3 json config files """ logger.info(f"Converting files in {root.absolute()}") - repo_toml_path = os.path.join(root.absolute(), "basic", "repo.toml") + repo_toml_path = os.path.join(root, "basic", "repo.toml") # TODO: loop through all dirs to find all task.toml - task_toml_path = os.path.join(root.absolute(), "basic", "task.toml") - result_json_path = os.path.join(root.absolute(), "basic", "task.json") + task_toml_path = os.path.join(root, "basic", "task.toml") + result_json_path = os.path.join(root, "basic", "task.json") with open(repo_toml_path) as repo_file: repo_toml = repo_file.read() with open(task_toml_path) as task_file: -- 2.30.2 From 42a3b2d34c8551b308d08e4b99ee8196c99520dc Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 23:40:04 +0800 Subject: [PATCH 093/131] fix: path to test --- joj3_config_generator/main.py | 6 +++--- tests/convert/basic/task.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 39e2d7e..3d7e63e 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -52,10 +52,10 @@ def convert(root: Path = Path(".")) -> result.Config: Convert given dir of JOJ3 toml config files to JOJ3 json config files """ logger.info(f"Converting files in {root.absolute()}") - repo_toml_path = os.path.join(root, "basic", "repo.toml") + repo_toml_path = os.path.join(root.absolute(), "basic", "repo.toml") # TODO: loop through all dirs to find all task.toml - task_toml_path = os.path.join(root, "basic", "task.toml") - result_json_path = os.path.join(root, "basic", "task.json") + task_toml_path = os.path.join(root.absolute(), "basic", "task.toml") + result_json_path = os.path.join(root.absolute(), "basic", "task.json") with open(repo_toml_path) as repo_file: repo_toml = repo_file.read() with open(task_toml_path) as task_file: diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index fe289a5..4c406f2 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -18,7 +18,7 @@ "//repo-health-checker", + "0x7f8686b98180>/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +70,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-l7uddq8e/repo-health-checker": { - "src": "//tmp/repo-checker-s5wx4xg3/repo-health-checker", + "//tmp/repo-checker-9jj98lrm/repo-health-checker": { + "src": "//tmp/repo-checker-er4az3r2/repo-health-checker", "content": null, "fileId": null, "name": null, -- 2.30.2 From 115f57ab84a8385d63908bbd3c66e50f67fac64d Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 7 Nov 2024 23:42:35 +0800 Subject: [PATCH 094/131] fix: path to test --- tests/convert/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 8a2c3f1..b532863 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -12,13 +12,13 @@ def read_convert_files( case_name: str, ) -> Tuple[repo.Config, task.Config, Dict[str, Any]]: root = os.path.dirname(os.path.realpath(__file__)) - repo_toml_path = os.path.join(root, case_name, "repo.toml") + repo_toml_path = os.path.join(root.absolute(), case_name, "repo.toml") with open(repo_toml_path) as f: repo_toml = f.read() - task_toml_path = os.path.join(root, case_name, "task.toml") + task_toml_path = os.path.join(root.absolute(), case_name, "task.toml") with open(task_toml_path) as f: task_toml = f.read() - result_json_path = os.path.join(root, case_name, "task.json") + result_json_path = os.path.join(root.absolute(), case_name, "task.json") with open(result_json_path) as f: result: Dict[str, Any] = json.load(f) repo_obj = rtoml.loads(repo_toml) -- 2.30.2 From 08c75756e073582596121341d5f7030ec7ac517c Mon Sep 17 00:00:00 2001 From: Nuvole Date: Fri, 8 Nov 2024 00:05:22 +0800 Subject: [PATCH 095/131] feat: pass test --- joj3_config_generator/lib/repo.py | 11 ++--------- joj3_config_generator/main.py | 10 ++++++---- tests/convert/basic/task.json | 9 +++------ tests/convert/utils.py | 7 ++++--- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index cb679c4..59f94f9 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -1,6 +1,5 @@ import hashlib import socket -import tempfile from joj3_config_generator.models import ( Cmd, @@ -17,10 +16,6 @@ from joj3_config_generator.models import ( ) -def get_temp_directory() -> str: - return tempfile.mkdtemp(prefix="repo-checker-") - - def getGradingRepoName() -> str: host_name = socket.gethostname() return f"{host_name.split('-')[0]}-joj" @@ -53,7 +48,7 @@ def getHealthcheckCmd(repo_conf: Repo) -> Cmd: else: immutable_files = immutable_files + name + "," # FIXME: need to make solution and make things easier to edit with global scope - chore = f"/{get_temp_directory}/repo-health-checker -root=. " + chore = f"/tmp/repo-health-checker -root=. " args = "" args = args + chore args = args + repo_size @@ -68,9 +63,7 @@ def getHealthcheckCmd(repo_conf: Repo) -> Cmd: args=args.split(), # FIXME: easier to edit within global scope copy_in={ - f"/{get_temp_directory()}/repo-health-checker": CmdFile( - src=f"/{get_temp_directory()}/repo-health-checker" - ) + f"/tmp/repo-health-checker": result.CmdFile(src=f"/tmp/repo-health-checker") }, ) return cmd diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 3d7e63e..543227b 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -8,9 +8,8 @@ import typer import yaml from joj3_config_generator.convert import convert as convert_conf - -# from joj3_config_generator.lib.task import get_processed_task_obj -from joj3_config_generator.models import Repo, Task +from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf +from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.utils.logger import logger app = typer.Typer(add_completion=False) @@ -47,6 +46,7 @@ def convert_joj1(yaml_file: typer.FileText, toml_file: typer.FileTextWrite) -> N @app.command() +def convert(root: Path = Path(".")) -> result.Config: def convert(root: Path = Path(".")) -> result.Config: """ Convert given dir of JOJ3 toml config files to JOJ3 json config files @@ -64,9 +64,11 @@ def convert(root: Path = Path(".")) -> result.Config: task_obj = rtoml.loads(task_toml) result_model = convert_conf(Repo(**repo_obj), Task(**task_obj)) result_dict = result_model.model_dump(by_alias=True) - + with open(result_json_path, "w") as result_file: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) result_file.write("\n") return result_model + + return result_model diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 4c406f2..1a55fb8 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -15,10 +15,7 @@ "with": { "default": { "args": [ - "//repo-health-checker", + "/tmp/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -70,8 +67,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "//tmp/repo-checker-9jj98lrm/repo-health-checker": { - "src": "//tmp/repo-checker-er4az3r2/repo-health-checker", + "/tmp/repo-health-checker": { + "src": "/tmp/repo-health-checker", "content": null, "fileId": null, "name": null, diff --git a/tests/convert/utils.py b/tests/convert/utils.py index b532863..4b8b15a 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -3,6 +3,7 @@ import os from typing import Any, Dict, Tuple import rtoml +from deepdiff import DeepDiff from joj3_config_generator.convert import convert from joj3_config_generator.models import repo, task @@ -12,13 +13,13 @@ def read_convert_files( case_name: str, ) -> Tuple[repo.Config, task.Config, Dict[str, Any]]: root = os.path.dirname(os.path.realpath(__file__)) - repo_toml_path = os.path.join(root.absolute(), case_name, "repo.toml") + repo_toml_path = os.path.join(root, case_name, "repo.toml") with open(repo_toml_path) as f: repo_toml = f.read() - task_toml_path = os.path.join(root.absolute(), case_name, "task.toml") + task_toml_path = os.path.join(root, case_name, "task.toml") with open(task_toml_path) as f: task_toml = f.read() - result_json_path = os.path.join(root.absolute(), case_name, "task.json") + result_json_path = os.path.join(root, case_name, "task.json") with open(result_json_path) as f: result: Dict[str, Any] = json.load(f) repo_obj = rtoml.loads(repo_toml) -- 2.30.2 From 4d65165da547b156580328b0ca446b1e7352d25f Mon Sep 17 00:00:00 2001 From: Nuvole Date: Fri, 8 Nov 2024 00:07:35 +0800 Subject: [PATCH 096/131] feat: pass test --- tests/convert/test_convert_cases.py | 3 --- tests/convert/utils.py | 1 - 2 files changed, 4 deletions(-) diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index 6aa8a0c..1a3392a 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -3,6 +3,3 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") - - -test_basic() diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 4b8b15a..8a2c3f1 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -3,7 +3,6 @@ import os from typing import Any, Dict, Tuple import rtoml -from deepdiff import DeepDiff from joj3_config_generator.convert import convert from joj3_config_generator.models import repo, task -- 2.30.2 From fc435027deaf3f2bc2a394d13c0a5e47f12b32a9 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 10:45:40 +0800 Subject: [PATCH 097/131] feat: remove tmp directory --- joj3_config_generator/convert.py | 2 +- joj3_config_generator/lib/repo.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 13de522..6ac270c 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -28,7 +28,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: ) # Construct healthcheck stage - healthcheck_stage = getHealthcheckConfig(repo_conf, task_conf) + healthcheck_stage = getHealthcheckConfig(repo_conf) result_conf.stage.stages.append(healthcheck_stage) cached: list[str] = [] # Convert each stage in the task configuration diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index 59f94f9..669f3f8 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -48,7 +48,7 @@ def getHealthcheckCmd(repo_conf: Repo) -> Cmd: else: immutable_files = immutable_files + name + "," # FIXME: need to make solution and make things easier to edit with global scope - chore = f"/tmp/repo-health-checker -root=. " + chore = f"./repo-health-checker -root=. " args = "" args = args + chore args = args + repo_size @@ -63,14 +63,14 @@ def getHealthcheckCmd(repo_conf: Repo) -> Cmd: args=args.split(), # FIXME: easier to edit within global scope copy_in={ - f"/tmp/repo-health-checker": result.CmdFile(src=f"/tmp/repo-health-checker") + f"./repo-health-checker": result.CmdFile(src=f"./repo-health-checker") }, ) return cmd -def getHealthcheckConfig(repo_conf: Repo, task_conf: Task) -> Stage: - healthcheck_stage = Stage( +def getHealthcheckConfig(repo_conf: repo.Config) -> result.StageDetail: + healthcheck_stage = result.StageDetail( name="healthcheck", group="", executor=ExecutorConfig( -- 2.30.2 From 54a671d051a19791e9a1fe8d13f70c5c1720d0a3 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 10:51:00 +0800 Subject: [PATCH 098/131] fix: task.json --- tests/convert/basic/task.json | 6 +++--- tests/convert/test_convert_cases.py | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 1a55fb8..a49a9d9 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -15,7 +15,7 @@ "with": { "default": { "args": [ - "/tmp/repo-health-checker", + "./repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=main.py", @@ -67,8 +67,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "/tmp/repo-health-checker": { - "src": "/tmp/repo-health-checker", + "./repo-health-checker": { + "src": "./repo-health-checker", "content": null, "fileId": null, "name": null, diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index 1a3392a..c3ac6cb 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -3,3 +3,5 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") + +test_basic() \ No newline at end of file -- 2.30.2 From bed58365f28548e7d721b66b28e5aaf5add80430 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 13:08:08 +0800 Subject: [PATCH 099/131] feat: remove nulls function --- joj3_config_generator/lib/task.py | 11 +- joj3_config_generator/main.py | 2 + tests/convert/basic/repo.toml | 4 +- tests/convert/basic/task.json | 1228 +++++++++++---------------- tests/convert/basic/task.toml | 143 ++-- tests/convert/test_convert_cases.py | 2 - 6 files changed, 598 insertions(+), 792 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index f11c1c7..eaa0604 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,4 +1,4 @@ -from typing import Tuple +from typing import Any, Dict, Tuple import rtoml @@ -12,6 +12,15 @@ from joj3_config_generator.models.result import Stage as ResultStage from joj3_config_generator.models.task import Stage as TaskStage +def remove_nulls(d: Dict[str, Any]) -> Dict[str, Any]: + if isinstance(d, dict): + return {k: remove_nulls(v) for k, v in d.items() if v is not None} + elif isinstance(d, list): + return [remove_nulls(item) for item in d] + else: + return d + + def get_conf_stage( task_stage: TaskStage, executor_with_config: ExecutorWithConfig ) -> ResultStage: diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 543227b..001476e 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -9,6 +9,7 @@ import yaml from joj3_config_generator.convert import convert as convert_conf from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf +from joj3_config_generator.lib.task import remove_nulls from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.utils.logger import logger @@ -64,6 +65,7 @@ def convert(root: Path = Path(".")) -> result.Config: task_obj = rtoml.loads(task_toml) result_model = convert_conf(Repo(**repo_obj), Task(**task_obj)) result_dict = result_model.model_dump(by_alias=True) + result_dict = remove_nulls(result_dict) with open(result_json_path, "w") as result_file: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index 28b5c05..bb9818b 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -6,5 +6,5 @@ sandbox_token = "test" [files] whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" -required = ["main.py", "README.md"] -immutable = [] +required = [ "Changelog.md", "Readme.md" ] +immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index a49a9d9..9277b16 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "Homework 1 exercise 2", - "logPath": "Homework-1-exercise-2.log", + "name": "p2 m3", + "logPath": "p2-m3.log", "expireUnixTimestamp": 1728748740, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -18,42 +18,31 @@ "./repo-health-checker", "-root=.", "-repoSize=50.5", - "-meta=main.py", - "-meta=README.md", - "-checkFileSumList=-checkFileNameList=" + "-meta=Changelog.md", + "-meta=Readme.md", + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", + "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4096, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4096, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -69,11 +58,7 @@ "copyIn": { "./repo-health-checker": { "src": "./repo-health-checker", - "content": null, - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -104,117 +89,144 @@ ] }, { - "name": "Compilation", - "group": null, + "name": "Abuse of strings detected", "executor": { "name": "sandbox", "with": { "default": { "args": [ - "make.sh" + "./strdetect", + "src/" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", - "max": 128000000000, - "symlink": null, + "max": 4000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 180000000000, + "cpuLimit": 4000000000, "realCpuLimit": 0, - "clockLimit": 360000000000, + "clockLimit": 8000000000, "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "tools/make.sh": { - "src": "/home/tt/.config/joj/tools/make.sh", - "content": null, - "fileId": null, - "name": null, + "tools/strdetec": { + "src": "/home/tt/.config/joj/tools/strdetec", "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/main.c": { - "src": "/home/tt/.config/joj/src/main.c", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/task.h": { - "src": "/home/tt/.config/joj/src/task.h", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "srcCMakelist.txt": { - "src": "/home/tt/.config/joj/srcCMakelist.txt", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false } }, "copyInCached": { - "tools/make.sh": "tools/make.sh", - "src/main.c": "src/main.c", - "src/task.h": "src/task.h", - "srcCMakelist.txt": "srcCMakelist.txt" + "tools/strdetec": "tools/strdetec" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true + } + } + ] + }, + { + "name": "Compilation", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "compile" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/compile": { + "src": "/home/tt/.config/joj/tools/compile", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/compile": "tools/compile" }, "copyInDir": ".", "copyOut": [], "copyOutCached": [ - "driver", - "p2", - "p2-msan" + "build/onecard", + "build/asan", + "build/ubsan", + "build/msan", + "build/compile_commands.json" ], "copyOutMax": 0, "copyOutDir": "", @@ -245,7 +257,7 @@ "with": { "score": 1, "comment": "Congratulations! Your code compiled successfully.", - "forceQuitOnNotAccepted": false + "forceQuitOnNotAccepted": true } }, { @@ -253,22 +265,21 @@ "with": { "score": 1, "comment": "Congratulations! Your code compiled successfully.", - "forceQuitOnNotAccepted": false + "forceQuitOnNotAccepted": true } } ] }, { - "name": "File length check", - "group": null, + "name": "[cq] Filelength", "executor": { "name": "sandbox", "with": { "default": { "args": [ "./file-length", - "500", "400", + "300", "*.c", "*.h" ], @@ -276,34 +287,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -317,20 +316,16 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "tools/file-length": { - "src": "/home/tt/.config/joj/tools/file-length", - "content": null, - "fileId": null, - "name": null, + "tools/filelength": { + "src": "/home/tt/.config/joj/tools/filelength", "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false } }, "copyInCached": { - "tools/file-length": "tools/file-length" + "tools/filelength": "tools/filelength" }, "copyInDir": ".", "copyOut": [], @@ -352,154 +347,15 @@ "matches": [ { "keywords": [ - "max" - ], - "score": 50 - }, - { - "keywords": [ - "recommend" - ], - "score": 20 - } - ] - } - }, - { - "name": "dummy", - "with": { - "score": 10000, - "comment": "Manuel Charlemagne", - "forceQuitOnNotAccepted": true - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Clang-tidy checks", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "run-clang-tidy-18", - "-header-filter=.*", - "-quiet", - "-load=/usr/local/lib/libcodequality.so", - "-p", - "build" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "clangtidy", - "with": { - "matches": [ - { - "keywords": [ - "bugprone-suspicious-string-compare" - ], - "score": 8 - }, - { - "keywords": [ - "codequality-no-global-variables", - "codequality-no-header-guard", - "readability-duplicate-include", - "readability-misleading-indentation" + "recommended" ], "score": 10 }, { "keywords": [ - "readability-function-size" + "max" ], - "score": 50 - }, - { - "keywords": [ - "readability-identifier-naming", - "readability-redundant", - "readability-misplaced-array-index", - "cppcoreguidelines-init-variables", - "google-global-names-in-headers", - "clang-diagnostic", - "clang-analyzer", - "misc performance" - ], - "score": 5 + "score": 20 } ] } @@ -528,8 +384,147 @@ ] }, { - "name": "Cppcheck check", - "group": null, + "name": "[cq] Clang-tidy", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "run-clang-tidy-18", + "-header-filter=.*", + "-quiet", + "-load=/usr/local/lib/libcodequality.so", + "-p", + "build" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 65000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "projects/p2/.clang-tidy": { + "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "projects/p2/.clang-tidy": "projects/p2/.clang-tidy" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "clangtidy", + "with": { + "matches": [ + { + "keywords": [ + "readability-function-size" + ], + "score": 10 + }, + { + "keywords": [ + "codequality-no-global-variables", + "codequality-no-header-guard", + "codequality-no-fflush-stdin" + ], + "score": 20 + }, + { + "keywords": [ + "codequality-unchecked-malloc-result", + "readability-duplicate-include", + "readability-identifier-naming", + "readability-redundant", + "readability-misplaced-array-index", + "cppcoreguidelines-init-variables", + "bugprone-suspicious-string-compare", + "google-global-names-in-headers", + "clang-diagnostic", + "clang-analyzer", + "misc", + "performance", + "portability" + ], + "score": 5 + }, + { + "keywords": [ + "readability-misleading-indentation" + ], + "score": 15 + } + ] + } + }, + { + "name": "dummy", + "with": { + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "[cq] Cppcheck", "executor": { "name": "sandbox", "with": { @@ -543,6 +538,7 @@ "\"id\":\"{id}\"}'", "--force", "--enable=all", + "--suppress=missingIncludeSystem", "--quiet", "./" ], @@ -550,34 +546,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 65000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -613,21 +597,16 @@ { "keywords": [ "warning", + "portability", + "performance", "style" ], - "score": 10 + "score": 5 }, { "keywords": [ "error" ], - "score": 20 - }, - { - "keywords": [ - "portability", - "performance" - ], "score": 15 } ] @@ -657,8 +636,7 @@ ] }, { - "name": "Cpplint check", - "group": null, + "name": "[cq] Cpplint", "executor": { "name": "sandbox", "with": { @@ -675,34 +653,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 65000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -740,7 +706,7 @@ "matches": [ { "keywords": [ - "runtime" + "build" ], "score": 10 }, @@ -752,262 +718,9 @@ }, { "keywords": [ - "build" + "runtime" ], - "score": 15 - } - ] - } - }, - { - "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "judge-base", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 3000000000, - "realCpuLimit": 0, - "clockLimit": 6000000000, - "memoryLimit": 78643200, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case8.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case8.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] + "score": 5 } ] } @@ -1029,63 +742,50 @@ "stderr" ], "showExitStatus": true, - "showRuntime": true, - "showMemory": true + "showRuntime": false, + "showMemory": false } } ] }, { - "name": "judge-msan", - "group": "joj", + "name": "[run] onecard", "executor": { "name": "sandbox", "with": { "default": { "args": [ - "./driver", - "./mumsh-msan" + "./onecard", + "-a" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 10000000000, + "cpuLimit": 4000000000, "realCpuLimit": 0, - "clockLimit": 20000000000, - "memoryLimit": 524288000, + "clockLimit": 8000000000, + "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -1102,175 +802,259 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case6.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] + "cases": [] } }, "parsers": [ { - "name": "diff", + "name": "result-status", "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", - "forceQuitOnDiff": true, - "alwaysHide": true, - "compareSpace": true - } - ] - } - ] + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false } }, { - "name": "dummy", + "name": "result-detail", "with": { "score": 0, "comment": "", - "forceQuitOnNotAccepted": true + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[run] address sanitizer", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./asan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[run] memory sanitizer", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./msan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[run] undefined behavior sanitizer", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./ubsan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false } }, { diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index b060a9e..118247d 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,22 +1,31 @@ -# general task configuration -task="Homework 1 exercise 2" # task name +# p2 repo config + +task="p2 m3" # task name release.deadline = 2024-10-12 23:59:00+08:00 release.stages = [ "compile" ] +[files] +immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] +required = [ "Changelog.md", "Readme.md" ] + +[[stages]] +name = "Abuse of strings detected" +command = "./strdetect src/" +files.import = [ "tools/strdetec" ] + +parsers = [ "result-status" ] + + [[stages]] name = "Compilation" -command = "make.sh" # eg. script running cmake commands -files.import = [ "tools/make.sh", "src/main.c", "src/task.h", "srcCMakelist.txt" ] -files.export = [ "driver", "p2", "p2-msan" ] -limit.cpu = 180 # p2 takes long to compile -limit.stderr = 128 +command = "compile" +files.import = [ "tools/compile" ] +files.export = [ "build/onecard", "build/asan", "build/ubsan", "build/msan", "build/compile_commands.json" ] -# 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 @@ -24,29 +33,13 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "File length check" -command = "./file-length 500 400 *.c *.h" # command to run -files.import = [ "tools/file-length" ] +name = "[cq] Filelength" +command = "./file-length 400 300 *.c *.h" +files.import = [ "tools/filelength" ] parsers = [ "keyword", "dummy", "result-detail" ] -keyword.keyword = [ "max", "recommend"] # keywords caught by corresponding JOJ plugin -keyword.weight = [ 50, 20 ] # weight of each keyword -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" -command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" -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] +keyword.keyword = [ "max", "recommended"] +keyword.weight = [ 20, 10 ] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stdout = true @@ -54,13 +47,28 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "Cppcheck check" -command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --quiet ./" +name = "[cq] Clang-tidy" +command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" +files.import = [ "projects/p2/.clang-tidy", "build/compile_commands.json" ] +limit.stdout = 65 + +parsers = [ "clangtidy", "dummy", "result-detail" ] +clangtidy.keyword = [ "codequality-unchecked-malloc-result", "codequality-no-global-variables", "codequality-no-header-guard", "codequality-no-fflush-stdin", "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", "portability" ] +clangtidy.weight = [ 5, 20, 20, 20, 10, 5, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stdout = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[cq] Cppcheck" +command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --suppress=missingIncludeSystem --quiet ./" limit.stderr = 65 parsers = [ "cppcheck", "dummy", "result-detail" ] cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] -cppcheck.weight = [20, 10, 15, 15, 10] +cppcheck.weight = [15, 5, 5, 5, 5] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stderr = true @@ -68,57 +76,62 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "Cpplint check" +name = "[cq] Cpplint" command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard --recursive --exclude=build ." limit.stdout = 65 parsers = [ "cpplint", "dummy", "result-detail" ] cpplint.keyword = [ "runtime", "readability", "build" ] -cpplint.weight = [ 10, 20, 15] +cpplint.weight = [ 5, 20, 10] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true -result-detail.stdout = true +result-detail.stderr = true result-detail.time = false result-detail.mem = false [[stages]] -name = "judge-base" -command="./driver ./mumsh" -limit.cpu = 3 -limit.mem = 75 -score = 10 +name = "[run] onecard" +group = "run" +command="./onecard -a" +files.import = [ "build/onecard" ] -parsers = ["diff", "dummy", "result-detail"] -dummy.comment = "\n\n### Details\n" +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false result-detail.exitstatus = true result-detail.stderr = true -case4.score = 15 -case4.limit.cpu = 30 -case4.limit.mem = 10 -case4.limit.stdout = 8 - -case5.score = 25 - -case8.limit.stderr = 128 - [[stages]] -name = "judge-msan" -command="./driver ./mumsh-msan" -limit.cpu = 10 # default cpu limit (in sec) for each test case -limit.mem = 500 # set default mem limit (in MB) for all OJ test cases -score = 10 -skip = ["case0", "case11"] +name = "[run] address sanitizer" +group = "run" +command="./asan -a" +files.import = [ "build/asan" ] -parsers = ["diff", "dummy", "result-detail"] -dummy.comment = "\n\n### Details\n" +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false result-detail.exitstatus = true result-detail.stderr = true -case4.score = 15 -case4.limit.cpu = 30 -case4.limit.mem = 10 +[[stages]] +name = "[run] memory sanitizer" +group = "run" +command="./msan -a" +files.import = [ "build/msan" ] -case5.diff.output.ignorespaces = false +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true -case6.diff.output.hide = true +[[stages]] +name = "[run] undefined behavior sanitizer" +command="./ubsan -a" +files.import = [ "build/ubsan" ] + +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index c3ac6cb..1a3392a 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -3,5 +3,3 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") - -test_basic() \ No newline at end of file -- 2.30.2 From 912580eacff9677b4842f2b9e804437e1ba286c7 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 14:05:54 +0800 Subject: [PATCH 100/131] fix: shell split command args --- joj3_config_generator/lib/repo.py | 5 +++-- joj3_config_generator/lib/task.py | 11 ++++++++--- tests/convert/basic/task.json | 6 +----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index 669f3f8..e802cbf 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -1,4 +1,5 @@ import hashlib +import shlex import socket from joj3_config_generator.models import ( @@ -59,8 +60,8 @@ def getHealthcheckCmd(repo_conf: Repo) -> Cmd: args = args + immutable_files - cmd = Cmd( - args=args.split(), + cmd = result.Cmd( + args=shlex.split(args), # FIXME: easier to edit within global scope copy_in={ f"./repo-health-checker": result.CmdFile(src=f"./repo-health-checker") diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index eaa0604..50308b0 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,3 +1,4 @@ +import shlex from typing import Any, Dict, Tuple import rtoml @@ -64,9 +65,13 @@ def get_executorWithConfig( and (task_stage.files is not None) else [] ) - executor_with_config = ExecutorWithConfig( - default=Cmd( - args=(task_stage.command.split() if task_stage.command is not None else []), + executor_with_config = result.ExecutorWith( + default=result.Cmd( + args=( + shlex.split(task_stage.command) + if task_stage.command is not None + else [] + ), copy_in={ file: CmdFile(src=f"/home/tt/.config/joj/{file}") for file in copy_in_files diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 9277b16..9d67b24 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -531,11 +531,7 @@ "default": { "args": [ "cppcheck", - "--template='{\"file\":\"{file}\",\"line\":{line},", - "\"column\":{column},", - "\"severity\":\"{severity}\",", - "\"message\":\"{message}\",", - "\"id\":\"{id}\"}'", + "--template={\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}", "--force", "--enable=all", "--suppress=missingIncludeSystem", -- 2.30.2 From c786ddddfe20ed59564189fa3d7427238d1f38d1 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 14:38:20 +0800 Subject: [PATCH 101/131] fix: file path setting --- joj3_config_generator/lib/repo.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/lib/repo.py index e802cbf..dae259c 100644 --- a/joj3_config_generator/lib/repo.py +++ b/joj3_config_generator/lib/repo.py @@ -1,6 +1,7 @@ import hashlib import shlex import socket +from pathlib import Path from joj3_config_generator.models import ( Cmd, @@ -92,7 +93,10 @@ def calc_sha256sum(file_path: str) -> str: def get_hash(immutable_files: list[str]) -> str: # input should be a list - file_path = "../immutable_file/" # TODO: change this when things are on the server + # FIXME: should be finalized when get into the server + current_file_path = Path(__file__).resolve() + project_root = current_file_path.parents[2] + file_path = f"{project_root}/tests/immutable_file/" immutable_hash = [] for i, file in enumerate(immutable_files): immutable_files[i] = file_path + file.rsplit("/", 1)[-1] -- 2.30.2 From 230b777e4081a1d3a85439248ae6f50892b2c9cb Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 14:48:23 +0800 Subject: [PATCH 102/131] fix: pass test --- joj3_config_generator/main.py | 4 +- tests/convert/basic/task.json | 162 ++++++++++++++++++++++++++++ tests/convert/test_convert_cases.py | 2 + tests/convert/utils.py | 2 +- 4 files changed, 167 insertions(+), 3 deletions(-) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 001476e..09018d0 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -63,9 +63,9 @@ def convert(root: Path = Path(".")) -> result.Config: task_toml = task_file.read() repo_obj = rtoml.loads(repo_toml) task_obj = rtoml.loads(task_toml) - result_model = convert_conf(Repo(**repo_obj), Task(**task_obj)) + result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj)) + result_model = remove_nulls(result_model) result_dict = result_model.model_dump(by_alias=True) - result_dict = remove_nulls(result_dict) with open(result_json_path, "w") as result_file: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 9d67b24..1603820 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -27,22 +27,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4096, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4096, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -58,7 +70,11 @@ "copyIn": { "./repo-health-checker": { "src": "./repo-health-checker", + "content": null, + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -90,6 +106,7 @@ }, { "name": "Abuse of strings detected", + "group": null, "executor": { "name": "sandbox", "with": { @@ -102,22 +119,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -133,7 +162,11 @@ "copyIn": { "tools/strdetec": { "src": "/home/tt/.config/joj/tools/strdetec", + "content": null, + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -168,6 +201,7 @@ }, { "name": "Compilation", + "group": null, "executor": { "name": "sandbox", "with": { @@ -179,22 +213,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -210,7 +256,11 @@ "copyIn": { "tools/compile": { "src": "/home/tt/.config/joj/tools/compile", + "content": null, + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -272,6 +322,7 @@ }, { "name": "[cq] Filelength", + "group": null, "executor": { "name": "sandbox", "with": { @@ -287,22 +338,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -318,7 +381,11 @@ "copyIn": { "tools/filelength": { "src": "/home/tt/.config/joj/tools/filelength", + "content": null, + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -385,6 +452,7 @@ }, { "name": "[cq] Clang-tidy", + "group": null, "executor": { "name": "sandbox", "with": { @@ -401,22 +469,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 65000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -432,7 +512,11 @@ "copyIn": { "projects/p2/.clang-tidy": { "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", + "content": null, + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -525,6 +609,7 @@ }, { "name": "[cq] Cppcheck", + "group": null, "executor": { "name": "sandbox", "with": { @@ -542,22 +627,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 65000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -633,6 +730,7 @@ }, { "name": "[cq] Cpplint", + "group": null, "executor": { "name": "sandbox", "with": { @@ -649,22 +747,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 65000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -746,6 +856,7 @@ }, { "name": "[run] onecard", + "group": null, "executor": { "name": "sandbox", "with": { @@ -758,22 +869,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -827,6 +950,7 @@ }, { "name": "[run] address sanitizer", + "group": null, "executor": { "name": "sandbox", "with": { @@ -839,22 +963,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -908,6 +1044,7 @@ }, { "name": "[run] memory sanitizer", + "group": null, "executor": { "name": "sandbox", "with": { @@ -920,22 +1057,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -989,6 +1138,7 @@ }, { "name": "[run] undefined behavior sanitizer", + "group": null, "executor": { "name": "sandbox", "with": { @@ -1001,22 +1151,34 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { + "src": null, "content": "", + "fileId": null, + "name": null, "max": 4194304, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { + "src": null, + "content": null, + "fileId": null, "name": "stdout", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { + "src": null, + "content": null, + "fileId": null, "name": "stderr", "max": 4000000000, + "symlink": null, "streamIn": false, "streamOut": false, "pipe": false diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index 1a3392a..c3ac6cb 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -3,3 +3,5 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") + +test_basic() \ No newline at end of file diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 8a2c3f1..0d7e395 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -29,5 +29,5 @@ def read_convert_files( def load_case(case_name: str) -> None: repo, task, expected_result = read_convert_files(case_name) result = convert(repo, task).model_dump(mode="json", by_alias=True) - + assert result == expected_result -- 2.30.2 From ec5c77782a5e95035ddece444be33e3419e637d5 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 14:54:39 +0800 Subject: [PATCH 103/131] fix: type annotation --- joj3_config_generator/lib/task.py | 4 ++-- tests/convert/test_convert_cases.py | 3 ++- tests/convert/utils.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 50308b0..5faa905 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,5 +1,5 @@ import shlex -from typing import Any, Dict, Tuple +from typing import Tuple import rtoml @@ -13,7 +13,7 @@ from joj3_config_generator.models.result import Stage as ResultStage from joj3_config_generator.models.task import Stage as TaskStage -def remove_nulls(d: Dict[str, Any]) -> Dict[str, Any]: +def remove_nulls(d: result.Config) -> result.Config: if isinstance(d, dict): return {k: remove_nulls(v) for k, v in d.items() if v is not None} elif isinstance(d, list): diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index c3ac6cb..6aa8a0c 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -4,4 +4,5 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") -test_basic() \ No newline at end of file + +test_basic() diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 0d7e395..8a2c3f1 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -29,5 +29,5 @@ def read_convert_files( def load_case(case_name: str) -> None: repo, task, expected_result = read_convert_files(case_name) result = convert(repo, task).model_dump(mode="json", by_alias=True) - + assert result == expected_result -- 2.30.2 From 509450711292a3e8650a5a45033085e12de9386f Mon Sep 17 00:00:00 2001 From: Nuvole Date: Tue, 12 Nov 2024 16:47:40 +0800 Subject: [PATCH 104/131] chore: remove redundant import & rename folder --- .../{lib => processers}/__init__.py | 0 .../{lib => processers}/repo.py | 0 .../{lib => processers}/task.py | 43 ++++++++----------- 3 files changed, 19 insertions(+), 24 deletions(-) rename joj3_config_generator/{lib => processers}/__init__.py (100%) rename joj3_config_generator/{lib => processers}/repo.py (100%) rename joj3_config_generator/{lib => processers}/task.py (90%) diff --git a/joj3_config_generator/lib/__init__.py b/joj3_config_generator/processers/__init__.py similarity index 100% rename from joj3_config_generator/lib/__init__.py rename to joj3_config_generator/processers/__init__.py diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/processers/repo.py similarity index 100% rename from joj3_config_generator/lib/repo.py rename to joj3_config_generator/processers/repo.py diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/processers/task.py similarity index 90% rename from joj3_config_generator/lib/task.py rename to joj3_config_generator/processers/task.py index 5faa905..3ec6d02 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/processers/task.py @@ -1,16 +1,7 @@ import shlex from typing import Tuple -import rtoml - -from joj3_config_generator.models import ( - ExecutorConfig, - ExecutorWithConfig, - ParserConfig, -) -from joj3_config_generator.models.result import Cmd, CmdFile, OptionalCmd -from joj3_config_generator.models.result import Stage as ResultStage -from joj3_config_generator.models.task import Stage as TaskStage +from joj3_config_generator.models import joj1, repo, result, task def remove_nulls(d: result.Config) -> result.Config: @@ -23,9 +14,9 @@ def remove_nulls(d: result.Config) -> result.Config: def get_conf_stage( - task_stage: TaskStage, executor_with_config: ExecutorWithConfig -) -> ResultStage: - conf_stage = ResultStage( + task_stage: task.Stage, executor_with_config: result.ExecutorWith +) -> result.StageDetail: + conf_stage = result.StageDetail( name=task_stage.name if task_stage.name is not None else "", # TODO: we may have cq in future group=( @@ -33,12 +24,12 @@ def get_conf_stage( if (task_stage.name is not None) and ("judge" in task_stage.name) else None ), - executor=ExecutorConfig( + executor=result.Executor( name="sandbox", with_=executor_with_config, ), parsers=( - [ParserConfig(name=parser, with_={}) for parser in task_stage.parsers] + [result.Parser(name=parser, with_={}) for parser in task_stage.parsers] if task_stage.parsers is not None else [] ), @@ -47,8 +38,8 @@ def get_conf_stage( def get_executorWithConfig( - task_stage: TaskStage, cached: list[str] -) -> Tuple[ExecutorWithConfig, list[str]]: + task_stage: task.Stage, cached: list[str] +) -> Tuple[result.ExecutorWith, list[str]]: file_import = ( task_stage.files.import_ if hasattr(task_stage, "files") @@ -73,7 +64,7 @@ def get_executorWithConfig( else [] ), copy_in={ - file: CmdFile(src=f"/home/tt/.config/joj/{file}") + file: result.CmdFile(src=f"/home/tt/.config/joj/{file}") for file in copy_in_files }, copy_in_cached={file: file for file in copy_in_files}, @@ -93,7 +84,7 @@ def get_executorWithConfig( if task_stage.limit is not None and task_stage.limit.mem is not None else 4 * 1_024 * 1_024 ), - stderr=CmdFile( + stderr=result.CmdFile( name="stderr", max=( task_stage.limit.stderr * 1_000_000_000 @@ -102,7 +93,7 @@ def get_executorWithConfig( else 4 * 1_024 * 1_024 ), ), - stdout=CmdFile( + stdout=result.CmdFile( name="stdout", max=( task_stage.limit.stdout * 1_000_000_000 @@ -154,7 +145,9 @@ def fix_keyword( return conf_stage -def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: +def fix_result_detail( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: if (task_stage.parsers is not None) and ("result-detail" in task_stage.parsers): result_detail_parser = next( p for p in conf_stage.parsers if p.name == "result-detail" @@ -212,7 +205,9 @@ def fix_dummy( return conf_stage -def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: +def fix_diff( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: if task_stage.parsers is not None and "diff" in task_stage.parsers: diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) skip = task_stage.skip or [] @@ -245,8 +240,8 @@ def fix_diff(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: ) stage_cases.append( - OptionalCmd( - stdin=CmdFile( + result.OptionalCmd( + stdin=result.CmdFile( src=f"/home/tt/.config/joj/{conf_stage.name}/{case}.in" ), cpu_limit=cpu_limit, -- 2.30.2 From df6b0923f437f33ed0e69602303aeb2fce88f55f Mon Sep 17 00:00:00 2001 From: Nuvole Date: Tue, 12 Nov 2024 16:50:59 +0800 Subject: [PATCH 105/131] Revert "chore: remove redundant import & rename folder" This reverts commit 5a8ea67bc82d1a5e2c23666cb09d54244708b669. --- .../{processers => lib}/__init__.py | 0 .../{processers => lib}/repo.py | 0 .../{processers => lib}/task.py | 2 + tests/basic/task.json | 1327 +++++++++++++++++ tests/basic/task.toml | 119 ++ 5 files changed, 1448 insertions(+) rename joj3_config_generator/{processers => lib}/__init__.py (100%) rename joj3_config_generator/{processers => lib}/repo.py (100%) rename joj3_config_generator/{processers => lib}/task.py (99%) create mode 100644 tests/basic/task.json create mode 100644 tests/basic/task.toml diff --git a/joj3_config_generator/processers/__init__.py b/joj3_config_generator/lib/__init__.py similarity index 100% rename from joj3_config_generator/processers/__init__.py rename to joj3_config_generator/lib/__init__.py diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/lib/repo.py similarity index 100% rename from joj3_config_generator/processers/repo.py rename to joj3_config_generator/lib/repo.py diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/lib/task.py similarity index 99% rename from joj3_config_generator/processers/task.py rename to joj3_config_generator/lib/task.py index 3ec6d02..c1ccdfc 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,6 +1,8 @@ import shlex from typing import Tuple +import rtoml + from joj3_config_generator.models import joj1, repo, result, task diff --git a/tests/basic/task.json b/tests/basic/task.json new file mode 100644 index 0000000..c15b691 --- /dev/null +++ b/tests/basic/task.json @@ -0,0 +1,1327 @@ +{ + "name": "h4 ex1", + "logPath": "h4-ex1.log", + "expireUnixTimestamp": 1728748740, + "stage": { + "sandboxExecServer": "172.17.0.1:5051", + "sandboxToken": "test", + "outputPath": "/tmp/joj3_result.json", + "stages": [ + { + "name": "healthcheck", + "group": "", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "//repo-health-checker", + "-root=.", + "-repoSize=50.5", + "-meta=main.py", + "-meta=README.md", + "-checkFileSumList=-checkFileNameList=" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4096, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "//tmp/repo-checker-lf3ranpy/repo-health-checker": { + "src": "//tmp/repo-checker-gd58j2qv/repo-health-checker", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 0, + "comment": "" + } + } + ] + }, + { + "name": "Compilation", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "make.sh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 128000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 180000000000, + "realCpuLimit": 0, + "clockLimit": 360000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/make.sh": { + "src": "/home/tt/.config/joj/tools/make.sh", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/main.c": { + "src": "/home/tt/.config/joj/src/main.c", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "src/task.h": { + "src": "/home/tt/.config/joj/src/task.h", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "srcCMakelist.txt": { + "src": "/home/tt/.config/joj/srcCMakelist.txt", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/make.sh": "tools/make.sh", + "src/main.c": "src/main.c", + "src/task.h": "src/task.h", + "srcCMakelist.txt": "srcCMakelist.txt" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [ + "driver", + "p2", + "p2-msan" + ], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-status", + "with": { + "comment": "Congratulations! Your code compiled successfully." + } + } + ] + }, + { + "name": "File length check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./file-length", + "500", + "400", + "*.c", + "*.h" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/file-length": { + "src": "/home/tt/.config/joj/tools/file-length", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/file-length": "tools/file-length" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "keyword", + "with": { + "match": [ + { + "keyword": [ + "max" + ], + "score": 50 + }, + { + "keyword": [ + "recommend" + ], + "score": 20 + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": false, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Clang-tidy checks", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "run-clang-tidy-18", + "-header-filter=.*", + "-quiet", + "-load=/usr/local/lib/libcodequality.so", + "-p", + "build" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "clangtidy", + "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": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Cppcheck check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cppcheck", + "--template='{\"file\":\"{file}\",\"line\":{line},", + "\"column\":{column},", + "\"severity\":\"{severity}\",", + "\"message\":\"{message}\",", + "\"id\":\"{id}\"}'", + "--force", + "--enable=all", + "--quiet", + "./" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cppcheck", + "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": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "Cpplint check", + "group": null, + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cpplint", + "--linelength=120", + "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", + "--recursive", + "--exclude=build", + "." + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 65000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cpplint", + "with": { + "comment": "" + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "judge-base", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 3000000000, + "realCpuLimit": 0, + "clockLimit": 6000000000, + "memoryLimit": 78643200, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-base/case8.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-base/case8.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "judge-msan", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./driver", + "./mumsh-msan" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": null, + "content": "", + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "src": null, + "content": null, + "fileId": null, + "name": "stdout", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "src": null, + "content": null, + "fileId": null, + "name": "stderr", + "max": 4000000000, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 10000000000, + "realCpuLimit": 0, + "clockLimit": 20000000000, + "memoryLimit": 524288000, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case4.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 30000000000, + "realCpuLimit": null, + "clockLimit": 60000000000, + "memoryLimit": 10485760, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case5.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + }, + { + "args": null, + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/judge-msan/case6.in", + "content": null, + "fileId": null, + "name": null, + "max": 4194304, + "symlink": null, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": null, + "stderr": null, + "cpuLimit": 4000000000, + "realCpuLimit": null, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": null, + "procLimit": 50, + "cpuRateLimit": null, + "cpuSetLimit": null, + "copyIn": null, + "copyInCached": null, + "copyInDir": null, + "copyOut": null, + "copyOutCached": null, + "copyOutMax": null, + "copyOutDir": null, + "tty": null, + "strictMemoryLimit": null, + "dataSegmentLimit": null, + "addressSpaceLimit": null + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", + "forceQuitOnDiff": true, + "alwaysHide": true, + "compareSpace": true + } + ] + } + ] + } + }, + { + "name": "dummy", + "with": { + "comment": "\n\n### Details\n" + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + } + ] + }, + "teapot": { + "logPath": "h4-ex1-joint-teapot-debug.log", + "scoreboardPath": "h4-ex1-scoreboard.csv", + "failedTablePath": "h4-ex1-failed-table.md", + "gradingRepoName": "Nuvole-joj", + "skipIssue": false, + "skipScoreboard": false, + "skipFailedTable": false + } +} diff --git a/tests/basic/task.toml b/tests/basic/task.toml new file mode 100644 index 0000000..ec4cdfc --- /dev/null +++ b/tests/basic/task.toml @@ -0,0 +1,119 @@ +# general task configuration +task="h4 ex1" # task name + +release.deadline = 2024-10-12 23:59:00+08:00 +release.stages = [ "compile" ] + +[[stages]] +name = "Compilation" +command = "make.sh" # eg. script running cmake commands +files.import = [ "tools/make.sh", "src/main.c", "src/task.h", "srcCMakelist.txt" ] +files.export = [ "driver", "p2", "p2-msan" ] +limit.cpu = 180 # p2 takes long to compile +limit.stderr = 128 + +# compile parsers +parsers = [ "result-detail", "dummy", "result-status" ] +result-status.comment = "Congratulations! Your code compiled successfully." +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stderr = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "File length check" +command = "./file-length 500 400 *.c *.h" # command to run +files.import = [ "tools/file-length" ] + +parsers = [ "keyword", "dummy", "result-detail" ] +keyword.keyword = [ "max", "recommend"] # keywords caught by corresponding JOJ plugin +keyword.weight = [ 50, 20 ] # weight of each keyword +result-detail.exitstatus = false +result-detail.stderr = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "Clang-tidy checks" +command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" +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] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stdout = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "Cppcheck check" +command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --quiet ./" +limit.stderr = 65 + +parsers = [ "cppcheck", "dummy", "result-detail" ] +cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] +cppcheck.weight = [20, 10, 15, 15, 10] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stderr = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "Cpplint check" +command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard --recursive --exclude=build ." +limit.stdout = 65 + +parsers = [ "cpplint", "dummy", "result-detail" ] +cpplint.keyword = [ "runtime", "readability", "build" ] +cpplint.weight = [ 10, 20, 15] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stdout = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "judge-base" +command="./driver ./mumsh" +limit.cpu = 3 +limit.mem = 75 +score = 10 + +parsers = ["diff", "dummy", "result-detail"] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stderr = true + +case4.score = 15 +case4.limit.cpu = 30 +case4.limit.mem = 10 +case4.limit.stdout = 8 + +case5.score = 25 + +case8.limit.stderr = 128 + +[[stages]] +name = "judge-msan" +command="./driver ./mumsh-msan" +limit.cpu = 10 # default cpu limit (in sec) for each test case +limit.mem = 500 # set default mem limit (in MB) for all OJ test cases +score = 10 +skip = ["case0", "case11"] + +parsers = ["diff", "dummy", "result-detail"] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stderr = true + +case4.score = 15 +case4.limit.cpu = 30 +case4.limit.mem = 10 + +case5.diff.output.ignorespaces = false + +case6.diff.output.hide = true -- 2.30.2 From b0132a35a9cacdc61be87a03cf3934bc2d8f24d6 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Tue, 12 Nov 2024 16:53:19 +0800 Subject: [PATCH 106/131] chore: remove redundant import & rename folder --- joj3_config_generator/convert.py | 13 +++++++++++-- joj3_config_generator/main.py | 2 +- .../{lib => processers}/__init__.py | 0 joj3_config_generator/{lib => processers}/repo.py | 0 joj3_config_generator/{lib => processers}/task.py | 2 -- 5 files changed, 12 insertions(+), 5 deletions(-) rename joj3_config_generator/{lib => processers}/__init__.py (100%) rename joj3_config_generator/{lib => processers}/repo.py (100%) rename joj3_config_generator/{lib => processers}/task.py (99%) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 6ac270c..9673a77 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,7 +1,16 @@ from typing import List -from joj3_config_generator.lib.repo import getHealthcheckConfig -from joj3_config_generator.lib.task import ( +from joj3_config_generator.processers.repo import getHealthcheckConfig, getTeapotConfig +from joj3_config_generator.processers.task import ( + fix_comment, + fix_diff, + fix_keyword, + fix_result_detail, + get_conf_stage, + get_executorWithConfig, +) +from joj3_config_generator.models import joj1, repo, result, task +from joj3_config_generator.processers.task import ( fix_diff, fix_dummy, fix_keyword, diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 09018d0..7dcf687 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -9,7 +9,7 @@ import yaml from joj3_config_generator.convert import convert as convert_conf from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf -from joj3_config_generator.lib.task import remove_nulls +from joj3_config_generator.processers.task import remove_nulls from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.utils.logger import logger diff --git a/joj3_config_generator/lib/__init__.py b/joj3_config_generator/processers/__init__.py similarity index 100% rename from joj3_config_generator/lib/__init__.py rename to joj3_config_generator/processers/__init__.py diff --git a/joj3_config_generator/lib/repo.py b/joj3_config_generator/processers/repo.py similarity index 100% rename from joj3_config_generator/lib/repo.py rename to joj3_config_generator/processers/repo.py diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/processers/task.py similarity index 99% rename from joj3_config_generator/lib/task.py rename to joj3_config_generator/processers/task.py index c1ccdfc..3ec6d02 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/processers/task.py @@ -1,8 +1,6 @@ import shlex from typing import Tuple -import rtoml - from joj3_config_generator.models import joj1, repo, result, task -- 2.30.2 From 5c98e6ef24bd5051628d0db25a4d85166eff1f62 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Tue, 12 Nov 2024 16:54:08 +0800 Subject: [PATCH 107/131] chore: remove redundant folder --- tests/basic/task.json | 1327 ----------------------------------------- tests/basic/task.toml | 119 ---- 2 files changed, 1446 deletions(-) delete mode 100644 tests/basic/task.json delete mode 100644 tests/basic/task.toml diff --git a/tests/basic/task.json b/tests/basic/task.json deleted file mode 100644 index c15b691..0000000 --- a/tests/basic/task.json +++ /dev/null @@ -1,1327 +0,0 @@ -{ - "name": "h4 ex1", - "logPath": "h4-ex1.log", - "expireUnixTimestamp": 1728748740, - "stage": { - "sandboxExecServer": "172.17.0.1:5051", - "sandboxToken": "test", - "outputPath": "/tmp/joj3_result.json", - "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "//repo-health-checker", - "-root=.", - "-repoSize=50.5", - "-meta=main.py", - "-meta=README.md", - "-checkFileSumList=-checkFileNameList=" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4096, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4096, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "//tmp/repo-checker-lf3ranpy/repo-health-checker": { - "src": "//tmp/repo-checker-gd58j2qv/repo-health-checker", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "healthcheck", - "with": { - "score": 0, - "comment": "" - } - } - ] - }, - { - "name": "Compilation", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "make.sh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 128000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 180000000000, - "realCpuLimit": 0, - "clockLimit": 360000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/make.sh": { - "src": "/home/tt/.config/joj/tools/make.sh", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/main.c": { - "src": "/home/tt/.config/joj/src/main.c", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/task.h": { - "src": "/home/tt/.config/joj/src/task.h", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "srcCMakelist.txt": { - "src": "/home/tt/.config/joj/srcCMakelist.txt", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/make.sh": "tools/make.sh", - "src/main.c": "src/main.c", - "src/task.h": "src/task.h", - "srcCMakelist.txt": "srcCMakelist.txt" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [ - "driver", - "p2", - "p2-msan" - ], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-status", - "with": { - "comment": "Congratulations! Your code compiled successfully." - } - } - ] - }, - { - "name": "File length check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./file-length", - "500", - "400", - "*.c", - "*.h" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/file-length": { - "src": "/home/tt/.config/joj/tools/file-length", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/file-length": "tools/file-length" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "keyword", - "with": { - "match": [ - { - "keyword": [ - "max" - ], - "score": 50 - }, - { - "keyword": [ - "recommend" - ], - "score": 20 - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": false, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Clang-tidy checks", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "run-clang-tidy-18", - "-header-filter=.*", - "-quiet", - "-load=/usr/local/lib/libcodequality.so", - "-p", - "build" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "clangtidy", - "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": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Cppcheck check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cppcheck", - "--template='{\"file\":\"{file}\",\"line\":{line},", - "\"column\":{column},", - "\"severity\":\"{severity}\",", - "\"message\":\"{message}\",", - "\"id\":\"{id}\"}'", - "--force", - "--enable=all", - "--quiet", - "./" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cppcheck", - "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": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Cpplint check", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cpplint", - "--linelength=120", - "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", - "--recursive", - "--exclude=build", - "." - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cpplint", - "with": { - "comment": "" - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "judge-base", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 3000000000, - "realCpuLimit": 0, - "clockLimit": 6000000000, - "memoryLimit": 78643200, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case8.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case8.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "judge-msan", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh-msan" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 10000000000, - "realCpuLimit": 0, - "clockLimit": 20000000000, - "memoryLimit": 524288000, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case6.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", - "forceQuitOnDiff": true, - "alwaysHide": true, - "compareSpace": true - } - ] - } - ] - } - }, - { - "name": "dummy", - "with": { - "comment": "\n\n### Details\n" - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - } - ] - }, - "teapot": { - "logPath": "h4-ex1-joint-teapot-debug.log", - "scoreboardPath": "h4-ex1-scoreboard.csv", - "failedTablePath": "h4-ex1-failed-table.md", - "gradingRepoName": "Nuvole-joj", - "skipIssue": false, - "skipScoreboard": false, - "skipFailedTable": false - } -} diff --git a/tests/basic/task.toml b/tests/basic/task.toml deleted file mode 100644 index ec4cdfc..0000000 --- a/tests/basic/task.toml +++ /dev/null @@ -1,119 +0,0 @@ -# general task configuration -task="h4 ex1" # task name - -release.deadline = 2024-10-12 23:59:00+08:00 -release.stages = [ "compile" ] - -[[stages]] -name = "Compilation" -command = "make.sh" # eg. script running cmake commands -files.import = [ "tools/make.sh", "src/main.c", "src/task.h", "srcCMakelist.txt" ] -files.export = [ "driver", "p2", "p2-msan" ] -limit.cpu = 180 # p2 takes long to compile -limit.stderr = 128 - -# compile parsers -parsers = [ "result-detail", "dummy", "result-status" ] -result-status.comment = "Congratulations! Your code compiled successfully." -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stderr = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "File length check" -command = "./file-length 500 400 *.c *.h" # command to run -files.import = [ "tools/file-length" ] - -parsers = [ "keyword", "dummy", "result-detail" ] -keyword.keyword = [ "max", "recommend"] # keywords caught by corresponding JOJ plugin -keyword.weight = [ 50, 20 ] # weight of each keyword -result-detail.exitstatus = false -result-detail.stderr = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "Clang-tidy checks" -command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" -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] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stdout = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "Cppcheck check" -command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --quiet ./" -limit.stderr = 65 - -parsers = [ "cppcheck", "dummy", "result-detail" ] -cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] -cppcheck.weight = [20, 10, 15, 15, 10] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stderr = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "Cpplint check" -command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard --recursive --exclude=build ." -limit.stdout = 65 - -parsers = [ "cpplint", "dummy", "result-detail" ] -cpplint.keyword = [ "runtime", "readability", "build" ] -cpplint.weight = [ 10, 20, 15] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stdout = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "judge-base" -command="./driver ./mumsh" -limit.cpu = 3 -limit.mem = 75 -score = 10 - -parsers = ["diff", "dummy", "result-detail"] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stderr = true - -case4.score = 15 -case4.limit.cpu = 30 -case4.limit.mem = 10 -case4.limit.stdout = 8 - -case5.score = 25 - -case8.limit.stderr = 128 - -[[stages]] -name = "judge-msan" -command="./driver ./mumsh-msan" -limit.cpu = 10 # default cpu limit (in sec) for each test case -limit.mem = 500 # set default mem limit (in MB) for all OJ test cases -score = 10 -skip = ["case0", "case11"] - -parsers = ["diff", "dummy", "result-detail"] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stderr = true - -case4.score = 15 -case4.limit.cpu = 30 -case4.limit.mem = 10 - -case5.diff.output.ignorespaces = false - -case6.diff.output.hide = true -- 2.30.2 From a38a15597519b68ff9718852ce1d62ce1d222c78 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Tue, 12 Nov 2024 16:58:08 +0800 Subject: [PATCH 108/131] chore: remove redundant import --- joj3_config_generator/convert.py | 2 +- joj3_config_generator/processers/repo.py | 14 +------------- joj3_config_generator/processers/task.py | 2 +- tests/convert/basic/task.json | 8 ++++---- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 9673a77..e8bf0a4 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -2,7 +2,7 @@ from typing import List from joj3_config_generator.processers.repo import getHealthcheckConfig, getTeapotConfig from joj3_config_generator.processers.task import ( - fix_comment, + fix_dummy, fix_diff, fix_keyword, fix_result_detail, diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index dae259c..c993690 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -3,19 +3,7 @@ import shlex import socket from pathlib import Path -from joj3_config_generator.models import ( - Cmd, - CmdFile, - ExecutorConfig, - ExecutorWithConfig, - ParserConfig, - Repo, - ResultConfig, - Stage, - StageConfig, - Task, - TeapotConfig, -) +from joj3_config_generator.models import repo, result, task def getGradingRepoName() -> str: diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 3ec6d02..e6d9f31 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -1,7 +1,7 @@ import shlex from typing import Tuple -from joj3_config_generator.models import joj1, repo, result, task +from joj3_config_generator.models import result, task def remove_nulls(d: result.Config) -> result.Config: diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 1603820..67e68f7 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1233,10 +1233,10 @@ ] }, "teapot": { - "logPath": "/home/tt/.cache/joint-teapot-debug.log", - "scoreboardPath": "scoreboard.csv", - "failedTablePath": "failed-table.md", - "gradingRepoName": "", + "logPath": "p2-m3-joint-teapot-debug.log", + "scoreboardPath": "p2-m3-scoreboard.csv", + "failedTablePath": "p2-m3-failed-table.md", + "gradingRepoName": "Nuvole-joj", "skipIssue": false, "skipScoreboard": false, "skipFailedTable": false -- 2.30.2 From e79e66c1a77e8b4a979c11757b46994359d1dfa7 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Tue, 12 Nov 2024 17:14:56 +0800 Subject: [PATCH 109/131] chore: remove redundant import --- joj3_config_generator/convert.py | 11 +- joj3_config_generator/main.py | 14 +- joj3_config_generator/processers/repo.py | 4 +- joj3_config_generator/processers/task.py | 9 -- tests/convert/basic/task.json | 164 +---------------------- tests/convert/test_convert_cases.py | 3 - tests/convert/utils.py | 4 +- 7 files changed, 11 insertions(+), 198 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index e8bf0a4..f2989cb 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,15 +1,7 @@ from typing import List +from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.processers.repo import getHealthcheckConfig, getTeapotConfig -from joj3_config_generator.processers.task import ( - fix_dummy, - fix_diff, - fix_keyword, - fix_result_detail, - get_conf_stage, - get_executorWithConfig, -) -from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.processers.task import ( fix_diff, fix_dummy, @@ -18,7 +10,6 @@ from joj3_config_generator.processers.task import ( get_conf_stage, get_executorWithConfig, ) -from joj3_config_generator.models import joj1, repo, result, task def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 7dcf687..115b9a8 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -1,6 +1,7 @@ import json import os from pathlib import Path +from typing import Any, Dict import inquirer import rtoml @@ -9,8 +10,7 @@ import yaml from joj3_config_generator.convert import convert as convert_conf from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf -from joj3_config_generator.processers.task import remove_nulls -from joj3_config_generator.models import joj1, repo, result, task +from joj3_config_generator.models import joj1, repo, task from joj3_config_generator.utils.logger import logger app = typer.Typer(add_completion=False) @@ -47,8 +47,7 @@ def convert_joj1(yaml_file: typer.FileText, toml_file: typer.FileTextWrite) -> N @app.command() -def convert(root: Path = Path(".")) -> result.Config: -def convert(root: Path = Path(".")) -> result.Config: +def convert(root: Path = Path(".")) -> Dict[str, Any]: """ Convert given dir of JOJ3 toml config files to JOJ3 json config files """ @@ -64,13 +63,10 @@ def convert(root: Path = Path(".")) -> result.Config: repo_obj = rtoml.loads(repo_toml) task_obj = rtoml.loads(task_toml) result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj)) - result_model = remove_nulls(result_model) - result_dict = result_model.model_dump(by_alias=True) + result_dict = result_model.model_dump(by_alias=True, exclude_none=True) with open(result_json_path, "w") as result_file: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) result_file.write("\n") - return result_model - - return result_model + return result_dict diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index c993690..4240fb3 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -7,7 +7,9 @@ from joj3_config_generator.models import repo, result, task def getGradingRepoName() -> str: - host_name = socket.gethostname() + # FIXME: uncomment back when everything is ready! + host_name = "engr151" + # host_name = socket.gethostname() return f"{host_name.split('-')[0]}-joj" diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index e6d9f31..4b389d3 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -4,15 +4,6 @@ from typing import Tuple from joj3_config_generator.models import result, task -def remove_nulls(d: result.Config) -> result.Config: - if isinstance(d, dict): - return {k: remove_nulls(v) for k, v in d.items() if v is not None} - elif isinstance(d, list): - return [remove_nulls(item) for item in d] - else: - return d - - def get_conf_stage( task_stage: task.Stage, executor_with_config: result.ExecutorWith ) -> result.StageDetail: diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 67e68f7..70c21d8 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -27,34 +27,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4096, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4096, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -70,11 +58,7 @@ "copyIn": { "./repo-health-checker": { "src": "./repo-health-checker", - "content": null, - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -106,7 +90,6 @@ }, { "name": "Abuse of strings detected", - "group": null, "executor": { "name": "sandbox", "with": { @@ -119,34 +102,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -162,11 +133,7 @@ "copyIn": { "tools/strdetec": { "src": "/home/tt/.config/joj/tools/strdetec", - "content": null, - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -201,7 +168,6 @@ }, { "name": "Compilation", - "group": null, "executor": { "name": "sandbox", "with": { @@ -213,34 +179,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -256,11 +210,7 @@ "copyIn": { "tools/compile": { "src": "/home/tt/.config/joj/tools/compile", - "content": null, - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -322,7 +272,6 @@ }, { "name": "[cq] Filelength", - "group": null, "executor": { "name": "sandbox", "with": { @@ -338,34 +287,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -381,11 +318,7 @@ "copyIn": { "tools/filelength": { "src": "/home/tt/.config/joj/tools/filelength", - "content": null, - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -452,7 +385,6 @@ }, { "name": "[cq] Clang-tidy", - "group": null, "executor": { "name": "sandbox", "with": { @@ -469,34 +401,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 65000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -512,11 +432,7 @@ "copyIn": { "projects/p2/.clang-tidy": { "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", - "content": null, - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -609,7 +525,6 @@ }, { "name": "[cq] Cppcheck", - "group": null, "executor": { "name": "sandbox", "with": { @@ -627,34 +542,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 65000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -730,7 +633,6 @@ }, { "name": "[cq] Cpplint", - "group": null, "executor": { "name": "sandbox", "with": { @@ -747,34 +649,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 65000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -856,7 +746,6 @@ }, { "name": "[run] onecard", - "group": null, "executor": { "name": "sandbox", "with": { @@ -869,34 +758,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -950,7 +827,6 @@ }, { "name": "[run] address sanitizer", - "group": null, "executor": { "name": "sandbox", "with": { @@ -963,34 +839,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -1044,7 +908,6 @@ }, { "name": "[run] memory sanitizer", - "group": null, "executor": { "name": "sandbox", "with": { @@ -1057,34 +920,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -1138,7 +989,6 @@ }, { "name": "[run] undefined behavior sanitizer", - "group": null, "executor": { "name": "sandbox", "with": { @@ -1151,34 +1001,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -1236,7 +1074,7 @@ "logPath": "p2-m3-joint-teapot-debug.log", "scoreboardPath": "p2-m3-scoreboard.csv", "failedTablePath": "p2-m3-failed-table.md", - "gradingRepoName": "Nuvole-joj", + "gradingRepoName": "engr151-joj", "skipIssue": false, "skipScoreboard": false, "skipFailedTable": false diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index 6aa8a0c..1a3392a 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -3,6 +3,3 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") - - -test_basic() diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 8a2c3f1..aa21863 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -7,7 +7,6 @@ import rtoml from joj3_config_generator.convert import convert from joj3_config_generator.models import repo, task - def read_convert_files( case_name: str, ) -> Tuple[repo.Config, task.Config, Dict[str, Any]]: @@ -28,6 +27,5 @@ def read_convert_files( def load_case(case_name: str) -> None: repo, task, expected_result = read_convert_files(case_name) - result = convert(repo, task).model_dump(mode="json", by_alias=True) - + result = convert(repo, task).model_dump(mode="json", by_alias=True, exclude_none=True) assert result == expected_result -- 2.30.2 From 610cb3a1d5f721002940454485b146fae1b55e19 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Tue, 12 Nov 2024 17:20:58 +0800 Subject: [PATCH 110/131] chore: change camel case naming --- joj3_config_generator/convert.py | 6 +++--- joj3_config_generator/processers/repo.py | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index f2989cb..2a5fe84 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,7 +1,7 @@ from typing import List from joj3_config_generator.models import joj1, repo, result, task -from joj3_config_generator.processers.repo import getHealthcheckConfig, getTeapotConfig +from joj3_config_generator.processers.repo import get_healthcheck_config, get_teapot_config from joj3_config_generator.processers.task import ( fix_diff, fix_dummy, @@ -24,11 +24,11 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: else -1 ), stage=result.Stage(stages=[], sandbox_token=repo_conf.sandbox_token), - teapot=result.Teapot(), + teapot=get_teapot_config(repo_conf, task_conf), ) # Construct healthcheck stage - healthcheck_stage = getHealthcheckConfig(repo_conf) + healthcheck_stage = get_healthcheck_config(repo_conf) result_conf.stage.stages.append(healthcheck_stage) cached: list[str] = [] # Convert each stage in the task configuration diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index 4240fb3..414ffca 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -6,25 +6,25 @@ from pathlib import Path from joj3_config_generator.models import repo, result, task -def getGradingRepoName() -> str: +def get_grading_repo_name() -> str: # FIXME: uncomment back when everything is ready! host_name = "engr151" # host_name = socket.gethostname() return f"{host_name.split('-')[0]}-joj" -def getTeapotConfig(repo_conf: Repo, task_conf: Task) -> TeapotConfig: - teapot = TeapotConfig( +def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result.Teapot: + teapot = result.Teapot( # TODO: fix the log path log_path=f"{task_conf.task.replace(' ', '-')}-joint-teapot-debug.log", scoreboard_path=f"{task_conf.task.replace(' ', '-')}-scoreboard.csv", failed_table_path=f"{task_conf.task.replace(' ', '-')}-failed-table.md", - grading_repo_name=getGradingRepoName(), + grading_repo_name=get_grading_repo_name(), ) return teapot -def getHealthcheckCmd(repo_conf: Repo) -> Cmd: +def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: repoSize = repo_conf.max_size immutable = repo_conf.files.immutable repo_size = f"-repoSize={str(repoSize)} " @@ -61,13 +61,13 @@ def getHealthcheckCmd(repo_conf: Repo) -> Cmd: return cmd -def getHealthcheckConfig(repo_conf: repo.Config) -> result.StageDetail: +def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail: healthcheck_stage = result.StageDetail( name="healthcheck", group="", executor=ExecutorConfig( name="sandbox", - with_=ExecutorWithConfig(default=getHealthcheckCmd(repo_conf), cases=[]), + with_=result.ExecutorWith(default=get_healthcheck_cmd(repo_conf), cases=[]), ), parsers=[ParserConfig(name="healthcheck", with_={"score": 0, "comment": ""})], ) -- 2.30.2 From 45e203cf606e656f9eda65c9a8e7e7672e80c5aa Mon Sep 17 00:00:00 2001 From: Nuvole Date: Tue, 12 Nov 2024 23:17:53 +0800 Subject: [PATCH 111/131] feat: change path & add task.type in toml --- joj3_config_generator/convert.py | 22 +- joj3_config_generator/models/task.py | 9 +- joj3_config_generator/processers/repo.py | 22 +- joj3_config_generator/processers/task.py | 6 +- tests/convert/basic/repo.toml | 2 +- tests/convert/basic/task.json | 593 ++++++++++++++++------- tests/convert/basic/task.toml | 98 ++-- tests/convert/utils.py | 5 +- 8 files changed, 539 insertions(+), 218 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 2a5fe84..0d190c8 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,7 +1,10 @@ from typing import List from joj3_config_generator.models import joj1, repo, result, task -from joj3_config_generator.processers.repo import get_healthcheck_config, get_teapot_config +from joj3_config_generator.processers.repo import ( + get_healthcheck_config, + get_teapot_config, +) from joj3_config_generator.processers.task import ( fix_diff, fix_dummy, @@ -14,10 +17,10 @@ from joj3_config_generator.processers.task import ( def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Create the base ResultConf object - result_conf = ResultConfig( - name=task_conf.task, + result_conf = result.Config( + name=task_conf.task.name, # TODO: specify the exact folder difference - log_path=f"{task_conf.task.replace(' ', '-')}.log", + log_path=f"/home/tt/.cache/joj3/{task_conf.task.type_}.log", expire_unix_timestamp=( int(task_conf.release.deadline.timestamp()) if task_conf.release.deadline @@ -38,7 +41,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: conf_stage = fix_result_detail(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) + conf_stage = fix_diff(task_stage, conf_stage, task_conf) result_conf.stage.stages.append(conf_stage) return result_conf @@ -76,7 +79,14 @@ def convert_joj1(joj1_conf: joj1.Config) -> task.Config: ) return task.Config( - task=joj1_conf.languages[0].language if joj1_conf.languages else "Unnamed Task", + task=task.Task( + name=( + joj1_conf.languages[0].language + if joj1_conf.languages + else "Unnamed Task" + ), + type_="", + ), # FIXME: fix this type later release=task.Release(deadline=release_deadline), stages=stages, ) diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index e8b28c2..dc58558 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -83,7 +83,14 @@ class Release(BaseModel): deadline: Optional[datetime] # RFC 3339 formatted date-time with offset +class Task(BaseModel): + type_: Optional[str] = Field( + "", serialization_alias="type", validation_alias="type" + ) + name: str + + class Config(BaseModel): - task: str # Task name (e.g., hw3 ex5) + task: Task release: Release # Release configuration stages: List[Stage] # list of stage configurations diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index 414ffca..bef99e3 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -1,6 +1,5 @@ import hashlib import shlex -import socket from pathlib import Path from joj3_config_generator.models import repo, result, task @@ -16,9 +15,18 @@ def get_grading_repo_name() -> str: def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result.Teapot: teapot = result.Teapot( # TODO: fix the log path - log_path=f"{task_conf.task.replace(' ', '-')}-joint-teapot-debug.log", - scoreboard_path=f"{task_conf.task.replace(' ', '-')}-scoreboard.csv", - failed_table_path=f"{task_conf.task.replace(' ', '-')}-failed-table.md", + log_path=f"/home/tt/.cache/joj3/{task_conf.task.type_}-joint-teapot-debug.log", + # FIXME: may need to fix the path below + scoreboard_path=( + f"{task_conf.task.type_.split("/")[0]}/{task_conf.task.type_.split("/")[1]}-scoreboard.csv" + if task_conf.task.type_ is not None + else "scoreboard.csv" + ), + failed_table_path=( + f"{task_conf.task.type_.split("/")[0]}/{task_conf.task.type_.split("/")[1]}-failed-table.md" + if task_conf.task.type_ is not None + else "failed-table.md" + ), grading_repo_name=get_grading_repo_name(), ) return teapot @@ -53,9 +61,11 @@ def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: cmd = result.Cmd( args=shlex.split(args), - # FIXME: easier to edit within global scope copy_in={ - f"./repo-health-checker": result.CmdFile(src=f"./repo-health-checker") + # This path is hardcoded + f"./repo-health-checker": result.CmdFile( + src="/usr/local/bin/repo-health-checker" + ) }, ) return cmd diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 4b389d3..d5eb32d 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -197,7 +197,7 @@ def fix_dummy( def fix_diff( - task_stage: task.Stage, conf_stage: result.StageDetail + task_stage: task.Stage, conf_stage: result.StageDetail, task_conf: task.Config ) -> result.StageDetail: if task_stage.parsers is not None and "diff" in task_stage.parsers: diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) @@ -233,7 +233,7 @@ def fix_diff( stage_cases.append( result.OptionalCmd( stdin=result.CmdFile( - src=f"/home/tt/.config/joj/{conf_stage.name}/{case}.in" + src=f"/home/tt/.config/joj/{task_conf.task.type_}/{case}.in" ), cpu_limit=cpu_limit, clock_limit=clock_limit, @@ -255,7 +255,7 @@ def fix_diff( { "score": diff_output.score, "fileName": "stdout", - "answerPath": f"/home/tt/.config/joj/{conf_stage.name}/{case}.out", + "answerPath": f"/home/tt/.config/joj/{task_conf.task.type_}/{case}.out", "forceQuitOnDiff": diff_output.forcequit, "alwaysHide": diff_output.hide, "compareSpace": not diff_output.ignorespaces, diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index bb9818b..d815ed4 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -6,5 +6,5 @@ sandbox_token = "test" [files] whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" -required = [ "Changelog.md", "Readme.md" ] +required = ["Readme.md" ] immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 70c21d8..caaba83 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,7 +1,7 @@ { - "name": "p2 m3", - "logPath": "p2-m3.log", - "expireUnixTimestamp": 1728748740, + "name": "hw 6 ex3", + "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e3.log", + "expireUnixTimestamp": 1731686399, "stage": { "sandboxExecServer": "172.17.0.1:5051", "sandboxToken": "test", @@ -18,7 +18,6 @@ "./repo-health-checker", "-root=.", "-repoSize=50.5", - "-meta=Changelog.md", "-meta=Readme.md", "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml" @@ -57,7 +56,7 @@ "cpuSetLimit": "", "copyIn": { "./repo-health-checker": { - "src": "./repo-health-checker", + "src": "/usr/local/bin/repo-health-checker", "max": 4194304, "streamIn": false, "streamOut": false, @@ -88,84 +87,6 @@ } ] }, - { - "name": "Abuse of strings detected", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./strdetect", - "src/" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 4194304, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "name": "stdout", - "max": 4000000000, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "name": "stderr", - "max": 4000000000, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/strdetec": { - "src": "/home/tt/.config/joj/tools/strdetec", - "max": 4194304, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "tools/strdetec": "tools/strdetec" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } - } - ] - }, { "name": "Compilation", "executor": { @@ -173,7 +94,7 @@ "with": { "default": { "args": [ - "compile" + "./tools/compile" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -222,7 +143,7 @@ "copyInDir": ".", "copyOut": [], "copyOutCached": [ - "build/onecard", + "h6/build/ex3", "build/asan", "build/ubsan", "build/msan", @@ -255,7 +176,7 @@ { "name": "dummy", "with": { - "score": 1, + "score": 0, "comment": "Congratulations! Your code compiled successfully.", "forceQuitOnNotAccepted": true } @@ -263,7 +184,7 @@ { "name": "result-status", "with": { - "score": 1, + "score": 0, "comment": "Congratulations! Your code compiled successfully.", "forceQuitOnNotAccepted": true } @@ -744,87 +665,6 @@ } ] }, - { - "name": "[run] onecard", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./onecard", - "-a" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 4194304, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "name": "stdout", - "max": 4000000000, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "name": "stderr", - "max": 4000000000, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 1, - "comment": "", - "forceQuitOnNotAccepted": false - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, { "name": "[run] address sanitizer", "executor": { @@ -1067,13 +907,424 @@ } } ] + }, + { + "name": "[joj] ex3", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./ex3" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "h6/build/ex2": { + "src": "/home/tt/.config/joj/h6/build/ex2", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "h6/build/ex4": { + "src": "/home/tt/.config/joj/h6/build/ex4", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "h6/build/ex5": { + "src": "/home/tt/.config/joj/h6/build/ex5", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "h6/build/ex6": { + "src": "/home/tt/.config/joj/h6/build/ex6", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "h6/build/ex7": { + "src": "/home/tt/.config/joj/h6/build/ex7", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "h6/build/ex2": "h6/build/ex2", + "h6/build/ex4": "h6/build/ex4", + "h6/build/ex5": "h6/build/ex5", + "h6/build/ex6": "h6/build/ex6", + "h6/build/ex7": "h6/build/ex7" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case0.in", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 30000000000, + "clockLimit": 60000000000, + "memoryLimit": 33554432, + "procLimit": 50 + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case1.in", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 30000000000, + "clockLimit": 60000000000, + "memoryLimit": 33554432, + "procLimit": 50 + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case2.in", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 30000000000, + "clockLimit": 60000000000, + "memoryLimit": 33554432, + "procLimit": 50 + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case3.in", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 30000000000, + "clockLimit": 60000000000, + "memoryLimit": 33554432, + "procLimit": 50 + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case4.in", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 30000000000, + "clockLimit": 60000000000, + "memoryLimit": 33554432, + "procLimit": 50 + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case5.in", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 30000000000, + "clockLimit": 60000000000, + "memoryLimit": 33554432, + "procLimit": 50 + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case6.in", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 30000000000, + "clockLimit": 60000000000, + "memoryLimit": 33554432, + "procLimit": 50 + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case7.in", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 30000000000, + "clockLimit": 60000000000, + "memoryLimit": 33554432, + "procLimit": 50 + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case8.in", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 30000000000, + "clockLimit": 60000000000, + "memoryLimit": 33554432, + "procLimit": 50 + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case9.in", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 30000000000, + "clockLimit": 60000000000, + "memoryLimit": 33554432, + "procLimit": 50 + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case0.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case1.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case2.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case3.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case4.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case5.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case6.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case7.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case8.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + }, + { + "outputs": [ + { + "score": 0, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case9.out", + "forceQuitOnDiff": true, + "alwaysHide": false, + "compareSpace": true + } + ] + } + ] + } + }, + { + "name": "dummy", + "with": { + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] } ] }, "teapot": { - "logPath": "p2-m3-joint-teapot-debug.log", - "scoreboardPath": "p2-m3-scoreboard.csv", - "failedTablePath": "p2-m3-failed-table.md", + "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e3-joint-teapot-debug.log", + "scoreboardPath": "tests/homework-scoreboard.csv", + "failedTablePath": "tests/homework-failed-table.md", "gradingRepoName": "engr151-joj", "skipIssue": false, "skipScoreboard": false, diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 118247d..245f529 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,31 +1,20 @@ -# p2 repo config +# general task configuration +task.name = "hw 6 ex3" # task name -task="p2 m3" # task name +task.type = "tests/homework/h6/e3" -release.deadline = 2024-10-12 23:59:00+08:00 +release.deadline = 2024-11-15 23:59:59+08:00 release.stages = [ "compile" ] -[files] -immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] -required = [ "Changelog.md", "Readme.md" ] - -[[stages]] -name = "Abuse of strings detected" -command = "./strdetect src/" -files.import = [ "tools/strdetec" ] - -parsers = [ "result-status" ] - - [[stages]] name = "Compilation" -command = "compile" +command = "./tools/compile" # eg. script running cmake commands files.import = [ "tools/compile" ] -files.export = [ "build/onecard", "build/asan", "build/ubsan", "build/msan", "build/compile_commands.json" ] +files.export = [ "h6/build/ex3", "build/asan", "build/ubsan", "build/msan", "build/compile_commands.json" ] +# compile parsers parsers = [ "result-detail", "dummy", "result-status" ] result-status.comment = "Congratulations! Your code compiled successfully." -result-status.score = 1 dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stderr = true @@ -89,17 +78,6 @@ result-detail.stderr = true result-detail.time = false result-detail.mem = false -[[stages]] -name = "[run] onecard" -group = "run" -command="./onecard -a" -files.import = [ "build/onecard" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true [[stages]] name = "[run] address sanitizer" @@ -135,3 +113,65 @@ result-status.score = 1 result-status.forcequit = false result-detail.exitstatus = true result-detail.stderr = true + +[[stages]] +name = "[joj] ex3" +group = "joj" +command="./ex3" +files.import = [ "h6/build/ex2", "h6/build/ex3", "h6/build/ex4", "h6/build/ex5", "h6/build/ex6", "h6/build/ex7" ] +score = 10 + +parsers = [ "diff", "dummy", "result-detail" ] +result-detail.exitstatus = true +result-detail.stderr = true + +# will be removed as long as the name is fixed +case0.score = 10 +case0.limit.cpu = 30 +case0.limit.mem = 32 +case0.limit.stdout = 8 + +case1.score = 10 +case1.limit.cpu = 30 +case1.limit.mem = 32 +case1.limit.stdout = 8 + +case2.score = 10 +case2.limit.cpu = 30 +case2.limit.mem = 32 +case2.limit.stdout = 8 + +case3.score = 10 +case3.limit.cpu = 30 +case3.limit.mem = 32 +case3.limit.stdout = 8 + +case4.score = 10 +case4.limit.cpu = 30 +case4.limit.mem = 32 +case4.limit.stdout = 8 + +case5.score = 10 +case5.limit.cpu = 30 +case5.limit.mem = 32 +case5.limit.stdout = 8 + +case6.score = 10 +case6.limit.cpu = 30 +case6.limit.mem = 32 +case6.limit.stdout = 8 + +case7.score = 10 +case7.limit.cpu = 30 +case7.limit.mem = 32 +case7.limit.stdout = 8 + +case8.score = 10 +case8.limit.cpu = 30 +case8.limit.mem = 32 +case8.limit.stdout = 8 + +case9.score = 10 +case9.limit.cpu = 30 +case9.limit.mem = 32 +case9.limit.stdout = 8 diff --git a/tests/convert/utils.py b/tests/convert/utils.py index aa21863..35fce31 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -7,6 +7,7 @@ import rtoml from joj3_config_generator.convert import convert from joj3_config_generator.models import repo, task + def read_convert_files( case_name: str, ) -> Tuple[repo.Config, task.Config, Dict[str, Any]]: @@ -27,5 +28,7 @@ def read_convert_files( def load_case(case_name: str) -> None: repo, task, expected_result = read_convert_files(case_name) - result = convert(repo, task).model_dump(mode="json", by_alias=True, exclude_none=True) + result = convert(repo, task).model_dump( + mode="json", by_alias=True, exclude_none=True + ) assert result == expected_result -- 2.30.2 From 184142536b0904c316985ed61bc50bed34dd5bf8 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Tue, 12 Nov 2024 23:20:26 +0800 Subject: [PATCH 112/131] fix: default value --- joj3_config_generator/models/result.py | 27 +++-------- tests/convert/basic/task.json | 64 +++++++++++++------------- 2 files changed, 39 insertions(+), 52 deletions(-) diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index f2ea268..0aebb33 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -8,8 +8,7 @@ class CmdFile(BaseModel): content: Optional[str] = None file_id: Optional[str] = Field(None, serialization_alias="fileId") name: Optional[str] = None - max: Optional[int] = 4 * 1024 * 1024 - max: Optional[int] = 4 * 1024 * 1024 + max: Optional[int] = 40 * 1024 * 1024 symlink: Optional[str] = None stream_in: bool = Field(False, serialization_alias="streamIn") stream_out: bool = Field(False, serialization_alias="streamOut") @@ -22,17 +21,10 @@ class Cmd(BaseModel): stdin: Optional[CmdFile] = CmdFile(content="") stdout: Optional[CmdFile] = CmdFile(name="stdout", max=4 * 1024) stderr: Optional[CmdFile] = CmdFile(name="stderr", max=4 * 1024) - cpu_limit: int = Field(4 * 1000000000, serialization_alias="cpuLimit") - env: list[str] = ["PATH=/usr/bin:/bin:/usr/local/bin"] - stdin: Optional[CmdFile] = CmdFile(content="") - stdout: Optional[CmdFile] = CmdFile(name="stdout", max=4 * 1024) - stderr: Optional[CmdFile] = CmdFile(name="stderr", max=4 * 1024) - cpu_limit: int = Field(4 * 1000000000, serialization_alias="cpuLimit") + cpu_limit: int = Field(4 * 1000000000000, serialization_alias="cpuLimit") real_cpu_limit: int = Field(0, serialization_alias="realCpuLimit") - clock_limit: int = Field(8 * 1000000000, serialization_alias="clockLimit") - memory_limit: int = Field(4 * 1024 * 1024, serialization_alias="memoryLimit") - clock_limit: int = Field(8 * 1000000000, serialization_alias="clockLimit") - memory_limit: int = Field(4 * 1024 * 1024, serialization_alias="memoryLimit") + clock_limit: int = Field(8 * 1000000000000, serialization_alias="clockLimit") + memory_limit: int = Field(80 * 1024 * 1024, serialization_alias="memoryLimit") stack_limit: int = Field(0, serialization_alias="stackLimit") proc_limit: int = Field(50, serialization_alias="procLimit") proc_limit: int = Field(50, serialization_alias="procLimit") @@ -58,16 +50,11 @@ class OptionalCmd(BaseModel): stdin: Optional[CmdFile] = None stdout: Optional[CmdFile] = None stderr: Optional[CmdFile] = None - cpu_limit: Optional[int] = Field(4 * 1000000000, serialization_alias="cpuLimit") - cpu_limit: Optional[int] = Field(4 * 1000000000, serialization_alias="cpuLimit") + cpu_limit: Optional[int] = Field(4 * 1000000000000, serialization_alias="cpuLimit") real_cpu_limit: Optional[int] = Field(None, serialization_alias="realCpuLimit") - clock_limit: Optional[int] = Field(8 * 1000000000, serialization_alias="clockLimit") + clock_limit: Optional[int] = Field(8 * 1000000000000, serialization_alias="clockLimit") memory_limit: Optional[int] = Field( - 4 * 1024 * 1024, serialization_alias="memoryLimit" - ) - clock_limit: Optional[int] = Field(8 * 1000000000, serialization_alias="clockLimit") - memory_limit: Optional[int] = Field( - 4 * 1024 * 1024, serialization_alias="memoryLimit" + 80 * 1024 * 1024, serialization_alias="memoryLimit" ) stack_limit: Optional[int] = Field(None, serialization_alias="stackLimit") proc_limit: Optional[int] = Field(50, serialization_alias="procLimit") diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index caaba83..2716a74 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -27,7 +27,7 @@ ], "stdin": { "content": "", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -46,10 +46,10 @@ "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 4000000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 8000000000000, + "memoryLimit": 83886080, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -57,7 +57,7 @@ "copyIn": { "./repo-health-checker": { "src": "/usr/local/bin/repo-health-checker", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -101,7 +101,7 @@ ], "stdin": { "content": "", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -131,7 +131,7 @@ "copyIn": { "tools/compile": { "src": "/home/tt/.config/joj/tools/compile", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -209,7 +209,7 @@ ], "stdin": { "content": "", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -239,7 +239,7 @@ "copyIn": { "tools/filelength": { "src": "/home/tt/.config/joj/tools/filelength", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -323,7 +323,7 @@ ], "stdin": { "content": "", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -353,7 +353,7 @@ "copyIn": { "projects/p2/.clang-tidy": { "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -464,7 +464,7 @@ ], "stdin": { "content": "", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -571,7 +571,7 @@ ], "stdin": { "content": "", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -680,7 +680,7 @@ ], "stdin": { "content": "", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -761,7 +761,7 @@ ], "stdin": { "content": "", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -842,7 +842,7 @@ ], "stdin": { "content": "", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -922,7 +922,7 @@ ], "stdin": { "content": "", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -952,35 +952,35 @@ "copyIn": { "h6/build/ex2": { "src": "/home/tt/.config/joj/h6/build/ex2", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false }, "h6/build/ex4": { "src": "/home/tt/.config/joj/h6/build/ex4", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false }, "h6/build/ex5": { "src": "/home/tt/.config/joj/h6/build/ex5", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false }, "h6/build/ex6": { "src": "/home/tt/.config/joj/h6/build/ex6", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false }, "h6/build/ex7": { "src": "/home/tt/.config/joj/h6/build/ex7", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -1010,7 +1010,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case0.in", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -1026,7 +1026,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case1.in", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -1042,7 +1042,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case2.in", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -1058,7 +1058,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case3.in", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -1074,7 +1074,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case4.in", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -1090,7 +1090,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case5.in", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -1106,7 +1106,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case6.in", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -1122,7 +1122,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case7.in", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -1138,7 +1138,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case8.in", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false @@ -1154,7 +1154,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case9.in", - "max": 4194304, + "max": 41943040, "streamIn": false, "streamOut": false, "pipe": false -- 2.30.2 From f163b88a6b98508e236a64f04fb68c3fbb503a7f Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 13 Nov 2024 00:59:05 +0800 Subject: [PATCH 113/131] fix: copyInCached --- joj3_config_generator/convert.py | 2 +- joj3_config_generator/models/result.py | 6 +- joj3_config_generator/models/task.py | 8 +- joj3_config_generator/processers/repo.py | 5 +- joj3_config_generator/processers/task.py | 26 +-- tests/convert/basic/task.json | 267 ++++++++++++++--------- tests/convert/basic/task.toml | 2 +- tests/immutable_file/push.yaml | 3 +- tests/immutable_file/release.yaml | 3 +- 9 files changed, 195 insertions(+), 127 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 0d190c8..b12c3ce 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -33,7 +33,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Construct healthcheck stage healthcheck_stage = get_healthcheck_config(repo_conf) result_conf.stage.stages.append(healthcheck_stage) - cached: list[str] = [] + cached: List[str] = [] # Convert each stage in the task configuration for task_stage in task_conf.stages: executor_with_config, cached = get_executorWithConfig(task_stage, cached) diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index 0aebb33..a7095b4 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -8,7 +8,7 @@ class CmdFile(BaseModel): content: Optional[str] = None file_id: Optional[str] = Field(None, serialization_alias="fileId") name: Optional[str] = None - max: Optional[int] = 40 * 1024 * 1024 + max: Optional[int] = 400 * 1024 * 1024 symlink: Optional[str] = None stream_in: bool = Field(False, serialization_alias="streamIn") stream_out: bool = Field(False, serialization_alias="streamOut") @@ -24,7 +24,7 @@ class Cmd(BaseModel): cpu_limit: int = Field(4 * 1000000000000, serialization_alias="cpuLimit") real_cpu_limit: int = Field(0, serialization_alias="realCpuLimit") clock_limit: int = Field(8 * 1000000000000, serialization_alias="clockLimit") - memory_limit: int = Field(80 * 1024 * 1024, serialization_alias="memoryLimit") + memory_limit: int = Field(800 * 1024 * 1024, serialization_alias="memoryLimit") stack_limit: int = Field(0, serialization_alias="stackLimit") proc_limit: int = Field(50, serialization_alias="procLimit") proc_limit: int = Field(50, serialization_alias="procLimit") @@ -54,7 +54,7 @@ class OptionalCmd(BaseModel): real_cpu_limit: Optional[int] = Field(None, serialization_alias="realCpuLimit") clock_limit: Optional[int] = Field(8 * 1000000000000, serialization_alias="clockLimit") memory_limit: Optional[int] = Field( - 80 * 1024 * 1024, serialization_alias="memoryLimit" + 800 * 1024 * 1024, serialization_alias="memoryLimit" ) stack_limit: Optional[int] = Field(None, serialization_alias="stackLimit") proc_limit: Optional[int] = Field(50, serialization_alias="procLimit") diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index dc58558..821cd10 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -40,10 +40,10 @@ class Files(BaseModel): class Limit(BaseModel): - mem: Optional[int] = 4 - cpu: Optional[int] = 4 - stderr: Optional[int] = 4 - stdout: Optional[int] = 4 + mem: Optional[int] = 800 + cpu: Optional[int] = 1000 + stderr: Optional[int] = 800 + stdout: Optional[int] = 800 class Stage(BaseModel): diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index bef99e3..6bb5c68 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -47,8 +47,7 @@ def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: immutable_files = immutable_files + name + " " else: immutable_files = immutable_files + name + "," - # FIXME: need to make solution and make things easier to edit with global scope - chore = f"./repo-health-checker -root=. " + chore = f"/tmp/repo-health-checker -root=. " args = "" args = args + chore args = args + repo_size @@ -63,7 +62,7 @@ def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: args=shlex.split(args), copy_in={ # This path is hardcoded - f"./repo-health-checker": result.CmdFile( + f"/tmp/repo-health-checker": result.CmdFile( src="/usr/local/bin/repo-health-checker" ) }, diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index d5eb32d..0d4e767 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -1,5 +1,5 @@ import shlex -from typing import Tuple +from typing import Tuple, List from joj3_config_generator.models import result, task @@ -29,8 +29,8 @@ def get_conf_stage( def get_executorWithConfig( - task_stage: task.Stage, cached: list[str] -) -> Tuple[result.ExecutorWith, list[str]]: + task_stage: task.Stage, cached: List[str] +) -> Tuple[result.ExecutorWith, List[str]]: file_import = ( task_stage.files.import_ if hasattr(task_stage, "files") @@ -58,39 +58,39 @@ def get_executorWithConfig( file: result.CmdFile(src=f"/home/tt/.config/joj/{file}") for file in copy_in_files }, - copy_in_cached={file: file for file in copy_in_files}, + copy_in_cached={file: file for file in cached}, copy_out_cached=file_export if file_export is not None else [], cpu_limit=( - task_stage.limit.cpu * 1_000_000_000 + task_stage.limit.cpu * 1_000_000_000_000 if task_stage.limit is not None and task_stage.limit.cpu is not None - else 4 * 1_000_000_000 + else 80 * 1_000_000_000_000 ), clock_limit=( - 2 * task_stage.limit.cpu * 1_000_000_000 + 2 * task_stage.limit.cpu * 1_000_000_000_000 if task_stage.limit is not None and task_stage.limit.cpu is not None - else 8 * 1_000_000_000 + else 80 * 1_000_000_000_000 ), memory_limit=( task_stage.limit.mem * 1_024 * 1_024 if task_stage.limit is not None and task_stage.limit.mem is not None - else 4 * 1_024 * 1_024 + else 800 * 1_024 * 1_024 ), stderr=result.CmdFile( name="stderr", max=( - task_stage.limit.stderr * 1_000_000_000 + task_stage.limit.stderr * 1_000_000_000_000 if task_stage.limit is not None and task_stage.limit.stderr is not None - else 4 * 1_024 * 1_024 + else 800 * 1_024 * 1_024 ), ), stdout=result.CmdFile( name="stdout", max=( - task_stage.limit.stdout * 1_000_000_000 + task_stage.limit.stdout * 1_000_000_000_000 if task_stage.limit is not None and task_stage.limit.stdout is not None - else 4 * 1_024 * 1_024 + else 800 * 1_024 * 1_024 ), ), ), diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 2716a74..ecb7fed 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -15,11 +15,11 @@ "with": { "default": { "args": [ - "./repo-health-checker", + "/tmp/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=Readme.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,7300de510e1674f6d533ae799eb5395fae6d5fbe6f64ff5047480e503602a4da,ad7ba6fbee5d80e018e4190e31bd842553d540044f0faf13592d73cef93a061b", "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml" ], "env": [ @@ -27,7 +27,7 @@ ], "stdin": { "content": "", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false @@ -49,15 +49,15 @@ "cpuLimit": 4000000000000, "realCpuLimit": 0, "clockLimit": 8000000000000, - "memoryLimit": 83886080, + "memoryLimit": 838860800, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "./repo-health-checker": { + "/tmp/repo-health-checker": { "src": "/usr/local/bin/repo-health-checker", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false @@ -101,29 +101,29 @@ ], "stdin": { "content": "", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { "name": "stdout", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { "name": "stderr", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 1000000000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -131,23 +131,21 @@ "copyIn": { "tools/compile": { "src": "/home/tt/.config/joj/tools/compile", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false } }, - "copyInCached": { - "tools/compile": "tools/compile" - }, + "copyInCached": {}, "copyInDir": ".", "copyOut": [], "copyOutCached": [ "h6/build/ex3", - "build/asan", - "build/ubsan", - "build/msan", - "build/compile_commands.json" + "h6/build/asan", + "h6/build/ubsan", + "h6/build/msan", + "h6/build/compile_commands.json" ], "copyOutMax": 0, "copyOutDir": "", @@ -209,29 +207,29 @@ ], "stdin": { "content": "", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { "name": "stdout", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { "name": "stderr", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 1000000000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -239,14 +237,18 @@ "copyIn": { "tools/filelength": { "src": "/home/tt/.config/joj/tools/filelength", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false } }, "copyInCached": { - "tools/filelength": "tools/filelength" + "h6/build/ex3": "h6/build/ex3", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", + "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", "copyOut": [], @@ -323,29 +325,29 @@ ], "stdin": { "content": "", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { "name": "stdout", - "max": 65000000000, + "max": 65000000000000, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { "name": "stderr", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 1000000000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -353,14 +355,25 @@ "copyIn": { "projects/p2/.clang-tidy": { "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", - "max": 41943040, + "max": 419430400, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "build/compile_commands.json": { + "src": "/home/tt/.config/joj/build/compile_commands.json", + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false } }, "copyInCached": { - "projects/p2/.clang-tidy": "projects/p2/.clang-tidy" + "h6/build/ex3": "h6/build/ex3", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", + "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", "copyOut": [], @@ -464,35 +477,41 @@ ], "stdin": { "content": "", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { "name": "stdout", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { "name": "stderr", - "max": 65000000000, + "max": 65000000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 1000000000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": {}, - "copyInCached": {}, + "copyInCached": { + "h6/build/ex3": "h6/build/ex3", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", + "h6/build/compile_commands.json": "h6/build/compile_commands.json" + }, "copyInDir": ".", "copyOut": [], "copyOutCached": [], @@ -571,35 +590,41 @@ ], "stdin": { "content": "", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { "name": "stdout", - "max": 65000000000, + "max": 65000000000000, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { "name": "stderr", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 1000000000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": {}, - "copyInCached": {}, + "copyInCached": { + "h6/build/ex3": "h6/build/ex3", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", + "h6/build/compile_commands.json": "h6/build/compile_commands.json" + }, "copyInDir": ".", "copyOut": [], "copyOutCached": [], @@ -680,35 +705,49 @@ ], "stdin": { "content": "", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { "name": "stdout", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { "name": "stderr", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 1000000000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, + "copyIn": { + "build/asan": { + "src": "/home/tt/.config/joj/build/asan", + "max": 419430400, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "h6/build/ex3": "h6/build/ex3", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", + "h6/build/compile_commands.json": "h6/build/compile_commands.json" + }, "copyInDir": ".", "copyOut": [], "copyOutCached": [], @@ -761,35 +800,49 @@ ], "stdin": { "content": "", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { "name": "stdout", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { "name": "stderr", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 1000000000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, + "copyIn": { + "build/msan": { + "src": "/home/tt/.config/joj/build/msan", + "max": 419430400, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "h6/build/ex3": "h6/build/ex3", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", + "h6/build/compile_commands.json": "h6/build/compile_commands.json" + }, "copyInDir": ".", "copyOut": [], "copyOutCached": [], @@ -842,35 +895,49 @@ ], "stdin": { "content": "", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { "name": "stdout", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { "name": "stderr", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 1000000000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, + "copyIn": { + "build/ubsan": { + "src": "/home/tt/.config/joj/build/ubsan", + "max": 419430400, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "h6/build/ex3": "h6/build/ex3", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", + "h6/build/compile_commands.json": "h6/build/compile_commands.json" + }, "copyInDir": ".", "copyOut": [], "copyOutCached": [], @@ -922,29 +989,29 @@ ], "stdin": { "content": "", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { "name": "stdout", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { "name": "stderr", - "max": 4000000000, + "max": 800000000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 4000000000, + "cpuLimit": 1000000000000000, "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -952,46 +1019,46 @@ "copyIn": { "h6/build/ex2": { "src": "/home/tt/.config/joj/h6/build/ex2", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "h6/build/ex4": { "src": "/home/tt/.config/joj/h6/build/ex4", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "h6/build/ex5": { "src": "/home/tt/.config/joj/h6/build/ex5", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "h6/build/ex6": { "src": "/home/tt/.config/joj/h6/build/ex6", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false }, "h6/build/ex7": { "src": "/home/tt/.config/joj/h6/build/ex7", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false } }, "copyInCached": { - "h6/build/ex2": "h6/build/ex2", - "h6/build/ex4": "h6/build/ex4", - "h6/build/ex5": "h6/build/ex5", - "h6/build/ex6": "h6/build/ex6", - "h6/build/ex7": "h6/build/ex7" + "h6/build/ex3": "h6/build/ex3", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", + "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", "copyOut": [], @@ -1010,7 +1077,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case0.in", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false @@ -1026,7 +1093,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case1.in", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false @@ -1042,7 +1109,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case2.in", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false @@ -1058,7 +1125,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case3.in", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false @@ -1074,7 +1141,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case4.in", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false @@ -1090,7 +1157,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case5.in", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false @@ -1106,7 +1173,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case6.in", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false @@ -1122,7 +1189,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case7.in", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false @@ -1138,7 +1205,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case8.in", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false @@ -1154,7 +1221,7 @@ ], "stdin": { "src": "/home/tt/.config/joj/tests/homework/h6/e3/case9.in", - "max": 41943040, + "max": 419430400, "streamIn": false, "streamOut": false, "pipe": false diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 245f529..3ec2dba 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -10,7 +10,7 @@ release.stages = [ "compile" ] name = "Compilation" command = "./tools/compile" # eg. script running cmake commands files.import = [ "tools/compile" ] -files.export = [ "h6/build/ex3", "build/asan", "build/ubsan", "build/msan", "build/compile_commands.json" ] +files.export = [ "h6/build/ex3", "h6/build/asan", "h6/build/ubsan", "h6/build/msan", "h6/build/compile_commands.json" ] # compile parsers parsers = [ "result-detail", "dummy", "result-status" ] diff --git a/tests/immutable_file/push.yaml b/tests/immutable_file/push.yaml index 2f890b6..0b35d39 100644 --- a/tests/immutable_file/push.yaml +++ b/tests/immutable_file/push.yaml @@ -1,5 +1,6 @@ name: Run JOJ3 on Push on: [push] + jobs: run: container: @@ -15,4 +16,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/tests/homework diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml index afd2838..6438234 100644 --- a/tests/immutable_file/release.yaml +++ b/tests/immutable_file/release.yaml @@ -2,6 +2,7 @@ name: Run JOJ3 on Release on: release: types: [published] + jobs: run: container: @@ -17,4 +18,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj -msg "feat(h1-release): joj on ${{ github.ref }}" + sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/tests/homework" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" -- 2.30.2 From 8af28ded35cbde3a371874ce8413516aebb044b1 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 13 Nov 2024 17:10:42 +0800 Subject: [PATCH 114/131] fix: copyOut & some default value --- joj3_config_generator/models/result.py | 6 +- joj3_config_generator/models/task.py | 2 +- joj3_config_generator/processers/task.py | 5 + tests/convert/basic/task.json | 442 +++-------------------- tests/convert/basic/task.toml | 69 +--- 5 files changed, 82 insertions(+), 442 deletions(-) diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index a7095b4..7029657 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -10,9 +10,9 @@ class CmdFile(BaseModel): name: Optional[str] = None max: Optional[int] = 400 * 1024 * 1024 symlink: Optional[str] = None - stream_in: bool = Field(False, serialization_alias="streamIn") - stream_out: bool = Field(False, serialization_alias="streamOut") - pipe: bool = False + stream_in: bool = Field(True, serialization_alias="streamIn") + stream_out: bool = Field(True, serialization_alias="streamOut") + pipe: bool = True class Cmd(BaseModel): diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 821cd10..969237e 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -25,7 +25,7 @@ class ParserKeyword(BaseModel): class Outputs(BaseModel): score: Optional[int] = 0 - ignorespaces: Optional[bool] = False + ignorespaces: Optional[bool] = True hide: Optional[bool] = False forcequit: Optional[bool] = True diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 0d4e767..55357be 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -47,6 +47,10 @@ def get_executorWithConfig( and (task_stage.files is not None) else [] ) + copy_out_files = [ + "stdout", + "stderr" + ] executor_with_config = result.ExecutorWith( default=result.Cmd( args=( @@ -58,6 +62,7 @@ def get_executorWithConfig( file: result.CmdFile(src=f"/home/tt/.config/joj/{file}") for file in copy_in_files }, + copy_out=copy_out_files, copy_in_cached={file: file for file in cached}, copy_out_cached=file_export if file_export is not None else [], cpu_limit=( diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index ecb7fed..6c1535e 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "hw 6 ex3", - "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e3.log", + "name": "hw 6 ex6", + "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e6.log", "expireUnixTimestamp": 1731686399, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -139,12 +139,12 @@ }, "copyInCached": {}, "copyInDir": ".", - "copyOut": [], + "copyOut": [ + "stdout", + "stderr" + ], "copyOutCached": [ - "h6/build/ex3", - "h6/build/asan", - "h6/build/ubsan", - "h6/build/msan", + "h6/build/ex6", "h6/build/compile_commands.json" ], "copyOutMax": 0, @@ -196,7 +196,7 @@ "with": { "default": { "args": [ - "./file-length", + "./tools/filelength", "400", "300", "*.c", @@ -244,14 +244,14 @@ } }, "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex6": "h6/build/ex6", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", - "copyOut": [], + "copyOut": [ + "stdout", + "stderr" + ], "copyOutCached": [], "copyOutMax": 0, "copyOutDir": "", @@ -318,7 +318,7 @@ "-quiet", "-load=/usr/local/lib/libcodequality.so", "-p", - "build" + "h6/build" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -359,24 +359,17 @@ "streamIn": false, "streamOut": false, "pipe": false - }, - "build/compile_commands.json": { - "src": "/home/tt/.config/joj/build/compile_commands.json", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false } }, "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex6": "h6/build/ex6", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", - "copyOut": [], + "copyOut": [ + "stdout", + "stderr" + ], "copyOutCached": [], "copyOutMax": 0, "copyOutDir": "", @@ -506,14 +499,14 @@ "cpuSetLimit": "", "copyIn": {}, "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex6": "h6/build/ex6", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", - "copyOut": [], + "copyOut": [ + "stdout", + "stderr" + ], "copyOutCached": [], "copyOutMax": 0, "copyOutDir": "", @@ -580,7 +573,7 @@ "args": [ "cpplint", "--linelength=120", - "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard", + "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-runtime/int,-readability/todo,-build/include_subdir,-build/header_guard,-build/include_what_you_use", "--recursive", "--exclude=build", "." @@ -619,14 +612,14 @@ "cpuSetLimit": "", "copyIn": {}, "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex6": "h6/build/ex6", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", - "copyOut": [], + "copyOut": [ + "stdout", + "stderr" + ], "copyOutCached": [], "copyOutMax": 0, "copyOutDir": "", @@ -691,14 +684,13 @@ ] }, { - "name": "[run] address sanitizer", + "name": "[joj] ex6", "executor": { "name": "sandbox", "with": { "default": { "args": [ - "./asan", - "-a" + "./h6/build/ex6" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -732,336 +724,16 @@ "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", - "copyIn": { - "build/asan": { - "src": "/home/tt/.config/joj/build/asan", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, + "copyIn": {}, "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex6": "h6/build/ex6", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 1, - "comment": "", - "forceQuitOnNotAccepted": false - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ + "copyOut": [ + "stdout", "stderr" ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "[run] memory sanitizer", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./msan", - "-a" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "name": "stdout", - "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "name": "stderr", - "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "build/msan": { - "src": "/home/tt/.config/joj/build/msan", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", - "h6/build/compile_commands.json": "h6/build/compile_commands.json" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 1, - "comment": "", - "forceQuitOnNotAccepted": false - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "[run] undefined behavior sanitizer", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./ubsan", - "-a" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "name": "stdout", - "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "name": "stderr", - "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "build/ubsan": { - "src": "/home/tt/.config/joj/build/ubsan", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", - "h6/build/compile_commands.json": "h6/build/compile_commands.json" - }, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 1, - "comment": "", - "forceQuitOnNotAccepted": false - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "[joj] ex3", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./ex3" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "name": "stdout", - "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "name": "stderr", - "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "h6/build/ex2": { - "src": "/home/tt/.config/joj/h6/build/ex2", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "h6/build/ex4": { - "src": "/home/tt/.config/joj/h6/build/ex4", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "h6/build/ex5": { - "src": "/home/tt/.config/joj/h6/build/ex5", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "h6/build/ex6": { - "src": "/home/tt/.config/joj/h6/build/ex6", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "h6/build/ex7": { - "src": "/home/tt/.config/joj/h6/build/ex7", - "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false - } - }, - "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", - "h6/build/compile_commands.json": "h6/build/compile_commands.json" - }, - "copyInDir": ".", - "copyOut": [], "copyOutCached": [], "copyOutMax": 0, "copyOutDir": "", @@ -1076,7 +748,7 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case0.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e6/case0.in", "max": 419430400, "streamIn": false, "streamOut": false, @@ -1092,7 +764,7 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case1.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e6/case1.in", "max": 419430400, "streamIn": false, "streamOut": false, @@ -1108,7 +780,7 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case2.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e6/case2.in", "max": 419430400, "streamIn": false, "streamOut": false, @@ -1124,7 +796,7 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case3.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e6/case3.in", "max": 419430400, "streamIn": false, "streamOut": false, @@ -1140,7 +812,7 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case4.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e6/case4.in", "max": 419430400, "streamIn": false, "streamOut": false, @@ -1156,7 +828,7 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case5.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e6/case5.in", "max": 419430400, "streamIn": false, "streamOut": false, @@ -1172,7 +844,7 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case6.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e6/case6.in", "max": 419430400, "streamIn": false, "streamOut": false, @@ -1188,7 +860,7 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case7.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e6/case7.in", "max": 419430400, "streamIn": false, "streamOut": false, @@ -1204,7 +876,7 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case8.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e6/case8.in", "max": 419430400, "streamIn": false, "streamOut": false, @@ -1220,7 +892,7 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case9.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e6/case9.in", "max": 419430400, "streamIn": false, "streamOut": false, @@ -1245,7 +917,7 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case0.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case0.out", "forceQuitOnDiff": true, "alwaysHide": false, "compareSpace": true @@ -1257,7 +929,7 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case1.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case1.out", "forceQuitOnDiff": true, "alwaysHide": false, "compareSpace": true @@ -1269,7 +941,7 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case2.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case2.out", "forceQuitOnDiff": true, "alwaysHide": false, "compareSpace": true @@ -1281,7 +953,7 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case3.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case3.out", "forceQuitOnDiff": true, "alwaysHide": false, "compareSpace": true @@ -1293,7 +965,7 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case4.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case4.out", "forceQuitOnDiff": true, "alwaysHide": false, "compareSpace": true @@ -1305,7 +977,7 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case5.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case5.out", "forceQuitOnDiff": true, "alwaysHide": false, "compareSpace": true @@ -1317,7 +989,7 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case6.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case6.out", "forceQuitOnDiff": true, "alwaysHide": false, "compareSpace": true @@ -1329,7 +1001,7 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case7.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case7.out", "forceQuitOnDiff": true, "alwaysHide": false, "compareSpace": true @@ -1341,7 +1013,7 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case8.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case8.out", "forceQuitOnDiff": true, "alwaysHide": false, "compareSpace": true @@ -1353,7 +1025,7 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case9.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case9.out", "forceQuitOnDiff": true, "alwaysHide": false, "compareSpace": true @@ -1389,7 +1061,7 @@ ] }, "teapot": { - "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e3-joint-teapot-debug.log", + "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e6-joint-teapot-debug.log", "scoreboardPath": "tests/homework-scoreboard.csv", "failedTablePath": "tests/homework-failed-table.md", "gradingRepoName": "engr151-joj", diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 3ec2dba..e7a7c5a 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,18 +1,17 @@ # general task configuration -task.name = "hw 6 ex3" # task name - -task.type = "tests/homework/h6/e3" +task.name = "hw 6 ex6" # task name +task.type = "tests/homework/h6/e6" release.deadline = 2024-11-15 23:59:59+08:00 release.stages = [ "compile" ] [[stages]] name = "Compilation" -command = "./tools/compile" # eg. script running cmake commands -files.import = [ "tools/compile" ] -files.export = [ "h6/build/ex3", "h6/build/asan", "h6/build/ubsan", "h6/build/msan", "h6/build/compile_commands.json" ] +command = "./tools/compile" # eg. script running cmake commands +files.import = [ "tools/compile" ] +files.export = [ "h6/build/ex6", "h6/build/compile_commands.json" ] -# compile parsers +# compile parsers parsers = [ "result-detail", "dummy", "result-status" ] result-status.comment = "Congratulations! Your code compiled successfully." dummy.comment = "\n\n### Details\n" @@ -23,12 +22,12 @@ result-detail.mem = false [[stages]] name = "[cq] Filelength" -command = "./file-length 400 300 *.c *.h" +command = "./tools/filelength 400 300 *.c *.h" files.import = [ "tools/filelength" ] parsers = [ "keyword", "dummy", "result-detail" ] -keyword.keyword = [ "max", "recommended"] -keyword.weight = [ 20, 10 ] +keyword.keyword = [ "max", "recommended"] +keyword.weight = [ 20, 10 ] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stdout = true @@ -37,8 +36,8 @@ result-detail.mem = false [[stages]] name = "[cq] Clang-tidy" -command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" -files.import = [ "projects/p2/.clang-tidy", "build/compile_commands.json" ] +command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p h6/build" +files.import = [ "projects/p2/.clang-tidy", "h6/build/compile_commands.json" ] limit.stdout = 65 parsers = [ "clangtidy", "dummy", "result-detail" ] @@ -66,7 +65,7 @@ result-detail.mem = false [[stages]] name = "[cq] Cpplint" -command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard --recursive --exclude=build ." +command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-runtime/int,-readability/todo,-build/include_subdir,-build/header_guard,-build/include_what_you_use --recursive --exclude=build ." limit.stdout = 65 parsers = [ "cpplint", "dummy", "result-detail" ] @@ -78,47 +77,11 @@ result-detail.stderr = true result-detail.time = false result-detail.mem = false - [[stages]] -name = "[run] address sanitizer" -group = "run" -command="./asan -a" -files.import = [ "build/asan" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true - -[[stages]] -name = "[run] memory sanitizer" -group = "run" -command="./msan -a" -files.import = [ "build/msan" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true - -[[stages]] -name = "[run] undefined behavior sanitizer" -command="./ubsan -a" -files.import = [ "build/ubsan" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true - -[[stages]] -name = "[joj] ex3" +name = "[joj] ex6" group = "joj" -command="./ex3" -files.import = [ "h6/build/ex2", "h6/build/ex3", "h6/build/ex4", "h6/build/ex5", "h6/build/ex6", "h6/build/ex7" ] +command="./h6/build/ex6" +files.import = [ "h6/build/ex6" ] score = 10 parsers = [ "diff", "dummy", "result-detail" ] @@ -174,4 +137,4 @@ case8.limit.stdout = 8 case9.score = 10 case9.limit.cpu = 30 case9.limit.mem = 32 -case9.limit.stdout = 8 +case9.limit.stdout = 8 \ No newline at end of file -- 2.30.2 From 6e182a81b9d3296ccdb432b80989e883143a51a9 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 13 Nov 2024 17:33:59 +0800 Subject: [PATCH 115/131] feat: command for cases --- tests/convert/basic/task.json | 596 +++++++++++++++++++++++++--------- tests/convert/basic/task.toml | 47 ++- 2 files changed, 491 insertions(+), 152 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 6c1535e..b484b7d 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "hw 6 ex6", - "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e6.log", + "name": "hw 6 ex3", + "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e3.log", "expireUnixTimestamp": 1731686399, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -28,23 +28,23 @@ "stdin": { "content": "", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stdout": { "name": "stdout", "max": 4096, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stderr": { "name": "stderr", "max": 4096, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 4000000000000, "realCpuLimit": 0, @@ -58,9 +58,9 @@ "/tmp/repo-health-checker": { "src": "/usr/local/bin/repo-health-checker", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true } }, "copyInCached": {}, @@ -102,23 +102,23 @@ "stdin": { "content": "", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stdout": { "name": "stdout", "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stderr": { "name": "stderr", "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 1000000000000000, "realCpuLimit": 0, @@ -132,9 +132,9 @@ "tools/compile": { "src": "/home/tt/.config/joj/tools/compile", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true } }, "copyInCached": {}, @@ -144,7 +144,10 @@ "stderr" ], "copyOutCached": [ - "h6/build/ex6", + "h6/build/ex3", + "build/asan", + "build/ubsan", + "build/msan", "h6/build/compile_commands.json" ], "copyOutMax": 0, @@ -208,23 +211,23 @@ "stdin": { "content": "", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stdout": { "name": "stdout", "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stderr": { "name": "stderr", "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 1000000000000000, "realCpuLimit": 0, @@ -238,13 +241,16 @@ "tools/filelength": { "src": "/home/tt/.config/joj/tools/filelength", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true } }, "copyInCached": { - "h6/build/ex6": "h6/build/ex6", + "h6/build/ex3": "h6/build/ex3", + "build/asan": "build/asan", + "build/ubsan": "build/ubsan", + "build/msan": "build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -326,23 +332,23 @@ "stdin": { "content": "", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stdout": { "name": "stdout", "max": 65000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stderr": { "name": "stderr", "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 1000000000000000, "realCpuLimit": 0, @@ -356,13 +362,16 @@ "projects/p2/.clang-tidy": { "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true } }, "copyInCached": { - "h6/build/ex6": "h6/build/ex6", + "h6/build/ex3": "h6/build/ex3", + "build/asan": "build/asan", + "build/ubsan": "build/ubsan", + "build/msan": "build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -471,23 +480,23 @@ "stdin": { "content": "", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stdout": { "name": "stdout", "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stderr": { "name": "stderr", "max": 65000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 1000000000000000, "realCpuLimit": 0, @@ -499,7 +508,10 @@ "cpuSetLimit": "", "copyIn": {}, "copyInCached": { - "h6/build/ex6": "h6/build/ex6", + "h6/build/ex3": "h6/build/ex3", + "build/asan": "build/asan", + "build/ubsan": "build/ubsan", + "build/msan": "build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -584,23 +596,23 @@ "stdin": { "content": "", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stdout": { "name": "stdout", "max": 65000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stderr": { "name": "stderr", "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 1000000000000000, "realCpuLimit": 0, @@ -612,7 +624,10 @@ "cpuSetLimit": "", "copyIn": {}, "copyInCached": { - "h6/build/ex6": "h6/build/ex6", + "h6/build/ex3": "h6/build/ex3", + "build/asan": "build/asan", + "build/ubsan": "build/ubsan", + "build/msan": "build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -684,13 +699,14 @@ ] }, { - "name": "[joj] ex6", + "name": "[run] address sanitizer", "executor": { "name": "sandbox", "with": { "default": { "args": [ - "./h6/build/ex6" + "./build/asan", + "-a" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -698,23 +714,23 @@ "stdin": { "content": "", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stdout": { "name": "stdout", "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "stderr": { "name": "stderr", "max": 800000000000000, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 1000000000000000, "realCpuLimit": 0, @@ -726,7 +742,295 @@ "cpuSetLimit": "", "copyIn": {}, "copyInCached": { - "h6/build/ex6": "h6/build/ex6", + "h6/build/ex3": "h6/build/ex3", + "build/asan": "build/asan", + "build/ubsan": "build/ubsan", + "build/msan": "build/msan", + "h6/build/compile_commands.json": "h6/build/compile_commands.json" + }, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[run] memory sanitizer", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./h6/build/msan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 419430400, + "streamIn": true, + "streamOut": true, + "pipe": true + }, + "stdout": { + "name": "stdout", + "max": 800000000000000, + "streamIn": true, + "streamOut": true, + "pipe": true + }, + "stderr": { + "name": "stderr", + "max": 800000000000000, + "streamIn": true, + "streamOut": true, + "pipe": true + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "h6/build/msan": { + "src": "/home/tt/.config/joj/h6/build/msan", + "max": 419430400, + "streamIn": true, + "streamOut": true, + "pipe": true + } + }, + "copyInCached": { + "h6/build/ex3": "h6/build/ex3", + "build/asan": "build/asan", + "build/ubsan": "build/ubsan", + "build/msan": "build/msan", + "h6/build/compile_commands.json": "h6/build/compile_commands.json" + }, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[run] undefined behavior sanitizer", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./h6/build/ubsan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 419430400, + "streamIn": true, + "streamOut": true, + "pipe": true + }, + "stdout": { + "name": "stdout", + "max": 800000000000000, + "streamIn": true, + "streamOut": true, + "pipe": true + }, + "stderr": { + "name": "stderr", + "max": 800000000000000, + "streamIn": true, + "streamOut": true, + "pipe": true + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "h6/build/ubsan": { + "src": "/home/tt/.config/joj/h6/build/ubsan", + "max": 419430400, + "streamIn": true, + "streamOut": true, + "pipe": true + } + }, + "copyInCached": { + "h6/build/ex3": "h6/build/ex3", + "build/asan": "build/asan", + "build/ubsan": "build/ubsan", + "build/msan": "build/msan", + "h6/build/compile_commands.json": "h6/build/compile_commands.json" + }, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[joj] ex3", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./h6/build/ex3" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 419430400, + "streamIn": true, + "streamOut": true, + "pipe": true + }, + "stdout": { + "name": "stdout", + "max": 800000000000000, + "streamIn": true, + "streamOut": true, + "pipe": true + }, + "stderr": { + "name": "stderr", + "max": 800000000000000, + "streamIn": true, + "streamOut": true, + "pipe": true + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": { + "h6/build/ex3": "h6/build/ex3", + "build/asan": "build/asan", + "build/ubsan": "build/ubsan", + "build/msan": "build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -748,11 +1052,11 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e6/case0.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case0.in", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 30000000000, "clockLimit": 60000000000, @@ -764,11 +1068,11 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e6/case1.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case1.in", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 30000000000, "clockLimit": 60000000000, @@ -780,11 +1084,11 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e6/case2.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case2.in", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 30000000000, "clockLimit": 60000000000, @@ -796,11 +1100,11 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e6/case3.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case3.in", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 30000000000, "clockLimit": 60000000000, @@ -812,11 +1116,11 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e6/case4.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case4.in", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 30000000000, "clockLimit": 60000000000, @@ -828,11 +1132,11 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e6/case5.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case5.in", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 30000000000, "clockLimit": 60000000000, @@ -844,11 +1148,11 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e6/case6.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case6.in", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 30000000000, "clockLimit": 60000000000, @@ -860,11 +1164,11 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e6/case7.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case7.in", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 30000000000, "clockLimit": 60000000000, @@ -876,11 +1180,11 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e6/case8.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case8.in", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 30000000000, "clockLimit": 60000000000, @@ -892,11 +1196,11 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e6/case9.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e3/case9.in", "max": 419430400, - "streamIn": false, - "streamOut": false, - "pipe": false + "streamIn": true, + "streamOut": true, + "pipe": true }, "cpuLimit": 30000000000, "clockLimit": 60000000000, @@ -917,10 +1221,10 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case0.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case0.out", "forceQuitOnDiff": true, "alwaysHide": false, - "compareSpace": true + "compareSpace": false } ] }, @@ -929,10 +1233,10 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case1.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case1.out", "forceQuitOnDiff": true, "alwaysHide": false, - "compareSpace": true + "compareSpace": false } ] }, @@ -941,10 +1245,10 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case2.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case2.out", "forceQuitOnDiff": true, "alwaysHide": false, - "compareSpace": true + "compareSpace": false } ] }, @@ -953,10 +1257,10 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case3.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case3.out", "forceQuitOnDiff": true, "alwaysHide": false, - "compareSpace": true + "compareSpace": false } ] }, @@ -965,10 +1269,10 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case4.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case4.out", "forceQuitOnDiff": true, "alwaysHide": false, - "compareSpace": true + "compareSpace": false } ] }, @@ -977,10 +1281,10 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case5.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case5.out", "forceQuitOnDiff": true, "alwaysHide": false, - "compareSpace": true + "compareSpace": false } ] }, @@ -989,10 +1293,10 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case6.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case6.out", "forceQuitOnDiff": true, "alwaysHide": false, - "compareSpace": true + "compareSpace": false } ] }, @@ -1001,10 +1305,10 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case7.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case7.out", "forceQuitOnDiff": true, "alwaysHide": false, - "compareSpace": true + "compareSpace": false } ] }, @@ -1013,10 +1317,10 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case8.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case8.out", "forceQuitOnDiff": true, "alwaysHide": false, - "compareSpace": true + "compareSpace": false } ] }, @@ -1025,10 +1329,10 @@ { "score": 0, "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e6/case9.out", + "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case9.out", "forceQuitOnDiff": true, "alwaysHide": false, - "compareSpace": true + "compareSpace": false } ] } @@ -1061,7 +1365,7 @@ ] }, "teapot": { - "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e6-joint-teapot-debug.log", + "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e3-joint-teapot-debug.log", "scoreboardPath": "tests/homework-scoreboard.csv", "failedTablePath": "tests/homework-failed-table.md", "gradingRepoName": "engr151-joj", diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index e7a7c5a..e9fc796 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,6 +1,6 @@ # general task configuration -task.name = "hw 6 ex6" # task name -task.type = "tests/homework/h6/e6" +task.name = "hw 6 ex3" # task name +task.type = "tests/homework/h6/e3" release.deadline = 2024-11-15 23:59:59+08:00 release.stages = [ "compile" ] @@ -9,7 +9,7 @@ release.stages = [ "compile" ] name = "Compilation" command = "./tools/compile" # eg. script running cmake commands files.import = [ "tools/compile" ] -files.export = [ "h6/build/ex6", "h6/build/compile_commands.json" ] +files.export = [ "h6/build/ex3", "h6/build/asan", "h6/build/ubsan", "h6/build/msan", "h6/build/compile_commands.json" ] # compile parsers parsers = [ "result-detail", "dummy", "result-status" ] @@ -78,10 +78,45 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "[joj] ex6" +name = "[run] address sanitizer" +group = "run" +command="./h6/build/asan -a" +files.import = [ "h6/build/asan" ] + +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true + +[[stages]] +name = "[run] memory sanitizer" +group = "run" +command="./h6/build/msan -a" +files.import = [ "h6/build/msan" ] + +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true + +[[stages]] +name = "[run] undefined behavior sanitizer" +command="./h6/build/ubsan -a" +files.import = [ "h6/build/ubsan" ] + +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true + +[[stages]] +name = "[joj] ex3" group = "joj" -command="./h6/build/ex6" -files.import = [ "h6/build/ex6" ] +command="./h6/build/ex3" +files.import = [ "h6/build/ex3" ] score = 10 parsers = [ "diff", "dummy", "result-detail" ] -- 2.30.2 From 69b9af03a00d79fc174c0911e4eee9657966c18d Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 13 Nov 2024 17:36:00 +0800 Subject: [PATCH 116/131] fix: command in cases --- tests/convert/basic/task.json | 80 +++++++++++++++-------------------- tests/convert/basic/task.toml | 1 + 2 files changed, 35 insertions(+), 46 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index b484b7d..9fba48c 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -145,9 +145,9 @@ ], "copyOutCached": [ "h6/build/ex3", - "build/asan", - "build/ubsan", - "build/msan", + "h6/build/asan", + "h6/build/ubsan", + "h6/build/msan", "h6/build/compile_commands.json" ], "copyOutMax": 0, @@ -248,9 +248,9 @@ }, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "build/asan": "build/asan", - "build/ubsan": "build/ubsan", - "build/msan": "build/msan", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -369,9 +369,9 @@ }, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "build/asan": "build/asan", - "build/ubsan": "build/ubsan", - "build/msan": "build/msan", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -509,9 +509,9 @@ "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "build/asan": "build/asan", - "build/ubsan": "build/ubsan", - "build/msan": "build/msan", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -625,9 +625,9 @@ "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "build/asan": "build/asan", - "build/ubsan": "build/ubsan", - "build/msan": "build/msan", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -705,7 +705,7 @@ "with": { "default": { "args": [ - "./build/asan", + "./h6/build/asan", "-a" ], "env": [ @@ -743,9 +743,9 @@ "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "build/asan": "build/asan", - "build/ubsan": "build/ubsan", - "build/msan": "build/msan", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -830,20 +830,12 @@ "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", - "copyIn": { - "h6/build/msan": { - "src": "/home/tt/.config/joj/h6/build/msan", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - } - }, + "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "build/asan": "build/asan", - "build/ubsan": "build/ubsan", - "build/msan": "build/msan", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -928,20 +920,12 @@ "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", - "copyIn": { - "h6/build/ubsan": { - "src": "/home/tt/.config/joj/h6/build/ubsan", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - } - }, + "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "build/asan": "build/asan", - "build/ubsan": "build/ubsan", - "build/msan": "build/msan", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -1028,9 +1012,9 @@ "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "build/asan": "build/asan", - "build/ubsan": "build/ubsan", - "build/msan": "build/msan", + "h6/build/asan": "h6/build/asan", + "h6/build/ubsan": "h6/build/ubsan", + "h6/build/msan": "h6/build/msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -1048,6 +1032,10 @@ }, "cases": [ { + "args": [ + "Manuel", + "Charlemagne" + ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" ], diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index e9fc796..5fa7216 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -128,6 +128,7 @@ case0.score = 10 case0.limit.cpu = 30 case0.limit.mem = 32 case0.limit.stdout = 8 +case0.command = "Manuel Charlemagne" case1.score = 10 case1.limit.cpu = 30 -- 2.30.2 From 303c9d8e40266e787cde869776af94862d23fd14 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Thu, 14 Nov 2024 10:35:33 +0800 Subject: [PATCH 117/131] feat: support for custom stdin --- joj3_config_generator/models/task.py | 2 + joj3_config_generator/processers/task.py | 20 +++++- tests/convert/basic/task.json | 82 ++++++++++++------------ tests/convert/basic/task.toml | 37 +++++------ 4 files changed, 80 insertions(+), 61 deletions(-) diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 969237e..0dccb01 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -50,6 +50,8 @@ class Stage(BaseModel): name: Optional[str] = None # Stage name command: Optional[str] = None # Command to run files: Optional[Files] = None + in_: Optional[str] = Field(None, alias="in") + out_: Optional[str] = Field(None, alias="out") score: Optional[int] = 0 parsers: Optional[list[str]] = [] # list of parsers limit: Optional[Limit] = Limit() diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 55357be..0ca194d 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -234,12 +234,28 @@ def fix_diff( if case_stage.limit and case_stage.limit.mem is not None else 0 ) + command = ( + case_stage.command + if case_stage.command is not None + else None + ) + stdin = ( + case_stage.in_ + if case_stage.in_ is not None + else f"{case}.in" + ) + stdout = ( + case_stage.out_ + if case_stage.out_ is not None + else f"{case}.out" + ) stage_cases.append( result.OptionalCmd( stdin=result.CmdFile( - src=f"/home/tt/.config/joj/{task_conf.task.type_}/{case}.in" + src=f"/home/tt/.config/joj/{task_conf.task.type_}/{stdin}" ), + args=shlex.split(case_stage.command) if command is not None else None, cpu_limit=cpu_limit, clock_limit=clock_limit, memory_limit=memory_limit, @@ -260,7 +276,7 @@ def fix_diff( { "score": diff_output.score, "fileName": "stdout", - "answerPath": f"/home/tt/.config/joj/{task_conf.task.type_}/{case}.out", + "answerPath": f"/home/tt/.config/joj/{task_conf.task.type_}/{stdout}", "forceQuitOnDiff": diff_output.forcequit, "alwaysHide": diff_output.hide, "compareSpace": not diff_output.ignorespaces, diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 9fba48c..6bd740b 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -145,9 +145,9 @@ ], "copyOutCached": [ "h6/build/ex3", - "h6/build/asan", - "h6/build/ubsan", - "h6/build/msan", + "h6/build/ex3-asan", + "h6/build/ex3-ubsan", + "h6/build/ex3-msan", "h6/build/compile_commands.json" ], "copyOutMax": 0, @@ -248,9 +248,9 @@ }, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex3-asan": "h6/build/ex3-asan", + "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", + "h6/build/ex3-msan": "h6/build/ex3-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -369,9 +369,9 @@ }, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex3-asan": "h6/build/ex3-asan", + "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", + "h6/build/ex3-msan": "h6/build/ex3-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -509,9 +509,9 @@ "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex3-asan": "h6/build/ex3-asan", + "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", + "h6/build/ex3-msan": "h6/build/ex3-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -625,9 +625,9 @@ "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex3-asan": "h6/build/ex3-asan", + "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", + "h6/build/ex3-msan": "h6/build/ex3-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -705,7 +705,7 @@ "with": { "default": { "args": [ - "./h6/build/asan", + "./h6/build/ex3-asan", "-a" ], "env": [ @@ -743,9 +743,9 @@ "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex3-asan": "h6/build/ex3-asan", + "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", + "h6/build/ex3-msan": "h6/build/ex3-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -795,7 +795,7 @@ "with": { "default": { "args": [ - "./h6/build/msan", + "./h6/build/ex3-msan", "-a" ], "env": [ @@ -833,9 +833,9 @@ "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex3-asan": "h6/build/ex3-asan", + "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", + "h6/build/ex3-msan": "h6/build/ex3-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -885,7 +885,7 @@ "with": { "default": { "args": [ - "./h6/build/ubsan", + "./h6/build/ex3-ubsan", "-a" ], "env": [ @@ -923,9 +923,9 @@ "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex3-asan": "h6/build/ex3-asan", + "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", + "h6/build/ex3-msan": "h6/build/ex3-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -1012,9 +1012,9 @@ "copyIn": {}, "copyInCached": { "h6/build/ex3": "h6/build/ex3", - "h6/build/asan": "h6/build/asan", - "h6/build/ubsan": "h6/build/ubsan", - "h6/build/msan": "h6/build/msan", + "h6/build/ex3-asan": "h6/build/ex3-asan", + "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", + "h6/build/ex3-msan": "h6/build/ex3-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -1040,7 +1040,7 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case0.in", + "src": "/home/tt/.config/joj/tests/homework/h6/e3/paragraph.in", "max": 419430400, "streamIn": true, "streamOut": true, @@ -1207,7 +1207,7 @@ { "outputs": [ { - "score": 0, + "score": 5, "fileName": "stdout", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case0.out", "forceQuitOnDiff": true, @@ -1219,7 +1219,7 @@ { "outputs": [ { - "score": 0, + "score": 5, "fileName": "stdout", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case1.out", "forceQuitOnDiff": true, @@ -1231,7 +1231,7 @@ { "outputs": [ { - "score": 0, + "score": 5, "fileName": "stdout", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case2.out", "forceQuitOnDiff": true, @@ -1243,7 +1243,7 @@ { "outputs": [ { - "score": 0, + "score": 5, "fileName": "stdout", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case3.out", "forceQuitOnDiff": true, @@ -1255,7 +1255,7 @@ { "outputs": [ { - "score": 0, + "score": 10, "fileName": "stdout", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case4.out", "forceQuitOnDiff": true, @@ -1267,7 +1267,7 @@ { "outputs": [ { - "score": 0, + "score": 10, "fileName": "stdout", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case5.out", "forceQuitOnDiff": true, @@ -1279,7 +1279,7 @@ { "outputs": [ { - "score": 0, + "score": 15, "fileName": "stdout", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case6.out", "forceQuitOnDiff": true, @@ -1291,7 +1291,7 @@ { "outputs": [ { - "score": 0, + "score": 15, "fileName": "stdout", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case7.out", "forceQuitOnDiff": true, @@ -1303,7 +1303,7 @@ { "outputs": [ { - "score": 0, + "score": 15, "fileName": "stdout", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case8.out", "forceQuitOnDiff": true, @@ -1315,7 +1315,7 @@ { "outputs": [ { - "score": 0, + "score": 15, "fileName": "stdout", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case9.out", "forceQuitOnDiff": true, diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 5fa7216..e7b5d38 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -9,7 +9,7 @@ release.stages = [ "compile" ] name = "Compilation" command = "./tools/compile" # eg. script running cmake commands files.import = [ "tools/compile" ] -files.export = [ "h6/build/ex3", "h6/build/asan", "h6/build/ubsan", "h6/build/msan", "h6/build/compile_commands.json" ] +files.export = [ "h6/build/ex3", "h6/build/ex3-asan", "h6/build/ex3-ubsan", "h6/build/ex3-msan", "h6/build/compile_commands.json" ] # compile parsers parsers = [ "result-detail", "dummy", "result-status" ] @@ -80,8 +80,8 @@ result-detail.mem = false [[stages]] name = "[run] address sanitizer" group = "run" -command="./h6/build/asan -a" -files.import = [ "h6/build/asan" ] +command="./h6/build/ex3-asan -a" +files.import = [ "h6/build/ex3-asan" ] parsers = [ "result-status", "result-detail" ] result-status.score = 1 @@ -92,8 +92,8 @@ result-detail.stderr = true [[stages]] name = "[run] memory sanitizer" group = "run" -command="./h6/build/msan -a" -files.import = [ "h6/build/msan" ] +command="./h6/build/ex3-msan -a" +files.import = [ "h6/build/ex3-msan" ] parsers = [ "result-status", "result-detail" ] result-status.score = 1 @@ -103,8 +103,8 @@ result-detail.stderr = true [[stages]] name = "[run] undefined behavior sanitizer" -command="./h6/build/ubsan -a" -files.import = [ "h6/build/ubsan" ] +command="./h6/build/ex3-ubsan -a" +files.import = [ "h6/build/ex3-ubsan" ] parsers = [ "result-status", "result-detail" ] result-status.score = 1 @@ -124,53 +124,54 @@ result-detail.exitstatus = true result-detail.stderr = true # will be removed as long as the name is fixed -case0.score = 10 +case0.in = "paragraph.in" +case0.command = "Manuel Charlemagne" +case0.diff.output.score = 5 case0.limit.cpu = 30 case0.limit.mem = 32 case0.limit.stdout = 8 -case0.command = "Manuel Charlemagne" -case1.score = 10 +case1.diff.output.score = 5 case1.limit.cpu = 30 case1.limit.mem = 32 case1.limit.stdout = 8 -case2.score = 10 +case2.diff.output.score = 5 case2.limit.cpu = 30 case2.limit.mem = 32 case2.limit.stdout = 8 -case3.score = 10 +case3.diff.output.score = 5 case3.limit.cpu = 30 case3.limit.mem = 32 case3.limit.stdout = 8 -case4.score = 10 +case4.diff.output.score = 10 case4.limit.cpu = 30 case4.limit.mem = 32 case4.limit.stdout = 8 -case5.score = 10 +case5.diff.output.score = 10 case5.limit.cpu = 30 case5.limit.mem = 32 case5.limit.stdout = 8 -case6.score = 10 +case6.diff.output.score = 15 case6.limit.cpu = 30 case6.limit.mem = 32 case6.limit.stdout = 8 -case7.score = 10 +case7.diff.output.score = 15 case7.limit.cpu = 30 case7.limit.mem = 32 case7.limit.stdout = 8 -case8.score = 10 +case8.diff.output.score = 15 case8.limit.cpu = 30 case8.limit.mem = 32 case8.limit.stdout = 8 -case9.score = 10 +case9.diff.output.score = 15 case9.limit.cpu = 30 case9.limit.mem = 32 case9.limit.stdout = 8 \ No newline at end of file -- 2.30.2 From b755efac6de22ceecc8811b2c2beafaab0f34954 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Fri, 15 Nov 2024 18:54:53 +0800 Subject: [PATCH 118/131] fix: diff with stdin --- joj3_config_generator/models/result.py | 6 +- joj3_config_generator/processers/repo.py | 4 +- joj3_config_generator/processers/task.py | 5 +- tests/convert/basic/task.json | 811 ++--------------------- tests/convert/basic/task.toml | 108 +-- 5 files changed, 60 insertions(+), 874 deletions(-) diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index 7029657..408e51d 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -10,9 +10,9 @@ class CmdFile(BaseModel): name: Optional[str] = None max: Optional[int] = 400 * 1024 * 1024 symlink: Optional[str] = None - stream_in: bool = Field(True, serialization_alias="streamIn") - stream_out: bool = Field(True, serialization_alias="streamOut") - pipe: bool = True + stream_in: Optional[bool] = Field(None, serialization_alias="streamIn") + stream_out: Optional[bool] = Field(None, serialization_alias="streamOut") + pipe: Optional[bool] = None class Cmd(BaseModel): diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index 6bb5c68..4af04ce 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -73,8 +73,8 @@ def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail: healthcheck_stage = result.StageDetail( name="healthcheck", - group="", - executor=ExecutorConfig( + group=None, + executor=result.Executor( name="sandbox", with_=result.ExecutorWith(default=get_healthcheck_cmd(repo_conf), cases=[]), ), diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 0ca194d..0f27b3a 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -12,7 +12,7 @@ def get_conf_stage( # TODO: we may have cq in future group=( "joj" - if (task_stage.name is not None) and ("judge" in task_stage.name) + if (task_stage.name is not None) and (("joj" in task_stage.name) or ("run" in task_stage.name)) else None ), executor=result.Executor( @@ -62,6 +62,9 @@ def get_executorWithConfig( file: result.CmdFile(src=f"/home/tt/.config/joj/{file}") for file in copy_in_files }, + stdin=( + result.CmdFile(content="") if "diff" not in task_stage.parsers else None + ), copy_out=copy_out_files, copy_in_cached={file: file for file in cached}, copy_out_cached=file_export if file_export is not None else [], diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 6bd740b..ae7e285 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,7 +1,7 @@ { - "name": "hw 6 ex3", - "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e3.log", - "expireUnixTimestamp": 1731686399, + "name": "hw 6 ex1", + "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e1.log", + "expireUnixTimestamp": 1732031999, "stage": { "sandboxExecServer": "172.17.0.1:5051", "sandboxToken": "test", @@ -9,7 +9,6 @@ "stages": [ { "name": "healthcheck", - "group": "", "executor": { "name": "sandbox", "with": { @@ -27,24 +26,15 @@ ], "stdin": { "content": "", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 419430400 }, "stdout": { "name": "stdout", - "max": 4096, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 4096 }, "stderr": { "name": "stderr", - "max": 4096, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 4096 }, "cpuLimit": 4000000000000, "realCpuLimit": 0, @@ -57,10 +47,7 @@ "copyIn": { "/tmp/repo-health-checker": { "src": "/usr/local/bin/repo-health-checker", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 419430400 } }, "copyInCached": {}, @@ -101,24 +88,15 @@ ], "stdin": { "content": "", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 419430400 }, "stdout": { "name": "stdout", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 800000000000000 }, "stderr": { "name": "stderr", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 800000000000000 }, "cpuLimit": 1000000000000000, "realCpuLimit": 0, @@ -131,10 +109,7 @@ "copyIn": { "tools/compile": { "src": "/home/tt/.config/joj/tools/compile", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 419430400 } }, "copyInCached": {}, @@ -144,10 +119,10 @@ "stderr" ], "copyOutCached": [ - "h6/build/ex3", - "h6/build/ex3-asan", - "h6/build/ex3-ubsan", - "h6/build/ex3-msan", + "h6/build/ex1", + "h6/build/ex1-asan", + "h6/build/ex1-ubsan", + "h6/build/ex1-msan", "h6/build/compile_commands.json" ], "copyOutMax": 0, @@ -210,24 +185,15 @@ ], "stdin": { "content": "", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 419430400 }, "stdout": { "name": "stdout", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 800000000000000 }, "stderr": { "name": "stderr", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 800000000000000 }, "cpuLimit": 1000000000000000, "realCpuLimit": 0, @@ -240,17 +206,14 @@ "copyIn": { "tools/filelength": { "src": "/home/tt/.config/joj/tools/filelength", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 419430400 } }, "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/ex3-asan": "h6/build/ex3-asan", - "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", - "h6/build/ex3-msan": "h6/build/ex3-msan", + "h6/build/ex1": "h6/build/ex1", + "h6/build/ex1-asan": "h6/build/ex1-asan", + "h6/build/ex1-ubsan": "h6/build/ex1-ubsan", + "h6/build/ex1-msan": "h6/build/ex1-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -331,24 +294,15 @@ ], "stdin": { "content": "", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 419430400 }, "stdout": { "name": "stdout", - "max": 65000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 65000000000000 }, "stderr": { "name": "stderr", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 800000000000000 }, "cpuLimit": 1000000000000000, "realCpuLimit": 0, @@ -361,17 +315,14 @@ "copyIn": { "projects/p2/.clang-tidy": { "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 419430400 } }, "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/ex3-asan": "h6/build/ex3-asan", - "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", - "h6/build/ex3-msan": "h6/build/ex3-msan", + "h6/build/ex1": "h6/build/ex1", + "h6/build/ex1-asan": "h6/build/ex1-asan", + "h6/build/ex1-ubsan": "h6/build/ex1-ubsan", + "h6/build/ex1-msan": "h6/build/ex1-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -479,24 +430,15 @@ ], "stdin": { "content": "", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 419430400 }, "stdout": { "name": "stdout", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 800000000000000 }, "stderr": { "name": "stderr", - "max": 65000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 65000000000000 }, "cpuLimit": 1000000000000000, "realCpuLimit": 0, @@ -508,10 +450,10 @@ "cpuSetLimit": "", "copyIn": {}, "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/ex3-asan": "h6/build/ex3-asan", - "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", - "h6/build/ex3-msan": "h6/build/ex3-msan", + "h6/build/ex1": "h6/build/ex1", + "h6/build/ex1-asan": "h6/build/ex1-asan", + "h6/build/ex1-ubsan": "h6/build/ex1-ubsan", + "h6/build/ex1-msan": "h6/build/ex1-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -595,24 +537,15 @@ ], "stdin": { "content": "", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 419430400 }, "stdout": { "name": "stdout", - "max": 65000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 65000000000000 }, "stderr": { "name": "stderr", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true + "max": 800000000000000 }, "cpuLimit": 1000000000000000, "realCpuLimit": 0, @@ -624,10 +557,10 @@ "cpuSetLimit": "", "copyIn": {}, "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/ex3-asan": "h6/build/ex3-asan", - "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", - "h6/build/ex3-msan": "h6/build/ex3-msan", + "h6/build/ex1": "h6/build/ex1", + "h6/build/ex1-asan": "h6/build/ex1-asan", + "h6/build/ex1-ubsan": "h6/build/ex1-ubsan", + "h6/build/ex1-msan": "h6/build/ex1-msan", "h6/build/compile_commands.json": "h6/build/compile_commands.json" }, "copyInDir": ".", @@ -697,663 +630,11 @@ } } ] - }, - { - "name": "[run] address sanitizer", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./h6/build/ex3-asan", - "-a" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "stdout": { - "name": "stdout", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "stderr": { - "name": "stderr", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/ex3-asan": "h6/build/ex3-asan", - "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", - "h6/build/ex3-msan": "h6/build/ex3-msan", - "h6/build/compile_commands.json": "h6/build/compile_commands.json" - }, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 1, - "comment": "", - "forceQuitOnNotAccepted": false - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "[run] memory sanitizer", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./h6/build/ex3-msan", - "-a" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "stdout": { - "name": "stdout", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "stderr": { - "name": "stderr", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/ex3-asan": "h6/build/ex3-asan", - "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", - "h6/build/ex3-msan": "h6/build/ex3-msan", - "h6/build/compile_commands.json": "h6/build/compile_commands.json" - }, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 1, - "comment": "", - "forceQuitOnNotAccepted": false - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "[run] undefined behavior sanitizer", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./h6/build/ex3-ubsan", - "-a" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "stdout": { - "name": "stdout", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "stderr": { - "name": "stderr", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/ex3-asan": "h6/build/ex3-asan", - "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", - "h6/build/ex3-msan": "h6/build/ex3-msan", - "h6/build/compile_commands.json": "h6/build/compile_commands.json" - }, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "result-status", - "with": { - "score": 1, - "comment": "", - "forceQuitOnNotAccepted": false - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] - }, - { - "name": "[joj] ex3", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./h6/build/ex3" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "stdout": { - "name": "stdout", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "stderr": { - "name": "stderr", - "max": 800000000000000, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": { - "h6/build/ex3": "h6/build/ex3", - "h6/build/ex3-asan": "h6/build/ex3-asan", - "h6/build/ex3-ubsan": "h6/build/ex3-ubsan", - "h6/build/ex3-msan": "h6/build/ex3-msan", - "h6/build/compile_commands.json": "h6/build/compile_commands.json" - }, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": [ - "Manuel", - "Charlemagne" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/paragraph.in", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 30000000000, - "clockLimit": 60000000000, - "memoryLimit": 33554432, - "procLimit": 50 - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case1.in", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 30000000000, - "clockLimit": 60000000000, - "memoryLimit": 33554432, - "procLimit": 50 - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case2.in", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 30000000000, - "clockLimit": 60000000000, - "memoryLimit": 33554432, - "procLimit": 50 - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case3.in", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 30000000000, - "clockLimit": 60000000000, - "memoryLimit": 33554432, - "procLimit": 50 - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case4.in", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 30000000000, - "clockLimit": 60000000000, - "memoryLimit": 33554432, - "procLimit": 50 - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case5.in", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 30000000000, - "clockLimit": 60000000000, - "memoryLimit": 33554432, - "procLimit": 50 - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case6.in", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 30000000000, - "clockLimit": 60000000000, - "memoryLimit": 33554432, - "procLimit": 50 - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case7.in", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 30000000000, - "clockLimit": 60000000000, - "memoryLimit": 33554432, - "procLimit": 50 - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case8.in", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 30000000000, - "clockLimit": 60000000000, - "memoryLimit": 33554432, - "procLimit": 50 - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/tests/homework/h6/e3/case9.in", - "max": 419430400, - "streamIn": true, - "streamOut": true, - "pipe": true - }, - "cpuLimit": 30000000000, - "clockLimit": 60000000000, - "memoryLimit": 33554432, - "procLimit": 50 - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case0.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case1.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case2.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case3.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 10, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 10, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case6.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case7.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case8.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case9.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": false - } - ] - } - ] - } - }, - { - "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": true, - "showMemory": true - } - } - ] } ] }, "teapot": { - "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e3-joint-teapot-debug.log", + "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e1-joint-teapot-debug.log", "scoreboardPath": "tests/homework-scoreboard.csv", "failedTablePath": "tests/homework-failed-table.md", "gradingRepoName": "engr151-joj", diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index e7b5d38..6067f21 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,15 +1,15 @@ # general task configuration -task.name = "hw 6 ex3" # task name -task.type = "tests/homework/h6/e3" +task.name = "hw 6 ex1" # task name +task.type = "tests/homework/h6/e1" -release.deadline = 2024-11-15 23:59:59+08:00 +release.deadline = 2024-11-19 23:59:59+08:00 release.stages = [ "compile" ] [[stages]] name = "Compilation" command = "./tools/compile" # eg. script running cmake commands -files.import = [ "tools/compile" ] -files.export = [ "h6/build/ex3", "h6/build/ex3-asan", "h6/build/ex3-ubsan", "h6/build/ex3-msan", "h6/build/compile_commands.json" ] +files.import = [ "tools/compile"] +files.export = [ "h6/build/ex1", "h6/build/ex1-asan", "h6/build/ex1-ubsan", "h6/build/ex1-msan", "h6/build/compile_commands.json" ] # compile parsers parsers = [ "result-detail", "dummy", "result-status" ] @@ -77,101 +77,3 @@ result-detail.stderr = true result-detail.time = false result-detail.mem = false -[[stages]] -name = "[run] address sanitizer" -group = "run" -command="./h6/build/ex3-asan -a" -files.import = [ "h6/build/ex3-asan" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true - -[[stages]] -name = "[run] memory sanitizer" -group = "run" -command="./h6/build/ex3-msan -a" -files.import = [ "h6/build/ex3-msan" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true - -[[stages]] -name = "[run] undefined behavior sanitizer" -command="./h6/build/ex3-ubsan -a" -files.import = [ "h6/build/ex3-ubsan" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true - -[[stages]] -name = "[joj] ex3" -group = "joj" -command="./h6/build/ex3" -files.import = [ "h6/build/ex3" ] -score = 10 - -parsers = [ "diff", "dummy", "result-detail" ] -result-detail.exitstatus = true -result-detail.stderr = true - -# will be removed as long as the name is fixed -case0.in = "paragraph.in" -case0.command = "Manuel Charlemagne" -case0.diff.output.score = 5 -case0.limit.cpu = 30 -case0.limit.mem = 32 -case0.limit.stdout = 8 - -case1.diff.output.score = 5 -case1.limit.cpu = 30 -case1.limit.mem = 32 -case1.limit.stdout = 8 - -case2.diff.output.score = 5 -case2.limit.cpu = 30 -case2.limit.mem = 32 -case2.limit.stdout = 8 - -case3.diff.output.score = 5 -case3.limit.cpu = 30 -case3.limit.mem = 32 -case3.limit.stdout = 8 - -case4.diff.output.score = 10 -case4.limit.cpu = 30 -case4.limit.mem = 32 -case4.limit.stdout = 8 - -case5.diff.output.score = 10 -case5.limit.cpu = 30 -case5.limit.mem = 32 -case5.limit.stdout = 8 - -case6.diff.output.score = 15 -case6.limit.cpu = 30 -case6.limit.mem = 32 -case6.limit.stdout = 8 - -case7.diff.output.score = 15 -case7.limit.cpu = 30 -case7.limit.mem = 32 -case7.limit.stdout = 8 - -case8.diff.output.score = 15 -case8.limit.cpu = 30 -case8.limit.mem = 32 -case8.limit.stdout = 8 - -case9.diff.output.score = 15 -case9.limit.cpu = 30 -case9.limit.mem = 32 -case9.limit.stdout = 8 \ No newline at end of file -- 2.30.2 From b298a2ac3a8f95fe9734f503ddadd040f8e3ea4a Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 20 Nov 2024 22:32:59 +0800 Subject: [PATCH 119/131] feat: rough distrubte json function --- joj3_config_generator/convert.py | 28 +- joj3_config_generator/main.py | 6 + joj3_config_generator/models/result.py | 4 +- joj3_config_generator/models/task.py | 6 +- joj3_config_generator/processers/task.py | 38 +- tests/convert/basic/repo.toml | 4 +- tests/convert/basic/task.json | 540 +++-------------------- tests/convert/basic/task.toml | 75 +--- tests/immutable_file/.gitignore | 4 - tests/immutable_file/push.yaml | 2 +- tests/immutable_file/release.yaml | 2 +- 11 files changed, 120 insertions(+), 589 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index b12c3ce..1e7bb87 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,4 +1,8 @@ -from typing import List +import json +import os +from typing import Any, List + +import rtoml from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.processers.repo import ( @@ -90,3 +94,25 @@ def convert_joj1(joj1_conf: joj1.Config) -> task.Config: release=task.Release(deadline=release_deadline), stages=stages, ) + + +def distribute_json(folder_path: str, repo_obj: Any) -> None: + for root, _, files in os.walk(folder_path): + for file in files: + if file.endswith(".toml"): + toml_file_path = os.path.join(root, file) + json_file_path = os.path.join(root, file.replace(".toml", ".json")) + with open(toml_file_path) as toml_file: + task_toml = toml_file.read() + task_obj = rtoml.loads(task_toml) + result_model = convert(repo.Config(**repo_obj), task.Config(**task_obj)) + result_dict = result_model.model_dump(by_alias=True, exclude_none=True) + + with open(json_file_path, "w") as result_file: + json.dump(result_dict, result_file, ensure_ascii=False, indent=4) + result_file.write("\n") + print(f"Successfully convert {toml_file_path} into json!") + assert os.path.exists( + json_file_path + ), f"Failed to convert {toml_file_path} into json!" + return 0 diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 115b9a8..cbcbf2f 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -10,6 +10,7 @@ import yaml from joj3_config_generator.convert import convert as convert_conf from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf +from joj3_config_generator.convert import distribute_json from joj3_config_generator.models import joj1, repo, task from joj3_config_generator.utils.logger import logger @@ -69,4 +70,9 @@ def convert(root: Path = Path(".")) -> Dict[str, Any]: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) result_file.write("\n") + # FIXME: change the path to the server + homework_name = "h8" + folder_path = f"/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework/{homework_name}" + assert os.path.exists(folder_path), f"there exists no {folder_path}" + distribute_json(folder_path, repo_obj) return result_dict diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index 408e51d..bf22942 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -52,7 +52,9 @@ class OptionalCmd(BaseModel): stderr: Optional[CmdFile] = None cpu_limit: Optional[int] = Field(4 * 1000000000000, serialization_alias="cpuLimit") real_cpu_limit: Optional[int] = Field(None, serialization_alias="realCpuLimit") - clock_limit: Optional[int] = Field(8 * 1000000000000, serialization_alias="clockLimit") + clock_limit: Optional[int] = Field( + 8 * 1000000000000, serialization_alias="clockLimit" + ) memory_limit: Optional[int] = Field( 800 * 1024 * 1024, serialization_alias="memoryLimit" ) diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 0dccb01..ad4f3cf 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -15,7 +15,7 @@ class ParserResultDetail(BaseModel): class ParserDummy(BaseModel): comment: Optional[str] = "" score: Optional[int] = 0 - forcequit: Optional[bool] = True + forcequit: Optional[bool] = False class ParserKeyword(BaseModel): @@ -27,7 +27,7 @@ class Outputs(BaseModel): score: Optional[int] = 0 ignorespaces: Optional[bool] = True hide: Optional[bool] = False - forcequit: Optional[bool] = True + forcequit: Optional[bool] = False class ParserDiff(BaseModel): @@ -48,6 +48,8 @@ class Limit(BaseModel): class Stage(BaseModel): name: Optional[str] = None # Stage name + group: Optional[str] = None # TODO: may need to formulate this + path: Optional[str] = None # FIXME: this is highly possible to be removed in future command: Optional[str] = None # Command to run files: Optional[Files] = None in_: Optional[str] = Field(None, alias="in") diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 0f27b3a..09a955b 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -1,5 +1,5 @@ import shlex -from typing import Tuple, List +from typing import List, Tuple from joj3_config_generator.models import result, task @@ -12,7 +12,8 @@ def get_conf_stage( # TODO: we may have cq in future group=( "joj" - if (task_stage.name is not None) and (("joj" in task_stage.name) or ("run" in task_stage.name)) + if (task_stage.name is not None) + and (("joj" in task_stage.name) or ("run" in task_stage.name)) else None ), executor=result.Executor( @@ -47,10 +48,7 @@ def get_executorWithConfig( and (task_stage.files is not None) else [] ) - copy_out_files = [ - "stdout", - "stderr" - ] + copy_out_files = ["stdout", "stderr"] executor_with_config = result.ExecutorWith( default=result.Cmd( args=( @@ -237,28 +235,19 @@ def fix_diff( if case_stage.limit and case_stage.limit.mem is not None else 0 ) - command = ( - case_stage.command - if case_stage.command is not None - else None - ) - stdin = ( - case_stage.in_ - if case_stage.in_ is not None - else f"{case}.in" - ) - stdout = ( - case_stage.out_ - if case_stage.out_ is not None - else f"{case}.out" - ) + command = case_stage.command if case_stage.command is not None else None + stdin = case_stage.in_ if case_stage.in_ is not None else f"{case}.in" + stdout = case_stage.out_ if case_stage.out_ is not None else f"{case}.out" stage_cases.append( result.OptionalCmd( stdin=result.CmdFile( - src=f"/home/tt/.config/joj/{task_conf.task.type_}/{stdin}" + # src=f"/home/tt/.config/joj/{task_conf.task.type_}/{stdin}" + src=f"/home/tt/.config/joj/{task_stage.path}/{stdin}" + ), + args=( + shlex.split(case_stage.command) if command is not None else None ), - args=shlex.split(case_stage.command) if command is not None else None, cpu_limit=cpu_limit, clock_limit=clock_limit, memory_limit=memory_limit, @@ -279,7 +268,8 @@ def fix_diff( { "score": diff_output.score, "fileName": "stdout", - "answerPath": f"/home/tt/.config/joj/{task_conf.task.type_}/{stdout}", + # "answerPath": f"/home/tt/.config/joj/{task_conf.task.type_}/{stdout}", + "answerPath": f"/home/tt/.config/joj/{task_stage.path}/{stdin}", "forceQuitOnDiff": diff_output.forcequit, "alwaysHide": diff_output.hide, "compareSpace": not diff_output.ignorespaces, diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index d815ed4..91030c2 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -6,5 +6,5 @@ sandbox_token = "test" [files] whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" -required = ["Readme.md" ] -immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] +required = ["README.md" ] +immutable = [".gitignore", ".gitattributes", ".gitea/workflows/release.yaml" ] diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index ae7e285..9de523f 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,7 +1,7 @@ { - "name": "hw 6 ex1", - "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e1.log", - "expireUnixTimestamp": 1732031999, + "name": "e2", + "logPath": "/home/tt/.cache/joj3/exam/e2.log", + "expireUnixTimestamp": 1735574399, "stage": { "sandboxExecServer": "172.17.0.1:5051", "sandboxToken": "test", @@ -17,9 +17,9 @@ "/tmp/repo-health-checker", "-root=.", "-repoSize=50.5", - "-meta=Readme.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,7300de510e1674f6d533ae799eb5395fae6d5fbe6f64ff5047480e503602a4da,ad7ba6fbee5d80e018e4190e31bd842553d540044f0faf13592d73cef93a061b", - "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml" + "-meta=README.md", + "-checkFileSumList=12e3ffc45b2cf64a83f208d982b23559ac6b73e68055ba396fe291efeec3732a,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,46b08d7120f3947261eba15fd6323561f310b4732e8528c01e0144db1ce18375", + "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/release.yaml" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" @@ -110,6 +110,22 @@ "tools/compile": { "src": "/home/tt/.config/joj/tools/compile", "max": 419430400 + }, + "h6/build/ex3-main.c": { + "src": "/home/tt/.config/joj/h6/build/ex3-main.c", + "max": 419430400 + }, + "h6/build/ex4-main.c": { + "src": "/home/tt/.config/joj/h6/build/ex4-main.c", + "max": 419430400 + }, + "h6/build/ex5-main.c": { + "src": "/home/tt/.config/joj/h6/build/ex5-main.c", + "max": 419430400 + }, + "h6/build/ex7-main.c": { + "src": "/home/tt/.config/joj/h6/build/ex7-main.c", + "max": 419430400 } }, "copyInCached": {}, @@ -119,10 +135,34 @@ "stderr" ], "copyOutCached": [ - "h6/build/ex1", - "h6/build/ex1-asan", - "h6/build/ex1-ubsan", - "h6/build/ex1-msan", + "h6/build/ex2", + "h6/build/ex2-asan", + "h6/build/ex2-ubsan", + "h6/build/ex2-msan", + "h6/build/ex3", + "h6/build/ex3-asan", + "h6/build/ex3-ubsan", + "h6/build/ex3-msan", + "h6/build/ex4", + "h6/build/ex4-asan", + "h6/build/ex4-ubsan", + "h6/build/ex4-msan", + "h6/build/ex5", + "h6/build/ex5-asan", + "h6/build/ex5-ubsan", + "h6/build/ex5-msan", + "h6/build/ex6", + "h6/build/ex6-asan", + "h6/build/ex6-ubsan", + "h6/build/ex6-msan", + "h6/build/ex7", + "h6/build/ex7-asan", + "h6/build/ex7-ubsan", + "h6/build/ex7-msan", + "h6/build/ex3-main.c", + "h6/build/ex4-main.c", + "h6/build/ex5-main.c", + "h6/build/ex7-main.c", "h6/build/compile_commands.json" ], "copyOutMax": 0, @@ -149,484 +189,12 @@ "showMemory": false } }, - { - "name": "dummy", - "with": { - "score": 0, - "comment": "Congratulations! Your code compiled successfully.", - "forceQuitOnNotAccepted": true - } - }, { "name": "result-status", "with": { "score": 0, "comment": "Congratulations! Your code compiled successfully.", - "forceQuitOnNotAccepted": true - } - } - ] - }, - { - "name": "[cq] Filelength", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./tools/filelength", - "400", - "300", - "*.c", - "*.h" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400 - }, - "stdout": { - "name": "stdout", - "max": 800000000000000 - }, - "stderr": { - "name": "stderr", - "max": 800000000000000 - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "tools/filelength": { - "src": "/home/tt/.config/joj/tools/filelength", - "max": 419430400 - } - }, - "copyInCached": { - "h6/build/ex1": "h6/build/ex1", - "h6/build/ex1-asan": "h6/build/ex1-asan", - "h6/build/ex1-ubsan": "h6/build/ex1-ubsan", - "h6/build/ex1-msan": "h6/build/ex1-msan", - "h6/build/compile_commands.json": "h6/build/compile_commands.json" - }, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "keyword", - "with": { - "matches": [ - { - "keywords": [ - "recommended" - ], - "score": 10 - }, - { - "keywords": [ - "max" - ], - "score": 20 - } - ] - } - }, - { - "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "[cq] Clang-tidy", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "run-clang-tidy-18", - "-header-filter=.*", - "-quiet", - "-load=/usr/local/lib/libcodequality.so", - "-p", - "h6/build" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400 - }, - "stdout": { - "name": "stdout", - "max": 65000000000000 - }, - "stderr": { - "name": "stderr", - "max": 800000000000000 - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": { - "projects/p2/.clang-tidy": { - "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", - "max": 419430400 - } - }, - "copyInCached": { - "h6/build/ex1": "h6/build/ex1", - "h6/build/ex1-asan": "h6/build/ex1-asan", - "h6/build/ex1-ubsan": "h6/build/ex1-ubsan", - "h6/build/ex1-msan": "h6/build/ex1-msan", - "h6/build/compile_commands.json": "h6/build/compile_commands.json" - }, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "clangtidy", - "with": { - "matches": [ - { - "keywords": [ - "readability-function-size" - ], - "score": 10 - }, - { - "keywords": [ - "codequality-no-global-variables", - "codequality-no-header-guard", - "codequality-no-fflush-stdin" - ], - "score": 20 - }, - { - "keywords": [ - "codequality-unchecked-malloc-result", - "readability-duplicate-include", - "readability-identifier-naming", - "readability-redundant", - "readability-misplaced-array-index", - "cppcoreguidelines-init-variables", - "bugprone-suspicious-string-compare", - "google-global-names-in-headers", - "clang-diagnostic", - "clang-analyzer", - "misc", - "performance", - "portability" - ], - "score": 5 - }, - { - "keywords": [ - "readability-misleading-indentation" - ], - "score": 15 - } - ] - } - }, - { - "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "[cq] Cppcheck", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cppcheck", - "--template={\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}", - "--force", - "--enable=all", - "--suppress=missingIncludeSystem", - "--quiet", - "./" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400 - }, - "stdout": { - "name": "stdout", - "max": 800000000000000 - }, - "stderr": { - "name": "stderr", - "max": 65000000000000 - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": { - "h6/build/ex1": "h6/build/ex1", - "h6/build/ex1-asan": "h6/build/ex1-asan", - "h6/build/ex1-ubsan": "h6/build/ex1-ubsan", - "h6/build/ex1-msan": "h6/build/ex1-msan", - "h6/build/compile_commands.json": "h6/build/compile_commands.json" - }, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cppcheck", - "with": { - "matches": [ - { - "keywords": [ - "warning", - "portability", - "performance", - "style" - ], - "score": 5 - }, - { - "keywords": [ - "error" - ], - "score": 15 - } - ] - } - }, - { - "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "[cq] Cpplint", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "cpplint", - "--linelength=120", - "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-runtime/int,-readability/todo,-build/include_subdir,-build/header_guard,-build/include_what_you_use", - "--recursive", - "--exclude=build", - "." - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400 - }, - "stdout": { - "name": "stdout", - "max": 65000000000000 - }, - "stderr": { - "name": "stderr", - "max": 800000000000000 - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": { - "h6/build/ex1": "h6/build/ex1", - "h6/build/ex1-asan": "h6/build/ex1-asan", - "h6/build/ex1-ubsan": "h6/build/ex1-ubsan", - "h6/build/ex1-msan": "h6/build/ex1-msan", - "h6/build/compile_commands.json": "h6/build/compile_commands.json" - }, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "cpplint", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true, - "matches": [ - { - "keywords": [ - "build" - ], - "score": 10 - }, - { - "keywords": [ - "readability" - ], - "score": 20 - }, - { - "keywords": [ - "runtime" - ], - "score": 5 - } - ] - } - }, - { - "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false + "forceQuitOnNotAccepted": false } } ] @@ -634,9 +202,9 @@ ] }, "teapot": { - "logPath": "/home/tt/.cache/joj3/tests/homework/h6/e1-joint-teapot-debug.log", - "scoreboardPath": "tests/homework-scoreboard.csv", - "failedTablePath": "tests/homework-failed-table.md", + "logPath": "/home/tt/.cache/joj3/exam/e2-joint-teapot-debug.log", + "scoreboardPath": "exam/e2-scoreboard.csv", + "failedTablePath": "exam/e2-failed-table.md", "gradingRepoName": "engr151-joj", "skipIssue": false, "skipScoreboard": false, diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 6067f21..09ce72c 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,79 +1,20 @@ # general task configuration -task.name = "hw 6 ex1" # task name -task.type = "tests/homework/h6/e1" +task.name = "e2" # task name +task.type = "exam/e2" -release.deadline = 2024-11-19 23:59:59+08:00 +release.deadline = 2024-12-30 23:59:59+08:00 release.stages = [ "compile" ] [[stages]] name = "Compilation" -command = "./tools/compile" # eg. script running cmake commands -files.import = [ "tools/compile"] -files.export = [ "h6/build/ex1", "h6/build/ex1-asan", "h6/build/ex1-ubsan", "h6/build/ex1-msan", "h6/build/compile_commands.json" ] +command = "./tools/compile" # eg. script running cmake commands +files.import = [ "tools/compile", "h6/build/ex3-main.c", "h6/build/ex4-main.c", "h6/build/ex5-main.c", "h6/build/ex7-main.c" ] +files.export = [ "h6/build/ex2", "h6/build/ex2-asan", "h6/build/ex2-ubsan", "h6/build/ex2-msan", "h6/build/ex3", "h6/build/ex3-asan", "h6/build/ex3-ubsan", "h6/build/ex3-msan", "h6/build/ex4", "h6/build/ex4-asan", "h6/build/ex4-ubsan", "h6/build/ex4-msan", "h6/build/ex5", "h6/build/ex5-asan", "h6/build/ex5-ubsan", "h6/build/ex5-msan", "h6/build/ex6", "h6/build/ex6-asan", "h6/build/ex6-ubsan", "h6/build/ex6-msan", "h6/build/ex7", "h6/build/ex7-asan", "h6/build/ex7-ubsan", "h6/build/ex7-msan", "h6/build/ex3-main.c", "h6/build/ex4-main.c", "h6/build/ex5-main.c", "h6/build/ex7-main.c", "h6/build/compile_commands.json" ] -# compile parsers -parsers = [ "result-detail", "dummy", "result-status" ] +# compile parsers ex +parsers = [ "result-detail", "result-status" ] result-status.comment = "Congratulations! Your code compiled successfully." -dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stderr = true result-detail.time = false result-detail.mem = false - -[[stages]] -name = "[cq] Filelength" -command = "./tools/filelength 400 300 *.c *.h" -files.import = [ "tools/filelength" ] - -parsers = [ "keyword", "dummy", "result-detail" ] -keyword.keyword = [ "max", "recommended"] -keyword.weight = [ 20, 10 ] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stdout = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "[cq] Clang-tidy" -command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p h6/build" -files.import = [ "projects/p2/.clang-tidy", "h6/build/compile_commands.json" ] -limit.stdout = 65 - -parsers = [ "clangtidy", "dummy", "result-detail" ] -clangtidy.keyword = [ "codequality-unchecked-malloc-result", "codequality-no-global-variables", "codequality-no-header-guard", "codequality-no-fflush-stdin", "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", "portability" ] -clangtidy.weight = [ 5, 20, 20, 20, 10, 5, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stdout = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "[cq] Cppcheck" -command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --suppress=missingIncludeSystem --quiet ./" -limit.stderr = 65 - -parsers = [ "cppcheck", "dummy", "result-detail" ] -cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] -cppcheck.weight = [15, 5, 5, 5, 5] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stderr = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "[cq] Cpplint" -command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-runtime/int,-readability/todo,-build/include_subdir,-build/header_guard,-build/include_what_you_use --recursive --exclude=build ." -limit.stdout = 65 - -parsers = [ "cpplint", "dummy", "result-detail" ] -cpplint.keyword = [ "runtime", "readability", "build" ] -cpplint.weight = [ 5, 20, 10] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stderr = true -result-detail.time = false -result-detail.mem = false - diff --git a/tests/immutable_file/.gitignore b/tests/immutable_file/.gitignore index 754f776..21a639b 100644 --- a/tests/immutable_file/.gitignore +++ b/tests/immutable_file/.gitignore @@ -10,14 +10,10 @@ !.gitignore !.gitattributes !.gitea/ -!.gitea/issue_template/ !.gitea/workflows/ !*.yaml !Makefile !CMakeLists.txt -!h[0-8]/ -!*.m !*.c -!*.cpp !*.h !*.md diff --git a/tests/immutable_file/push.yaml b/tests/immutable_file/push.yaml index 0b35d39..664f371 100644 --- a/tests/immutable_file/push.yaml +++ b/tests/immutable_file/push.yaml @@ -16,4 +16,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/tests/homework + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/tests/homework diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml index 6438234..2bc37c5 100644 --- a/tests/immutable_file/release.yaml +++ b/tests/immutable_file/release.yaml @@ -18,4 +18,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/tests/homework" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" + sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/exam" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" -- 2.30.2 From 6e3b946eb3213b339aa7892bb22beeb8d3362a64 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Mon, 25 Nov 2024 23:36:04 +0800 Subject: [PATCH 120/131] feat: actorcsvpath --- joj3_config_generator/convert.py | 2 ++ joj3_config_generator/main.py | 5 ++++- joj3_config_generator/models/result.py | 1 + joj3_config_generator/processers/task.py | 17 ++++++++++++----- tests/convert/basic/repo.toml | 2 +- tests/convert/basic/task.json | 5 +++-- tests/immutable_file/.gitignore | 4 ++++ tests/immutable_file/release.yaml | 2 +- 8 files changed, 28 insertions(+), 10 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 1e7bb87..bc9c3e9 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -30,6 +30,8 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: if task_conf.release.deadline else -1 ), + # FIXME: don't hardcode + actor_csv_path="/home/tt/.config/joj/students.csv", stage=result.Stage(stages=[], sandbox_token=repo_conf.sandbox_token), teapot=get_teapot_config(repo_conf, task_conf), ) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index cbcbf2f..691fcfd 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -72,7 +72,10 @@ def convert(root: Path = Path(".")) -> Dict[str, Any]: # FIXME: change the path to the server homework_name = "h8" - folder_path = f"/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework/{homework_name}" + # folder_path = f"/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework/{homework_name}" + folder_path = ( + "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework" + ) assert os.path.exists(folder_path), f"there exists no {folder_path}" distribute_json(folder_path, repo_obj) return result_dict diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index bf22942..d45b1a5 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -144,5 +144,6 @@ class Config(BaseModel): name: str = "unknown" log_path: str = Field("", serialization_alias="logPath") expire_unix_timestamp: int = Field(-1, serialization_alias="expireUnixTimestamp") + actor_csv_path: str = Field("", serialization_alias="actorCsvPath") stage: Stage teapot: Teapot diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 09a955b..0aa9392 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -56,8 +56,15 @@ def get_executorWithConfig( if task_stage.command is not None else [] ), + # FIXME: remove this trick copy_in={ - file: result.CmdFile(src=f"/home/tt/.config/joj/{file}") + ("./.clang-tidy" if file.endswith("clang-tidy") else file): ( + result.CmdFile(src=f"/home/tt/.config/joj/{file}") + if not file.endswith("main.cpp") + else result.CmdFile( + src=f"/home/tt/.config/joj/tests/homework/h7/e3/ex3-main.cpp" + ) + ) for file in copy_in_files }, stdin=( @@ -242,8 +249,8 @@ def fix_diff( stage_cases.append( result.OptionalCmd( stdin=result.CmdFile( - # src=f"/home/tt/.config/joj/{task_conf.task.type_}/{stdin}" - src=f"/home/tt/.config/joj/{task_stage.path}/{stdin}" + src=f"/home/tt/.config/joj/{task_conf.task.type_}/{stdin}" + # src=f"/home/tt/.config/joj/{task_stage.path}/{stdin}" ), args=( shlex.split(case_stage.command) if command is not None else None @@ -268,8 +275,8 @@ def fix_diff( { "score": diff_output.score, "fileName": "stdout", - # "answerPath": f"/home/tt/.config/joj/{task_conf.task.type_}/{stdout}", - "answerPath": f"/home/tt/.config/joj/{task_stage.path}/{stdin}", + "answerPath": f"/home/tt/.config/joj/{task_conf.task.type_}/{stdout}", + # "answerPath": f"/home/tt/.config/joj/{task_stage.path}/{stdin}", "forceQuitOnDiff": diff_output.forcequit, "alwaysHide": diff_output.hide, "compareSpace": not diff_output.ignorespaces, diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index 91030c2..1174ac2 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -7,4 +7,4 @@ sandbox_token = "test" whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" required = ["README.md" ] -immutable = [".gitignore", ".gitattributes", ".gitea/workflows/release.yaml" ] +immutable = [".gitignore", ".gitattributes",".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 9de523f..e7207de 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -2,6 +2,7 @@ "name": "e2", "logPath": "/home/tt/.cache/joj3/exam/e2.log", "expireUnixTimestamp": 1735574399, + "actorCsvPath": "/home/tt/.config/joj/students.csv", "stage": { "sandboxExecServer": "172.17.0.1:5051", "sandboxToken": "test", @@ -18,8 +19,8 @@ "-root=.", "-repoSize=50.5", "-meta=README.md", - "-checkFileSumList=12e3ffc45b2cf64a83f208d982b23559ac6b73e68055ba396fe291efeec3732a,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,46b08d7120f3947261eba15fd6323561f310b4732e8528c01e0144db1ce18375", - "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/release.yaml" + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,f6740081487ca34963a005209e2e9adfdf6f3561719af082d40fe80145e0cceb,ad7ba6fbee5d80e018e4190e31bd842553d540044f0faf13592d73cef93a061b", + "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" diff --git a/tests/immutable_file/.gitignore b/tests/immutable_file/.gitignore index 21a639b..754f776 100644 --- a/tests/immutable_file/.gitignore +++ b/tests/immutable_file/.gitignore @@ -10,10 +10,14 @@ !.gitignore !.gitattributes !.gitea/ +!.gitea/issue_template/ !.gitea/workflows/ !*.yaml !Makefile !CMakeLists.txt +!h[0-8]/ +!*.m !*.c +!*.cpp !*.h !*.md diff --git a/tests/immutable_file/release.yaml b/tests/immutable_file/release.yaml index 2bc37c5..e740403 100644 --- a/tests/immutable_file/release.yaml +++ b/tests/immutable_file/release.yaml @@ -18,4 +18,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/exam" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" + sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/tests/homework" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" -- 2.30.2 From 6538d5da9147e014ac7c1cdb32eebe5f67030cb9 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 27 Nov 2024 10:36:57 +0800 Subject: [PATCH 121/131] feat: update structure --- joj3_config_generator/models/result.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index d45b1a5..d09aa25 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -138,6 +138,8 @@ class Teapot(BaseModel): skip_issue: bool = Field(False, serialization_alias="skipIssue") skip_scoreboard: bool = Field(False, serialization_alias="skipScoreboard") skip_failed_table: bool = Field(False, serialization_alias="skipFailedTable") + max_total_score: int = Field(100, serialization_alias="maxTotalScore") + groups: List[Dict[str, Any]] = Field([{"name": "", "maxCount": 100, "timePeriodHour": 24}]) class Config(BaseModel): -- 2.30.2 From e5530ae5805565a012ac67c2c4c8a0e20cc92f96 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 27 Nov 2024 11:41:51 +0800 Subject: [PATCH 122/131] fix: get group from within [] of task name --- joj3_config_generator/processers/task.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 0aa9392..c85b610 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -1,4 +1,5 @@ import shlex +import re from typing import List, Tuple from joj3_config_generator.models import result, task @@ -9,12 +10,10 @@ def get_conf_stage( ) -> result.StageDetail: conf_stage = result.StageDetail( name=task_stage.name if task_stage.name is not None else "", - # TODO: we may have cq in future group=( - "joj" - if (task_stage.name is not None) - and (("joj" in task_stage.name) or ("run" in task_stage.name)) - else None + re.search(r'\[([^\[\]]+)\]', task_stage.name).group(1) + if (task_stage.name is not None and re.search(r'\[([^\[\]]+)\]', task_stage.name)) + else "" ), executor=result.Executor( name="sandbox", @@ -62,7 +61,7 @@ def get_executorWithConfig( result.CmdFile(src=f"/home/tt/.config/joj/{file}") if not file.endswith("main.cpp") else result.CmdFile( - src=f"/home/tt/.config/joj/tests/homework/h7/e3/ex3-main.cpp" + src=f"/home/tt/.config/joj/homework/h7/e3/ex3-main.cpp" ) ) for file in copy_in_files @@ -188,7 +187,6 @@ def fix_dummy( dummy_parser = [ "dummy", "result-status", - "cpplint", ] if task_stage.parsers is not None: for parser in task_stage.parsers: -- 2.30.2 From bbda876180ecfbf3dea5f87682ff7a7188cc73f8 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 27 Nov 2024 14:51:27 +0800 Subject: [PATCH 123/131] feat: add limitation adaptation --- joj3_config_generator/main.py | 9 ++++++--- joj3_config_generator/models/repo.py | 8 ++++++-- joj3_config_generator/processers/repo.py | 22 ++++++++++++++++++++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 691fcfd..de9ff47 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -73,9 +73,12 @@ def convert(root: Path = Path(".")) -> Dict[str, Any]: # FIXME: change the path to the server homework_name = "h8" # folder_path = f"/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework/{homework_name}" - folder_path = ( - "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework" - ) + # folder_path = ( + # "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework" + # ) + folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/homework/h7" + # for projects + folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/projects/p3/p3m1" assert os.path.exists(folder_path), f"there exists no {folder_path}" distribute_json(folder_path, repo_obj) return result_dict diff --git a/joj3_config_generator/models/repo.py b/joj3_config_generator/models/repo.py index 4befab6..46486c0 100644 --- a/joj3_config_generator/models/repo.py +++ b/joj3_config_generator/models/repo.py @@ -4,11 +4,13 @@ from pydantic import BaseModel, Field class Files(BaseModel): - whitelist_patterns: List[str] - whitelist_file: Optional[str] required: List[str] immutable: List[str] +class Group(BaseModel): + name: List[str] + max_count: List[int] + time_period_hour: List[int] class Config(BaseModel): teaching_team: List[str] @@ -16,3 +18,5 @@ class Config(BaseModel): release_tags: List[str] files: Files sandbox_token: str + max_total_score: int = Field(100) + groups : Group diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index 4af04ce..8c1aec7 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -13,6 +13,22 @@ def get_grading_repo_name() -> str: def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result.Teapot: + groups_config = [] + for group_name in repo_conf.groups.name: + groups_config.append( + { + "name": group_name, + "maxCount": 1000, + "timePeriodHour": 24, + } + ) + + for idx, max_count in enumerate(repo_conf.groups.max_count): + groups_config[idx]["maxCount"] = max_count + + for idx, time_period_hour in enumerate(repo_conf.groups.time_period_hour): + groups_config[idx]["timePeriodHour"] = time_period_hour + teapot = result.Teapot( # TODO: fix the log path log_path=f"/home/tt/.cache/joj3/{task_conf.task.type_}-joint-teapot-debug.log", @@ -28,6 +44,8 @@ def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result. else "failed-table.md" ), grading_repo_name=get_grading_repo_name(), + max_total_score=repo_conf.max_total_score, + groups=groups_config ) return teapot @@ -73,7 +91,7 @@ def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail: healthcheck_stage = result.StageDetail( name="healthcheck", - group=None, + group="", executor=result.Executor( name="sandbox", with_=result.ExecutorWith(default=get_healthcheck_cmd(repo_conf), cases=[]), @@ -95,7 +113,7 @@ def get_hash(immutable_files: list[str]) -> str: # input should be a list # FIXME: should be finalized when get into the server current_file_path = Path(__file__).resolve() project_root = current_file_path.parents[2] - file_path = f"{project_root}/tests/immutable_file/" + file_path = f"{project_root}/tests/immutable_p3-test/" immutable_hash = [] for i, file in enumerate(immutable_files): immutable_files[i] = file_path + file.rsplit("/", 1)[-1] -- 2.30.2 From 8eb0443562941910c0cd96791d1c30223fa3b3f5 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Wed, 27 Nov 2024 14:52:57 +0800 Subject: [PATCH 124/131] refactor: update toml files & chore redundant field --- tests/convert/basic/repo.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index 1174ac2..ad6cb6f 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -3,8 +3,11 @@ max_size = 50.5 release_tags = ["v1.0", "v2.0", "final"] sandbox_token = "test" +max_total_score = 100 +groups.name = ["joj", "run"] +groups.max_count = [1000, 1000] +groups.time_period_hour = [24, 24] + [files] -whitelist_patterns = ["*.py", "*.txt", "*.md"] -whitelist_file = ".whitelist" required = ["README.md" ] immutable = [".gitignore", ".gitattributes",".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] -- 2.30.2 From 1c48d9794b7b2799d8e86046fb19954f9c950481 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Tue, 3 Dec 2024 23:56:06 +0800 Subject: [PATCH 125/131] feat: add file parser construction --- joj3_config_generator/convert.py | 2 + joj3_config_generator/main.py | 13 +- joj3_config_generator/models/task.py | 4 +- joj3_config_generator/processers/repo.py | 3 + joj3_config_generator/processers/task.py | 32 ++++- tests/convert/basic/repo.toml | 12 +- tests/convert/basic/repo.toml.bak | 10 -- tests/convert/basic/task.json | 29 ++++- tests/convert/basic/task.toml | 6 +- tests/convert/basic/task.toml.bak | 137 ---------------------- tests/immutable_hteam-test/.gitattributes | 33 ++++++ tests/immutable_hteam-test/.gitignore | 23 ++++ tests/immutable_hteam-test/push.yaml | 19 +++ tests/immutable_hteam-test/release.yaml | 21 ++++ tests/immutable_hteam/.gitattributes | 33 ++++++ tests/immutable_hteam/.gitignore | 23 ++++ tests/immutable_hteam/push.yaml | 19 +++ tests/immutable_hteam/release.yaml | 21 ++++ tests/immutable_p3-test/.gitattributes | 33 ++++++ tests/immutable_p3-test/.gitignore | 29 +++++ tests/immutable_p3-test/push.yaml | 20 ++++ tests/immutable_p3-test/release.yaml | 22 ++++ tests/immutable_p3/.gitattributes | 33 ++++++ tests/immutable_p3/.gitignore | 29 +++++ tests/immutable_p3/push.yaml | 20 ++++ tests/immutable_p3/release.yaml | 22 ++++ 26 files changed, 482 insertions(+), 166 deletions(-) delete mode 100644 tests/convert/basic/repo.toml.bak delete mode 100644 tests/convert/basic/task.toml.bak create mode 100644 tests/immutable_hteam-test/.gitattributes create mode 100644 tests/immutable_hteam-test/.gitignore create mode 100644 tests/immutable_hteam-test/push.yaml create mode 100644 tests/immutable_hteam-test/release.yaml create mode 100644 tests/immutable_hteam/.gitattributes create mode 100644 tests/immutable_hteam/.gitignore create mode 100644 tests/immutable_hteam/push.yaml create mode 100644 tests/immutable_hteam/release.yaml create mode 100644 tests/immutable_p3-test/.gitattributes create mode 100644 tests/immutable_p3-test/.gitignore create mode 100644 tests/immutable_p3-test/push.yaml create mode 100644 tests/immutable_p3-test/release.yaml create mode 100644 tests/immutable_p3/.gitattributes create mode 100644 tests/immutable_p3/.gitignore create mode 100644 tests/immutable_p3/push.yaml create mode 100644 tests/immutable_p3/release.yaml diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index bc9c3e9..7ed3067 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -13,6 +13,7 @@ from joj3_config_generator.processers.task import ( fix_diff, fix_dummy, fix_keyword, + fix_file, fix_result_detail, get_conf_stage, get_executorWithConfig, @@ -47,6 +48,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: conf_stage = fix_result_detail(task_stage, conf_stage) conf_stage = fix_dummy(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) + conf_stage = fix_file(task_stage, conf_stage) conf_stage = fix_diff(task_stage, conf_stage, task_conf) result_conf.stage.stages.append(conf_stage) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index de9ff47..a0ba795 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -71,14 +71,15 @@ def convert(root: Path = Path(".")) -> Dict[str, Any]: result_file.write("\n") # FIXME: change the path to the server - homework_name = "h8" + # homework_name = "h8" # folder_path = f"/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework/{homework_name}" # folder_path = ( - # "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework" + # "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/homework/h8" # ) - folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/homework/h7" + # folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/homework/h7" # for projects - folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/projects/p3/p3m1" - assert os.path.exists(folder_path), f"there exists no {folder_path}" - distribute_json(folder_path, repo_obj) + # folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/projects/p3/p3m3" + # folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/projects/p3/p3m1" + # assert os.path.exists(folder_path), f"there exists no {folder_path}" + # distribute_json(folder_path, repo_obj) return result_dict diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index ad4f3cf..78bb8a6 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -11,6 +11,8 @@ class ParserResultDetail(BaseModel): stderr: Optional[bool] = False # Display stderr messages exitstatus: Optional[bool] = False +class ParserFile(BaseModel): + name: str = None class ParserDummy(BaseModel): comment: Optional[str] = "" @@ -62,11 +64,11 @@ class Stage(BaseModel): keyword: Optional[ParserKeyword] = ParserKeyword() clangtidy: Optional[ParserKeyword] = ParserKeyword() cppcheck: Optional[ParserKeyword] = ParserKeyword() - # FIXME: determine cpplint type cpplint: Optional[ParserKeyword] = ParserKeyword() result_detail: Optional[ParserResultDetail] = Field( ParserResultDetail(), alias="result-detail" ) + file: Optional[ParserFile] = ParserFile() skip: Optional[list[str]] = [] diff: Optional[ParserDiff] = ParserDiff() cases: Optional[Dict[str, "Stage"]] = {} diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index 8c1aec7..325d5af 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -114,6 +114,9 @@ def get_hash(immutable_files: list[str]) -> str: # input should be a list current_file_path = Path(__file__).resolve() project_root = current_file_path.parents[2] file_path = f"{project_root}/tests/immutable_p3-test/" + # file_path = f"{project_root}/tests/immutable_hteam/" + # file_path = f"{project_root}/tests/immutable_hteam-test/" + # file_path = f"{project_root}/tests/immutable_p3/" immutable_hash = [] for i, file in enumerate(immutable_files): immutable_files[i] = file_path + file.rsplit("/", 1)[-1] diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index c85b610..97ba77a 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -10,9 +10,15 @@ def get_conf_stage( ) -> result.StageDetail: conf_stage = result.StageDetail( name=task_stage.name if task_stage.name is not None else "", + # FIXME: to be deterined the way + # group=( + # re.search(r'\[([^\[\]]+)\]', task_stage.name).group(1) + # if (task_stage.name is not None and re.search(r'\[([^\[\]]+)\]', task_stage.name)) + # else "" + # ), group=( - re.search(r'\[([^\[\]]+)\]', task_stage.name).group(1) - if (task_stage.name is not None and re.search(r'\[([^\[\]]+)\]', task_stage.name)) + task_stage.group + if (task_stage.group is not None) else "" ), executor=result.Executor( @@ -61,7 +67,8 @@ def get_executorWithConfig( result.CmdFile(src=f"/home/tt/.config/joj/{file}") if not file.endswith("main.cpp") else result.CmdFile( - src=f"/home/tt/.config/joj/homework/h7/e3/ex3-main.cpp" + # src=f"/home/tt/.config/joj/homework/h7/e3/ex3-main.cpp" + src=f"/home/tt/.config/joj/homework/h8/e1/ex1-main.cpp" ) ) for file in copy_in_files @@ -142,7 +149,7 @@ def fix_keyword( else: continue - keyword_parser_.with_.update({"matches": keyword_weight}) + keyword_parser_.with_.update({"matches": keyword_weight, "fullscore": 0, "minscore": -1000, "files": ["stdout", "stderr"]}) else: continue return conf_stage @@ -206,7 +213,22 @@ def fix_dummy( continue return conf_stage - +def fix_file(task_stage: task.Stage, conf_stage: result.StageDetail) -> result.StageDetail: + file_parser = ["file"] + if task_stage.parsers is not None: + for parser in task_stage.parsers: + if parser in file_parser: + file_parser_ = next(p for p in conf_stage.parsers if p.name == parser) + if task_stage.file is not None: + file_parser_.with_.update( + { + "name": task_stage.file.name + } + ) + else: + continue + return conf_stage + def fix_diff( task_stage: task.Stage, conf_stage: result.StageDetail, task_conf: task.Config ) -> result.StageDetail: diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index ad6cb6f..1322fa1 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -4,10 +4,20 @@ release_tags = ["v1.0", "v2.0", "final"] sandbox_token = "test" max_total_score = 100 + +# for projects +#groups.name = ["build", "run"] +#groups.max_count = [8, 5] +#groups.time_period_hour = [24, 24] + + +# for tests groups.name = ["joj", "run"] groups.max_count = [1000, 1000] groups.time_period_hour = [24, 24] [files] -required = ["README.md" ] +# projects +# required = ["README.md", "Changelog.md"] +required = ["README.md"] immutable = [".gitignore", ".gitattributes",".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] diff --git a/tests/convert/basic/repo.toml.bak b/tests/convert/basic/repo.toml.bak deleted file mode 100644 index bb9818b..0000000 --- a/tests/convert/basic/repo.toml.bak +++ /dev/null @@ -1,10 +0,0 @@ -teaching_team = ["prof_john", "ta_alice", "ta_bob"] -max_size = 50.5 -release_tags = ["v1.0", "v2.0", "final"] -sandbox_token = "test" - -[files] -whitelist_patterns = ["*.py", "*.txt", "*.md"] -whitelist_file = ".whitelist" -required = [ "Changelog.md", "Readme.md" ] -immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index e7207de..e0383f2 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -10,6 +10,7 @@ "stages": [ { "name": "healthcheck", + "group": "", "executor": { "name": "sandbox", "with": { @@ -19,7 +20,7 @@ "-root=.", "-repoSize=50.5", "-meta=README.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,f6740081487ca34963a005209e2e9adfdf6f3561719af082d40fe80145e0cceb,ad7ba6fbee5d80e018e4190e31bd842553d540044f0faf13592d73cef93a061b", + "-checkFileSumList=a7bda693bf603a20b0ecf1bcdae62c7268596313e7efffcbc8a6fe393e3397b6,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,0f786177a68c4553043d0c8f8235908730249cc84c5bbbbbe0dc05fad82ac5ca,50682ce666d694d2cf11aebb3a0d0c2e2d6649562dde38fbcedff006484bf994", "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml" ], "env": [ @@ -76,7 +77,8 @@ ] }, { - "name": "Compilation", + "name": "[cq] Compilation", + "group": "", "executor": { "name": "sandbox", "with": { @@ -195,7 +197,13 @@ "with": { "score": 0, "comment": "Congratulations! Your code compiled successfully.", - "forceQuitOnNotAccepted": false + "forceQuitOnNotAccepted": true + } + }, + { + "name": "file", + "with": { + "name": "stdout" } } ] @@ -209,6 +217,19 @@ "gradingRepoName": "engr151-joj", "skipIssue": false, "skipScoreboard": false, - "skipFailedTable": false + "skipFailedTable": false, + "maxTotalScore": 100, + "groups": [ + { + "name": "joj", + "maxCount": 1000, + "timePeriodHour": 24 + }, + { + "name": "run", + "maxCount": 1000, + "timePeriodHour": 24 + } + ] } } diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 09ce72c..bc90ccb 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -6,15 +6,17 @@ release.deadline = 2024-12-30 23:59:59+08:00 release.stages = [ "compile" ] [[stages]] -name = "Compilation" +name = "[cq] Compilation" command = "./tools/compile" # eg. script running cmake commands files.import = [ "tools/compile", "h6/build/ex3-main.c", "h6/build/ex4-main.c", "h6/build/ex5-main.c", "h6/build/ex7-main.c" ] files.export = [ "h6/build/ex2", "h6/build/ex2-asan", "h6/build/ex2-ubsan", "h6/build/ex2-msan", "h6/build/ex3", "h6/build/ex3-asan", "h6/build/ex3-ubsan", "h6/build/ex3-msan", "h6/build/ex4", "h6/build/ex4-asan", "h6/build/ex4-ubsan", "h6/build/ex4-msan", "h6/build/ex5", "h6/build/ex5-asan", "h6/build/ex5-ubsan", "h6/build/ex5-msan", "h6/build/ex6", "h6/build/ex6-asan", "h6/build/ex6-ubsan", "h6/build/ex6-msan", "h6/build/ex7", "h6/build/ex7-asan", "h6/build/ex7-ubsan", "h6/build/ex7-msan", "h6/build/ex3-main.c", "h6/build/ex4-main.c", "h6/build/ex5-main.c", "h6/build/ex7-main.c", "h6/build/compile_commands.json" ] # compile parsers ex -parsers = [ "result-detail", "result-status" ] +parsers = [ "result-detail", "result-status", "file" ] result-status.comment = "Congratulations! Your code compiled successfully." result-detail.exitstatus = true result-detail.stderr = true result-detail.time = false result-detail.mem = false +result-status.forcequit = true +file.name = "stdout" diff --git a/tests/convert/basic/task.toml.bak b/tests/convert/basic/task.toml.bak deleted file mode 100644 index 118247d..0000000 --- a/tests/convert/basic/task.toml.bak +++ /dev/null @@ -1,137 +0,0 @@ -# p2 repo config - -task="p2 m3" # task name - -release.deadline = 2024-10-12 23:59:00+08:00 -release.stages = [ "compile" ] - -[files] -immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] -required = [ "Changelog.md", "Readme.md" ] - -[[stages]] -name = "Abuse of strings detected" -command = "./strdetect src/" -files.import = [ "tools/strdetec" ] - -parsers = [ "result-status" ] - - -[[stages]] -name = "Compilation" -command = "compile" -files.import = [ "tools/compile" ] -files.export = [ "build/onecard", "build/asan", "build/ubsan", "build/msan", "build/compile_commands.json" ] - -parsers = [ "result-detail", "dummy", "result-status" ] -result-status.comment = "Congratulations! Your code compiled successfully." -result-status.score = 1 -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stderr = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "[cq] Filelength" -command = "./file-length 400 300 *.c *.h" -files.import = [ "tools/filelength" ] - -parsers = [ "keyword", "dummy", "result-detail" ] -keyword.keyword = [ "max", "recommended"] -keyword.weight = [ 20, 10 ] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stdout = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "[cq] Clang-tidy" -command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" -files.import = [ "projects/p2/.clang-tidy", "build/compile_commands.json" ] -limit.stdout = 65 - -parsers = [ "clangtidy", "dummy", "result-detail" ] -clangtidy.keyword = [ "codequality-unchecked-malloc-result", "codequality-no-global-variables", "codequality-no-header-guard", "codequality-no-fflush-stdin", "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", "portability" ] -clangtidy.weight = [ 5, 20, 20, 20, 10, 5, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stdout = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "[cq] Cppcheck" -command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --suppress=missingIncludeSystem --quiet ./" -limit.stderr = 65 - -parsers = [ "cppcheck", "dummy", "result-detail" ] -cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] -cppcheck.weight = [15, 5, 5, 5, 5] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stderr = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "[cq] Cpplint" -command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard --recursive --exclude=build ." -limit.stdout = 65 - -parsers = [ "cpplint", "dummy", "result-detail" ] -cpplint.keyword = [ "runtime", "readability", "build" ] -cpplint.weight = [ 5, 20, 10] -dummy.comment = "\n\n### Details\n" -result-detail.exitstatus = true -result-detail.stderr = true -result-detail.time = false -result-detail.mem = false - -[[stages]] -name = "[run] onecard" -group = "run" -command="./onecard -a" -files.import = [ "build/onecard" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true - -[[stages]] -name = "[run] address sanitizer" -group = "run" -command="./asan -a" -files.import = [ "build/asan" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true - -[[stages]] -name = "[run] memory sanitizer" -group = "run" -command="./msan -a" -files.import = [ "build/msan" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true - -[[stages]] -name = "[run] undefined behavior sanitizer" -command="./ubsan -a" -files.import = [ "build/ubsan" ] - -parsers = [ "result-status", "result-detail" ] -result-status.score = 1 -result-status.forcequit = false -result-detail.exitstatus = true -result-detail.stderr = true diff --git a/tests/immutable_hteam-test/.gitattributes b/tests/immutable_hteam-test/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/immutable_hteam-test/.gitattributes @@ -0,0 +1,33 @@ +*.avi filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.djvu filter=lfs diff=lfs merge=lfs -text +*.doc filter=lfs diff=lfs merge=lfs -text +*.docx filter=lfs diff=lfs merge=lfs -text +*.epub filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.ipynb filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.JPEG filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.JPG filter=lfs diff=lfs merge=lfs -text +*.mkv filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.ods filter=lfs diff=lfs merge=lfs -text +*.odt filter=lfs diff=lfs merge=lfs -text +*.otf filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.PDF filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.PNG filter=lfs diff=lfs merge=lfs -text +*.ppt filter=lfs diff=lfs merge=lfs -text +*.pptx filter=lfs diff=lfs merge=lfs -text +*.ps filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text +*.xls filter=lfs diff=lfs merge=lfs -text +*.xlsx filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_hteam-test/.gitignore b/tests/immutable_hteam-test/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/immutable_hteam-test/.gitignore @@ -0,0 +1,23 @@ +################################ +## White list based gitignore ## +################################ + +# forbidden +* +.* + +# allowed +!.gitignore +!.gitattributes +!.gitea/ +!.gitea/issue_template/ +!.gitea/workflows/ +!*.yaml +!Makefile +!CMakeLists.txt +!h[0-8]/ +!*.m +!*.c +!*.cpp +!*.h +!*.md diff --git a/tests/immutable_hteam-test/push.yaml b/tests/immutable_hteam-test/push.yaml new file mode 100644 index 0000000..0b35d39 --- /dev/null +++ b/tests/immutable_hteam-test/push.yaml @@ -0,0 +1,19 @@ +name: Run JOJ3 on Push +on: [push] + +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/tests/homework diff --git a/tests/immutable_hteam-test/release.yaml b/tests/immutable_hteam-test/release.yaml new file mode 100644 index 0000000..6438234 --- /dev/null +++ b/tests/immutable_hteam-test/release.yaml @@ -0,0 +1,21 @@ +name: Run JOJ3 on Release +on: + release: + types: [published] + +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/tests/homework" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" diff --git a/tests/immutable_hteam/.gitattributes b/tests/immutable_hteam/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/immutable_hteam/.gitattributes @@ -0,0 +1,33 @@ +*.avi filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.djvu filter=lfs diff=lfs merge=lfs -text +*.doc filter=lfs diff=lfs merge=lfs -text +*.docx filter=lfs diff=lfs merge=lfs -text +*.epub filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.ipynb filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.JPEG filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.JPG filter=lfs diff=lfs merge=lfs -text +*.mkv filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.ods filter=lfs diff=lfs merge=lfs -text +*.odt filter=lfs diff=lfs merge=lfs -text +*.otf filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.PDF filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.PNG filter=lfs diff=lfs merge=lfs -text +*.ppt filter=lfs diff=lfs merge=lfs -text +*.pptx filter=lfs diff=lfs merge=lfs -text +*.ps filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text +*.xls filter=lfs diff=lfs merge=lfs -text +*.xlsx filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_hteam/.gitignore b/tests/immutable_hteam/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/immutable_hteam/.gitignore @@ -0,0 +1,23 @@ +################################ +## White list based gitignore ## +################################ + +# forbidden +* +.* + +# allowed +!.gitignore +!.gitattributes +!.gitea/ +!.gitea/issue_template/ +!.gitea/workflows/ +!*.yaml +!Makefile +!CMakeLists.txt +!h[0-8]/ +!*.m +!*.c +!*.cpp +!*.h +!*.md diff --git a/tests/immutable_hteam/push.yaml b/tests/immutable_hteam/push.yaml new file mode 100644 index 0000000..d7cd314 --- /dev/null +++ b/tests/immutable_hteam/push.yaml @@ -0,0 +1,19 @@ +name: Run JOJ3 on Push +on: [push] + +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/homework diff --git a/tests/immutable_hteam/release.yaml b/tests/immutable_hteam/release.yaml new file mode 100644 index 0000000..36ef637 --- /dev/null +++ b/tests/immutable_hteam/release.yaml @@ -0,0 +1,21 @@ +name: Run JOJ3 on Release +on: + release: + types: [published] + +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/homework" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" diff --git a/tests/immutable_p3-test/.gitattributes b/tests/immutable_p3-test/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/immutable_p3-test/.gitattributes @@ -0,0 +1,33 @@ +*.avi filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.djvu filter=lfs diff=lfs merge=lfs -text +*.doc filter=lfs diff=lfs merge=lfs -text +*.docx filter=lfs diff=lfs merge=lfs -text +*.epub filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.ipynb filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.JPEG filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.JPG filter=lfs diff=lfs merge=lfs -text +*.mkv filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.ods filter=lfs diff=lfs merge=lfs -text +*.odt filter=lfs diff=lfs merge=lfs -text +*.otf filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.PDF filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.PNG filter=lfs diff=lfs merge=lfs -text +*.ppt filter=lfs diff=lfs merge=lfs -text +*.pptx filter=lfs diff=lfs merge=lfs -text +*.ps filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text +*.xls filter=lfs diff=lfs merge=lfs -text +*.xlsx filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_p3-test/.gitignore b/tests/immutable_p3-test/.gitignore new file mode 100644 index 0000000..1ecf413 --- /dev/null +++ b/tests/immutable_p3-test/.gitignore @@ -0,0 +1,29 @@ +################################ +## White list based gitignore ## +################################ + +# forbidden +* +.* + +# allowed +!.gitignore +!.gitattributes +!.gitea/ +!.gitea/issue_template/ +!.gitea/workflows/ +!src/ +src/* +!src/ipa +!src/ipa/*.h +!src/ipa/*.cpp +!src/ipa/Makefile +!src/pms +!src/pms/*.cpp +!src/pms/*.h +!src/pms/Makefile + +!CMakeLists.txt +!Makefile +!*.md +!*.yaml diff --git a/tests/immutable_p3-test/push.yaml b/tests/immutable_p3-test/push.yaml new file mode 100644 index 0000000..ff84b08 --- /dev/null +++ b/tests/immutable_p3-test/push.yaml @@ -0,0 +1,20 @@ +name: Run JOJ3 on Push +on: [push] + +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/tests/projects/p3 + diff --git a/tests/immutable_p3-test/release.yaml b/tests/immutable_p3-test/release.yaml new file mode 100644 index 0000000..ae66cf6 --- /dev/null +++ b/tests/immutable_p3-test/release.yaml @@ -0,0 +1,22 @@ +name: Run JOJ3 on Release +on: + release: + types: [published] + +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/tests/projects/p3" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" + diff --git a/tests/immutable_p3/.gitattributes b/tests/immutable_p3/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/immutable_p3/.gitattributes @@ -0,0 +1,33 @@ +*.avi filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.djvu filter=lfs diff=lfs merge=lfs -text +*.doc filter=lfs diff=lfs merge=lfs -text +*.docx filter=lfs diff=lfs merge=lfs -text +*.epub filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.ipynb filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.JPEG filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.JPG filter=lfs diff=lfs merge=lfs -text +*.mkv filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.ods filter=lfs diff=lfs merge=lfs -text +*.odt filter=lfs diff=lfs merge=lfs -text +*.otf filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.PDF filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.PNG filter=lfs diff=lfs merge=lfs -text +*.ppt filter=lfs diff=lfs merge=lfs -text +*.pptx filter=lfs diff=lfs merge=lfs -text +*.ps filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text +*.xls filter=lfs diff=lfs merge=lfs -text +*.xlsx filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/tests/immutable_p3/.gitignore b/tests/immutable_p3/.gitignore new file mode 100644 index 0000000..1ecf413 --- /dev/null +++ b/tests/immutable_p3/.gitignore @@ -0,0 +1,29 @@ +################################ +## White list based gitignore ## +################################ + +# forbidden +* +.* + +# allowed +!.gitignore +!.gitattributes +!.gitea/ +!.gitea/issue_template/ +!.gitea/workflows/ +!src/ +src/* +!src/ipa +!src/ipa/*.h +!src/ipa/*.cpp +!src/ipa/Makefile +!src/pms +!src/pms/*.cpp +!src/pms/*.h +!src/pms/Makefile + +!CMakeLists.txt +!Makefile +!*.md +!*.yaml diff --git a/tests/immutable_p3/push.yaml b/tests/immutable_p3/push.yaml new file mode 100644 index 0000000..80eb298 --- /dev/null +++ b/tests/immutable_p3/push.yaml @@ -0,0 +1,20 @@ +name: Run JOJ3 on Push +on: [push] + +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/projects/p3 + diff --git a/tests/immutable_p3/release.yaml b/tests/immutable_p3/release.yaml new file mode 100644 index 0000000..a14f14b --- /dev/null +++ b/tests/immutable_p3/release.yaml @@ -0,0 +1,22 @@ +name: Run JOJ3 on Release +on: + release: + types: [published] + +jobs: + run: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim + volumes: + - /home/tt/.config:/home/tt/.config + - /home/tt/.cache:/home/tt/.cache + - /home/tt/.ssh:/home/tt/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: run joj3 + run: | + sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/projects/p3" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" + -- 2.30.2 From 47c46755e6fcfd80634a59ea3b39683fa7d4fd39 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 1 Feb 2025 13:22:44 +0100 Subject: [PATCH 126/131] feat: teapot stage added --- joj3_config_generator/convert.py | 4 ++- joj3_config_generator/main.py | 1 - joj3_config_generator/models/repo.py | 6 +++-- joj3_config_generator/models/result.py | 10 +++++--- joj3_config_generator/models/task.py | 2 ++ joj3_config_generator/processers/repo.py | 18 ++++++++++--- joj3_config_generator/processers/task.py | 32 +++++++++++++----------- 7 files changed, 47 insertions(+), 26 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 7ed3067..612db83 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -8,12 +8,13 @@ from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.processers.repo import ( get_healthcheck_config, get_teapot_config, + get_teapotcheck_config, ) from joj3_config_generator.processers.task import ( fix_diff, fix_dummy, - fix_keyword, fix_file, + fix_keyword, fix_result_detail, get_conf_stage, get_executorWithConfig, @@ -39,6 +40,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Construct healthcheck stage healthcheck_stage = get_healthcheck_config(repo_conf) + teapotcheck_stage = get_teapotcheck_config(repo_conf, task_conf) result_conf.stage.stages.append(healthcheck_stage) cached: List[str] = [] # Convert each stage in the task configuration diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index a0ba795..6a8b681 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -10,7 +10,6 @@ import yaml from joj3_config_generator.convert import convert as convert_conf from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf -from joj3_config_generator.convert import distribute_json from joj3_config_generator.models import joj1, repo, task from joj3_config_generator.utils.logger import logger diff --git a/joj3_config_generator/models/repo.py b/joj3_config_generator/models/repo.py index 46486c0..e0dc9cf 100644 --- a/joj3_config_generator/models/repo.py +++ b/joj3_config_generator/models/repo.py @@ -1,4 +1,4 @@ -from typing import List, Optional +from typing import List from pydantic import BaseModel, Field @@ -7,11 +7,13 @@ class Files(BaseModel): required: List[str] immutable: List[str] + class Group(BaseModel): name: List[str] max_count: List[int] time_period_hour: List[int] + class Config(BaseModel): teaching_team: List[str] max_size: float = Field(..., ge=0) @@ -19,4 +21,4 @@ class Config(BaseModel): files: Files sandbox_token: str max_total_score: int = Field(100) - groups : Group + groups: Group diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index d09aa25..9107b22 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -33,7 +33,7 @@ class Cmd(BaseModel): copy_in: Dict[str, CmdFile] = Field({}, serialization_alias="copyIn") copy_in_cached: Dict[str, str] = Field({}, serialization_alias="copyInCached") copy_in_dir: str = Field(".", serialization_alias="copyInDir") - copy_out: List[str] = Field([], serialization_alias="copyOut") + copy_out: List[str] = Field(["stdout", "stderr"], serialization_alias="copyOut") copy_out_cached: List[str] = Field([], serialization_alias="copyOutCached") copy_out_max: int = Field(0, serialization_alias="copyOutMax") copy_out_dir: str = Field("", serialization_alias="copyOutDir") @@ -68,7 +68,9 @@ class OptionalCmd(BaseModel): None, serialization_alias="copyInCached" ) copy_in_dir: Optional[str] = Field(None, serialization_alias="copyInDir") - copy_out: Optional[List[str]] = Field(None, serialization_alias="copyOut") + copy_out: Optional[List[str]] = Field( + ["stdout", "stderr"], serialization_alias="copyOut" + ) copy_out_cached: Optional[List[str]] = Field( None, serialization_alias="copyOutCached" ) @@ -139,7 +141,9 @@ class Teapot(BaseModel): skip_scoreboard: bool = Field(False, serialization_alias="skipScoreboard") skip_failed_table: bool = Field(False, serialization_alias="skipFailedTable") max_total_score: int = Field(100, serialization_alias="maxTotalScore") - groups: List[Dict[str, Any]] = Field([{"name": "", "maxCount": 100, "timePeriodHour": 24}]) + groups: List[Dict[str, Any]] = Field( + [{"name": "", "maxCount": 100, "timePeriodHour": 24}] + ) class Config(BaseModel): diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 78bb8a6..6a4dbfc 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -11,9 +11,11 @@ class ParserResultDetail(BaseModel): stderr: Optional[bool] = False # Display stderr messages exitstatus: Optional[bool] = False + class ParserFile(BaseModel): name: str = None + class ParserDummy(BaseModel): comment: Optional[str] = "" score: Optional[int] = 0 diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index 325d5af..9d2c658 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -22,13 +22,13 @@ def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result. "timePeriodHour": 24, } ) - + for idx, max_count in enumerate(repo_conf.groups.max_count): groups_config[idx]["maxCount"] = max_count - + for idx, time_period_hour in enumerate(repo_conf.groups.time_period_hour): groups_config[idx]["timePeriodHour"] = time_period_hour - + teapot = result.Teapot( # TODO: fix the log path log_path=f"/home/tt/.cache/joj3/{task_conf.task.type_}-joint-teapot-debug.log", @@ -45,7 +45,7 @@ def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result. ), grading_repo_name=get_grading_repo_name(), max_total_score=repo_conf.max_total_score, - groups=groups_config + groups=groups_config, ) return teapot @@ -88,6 +88,16 @@ def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: return cmd +def get_teapotcheck_cmd(repo_conf: repo.Config, task_conf: task.Config) -> result.Cmd: + return 0 + + +def get_teapotcheck_config( + repo_conf: repo.Config, task_conf: task.Config +) -> result.StageDetail: + return 0 + + def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail: healthcheck_stage = result.StageDetail( name="healthcheck", diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 97ba77a..9147914 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -1,5 +1,4 @@ import shlex -import re from typing import List, Tuple from joj3_config_generator.models import result, task @@ -16,11 +15,7 @@ def get_conf_stage( # if (task_stage.name is not None and re.search(r'\[([^\[\]]+)\]', task_stage.name)) # else "" # ), - group=( - task_stage.group - if (task_stage.group is not None) - else "" - ), + group=(task_stage.group if (task_stage.group is not None) else ""), executor=result.Executor( name="sandbox", with_=executor_with_config, @@ -149,7 +144,14 @@ def fix_keyword( else: continue - keyword_parser_.with_.update({"matches": keyword_weight, "fullscore": 0, "minscore": -1000, "files": ["stdout", "stderr"]}) + keyword_parser_.with_.update( + { + "matches": keyword_weight, + "fullscore": 0, + "minscore": -1000, + "files": ["stdout", "stderr"], + } + ) else: continue return conf_stage @@ -213,22 +215,22 @@ def fix_dummy( continue return conf_stage -def fix_file(task_stage: task.Stage, conf_stage: result.StageDetail) -> result.StageDetail: + +def fix_file( + task_stage: task.Stage, conf_stage: result.StageDetail +) -> result.StageDetail: file_parser = ["file"] if task_stage.parsers is not None: for parser in task_stage.parsers: if parser in file_parser: file_parser_ = next(p for p in conf_stage.parsers if p.name == parser) if task_stage.file is not None: - file_parser_.with_.update( - { - "name": task_stage.file.name - } - ) + file_parser_.with_.update({"name": task_stage.file.name}) else: continue - return conf_stage - + return conf_stage + + def fix_diff( task_stage: task.Stage, conf_stage: result.StageDetail, task_conf: task.Config ) -> result.StageDetail: -- 2.30.2 From c67dd32cf2fdf36ee5e870270ec64e80d6fe76f4 Mon Sep 17 00:00:00 2001 From: jon-lee Date: Thu, 6 Feb 2025 09:16:11 +0100 Subject: [PATCH 127/131] fix: healthcheck & update teapot poststage --- joj3_config_generator/convert.py | 15 +- joj3_config_generator/models/repo.py | 2 - joj3_config_generator/models/result.py | 30 +- joj3_config_generator/models/task.py | 14 +- joj3_config_generator/processers/repo.py | 97 +- joj3_config_generator/processers/task.py | 16 +- tests/convert/basic/repo.toml | 24 +- tests/convert/basic/task.json | 2205 +++++++++++++++++++++- tests/convert/basic/task.toml | 456 ++++- tests/immutable_hteam-test/push.yaml | 2 +- tests/immutable_hteam-test/release.yaml | 2 +- tests/immutable_hteam/push.yaml | 2 +- tests/immutable_p3-test/push.yaml | 3 +- tests/immutable_p3-test/release.yaml | 3 +- tests/immutable_p3/push.yaml | 3 +- tests/immutable_p3/release.yaml | 3 +- 16 files changed, 2702 insertions(+), 175 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 612db83..64d7d86 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -5,10 +5,10 @@ from typing import Any, List import rtoml from joj3_config_generator.models import joj1, repo, result, task -from joj3_config_generator.processers.repo import ( +from joj3_config_generator.processers.repo import ( # get_teapotcheck_config, get_healthcheck_config, get_teapot_config, - get_teapotcheck_config, + get_teapot_stage, ) from joj3_config_generator.processers.task import ( fix_diff, @@ -34,13 +34,17 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: ), # FIXME: don't hardcode actor_csv_path="/home/tt/.config/joj/students.csv", - stage=result.Stage(stages=[], sandbox_token=repo_conf.sandbox_token), + stage=result.Stage( + stages=[], + sandbox_token=repo_conf.sandbox_token, + poststages=[get_teapot_stage(repo_conf)], + ), teapot=get_teapot_config(repo_conf, task_conf), ) # Construct healthcheck stage healthcheck_stage = get_healthcheck_config(repo_conf) - teapotcheck_stage = get_teapotcheck_config(repo_conf, task_conf) + # teapotcheck_stage = get_teapotcheck_config(repo_conf, task_conf) result_conf.stage.stages.append(healthcheck_stage) cached: List[str] = [] # Convert each stage in the task configuration @@ -65,7 +69,7 @@ def convert_joj1(joj1_conf: joj1.Config) -> task.Config: # You can define a command based on language properties command = f"run {language.language}" # Assuming we don't have explicit files, we will set empty ones or default behavior - files = task.Files(import_=[], export=[]) + files = task.Files(import_=[], export=[]) # type: ignore # Score can be derived from the first case or set to a default score = 0 parsers: List[str] = [] # Define parsers if applicable @@ -121,4 +125,3 @@ def distribute_json(folder_path: str, repo_obj: Any) -> None: assert os.path.exists( json_file_path ), f"Failed to convert {toml_file_path} into json!" - return 0 diff --git a/joj3_config_generator/models/repo.py b/joj3_config_generator/models/repo.py index e0dc9cf..6dbbdde 100644 --- a/joj3_config_generator/models/repo.py +++ b/joj3_config_generator/models/repo.py @@ -15,9 +15,7 @@ class Group(BaseModel): class Config(BaseModel): - teaching_team: List[str] max_size: float = Field(..., ge=0) - release_tags: List[str] files: Files sandbox_token: str max_total_score: int = Field(100) diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index 9107b22..6106455 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -16,8 +16,8 @@ class CmdFile(BaseModel): class Cmd(BaseModel): - args: list[str] - env: list[str] = ["PATH=/usr/bin:/bin:/usr/local/bin"] + args: Optional[List[str]] = None + env: Optional[List[str]] = ["PATH=/usr/bin:/bin:/usr/local/bin"] stdin: Optional[CmdFile] = CmdFile(content="") stdout: Optional[CmdFile] = CmdFile(name="stdout", max=4 * 1024) stderr: Optional[CmdFile] = CmdFile(name="stderr", max=4 * 1024) @@ -27,12 +27,12 @@ class Cmd(BaseModel): memory_limit: int = Field(800 * 1024 * 1024, serialization_alias="memoryLimit") stack_limit: int = Field(0, serialization_alias="stackLimit") proc_limit: int = Field(50, serialization_alias="procLimit") - proc_limit: int = Field(50, serialization_alias="procLimit") cpu_rate_limit: int = Field(0, serialization_alias="cpuRateLimit") cpu_set_limit: str = Field("", serialization_alias="cpuSetLimit") copy_in: Dict[str, CmdFile] = Field({}, serialization_alias="copyIn") copy_in_cached: Dict[str, str] = Field({}, serialization_alias="copyInCached") copy_in_dir: str = Field(".", serialization_alias="copyInDir") + # reconsider this default situation copy_out: List[str] = Field(["stdout", "stderr"], serialization_alias="copyOut") copy_out_cached: List[str] = Field([], serialization_alias="copyOutCached") copy_out_max: int = Field(0, serialization_alias="copyOutMax") @@ -46,7 +46,6 @@ class Cmd(BaseModel): class OptionalCmd(BaseModel): args: Optional[list[str]] = None env: Optional[list[str]] = ["PATH=/usr/bin:/bin:/usr/local/bin"] - env: Optional[list[str]] = ["PATH=/usr/bin:/bin:/usr/local/bin"] stdin: Optional[CmdFile] = None stdout: Optional[CmdFile] = None stderr: Optional[CmdFile] = None @@ -60,7 +59,6 @@ class OptionalCmd(BaseModel): ) stack_limit: Optional[int] = Field(None, serialization_alias="stackLimit") proc_limit: Optional[int] = Field(50, serialization_alias="procLimit") - proc_limit: Optional[int] = Field(50, serialization_alias="procLimit") cpu_rate_limit: Optional[int] = Field(None, serialization_alias="cpuRateLimit") cpu_set_limit: Optional[str] = Field(None, serialization_alias="cpuSetLimit") copy_in: Optional[Dict[str, CmdFile]] = Field(None, serialization_alias="copyIn") @@ -88,14 +86,7 @@ class OptionalCmd(BaseModel): ) -class Stage(BaseModel): - name: str - group: Optional[str] = None - executor: "ExecutorConfig" - parsers: list["ParserConfig"] - - -class ExecutorWithConfig(BaseModel): +class ExecutorWith(BaseModel): default: Cmd cases: List[OptionalCmd] @@ -105,7 +96,7 @@ class Executor(BaseModel): with_: ExecutorWith = Field(..., serialization_alias="with") -class Parser(BaseModel): +class ParserConfig(BaseModel): name: str with_: Dict[str, Any] = Field(..., serialization_alias="with") @@ -114,7 +105,7 @@ class StageDetail(BaseModel): name: str group: Optional[str] = "" executor: Executor - parsers: List[Parser] + parsers: List[ParserConfig] class Stage(BaseModel): @@ -126,6 +117,8 @@ class Stage(BaseModel): "/tmp/joj3_result.json", serialization_alias="outputPath" ) # nosec: B108 stages: List[StageDetail] + prestages: Optional[List[StageDetail]] = None + poststages: List[StageDetail] class Teapot(BaseModel): @@ -147,9 +140,10 @@ class Teapot(BaseModel): class Config(BaseModel): - name: str = "unknown" + name: str = "" log_path: str = Field("", serialization_alias="logPath") expire_unix_timestamp: int = Field(-1, serialization_alias="expireUnixTimestamp") - actor_csv_path: str = Field("", serialization_alias="actorCsvPath") + actor_csv_path: str = Field("", serialization_alias="actorpostStagesCsvPath") + max_total_score: int = Field(100, serialization_alias="maxTotalScore") stage: Stage - teapot: Teapot + teapot: Teapot # FIXME: remove this diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 6a4dbfc..8226f1b 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Dict, Optional, Type +from typing import Any, Dict, List, Optional, Type from pydantic import BaseModel, Field, root_validator @@ -13,7 +13,13 @@ class ParserResultDetail(BaseModel): class ParserFile(BaseModel): - name: str = None + name: Optional[str] = None + + +class ParserLog(BaseModel): + fileName: Optional[str] = None + msg: Optional[str] = None + level: Optional[str] = None class ParserDummy(BaseModel): @@ -54,6 +60,7 @@ class Stage(BaseModel): name: Optional[str] = None # Stage name group: Optional[str] = None # TODO: may need to formulate this path: Optional[str] = None # FIXME: this is highly possible to be removed in future + env: Optional[list[str]] = None command: Optional[str] = None # Command to run files: Optional[Files] = None in_: Optional[str] = Field(None, alias="in") @@ -72,8 +79,9 @@ class Stage(BaseModel): ) file: Optional[ParserFile] = ParserFile() skip: Optional[list[str]] = [] - diff: Optional[ParserDiff] = ParserDiff() + # cases related cases: Optional[Dict[str, "Stage"]] = {} + diff: Optional[ParserDiff] = ParserDiff() class Config: extra = "allow" diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index 9d2c658..7817cd4 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -1,5 +1,6 @@ import hashlib import shlex +import socket from pathlib import Path from joj3_config_generator.models import repo, result, task @@ -7,8 +8,8 @@ from joj3_config_generator.models import repo, result, task def get_grading_repo_name() -> str: # FIXME: uncomment back when everything is ready! - host_name = "engr151" - # host_name = socket.gethostname() + # host_name = "engr151" + host_name = socket.gethostname() return f"{host_name.split('-')[0]}-joj" @@ -50,7 +51,33 @@ def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result. return teapot -def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: +def get_teapot_stage(repo_conf: repo.Config) -> result.StageDetail: + args_ = "" + args_ = ( + args_ + + f"/usr/local/bin/joint-teapot joj3-all-env /home/tt/.config/teapot/teapot.env --grading-repo-name {get_grading_repo_name()} --max-total-score {repo_conf.max_total_score}" + ) + + stage_conf = result.StageDetail( + name="teapot", + executor=result.Executor( + name="local", + with_=result.ExecutorWith( + default=result.Cmd( + args=shlex.split(args_), + env=[ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], # TODO: fix it according to the task name + ), + cases=[], + ), + ), + parsers=[result.ParserConfig(name="log", with_={"msg": "joj3 summary"})], + ) + return stage_conf + + +def get_healthcheck_args(repo_conf: repo.Config) -> str: repoSize = repo_conf.max_size immutable = repo_conf.files.immutable repo_size = f"-repoSize={str(repoSize)} " @@ -59,13 +86,13 @@ def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: for i, meta in enumerate(required_files): required_files[i] = f"-meta={meta} " - immutable_files = f"-checkFileNameList=" + immutable_files = "-checkFileNameList=" for i, name in enumerate(immutable): if i == len(immutable) - 1: immutable_files = immutable_files + name + " " else: immutable_files = immutable_files + name + "," - chore = f"/tmp/repo-health-checker -root=. " + chore = "/usr/local/bin/repo-health-checker -root=. " args = "" args = args + chore args = args + repo_size @@ -76,26 +103,25 @@ def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd: args = args + immutable_files - cmd = result.Cmd( - args=shlex.split(args), - copy_in={ - # This path is hardcoded - f"/tmp/repo-health-checker": result.CmdFile( - src="/usr/local/bin/repo-health-checker" - ) - }, + return args + + +def get_debug_args(repo_conf: repo.Config) -> str: + args = "" + args = ( + args + + f"/usr/local/bin/joint-teapot joj3-check-env /home/tt/.config/teapot/teapot.env --grading-repo-name {get_grading_repo_name()} --group-config" ) - return cmd - - -def get_teapotcheck_cmd(repo_conf: repo.Config, task_conf: task.Config) -> result.Cmd: - return 0 - - -def get_teapotcheck_config( - repo_conf: repo.Config, task_conf: task.Config -) -> result.StageDetail: - return 0 + group_config = "" + for i, name in enumerate(repo_conf.groups.name): + group_config = ( + group_config + + f"{name}={repo_conf.groups.max_count[i]}:{repo_conf.groups.time_period_hour[i]}," + ) + # default value hardcoded + group_config = group_config + "=100:24" + args = args + group_config + return args def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail: @@ -103,10 +129,24 @@ def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail: name="healthcheck", group="", executor=result.Executor( - name="sandbox", - with_=result.ExecutorWith(default=get_healthcheck_cmd(repo_conf), cases=[]), + name="local", + with_=result.ExecutorWith( + default=result.Cmd(), + cases=[ + result.OptionalCmd( + args=shlex.split(get_healthcheck_args(repo_conf)), + ), + result.OptionalCmd( + args=shlex.split(get_debug_args(repo_conf)), + env=["LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log"], + ), + ], + ), ), - parsers=[ParserConfig(name="healthcheck", with_={"score": 0, "comment": ""})], + parsers=[ + result.ParserConfig(name="healthcheck", with_={"score": 1}), + result.ParserConfig(name="debug", with_={"score": 1}), + ], ) return healthcheck_stage @@ -124,9 +164,6 @@ def get_hash(immutable_files: list[str]) -> str: # input should be a list current_file_path = Path(__file__).resolve() project_root = current_file_path.parents[2] file_path = f"{project_root}/tests/immutable_p3-test/" - # file_path = f"{project_root}/tests/immutable_hteam/" - # file_path = f"{project_root}/tests/immutable_hteam-test/" - # file_path = f"{project_root}/tests/immutable_p3/" immutable_hash = [] for i, file in enumerate(immutable_files): immutable_files[i] = file_path + file.rsplit("/", 1)[-1] diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 9147914..839e171 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -21,7 +21,10 @@ def get_conf_stage( with_=executor_with_config, ), parsers=( - [result.Parser(name=parser, with_={}) for parser in task_stage.parsers] + [ + result.ParserConfig(name=parser, with_={}) + for parser in task_stage.parsers + ] if task_stage.parsers is not None else [] ), @@ -69,7 +72,12 @@ def get_executorWithConfig( for file in copy_in_files }, stdin=( - result.CmdFile(content="") if "diff" not in task_stage.parsers else None + result.CmdFile(content="") + if ( + (task_stage.parsers is not None) + and ("diff" not in task_stage.parsers) + ) + else None ), copy_out=copy_out_files, copy_in_cached={file: file for file in cached}, @@ -274,9 +282,7 @@ def fix_diff( src=f"/home/tt/.config/joj/{task_conf.task.type_}/{stdin}" # src=f"/home/tt/.config/joj/{task_stage.path}/{stdin}" ), - args=( - shlex.split(case_stage.command) if command is not None else None - ), + args=(shlex.split(command) if command is not None else None), cpu_limit=cpu_limit, clock_limit=clock_limit, memory_limit=memory_limit, diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index 1322fa1..9ec742d 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -1,23 +1,15 @@ -teaching_team = ["prof_john", "ta_alice", "ta_bob"] -max_size = 50.5 -release_tags = ["v1.0", "v2.0", "final"] sandbox_token = "test" +# reconfigure later max_total_score = 100 - -# for projects -#groups.name = ["build", "run"] -#groups.max_count = [8, 5] -#groups.time_period_hour = [24, 24] - +max_size = 50.5 # for tests -groups.name = ["joj", "run"] -groups.max_count = [1000, 1000] -groups.time_period_hour = [24, 24] +[groups] +name = ["joj", "run"] +max_count = [1000, 1000] +time_period_hour = [24, 24] [files] -# projects -# required = ["README.md", "Changelog.md"] -required = ["README.md"] -immutable = [".gitignore", ".gitattributes",".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] +required = ["README.md", "Changelog.md"] +immutable = [".gitignore", ".gitattributes",".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml"] diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index e0383f2..5b92cf0 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,8 +1,9 @@ { - "name": "e2", - "logPath": "/home/tt/.cache/joj3/exam/e2.log", + "name": "hw7 ex2", + "logPath": "/home/tt/.cache/joj3/homework/h7/e2.log", "expireUnixTimestamp": 1735574399, - "actorCsvPath": "/home/tt/.config/joj/students.csv", + "actorpostStagesCsvPath": "/home/tt/.config/joj/students.csv", + "maxTotalScore": 100, "stage": { "sandboxExecServer": "172.17.0.1:5051", "sandboxToken": "test", @@ -12,17 +13,9 @@ "name": "healthcheck", "group": "", "executor": { - "name": "sandbox", + "name": "local", "with": { "default": { - "args": [ - "/tmp/repo-health-checker", - "-root=.", - "-repoSize=50.5", - "-meta=README.md", - "-checkFileSumList=a7bda693bf603a20b0ecf1bcdae62c7268596313e7efffcbc8a6fe393e3397b6,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,0f786177a68c4553043d0c8f8235908730249cc84c5bbbbbe0dc05fad82ac5ca,50682ce666d694d2cf11aebb3a0d0c2e2d6649562dde38fbcedff006484bf994", - "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml" - ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" ], @@ -46,15 +39,121 @@ "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", - "copyIn": { - "/tmp/repo-health-checker": { - "src": "/usr/local/bin/repo-health-checker", - "max": 419430400 - } - }, + "copyIn": {}, "copyInCached": {}, "copyInDir": ".", - "copyOut": [], + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "args": [ + "/tmp/repo-health-checker", + "-root=.", + "-repoSize=50.5", + "-meta=README.md", + "-meta=Changelog.md", + "-checkFileSumList=a7bda693bf603a20b0ecf1bcdae62c7268596313e7efffcbc8a6fe393e3397b6,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,5906153391235cc9ed094402f2c5e42d98cf3073b0a8a1f3a4af354bdfc0c9a1,064c4ed06789f31bab546f36e2d40be547b92a6e1f647f7002fdea3a2b76ad98", + "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "cpuLimit": 4000000000000, + "clockLimit": 8000000000000, + "memoryLimit": 838860800, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-check-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "Nuvole-joj", + "--group-configjoj=1000:24,run=1000:24,=100:24" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "cpuLimit": 4000000000000, + "clockLimit": 8000000000000, + "memoryLimit": 838860800, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] + } + }, + "parsers": [ + { + "name": "healthcheck", + "with": { + "score": 1 + } + }, + { + "name": "debug", + "with": { + "score": 1 + } + } + ] + }, + { + "name": "healthcheck", + "group": "", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 419430400 + }, + "stdout": { + "name": "stdout", + "max": 800000000000000 + }, + "stderr": { + "name": "stderr", + "max": 800000000000000 + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], "copyOutCached": [], "copyOutMax": 0, "copyOutDir": "", @@ -69,15 +168,16 @@ "parsers": [ { "name": "healthcheck", - "with": { - "score": 0, - "comment": "" - } + "with": {} + }, + { + "name": "debug", + "with": {} } ] }, { - "name": "[cq] Compilation", + "name": "Compilation", "group": "", "executor": { "name": "sandbox", @@ -113,22 +213,6 @@ "tools/compile": { "src": "/home/tt/.config/joj/tools/compile", "max": 419430400 - }, - "h6/build/ex3-main.c": { - "src": "/home/tt/.config/joj/h6/build/ex3-main.c", - "max": 419430400 - }, - "h6/build/ex4-main.c": { - "src": "/home/tt/.config/joj/h6/build/ex4-main.c", - "max": 419430400 - }, - "h6/build/ex5-main.c": { - "src": "/home/tt/.config/joj/h6/build/ex5-main.c", - "max": 419430400 - }, - "h6/build/ex7-main.c": { - "src": "/home/tt/.config/joj/h6/build/ex7-main.c", - "max": 419430400 } }, "copyInCached": {}, @@ -138,35 +222,11 @@ "stderr" ], "copyOutCached": [ - "h6/build/ex2", - "h6/build/ex2-asan", - "h6/build/ex2-ubsan", - "h6/build/ex2-msan", - "h6/build/ex3", - "h6/build/ex3-asan", - "h6/build/ex3-ubsan", - "h6/build/ex3-msan", - "h6/build/ex4", - "h6/build/ex4-asan", - "h6/build/ex4-ubsan", - "h6/build/ex4-msan", - "h6/build/ex5", - "h6/build/ex5-asan", - "h6/build/ex5-ubsan", - "h6/build/ex5-msan", - "h6/build/ex6", - "h6/build/ex6-asan", - "h6/build/ex6-ubsan", - "h6/build/ex6-msan", - "h6/build/ex7", - "h6/build/ex7-asan", - "h6/build/ex7-ubsan", - "h6/build/ex7-msan", - "h6/build/ex3-main.c", - "h6/build/ex4-main.c", - "h6/build/ex5-main.c", - "h6/build/ex7-main.c", - "h6/build/compile_commands.json" + "h7/build/ex2", + "h7/build/ex2-asan", + "h7/build/ex2-ubsan", + "h7/build/ex2-msan", + "h7/build/compile_commands.json" ], "copyOutMax": 0, "copyOutDir": "", @@ -199,11 +259,2006 @@ "comment": "Congratulations! Your code compiled successfully.", "forceQuitOnNotAccepted": true } + } + ] + }, + { + "name": "[cq] Filelength", + "group": "", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./tools/filelength", + "400", + "300", + "*.cpp", + "*.h" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 419430400 + }, + "stdout": { + "name": "stdout", + "max": 800000000000000 + }, + "stderr": { + "name": "stderr", + "max": 800000000000000 + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/filelength": { + "src": "/home/tt/.config/joj/tools/filelength", + "max": 419430400 + } + }, + "copyInCached": { + "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", + "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/compile_commands.json": "h7/build/compile_commands.json" + }, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "keyword", + "with": { + "matches": [ + { + "keywords": [ + "recommended" + ], + "score": 10 + }, + { + "keywords": [ + "max" + ], + "score": 20 + } + ], + "fullscore": 0, + "minscore": -1000, + "files": [ + "stdout", + "stderr" + ] + } }, { - "name": "file", + "name": "result-detail", "with": { - "name": "stdout" + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "[cq] Clang-tidy", + "group": "", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "run-clang-tidy-18", + "-header-filter=.*", + "-quiet", + "-load=/usr/local/lib/libcodequality.so", + "-p", + "h7/build", + "h7/ex2.cpp" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 419430400 + }, + "stdout": { + "name": "stdout", + "max": 65000000000000 + }, + "stderr": { + "name": "stderr", + "max": 800000000000000 + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "./.clang-tidy": { + "src": "/home/tt/.config/joj/tests/homework/h7/.clang-tidy", + "max": 419430400 + } + }, + "copyInCached": { + "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", + "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/compile_commands.json": "h7/build/compile_commands.json" + }, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "clangtidy", + "with": { + "matches": [ + { + "keywords": [ + "readability-function-size" + ], + "score": 10 + }, + { + "keywords": [ + "codequality-no-global-variables", + "codequality-no-header-guard", + "codequality-no-fflush-stdin" + ], + "score": 20 + }, + { + "keywords": [ + "codequality-unchecked-malloc-result", + "readability-duplicate-include", + "readability-identifier-naming", + "readability-redundant", + "readability-misplaced-array-index", + "cppcoreguidelines-init-variables", + "bugprone-suspicious-string-compare", + "google-global-names-in-headers", + "clang-diagnostic", + "clang-analyzer", + "misc", + "performance", + "portability" + ], + "score": 5 + }, + { + "keywords": [ + "readability-misleading-indentation" + ], + "score": 15 + } + ], + "fullscore": 0, + "minscore": -1000, + "files": [ + "stdout", + "stderr" + ] + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "[cq] Cppcheck", + "group": "", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cppcheck", + "--template={\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}", + "--force", + "--enable=all", + "--suppress=missingIncludeSystem", + "--quiet", + "h7/ex2.cpp" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 419430400 + }, + "stdout": { + "name": "stdout", + "max": 800000000000000 + }, + "stderr": { + "name": "stderr", + "max": 65000000000000 + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": { + "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", + "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/compile_commands.json": "h7/build/compile_commands.json" + }, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cppcheck", + "with": { + "matches": [ + { + "keywords": [ + "warning", + "portability", + "performance", + "style" + ], + "score": 5 + }, + { + "keywords": [ + "error" + ], + "score": 15 + } + ], + "fullscore": 0, + "minscore": -1000, + "files": [ + "stdout", + "stderr" + ] + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "[cq] Cpplint", + "group": "", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "cpplint", + "--linelength=120", + "--filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-runtime/int,-readability/todo,-build/include_subdir,-build/header_guard,-build/include_what_you_use", + "--recursive", + "--exclude=build", + "h7/ex2.cpp" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 419430400 + }, + "stdout": { + "name": "stdout", + "max": 65000000000000 + }, + "stderr": { + "name": "stderr", + "max": 800000000000000 + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": { + "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", + "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/compile_commands.json": "h7/build/compile_commands.json" + }, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "cpplint", + "with": { + "matches": [ + { + "keywords": [ + "build" + ], + "score": 10 + }, + { + "keywords": [ + "readability" + ], + "score": 20 + }, + { + "keywords": [ + "runtime" + ], + "score": 5 + } + ], + "fullscore": 0, + "minscore": -1000, + "files": [ + "stdout", + "stderr" + ] + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "[joj] ex2-asan", + "group": "run", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./h7/build/ex2-asan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdout": { + "name": "stdout", + "max": 800000000000000 + }, + "stderr": { + "name": "stderr", + "max": 800000000000000 + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 95656304705536, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": { + "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", + "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/compile_commands.json": "h7/build/compile_commands.json" + }, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case0.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case1.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case2.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case3.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case4.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case5.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case6.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case7.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case8.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case9.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case0.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case1.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case2.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case3.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case4.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case5.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case6.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case7.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case8.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case9.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + } + ] + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[joj] ex2-msan", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./h7/build/ex2-msan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdout": { + "name": "stdout", + "max": 800000000000000 + }, + "stderr": { + "name": "stderr", + "max": 800000000000000 + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 95656304705536, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": { + "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", + "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/compile_commands.json": "h7/build/compile_commands.json" + }, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case0.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case1.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case2.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case3.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case4.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case5.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case6.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case7.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case8.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case9.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case0.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case1.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case2.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case3.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case4.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case5.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case6.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case7.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case8.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case9.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + } + ] + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[joj] ex2-ubsan", + "group": "", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./h7/build/ex2-ubsan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdout": { + "name": "stdout", + "max": 800000000000000 + }, + "stderr": { + "name": "stderr", + "max": 800000000000000 + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": { + "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", + "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/compile_commands.json": "h7/build/compile_commands.json" + }, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case0.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case1.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case2.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case3.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case4.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case5.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case6.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case7.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case8.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case9.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case0.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case1.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case2.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case3.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case4.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case5.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case6.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case7.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case8.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case9.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + } + ] + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[joj] ex2", + "group": "joj", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./h7/build/ex2" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdout": { + "name": "stdout", + "max": 800000000000000 + }, + "stderr": { + "name": "stderr", + "max": 800000000000000 + }, + "cpuLimit": 1000000000000000, + "realCpuLimit": 0, + "clockLimit": 2000000000000000, + "memoryLimit": 838860800, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": { + "h7/build/ex2": "h7/build/ex2", + "h7/build/ex2-asan": "h7/build/ex2-asan", + "h7/build/ex2-ubsan": "h7/build/ex2-ubsan", + "h7/build/ex2-msan": "h7/build/ex2-msan", + "h7/build/compile_commands.json": "h7/build/compile_commands.json" + }, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [ + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case0.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case1.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case2.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case3.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case4.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case5.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case6.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case7.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case8.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/tt/.config/joj/homework/h7/e2/case9.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] + } + }, + "parsers": [ + { + "name": "diff", + "with": { + "name": "diff", + "cases": [ + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case0.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case1.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case2.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case3.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case4.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case5.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case6.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case7.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case8.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/tt/.config/joj/homework/h7/e2/case9.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + } + ] + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + } + ], + "poststages": [ + { + "name": "teapot", + "group": "", + "executor": { + "name": "local", + "with": { + "default": { + "args": [ + "/usr/local/bin/joint-teapot", + "joj3-all-env", + "/home/tt/.config/teapot/teapot.env", + "--grading-repo-name", + "Nuvole-joj", + "--max-total-score", + "100" + ], + "env": [ + "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + ], + "stdin": { + "content": "", + "max": 419430400 + }, + "stdout": { + "name": "stdout", + "max": 4096 + }, + "stderr": { + "name": "stderr", + "max": 4096 + }, + "cpuLimit": 4000000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000000, + "memoryLimit": 838860800, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [ + "stdout", + "stderr" + ], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "log", + "with": { + "msg": "joj3 summary" } } ] @@ -211,10 +2266,10 @@ ] }, "teapot": { - "logPath": "/home/tt/.cache/joj3/exam/e2-joint-teapot-debug.log", - "scoreboardPath": "exam/e2-scoreboard.csv", - "failedTablePath": "exam/e2-failed-table.md", - "gradingRepoName": "engr151-joj", + "logPath": "/home/tt/.cache/joj3/homework/h7/e2-joint-teapot-debug.log", + "scoreboardPath": "homework/h7-scoreboard.csv", + "failedTablePath": "homework/h7-failed-table.md", + "gradingRepoName": "Nuvole-joj", "skipIssue": false, "skipScoreboard": false, "skipFailedTable": false, diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index bc90ccb..3c088ed 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,22 +1,460 @@ # general task configuration -task.name = "e2" # task name -task.type = "exam/e2" +task.name = "hw7 ex2" # task name +task.type = "homework/h7/e2" release.deadline = 2024-12-30 23:59:59+08:00 release.stages = [ "compile" ] [[stages]] -name = "[cq] Compilation" -command = "./tools/compile" # eg. script running cmake commands -files.import = [ "tools/compile", "h6/build/ex3-main.c", "h6/build/ex4-main.c", "h6/build/ex5-main.c", "h6/build/ex7-main.c" ] -files.export = [ "h6/build/ex2", "h6/build/ex2-asan", "h6/build/ex2-ubsan", "h6/build/ex2-msan", "h6/build/ex3", "h6/build/ex3-asan", "h6/build/ex3-ubsan", "h6/build/ex3-msan", "h6/build/ex4", "h6/build/ex4-asan", "h6/build/ex4-ubsan", "h6/build/ex4-msan", "h6/build/ex5", "h6/build/ex5-asan", "h6/build/ex5-ubsan", "h6/build/ex5-msan", "h6/build/ex6", "h6/build/ex6-asan", "h6/build/ex6-ubsan", "h6/build/ex6-msan", "h6/build/ex7", "h6/build/ex7-asan", "h6/build/ex7-ubsan", "h6/build/ex7-msan", "h6/build/ex3-main.c", "h6/build/ex4-main.c", "h6/build/ex5-main.c", "h6/build/ex7-main.c", "h6/build/compile_commands.json" ] +name = "healthcheck" +score = 1 -# compile parsers ex -parsers = [ "result-detail", "result-status", "file" ] +# healthcheck parsers +parsers = ["healthcheck", "debug"] +cases0.command = "/usr/local/bin/repo-health-checker -repoSize=100" +case1.command = """/usr/local/bin/joint-teapot + joj3-check-env + /home/tt/.config/teapot/teapot.env" + --grading-repo-name + JOJ3-actions-examples + --group-config + joj=50:24,=100:24""" +case1.env = ["LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log"] + +[[stages]] +name = "Compilation" +command = "./tools/compile" # eg. script running cmake commands +files.import = [ "tools/compile" ] +files.export = [ "h7/build/ex2", "h7/build/ex2-asan", "h7/build/ex2-ubsan", "h7/build/ex2-msan", "h7/build/compile_commands.json" ] +score = 1 + +# compile parsers +parsers = [ "result-detail", "result-status" ] result-status.comment = "Congratulations! Your code compiled successfully." result-detail.exitstatus = true result-detail.stderr = true result-detail.time = false result-detail.mem = false result-status.forcequit = true -file.name = "stdout" + +[[stages]] +name = "[cq] Filelength" +command = "./tools/filelength 400 300 *.cpp *.h" +files.import = [ "tools/filelength" ] + +parsers = [ "keyword", "result-detail" ] +keyword.keyword = [ "max", "recommended"] +keyword.weight = [ 20, 10 ] +result-detail.exitstatus = true +result-detail.stdout = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[cq] Clang-tidy" +command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p h7/build h7/ex2.cpp" +files.import = [ "tests/homework/h7/.clang-tidy", "h7/build/compile_commands.json" ] +limit.stdout = 65 + +parsers = [ "clangtidy", "result-detail" ] +clangtidy.keyword = [ "codequality-unchecked-malloc-result", "codequality-no-global-variables", "codequality-no-header-guard", "codequality-no-fflush-stdin", "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", "portability" ] +clangtidy.weight = [ 5, 20, 20, 20, 10, 5, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5] +result-detail.exitstatus = true +result-detail.stdout = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[cq] Cppcheck" +command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --suppress=missingIncludeSystem --quiet h7/ex2.cpp" +limit.stderr = 65 + +parsers = [ "cppcheck", "result-detail" ] +cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] +cppcheck.weight = [15, 5, 5, 5, 5] +result-detail.exitstatus = true +result-detail.stderr = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[cq] Cpplint" +command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-runtime/int,-readability/todo,-build/include_subdir,-build/header_guard,-build/include_what_you_use --recursive --exclude=build h7/ex2.cpp" +limit.stdout = 65 + +parsers = [ "cpplint", "result-detail" ] +cpplint.keyword = [ "runtime", "readability", "build" ] +cpplint.weight = [ 5, 20, 10] +result-detail.exitstatus = true +result-detail.stderr = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[joj] ex2-asan" +group = "run" +command="./h7/build/ex2-asan -a" +files.import = [ "h7/build/ex2-asan" ] +limit.mem = 91224961 + +parsers = [ "diff", "result-detail" ] +result-detail.exitstatus = true +result-detail.stderr = true + +# will be removed as long as the name is fixed +case0.diff.output.score = 5 +case0.limit.cpu = 1 +case0.limit.mem = 91224961 +case0.diff.output.ignorespaces = true +#case0.limit.stdout = 8 +#case0.command = "./h7/build/ex2" +case0.in = "case0.in" + +case1.diff.output.score = 5 +case1.limit.cpu = 1 +case1.limit.mem = 91224961 +case1.diff.output.ignorespaces = true +#case1.limit.stdout = 8 +#case1.command = "./h7/build/ex2" +case1.in = "case1.in" + +case2.diff.output.score = 5 +case2.limit.cpu = 1 +case2.limit.mem = 91224961 +case2.diff.output.ignorespaces = true +#case2.limit.stdout = 8 +#case2.command = "./h7/build/ex2" +case2.in = "case2.in" + +case3.diff.output.score = 5 +case3.limit.cpu = 1 +case3.limit.mem = 91224961 +case3.diff.output.ignorespaces = true +#case3.limit.stdout = 8 +#case3.command = "./h7/build/ex2" +case3.in = "case3.in" + +case4.diff.output.score = 10 +case4.limit.cpu = 1 +case4.limit.mem = 91224961 +case4.diff.output.ignorespaces = true +#case4.limit.stdout = 8 +#case4.command = "./h7/build/ex2" +case4.in = "case4.in" + +case5.diff.output.score = 10 +case5.limit.cpu = 1 +case5.limit.mem = 91224961 +case5.diff.output.ignorespaces = true +#case5.limit.stdout = 8 +#case5.command = "./h7/build/ex2" +case5.in = "case5.in" + +case6.diff.output.score = 15 +case6.limit.cpu = 1 +case6.limit.mem = 91224961 +case6.diff.output.ignorespaces = true +#case6.limit.stdout = 8 +#case6.command = "./h7/build/ex2" +case6.in = "case6.in" + +case7.diff.output.score = 15 +case7.limit.cpu = 1 +case7.limit.mem = 91224961 +case7.diff.output.ignorespaces = true +#case7.limit.stdout = 8 +#case7.command = "./h7/build/ex2" +case7.in = "case7.in" + +case8.diff.output.score = 15 +case8.limit.cpu = 1 +case8.limit.mem = 91224961 +case8.diff.output.ignorespaces = true +#case8.limit.stdout = 8 +#case8.command = "./h7/build/ex2" +case8.in = "case8.in" + +case9.diff.output.score = 15 +case9.limit.cpu = 1 +case9.limit.mem = 91224961 +case9.diff.output.ignorespaces = true +#case9.limit.stdout = 8 +#case9.command = "./h7/build/ex2" +case9.in = "case9.in" + +[[stages]] +name = "[joj] ex2-msan" +group = "joj" +command="./h7/build/ex2-msan -a" +files.import = [ "h7/build/ex2-msan" ] +limit.mem = 91224961 + +parsers = [ "diff", "result-detail" ] +result-detail.exitstatus = true +result-detail.stderr = true + +# will be removed as long as the name is fixed +case0.diff.output.score = 5 +case0.limit.cpu = 1 +case0.limit.mem = 91224961 +case0.diff.output.ignorespaces = true +#case0.limit.stdout = 8 +#case0.command = "./h7/build/ex2" +case0.in = "case0.in" + +case1.diff.output.score = 5 +case1.limit.cpu = 1 +case1.limit.mem = 91224961 +case1.diff.output.ignorespaces = true +#case1.limit.stdout = 8 +#case1.command = "./h7/build/ex2" +case1.in = "case1.in" + +case2.diff.output.score = 5 +case2.limit.cpu = 1 +case2.limit.mem = 91224961 +case2.diff.output.ignorespaces = true +#case2.limit.stdout = 8 +#case2.command = "./h7/build/ex2" +case2.in = "case2.in" + +case3.diff.output.score = 5 +case3.limit.cpu = 1 +case3.limit.mem = 91224961 +case3.diff.output.ignorespaces = true +#case3.limit.stdout = 8 +#case3.command = "./h7/build/ex2" +case3.in = "case3.in" + +case4.diff.output.score = 10 +case4.limit.cpu = 1 +case4.limit.mem = 91224961 +case4.diff.output.ignorespaces = true +#case4.limit.stdout = 8 +#case4.command = "./h7/build/ex2" +case4.in = "case4.in" + +case5.diff.output.score = 10 +case5.limit.cpu = 1 +case5.limit.mem = 91224961 +case5.diff.output.ignorespaces = true +#case5.limit.stdout = 8 +#case5.command = "./h7/build/ex2" +case5.in = "case5.in" + +case6.diff.output.score = 15 +case6.limit.cpu = 1 +case6.limit.mem = 91224961 +case6.diff.output.ignorespaces = true +#case6.limit.stdout = 8 +#case6.command = "./h7/build/ex2" +case6.in = "case6.in" + +case7.diff.output.score = 15 +case7.limit.cpu = 1 +case7.limit.mem = 91224961 +case7.diff.output.ignorespaces = true +#case7.limit.stdout = 8 +#case7.command = "./h7/build/ex2" +case7.in = "case7.in" + +case8.diff.output.score = 15 +case8.limit.cpu = 1 +case8.limit.mem = 91224961 +case8.diff.output.ignorespaces = true +#case8.limit.stdout = 8 +#case8.command = "./h7/build/ex2" +case8.in = "case8.in" + +case9.diff.output.score = 15 +case9.limit.cpu = 1 +case9.limit.mem = 91224961 +case9.diff.output.ignorespaces = true +#case9.limit.stdout = 8 +#case9.command = "./h7/build/ex2" +case9.in = "case9.in" + + +[[stages]] +name = "[joj] ex2-ubsan" +command="./h7/build/ex2-ubsan -a" +files.import = [ "h7/build/ex2-ubsan" ] + +parsers = [ "diff", "result-detail" ] +result-detail.exitstatus = true +result-detail.stderr = true + +# will be removed as long as the name is fixed +case0.diff.output.score = 5 +case0.limit.cpu = 1 +case0.limit.mem = 91224961 +case0.diff.output.ignorespaces = true +#case0.limit.stdout = 8 +#case0.command = "./h7/build/ex2" +case0.in = "case0.in" + +case1.diff.output.score = 5 +case1.limit.cpu = 1 +case1.limit.mem = 91224961 +case1.diff.output.ignorespaces = true +#case1.limit.stdout = 8 +#case1.command = "./h7/build/ex2" +case1.in = "case1.in" + +case2.diff.output.score = 5 +case2.limit.cpu = 1 +case2.limit.mem = 91224961 +case2.diff.output.ignorespaces = true +#case2.limit.stdout = 8 +#case2.command = "./h7/build/ex2" +case2.in = "case2.in" + +case3.diff.output.score = 5 +case3.limit.cpu = 1 +case3.limit.mem = 91224961 +case3.diff.output.ignorespaces = true +#case3.limit.stdout = 8 +#case3.command = "./h7/build/ex2" +case3.in = "case3.in" + +case4.diff.output.score = 10 +case4.limit.cpu = 1 +case4.limit.mem = 91224961 +case4.diff.output.ignorespaces = true +#case4.limit.stdout = 8 +#case4.command = "./h7/build/ex2" +case4.in = "case4.in" + +case5.diff.output.score = 10 +case5.limit.cpu = 1 +case5.limit.mem = 91224961 +case5.diff.output.ignorespaces = true +#case5.limit.stdout = 8 +#case5.command = "./h7/build/ex2" +case5.in = "case5.in" + +case6.diff.output.score = 15 +case6.limit.cpu = 1 +case6.limit.mem = 91224961 +case6.diff.output.ignorespaces = true +#case6.limit.stdout = 8 +#case6.command = "./h7/build/ex2" +case6.in = "case6.in" + +case7.diff.output.score = 15 +case7.limit.cpu = 1 +case7.limit.mem = 91224961 +case7.diff.output.ignorespaces = true +#case7.limit.stdout = 8 +#case7.command = "./h7/build/ex2" +case7.in = "case7.in" + +case8.diff.output.score = 15 +case8.limit.cpu = 1 +case8.limit.mem = 91224961 +case8.diff.output.ignorespaces = true +#case8.limit.stdout = 8 +#case8.command = "./h7/build/ex2" +case8.in = "case8.in" + +case9.diff.output.score = 15 +case9.limit.cpu = 1 +case9.limit.mem = 91224961 +case9.diff.output.ignorespaces = true +#case9.limit.stdout = 8 +#case9.command = "./h7/build/ex2" +case9.in = "case9.in" + + +[[stages]] +name = "[joj] ex2" +group = "joj" +command="./h7/build/ex2" +files.import = [ "h7/build/ex2" ] +score = 10 + +parsers = [ "diff", "result-detail" ] +result-detail.exitstatus = true +result-detail.stderr = true +result-status.forcequit = true + +# will be removed as long as the name is fixed +case0.diff.output.score = 5 +case0.limit.cpu = 1 +case0.limit.mem = 91224961 +case0.diff.output.ignorespaces = true +#case0.limit.stdout = 8 +#case0.command = "./h7/build/ex2" +case0.in = "case0.in" + +case1.diff.output.score = 5 +case1.limit.cpu = 1 +case1.limit.mem = 91224961 +case1.diff.output.ignorespaces = true +#case1.limit.stdout = 8 +#case1.command = "./h7/build/ex2" +case1.in = "case1.in" + +case2.diff.output.score = 5 +case2.limit.cpu = 1 +case2.limit.mem = 91224961 +case2.diff.output.ignorespaces = true +#case2.limit.stdout = 8 +#case2.command = "./h7/build/ex2" +case2.in = "case2.in" + +case3.diff.output.score = 5 +case3.limit.cpu = 1 +case3.limit.mem = 91224961 +case3.diff.output.ignorespaces = true +#case3.limit.stdout = 8 +#case3.command = "./h7/build/ex2" +case3.in = "case3.in" + +case4.diff.output.score = 10 +case4.limit.cpu = 1 +case4.limit.mem = 91224961 +case4.diff.output.ignorespaces = true +#case4.limit.stdout = 8 +#case4.command = "./h7/build/ex2" +case4.in = "case4.in" + +case5.diff.output.score = 10 +case5.limit.cpu = 1 +case5.limit.mem = 91224961 +case5.diff.output.ignorespaces = true +#case5.limit.stdout = 8 +#case5.command = "./h7/build/ex2" +case5.in = "case5.in" + +case6.diff.output.score = 15 +case6.limit.cpu = 1 +case6.limit.mem = 91224961 +case6.diff.output.ignorespaces = true +#case6.limit.stdout = 8 +#case6.command = "./h7/build/ex2" +case6.in = "case6.in" + +case7.diff.output.score = 15 +case7.limit.cpu = 1 +case7.limit.mem = 91224961 +case7.diff.output.ignorespaces = true +#case7.limit.stdout = 8 +#case7.command = "./h7/build/ex2" +case7.in = "case7.in" + +case8.diff.output.score = 15 +case8.limit.cpu = 1 +case8.limit.mem = 91224961 +case8.diff.output.ignorespaces = true +#case8.limit.stdout = 8 +#case8.command = "./h7/build/ex2" +case8.in = "case8.in" + +case9.diff.output.score = 15 +case9.limit.cpu = 1 +case9.limit.mem = 91224961 +case9.diff.output.ignorespaces = true +#case9.limit.stdout = 8 +#case9.command = "./h7/build/ex2" +case9.in = "case9.in" diff --git a/tests/immutable_hteam-test/push.yaml b/tests/immutable_hteam-test/push.yaml index 0b35d39..664f371 100644 --- a/tests/immutable_hteam-test/push.yaml +++ b/tests/immutable_hteam-test/push.yaml @@ -16,4 +16,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/tests/homework + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/tests/homework diff --git a/tests/immutable_hteam-test/release.yaml b/tests/immutable_hteam-test/release.yaml index 6438234..e740403 100644 --- a/tests/immutable_hteam-test/release.yaml +++ b/tests/immutable_hteam-test/release.yaml @@ -18,4 +18,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/tests/homework" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" + sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/tests/homework" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" diff --git a/tests/immutable_hteam/push.yaml b/tests/immutable_hteam/push.yaml index d7cd314..79eb2f4 100644 --- a/tests/immutable_hteam/push.yaml +++ b/tests/immutable_hteam/push.yaml @@ -16,4 +16,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/homework + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/homework diff --git a/tests/immutable_p3-test/push.yaml b/tests/immutable_p3-test/push.yaml index ff84b08..79d58e4 100644 --- a/tests/immutable_p3-test/push.yaml +++ b/tests/immutable_p3-test/push.yaml @@ -16,5 +16,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/tests/projects/p3 - + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/tests/projects/p3 diff --git a/tests/immutable_p3-test/release.yaml b/tests/immutable_p3-test/release.yaml index ae66cf6..213c226 100644 --- a/tests/immutable_p3-test/release.yaml +++ b/tests/immutable_p3-test/release.yaml @@ -18,5 +18,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/tests/projects/p3" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" - + sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/tests/projects/p3" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" diff --git a/tests/immutable_p3/push.yaml b/tests/immutable_p3/push.yaml index 80eb298..60d4082 100644 --- a/tests/immutable_p3/push.yaml +++ b/tests/immutable_p3/push.yaml @@ -16,5 +16,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/projects/p3 - + sudo -E -u tt joj3 -conf-root /home/tt/.config/joj/projects/p3 diff --git a/tests/immutable_p3/release.yaml b/tests/immutable_p3/release.yaml index a14f14b..ff2ff1d 100644 --- a/tests/immutable_p3/release.yaml +++ b/tests/immutable_p3/release.yaml @@ -18,5 +18,4 @@ jobs: fetch-depth: 0 - name: run joj3 run: | - sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/projects/p3" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" - + sudo -E -u tt joj3 -conf-root "/home/tt/.config/joj/projects/p3" -conf-name "conf-release.json" -tag "${{ github.ref_name }}" -- 2.30.2 From 9f3d820ae3d779e034cc7aed3d010922443e55f8 Mon Sep 17 00:00:00 2001 From: jon-lee Date: Thu, 6 Feb 2025 09:32:40 +0100 Subject: [PATCH 128/131] refactor: remove redundant teapot config code --- tests/convert/basic/task.json | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 5b92cf0..b871b7d 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -57,7 +57,7 @@ "cases": [ { "args": [ - "/tmp/repo-health-checker", + "/usr/local/bin/repo-health-checker", "-root=.", "-repoSize=50.5", "-meta=README.md", @@ -2264,27 +2264,5 @@ ] } ] - }, - "teapot": { - "logPath": "/home/tt/.cache/joj3/homework/h7/e2-joint-teapot-debug.log", - "scoreboardPath": "homework/h7-scoreboard.csv", - "failedTablePath": "homework/h7-failed-table.md", - "gradingRepoName": "Nuvole-joj", - "skipIssue": false, - "skipScoreboard": false, - "skipFailedTable": false, - "maxTotalScore": 100, - "groups": [ - { - "name": "joj", - "maxCount": 1000, - "timePeriodHour": 24 - }, - { - "name": "run", - "maxCount": 1000, - "timePeriodHour": 24 - } - ] } } -- 2.30.2 From 84e6f67f833570b482d9a128f37be4e368a8df25 Mon Sep 17 00:00:00 2001 From: jon-lee Date: Thu, 6 Feb 2025 10:16:22 +0100 Subject: [PATCH 129/131] refactor: remove redundant teapot config code --- joj3_config_generator/convert.py | 2 -- joj3_config_generator/models/result.py | 21 +------------ joj3_config_generator/processers/repo.py | 40 +----------------------- joj3_config_generator/processers/task.py | 2 +- tests/convert/basic/task.json | 2 +- 5 files changed, 4 insertions(+), 63 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 64d7d86..280c4c6 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -7,7 +7,6 @@ import rtoml from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.processers.repo import ( # get_teapotcheck_config, get_healthcheck_config, - get_teapot_config, get_teapot_stage, ) from joj3_config_generator.processers.task import ( @@ -39,7 +38,6 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: sandbox_token=repo_conf.sandbox_token, poststages=[get_teapot_stage(repo_conf)], ), - teapot=get_teapot_config(repo_conf, task_conf), ) # Construct healthcheck stage diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index 6106455..7cd49cf 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -121,29 +121,10 @@ class Stage(BaseModel): poststages: List[StageDetail] -class Teapot(BaseModel): - log_path: str = Field( - "/home/tt/.cache/joint-teapot-debug.log", serialization_alias="logPath" - ) - scoreboard_path: str = Field("scoreboard.csv", serialization_alias="scoreboardPath") - failed_table_path: str = Field( - "failed-table.md", serialization_alias="failedTablePath" - ) - grading_repo_name: str = Field("", serialization_alias="gradingRepoName") - skip_issue: bool = Field(False, serialization_alias="skipIssue") - skip_scoreboard: bool = Field(False, serialization_alias="skipScoreboard") - skip_failed_table: bool = Field(False, serialization_alias="skipFailedTable") - max_total_score: int = Field(100, serialization_alias="maxTotalScore") - groups: List[Dict[str, Any]] = Field( - [{"name": "", "maxCount": 100, "timePeriodHour": 24}] - ) - - class Config(BaseModel): name: str = "" log_path: str = Field("", serialization_alias="logPath") expire_unix_timestamp: int = Field(-1, serialization_alias="expireUnixTimestamp") - actor_csv_path: str = Field("", serialization_alias="actorpostStagesCsvPath") + actor_csv_path: str = Field("", serialization_alias="actorCsvPath") max_total_score: int = Field(100, serialization_alias="maxTotalScore") stage: Stage - teapot: Teapot # FIXME: remove this diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index 7817cd4..4530006 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -3,7 +3,7 @@ import shlex import socket from pathlib import Path -from joj3_config_generator.models import repo, result, task +from joj3_config_generator.models import repo, result def get_grading_repo_name() -> str: @@ -13,44 +13,6 @@ def get_grading_repo_name() -> str: return f"{host_name.split('-')[0]}-joj" -def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result.Teapot: - groups_config = [] - for group_name in repo_conf.groups.name: - groups_config.append( - { - "name": group_name, - "maxCount": 1000, - "timePeriodHour": 24, - } - ) - - for idx, max_count in enumerate(repo_conf.groups.max_count): - groups_config[idx]["maxCount"] = max_count - - for idx, time_period_hour in enumerate(repo_conf.groups.time_period_hour): - groups_config[idx]["timePeriodHour"] = time_period_hour - - teapot = result.Teapot( - # TODO: fix the log path - log_path=f"/home/tt/.cache/joj3/{task_conf.task.type_}-joint-teapot-debug.log", - # FIXME: may need to fix the path below - scoreboard_path=( - f"{task_conf.task.type_.split("/")[0]}/{task_conf.task.type_.split("/")[1]}-scoreboard.csv" - if task_conf.task.type_ is not None - else "scoreboard.csv" - ), - failed_table_path=( - f"{task_conf.task.type_.split("/")[0]}/{task_conf.task.type_.split("/")[1]}-failed-table.md" - if task_conf.task.type_ is not None - else "failed-table.md" - ), - grading_repo_name=get_grading_repo_name(), - max_total_score=repo_conf.max_total_score, - groups=groups_config, - ) - return teapot - - def get_teapot_stage(repo_conf: repo.Config) -> result.StageDetail: args_ = "" args_ = ( diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 839e171..10d2a46 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -9,7 +9,7 @@ def get_conf_stage( ) -> result.StageDetail: conf_stage = result.StageDetail( name=task_stage.name if task_stage.name is not None else "", - # FIXME: to be deterined the way + # FIXME: to be deterined the way # group=( # re.search(r'\[([^\[\]]+)\]', task_stage.name).group(1) # if (task_stage.name is not None and re.search(r'\[([^\[\]]+)\]', task_stage.name)) diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index b871b7d..39172b0 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -2,7 +2,7 @@ "name": "hw7 ex2", "logPath": "/home/tt/.cache/joj3/homework/h7/e2.log", "expireUnixTimestamp": 1735574399, - "actorpostStagesCsvPath": "/home/tt/.config/joj/students.csv", + "actorCsvPath": "/home/tt/.config/joj/students.csv", "maxTotalScore": 100, "stage": { "sandboxExecServer": "172.17.0.1:5051", -- 2.30.2 From 80b33324e5f808cada6e24dc366c184c306f3c93 Mon Sep 17 00:00:00 2001 From: jon-lee Date: Sat, 15 Feb 2025 11:40:21 +0100 Subject: [PATCH 130/131] feat: joj1 convert init --- joj3_config_generator/convert.py | 48 +- joj3_config_generator/main.py | 48 +- joj3_config_generator/models/task.py | 5 +- joj3_config_generator/processers/joj1.py | 50 + joj3_config_generator/processers/repo.py | 12 +- joj3_config_generator/processers/task.py | 1 + tests/convert/basic/task.json | 1259 +--------------------- tests/convert/basic/task.toml | 18 +- tests/convert_joj1/basic/task.toml | 586 +++++++++- 9 files changed, 638 insertions(+), 1389 deletions(-) create mode 100644 joj3_config_generator/processers/joj1.py diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 280c4c6..5b0ebe3 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -1,10 +1,12 @@ import json import os +from pathlib import Path from typing import Any, List import rtoml from joj3_config_generator.models import joj1, repo, result, task +from joj3_config_generator.processers.joj1 import get_joj1_run_stage from joj3_config_generator.processers.repo import ( # get_teapotcheck_config, get_healthcheck_config, get_teapot_stage, @@ -25,14 +27,14 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: result_conf = result.Config( name=task_conf.task.name, # TODO: specify the exact folder difference - log_path=f"/home/tt/.cache/joj3/{task_conf.task.type_}.log", + log_path=f"{Path.home()}/.cache/joj3/{task_conf.task.type_}.log", expire_unix_timestamp=( int(task_conf.release.deadline.timestamp()) if task_conf.release.deadline else -1 ), # FIXME: don't hardcode - actor_csv_path="/home/tt/.config/joj/students.csv", + actor_csv_path=f"{Path.home()}/.config/joj/students.csv", stage=result.Stage( stages=[], sandbox_token=repo_conf.sandbox_token, @@ -59,47 +61,13 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: return result_conf -# FIXME: LLM generated convert function, only for demostration def convert_joj1(joj1_conf: joj1.Config) -> task.Config: - stages = [] - for language in joj1_conf.languages: - # Here you might want to create a stage for each language - # You can define a command based on language properties - command = f"run {language.language}" - # Assuming we don't have explicit files, we will set empty ones or default behavior - files = task.Files(import_=[], export=[]) # type: ignore - # Score can be derived from the first case or set to a default - score = 0 - parsers: List[str] = [] # Define parsers if applicable - if joj1_conf.cases: - score = sum( - case.score for case in joj1_conf.cases - ) # Sum scores for all cases - # Creating a stage for each language - stages.append( - task.Stage( - name=language.language, - command=command, - files=files, - score=score, - parsers=parsers, - ) - ) - # Assuming no deadline is provided in `joj1`, you can set it accordingly - release_deadline = ( - None # Placeholder for future implementation if deadlines are defined - ) - + stages = [get_joj1_run_stage(joj1_conf)] return task.Config( task=task.Task( - name=( - joj1_conf.languages[0].language - if joj1_conf.languages - else "Unnamed Task" - ), - type_="", - ), # FIXME: fix this type later - release=task.Release(deadline=release_deadline), + name=("Blank Task"), + ), + release=task.Release(deadline=None), stages=stages, ) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 6a8b681..69df193 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -3,7 +3,6 @@ import os from pathlib import Path from typing import Any, Dict -import inquirer import rtoml import typer import yaml @@ -16,23 +15,6 @@ from joj3_config_generator.utils.logger import logger app = typer.Typer(add_completion=False) -@app.command() -def create(toml: typer.FileTextWrite) -> None: - """ - Create a new JOJ3 toml config file - """ - logger.info("Creating") - questions = [ - inquirer.List( - "size", - message="What size do you need?", - choices=["Jumbo", "Large", "Standard", "Medium", "Small", "Micro"], - ), - ] - answers = inquirer.prompt(questions) - logger.info(answers) - - @app.command() def convert_joj1(yaml_file: typer.FileText, toml_file: typer.FileTextWrite) -> None: """ @@ -42,15 +24,22 @@ def convert_joj1(yaml_file: typer.FileText, toml_file: typer.FileTextWrite) -> N joj1_obj = yaml.safe_load(yaml_file.read()) joj1_model = joj1.Config(**joj1_obj) task_model = convert_joj1_conf(joj1_model) - result_dict = task_model.model_dump(by_alias=True) + result_dict = task_model.model_dump(by_alias=True, exclude_none=True) toml_file.write(rtoml.dumps(result_dict)) @app.command() -def convert(root: Path = Path(".")) -> Dict[str, Any]: - """ - Convert given dir of JOJ3 toml config files to JOJ3 json config files - """ +def convert( + root: Path = typer.Option( + Path("."), + "--conf-root", + "-c", + help="This should be consistent with the root of how you run JOJ3", + ), + debug: bool = typer.Option( + False, "--debug", "-d", help="Enable debug mode for more verbose output" + ), +) -> Dict[str, Any]: logger.info(f"Converting files in {root.absolute()}") repo_toml_path = os.path.join(root.absolute(), "basic", "repo.toml") # TODO: loop through all dirs to find all task.toml @@ -69,16 +58,7 @@ def convert(root: Path = Path(".")) -> Dict[str, Any]: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) result_file.write("\n") - # FIXME: change the path to the server - # homework_name = "h8" - # folder_path = f"/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/homework/{homework_name}" - # folder_path = ( - # "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/homework/h8" - # ) - # folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/homework/h7" - # for projects - # folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/tests/projects/p3/p3m3" - # folder_path = "/mnt/c/Users/Nuvole/Desktop/engr151-joj/home/tt/.config/joj/projects/p3/p3m1" - # assert os.path.exists(folder_path), f"there exists no {folder_path}" + # distribution on json + # need a get folder path function # distribute_json(folder_path, repo_obj) return result_dict diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 8226f1b..aba9497 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -86,8 +86,7 @@ class Stage(BaseModel): class Config: extra = "allow" - @root_validator(pre=True) - def gather_cases(cls: Type["Stage"], values: Dict[str, Any]) -> Dict[str, Any]: + def gather_cases(self, values: Dict[str, Any]) -> Dict[str, Any]: cases = {k: v for k, v in values.items() if k.startswith("case")} for key in cases: values.pop(key) @@ -108,5 +107,5 @@ class Task(BaseModel): class Config(BaseModel): task: Task - release: Release # Release configuration + release: Release stages: List[Stage] # list of stage configurations diff --git a/joj3_config_generator/processers/joj1.py b/joj3_config_generator/processers/joj1.py new file mode 100644 index 0000000..cf24377 --- /dev/null +++ b/joj3_config_generator/processers/joj1.py @@ -0,0 +1,50 @@ +from typing import List + +import humanfriendly +from pytimeparse.timeparse import timeparse + +from joj3_config_generator.models import joj1, result, task + + +def get_joj1_run_stage(joj1_config: joj1.Config) -> task.Stage: + default_cpu = timeparse("1s") + default_mem = humanfriendly.parse_size("32m") + cases_conf = [] + for i, case in enumerate(joj1_config.cases): + cases_conf.append( + task.Stage( + score=case.score, + command=case.execute_args if case.execute_args else None, + limit=task.Limit( + cpu=timeparse(case.time) if case.time else default_cpu, + mem=( + humanfriendly.parse_size(case.memory) + if case.memory + else default_mem + ), + ), + ) + ) + for i, case in enumerate(joj1_config.cases): + cases_conf[i].in_ = case.input + cases_conf[i].out_ = case.output + run_config = task.Stage( + name="This is the converted joj1 run stage", + group="joj", + parsers=["diff", "result-status"], + score=100, + limit=task.Limit( + cpu=( + timeparse(joj1_config.cases[0].time) + if joj1_config.cases[0].time is not None + else default_cpu + ), + mem=( + humanfriendly.parse_size(joj1_config.cases[0].memory) + if joj1_config.cases[0].memory is not None + else default_mem + ), + ), + cases={f"case{i}": cases_conf[i] for i, case in enumerate(joj1_config.cases)}, + ) + return run_config diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index 4530006..6ce840b 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -28,7 +28,7 @@ def get_teapot_stage(repo_conf: repo.Config) -> result.StageDetail: default=result.Cmd( args=shlex.split(args_), env=[ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + f"LOG_FILE_PATH={Path.home()}/.cache/joint-teapot-debug.log" ], # TODO: fix it according to the task name ), cases=[], @@ -72,7 +72,7 @@ def get_debug_args(repo_conf: repo.Config) -> str: args = "" args = ( args - + f"/usr/local/bin/joint-teapot joj3-check-env /home/tt/.config/teapot/teapot.env --grading-repo-name {get_grading_repo_name()} --group-config" + + f"/usr/local/bin/joint-teapot joj3-check-env {Path.home()}/.config/teapot/teapot.env --grading-repo-name {get_grading_repo_name()} --group-config " ) group_config = "" for i, name in enumerate(repo_conf.groups.name): @@ -100,14 +100,16 @@ def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail: ), result.OptionalCmd( args=shlex.split(get_debug_args(repo_conf)), - env=["LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log"], + env=[ + f"LOG_FILE_PATH={Path.home()}/.cache/joint-teapot-debug.log" + ], ), ], ), ), parsers=[ result.ParserConfig(name="healthcheck", with_={"score": 1}), - result.ParserConfig(name="debug", with_={"score": 1}), + result.ParserConfig(name="debug", with_={"score": 0}), ], ) return healthcheck_stage @@ -126,6 +128,8 @@ def get_hash(immutable_files: list[str]) -> str: # input should be a list current_file_path = Path(__file__).resolve() project_root = current_file_path.parents[2] file_path = f"{project_root}/tests/immutable_p3-test/" + # default value as hardcoded + # file_path = "{Path.home()}/.cache/immutable" immutable_hash = [] for i, file in enumerate(immutable_files): immutable_files[i] = file_path + file.rsplit("/", 1)[-1] diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 10d2a46..fb32a8e 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -239,6 +239,7 @@ def fix_file( return conf_stage +# TODO: add the logic of looping through all the files in the conf-root and generated conf.toml accordingly, while also get the path of the json file. def fix_diff( task_stage: task.Stage, conf_stage: result.StageDetail, task_conf: task.Config ) -> result.StageDetail: diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 39172b0..692050b 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,8 +1,8 @@ { "name": "hw7 ex2", - "logPath": "/home/tt/.cache/joj3/homework/h7/e2.log", + "logPath": "/home/nuvole0217/.cache/joj3/homework/h7/e2.log", "expireUnixTimestamp": 1735574399, - "actorCsvPath": "/home/tt/.config/joj/students.csv", + "actorCsvPath": "/home/nuvole0217/.config/joj/students.csv", "maxTotalScore": 100, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -81,13 +81,14 @@ "args": [ "/usr/local/bin/joint-teapot", "joj3-check-env", - "/home/tt/.config/teapot/teapot.env", + "/home/nuvole0217/.config/teapot/teapot.env", "--grading-repo-name", "Nuvole-joj", - "--group-configjoj=1000:24,run=1000:24,=100:24" + "--group-config", + "joj=1000:24,run=1000:24,=100:24" ], "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + "LOG_FILE_PATH=/home/nuvole0217/.cache/joint-teapot-debug.log" ], "cpuLimit": 4000000000000, "clockLimit": 8000000000000, @@ -111,71 +112,11 @@ { "name": "debug", "with": { - "score": 1 + "score": 0 } } ] }, - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400 - }, - "stdout": { - "name": "stdout", - "max": 800000000000000 - }, - "stderr": { - "name": "stderr", - "max": 800000000000000 - }, - "cpuLimit": 1000000000000000, - "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "healthcheck", - "with": {} - }, - { - "name": "debug", - "with": {} - } - ] - }, { "name": "Compilation", "group": "", @@ -771,178 +712,7 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [ - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case0.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case1.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case2.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case3.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case4.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case5.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case6.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case7.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case8.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case9.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - } - ] + "cases": [] } }, "parsers": [ @@ -950,128 +720,7 @@ "name": "diff", "with": { "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case0.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case1.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case2.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case3.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 10, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case4.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 10, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case5.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case6.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case7.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case8.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case9.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - } - ] + "cases": [] } }, { @@ -1140,178 +789,7 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [ - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case0.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case1.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case2.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case3.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case4.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case5.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case6.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case7.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case8.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case9.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - } - ] + "cases": [] } }, "parsers": [ @@ -1319,128 +797,7 @@ "name": "diff", "with": { "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case0.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case1.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case2.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case3.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 10, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case4.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 10, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case5.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case6.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case7.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case8.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case9.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - } - ] + "cases": [] } }, { @@ -1509,178 +866,7 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [ - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case0.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case1.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case2.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case3.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case4.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case5.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case6.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case7.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case8.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case9.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - } - ] + "cases": [] } }, "parsers": [ @@ -1688,128 +874,7 @@ "name": "diff", "with": { "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case0.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case1.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case2.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case3.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 10, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case4.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 10, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case5.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case6.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case7.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case8.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case9.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - } - ] + "cases": [] } }, { @@ -1877,178 +942,7 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [ - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case0.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case1.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case2.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case3.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case4.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case5.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case6.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case7.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case8.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/homework/h7/e2/case9.in", - "max": 419430400 - }, - "cpuLimit": 1000000000, - "clockLimit": 2000000000, - "memoryLimit": 95656304705536, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - } - ] + "cases": [] } }, "parsers": [ @@ -2056,128 +950,7 @@ "name": "diff", "with": { "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case0.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case1.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case2.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 5, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case3.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 10, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case4.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 10, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case5.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case6.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case7.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case8.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - }, - { - "outputs": [ - { - "score": 15, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/homework/h7/e2/case9.out", - "forceQuitOnDiff": false, - "alwaysHide": false, - "compareSpace": false - } - ] - } - ] + "cases": [] } }, { @@ -2214,7 +987,7 @@ "100" ], "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" + "LOG_FILE_PATH=/home/nuvole0217/.cache/joint-teapot-debug.log" ], "stdin": { "content": "", diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 3c088ed..98001df 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,26 +1,10 @@ # general task configuration task.name = "hw7 ex2" # task name -task.type = "homework/h7/e2" +task.type = "homework/h7/e2" # remove this task type later release.deadline = 2024-12-30 23:59:59+08:00 release.stages = [ "compile" ] -[[stages]] -name = "healthcheck" -score = 1 - -# healthcheck parsers -parsers = ["healthcheck", "debug"] -cases0.command = "/usr/local/bin/repo-health-checker -repoSize=100" -case1.command = """/usr/local/bin/joint-teapot - joj3-check-env - /home/tt/.config/teapot/teapot.env" - --grading-repo-name - JOJ3-actions-examples - --group-config - joj=50:24,=100:24""" -case1.env = ["LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log"] - [[stages]] name = "Compilation" command = "./tools/compile" # eg. script running cmake commands diff --git a/tests/convert_joj1/basic/task.toml b/tests/convert_joj1/basic/task.toml index a58cd74..e035351 100644 --- a/tests/convert_joj1/basic/task.toml +++ b/tests/convert_joj1/basic/task.toml @@ -1,31 +1,25 @@ -task = "cc" - [[stages]] -name = "cc" -command = "run cc" +name = "This is the converted joj1 run stage" +group = "joj" score = 100 -parsers = [] +parsers = ["diff", "result-status"] skip = [] -[stages.files] -import = [] -export = [] - [stages.limit] -mem = 4 -cpu = 4 -stderr = 4 -stdout = 4 +mem = 32000000 +cpu = 1 +stderr = 800 +stdout = 800 [stages.dummy] comment = "" score = 0 -forcequit = true +forcequit = false [stages.result-status] comment = "" score = 0 -forcequit = true +forcequit = false [stages.keyword] keyword = [] @@ -49,70 +43,566 @@ mem = true stdout = false stderr = false exitstatus = false -[stages.diff.output] -score = 0 -ignorespaces = false -hide = false -forcequit = true -[stages.cases] - -[[stages]] -name = "c" -command = "run c" -score = 100 +[stages.file] +[stages.cases.case0] +command = "-abcd --aaaa bbbb" +in = "case0.in" +out = "case0.out" +score = 10 parsers = [] skip = [] -[stages.files] -import = [] -export = [] +[stages.cases.case0.limit] +mem = 32000000 +cpu = 1 +stderr = 800 +stdout = 800 -[stages.limit] -mem = 4 -cpu = 4 -stderr = 4 -stdout = 4 - -[stages.dummy] +[stages.cases.case0.dummy] comment = "" score = 0 -forcequit = true +forcequit = false -[stages.result-status] +[stages.cases.case0.result-status] comment = "" score = 0 -forcequit = true +forcequit = false -[stages.keyword] +[stages.cases.case0.keyword] keyword = [] weight = [] -[stages.clangtidy] +[stages.cases.case0.clangtidy] keyword = [] weight = [] -[stages.cppcheck] +[stages.cases.case0.cppcheck] keyword = [] weight = [] -[stages.cpplint] +[stages.cases.case0.cpplint] keyword = [] weight = [] -[stages.result-detail] +[stages.cases.case0.result-detail] time = true mem = true stdout = false stderr = false exitstatus = false + +[stages.cases.case0.file] + +[stages.cases.case0.cases] +[stages.cases.case0.diff.output] +score = 0 +ignorespaces = true +hide = false +forcequit = false + +[stages.cases.case1] +in = "case1.in" +out = "case1.out" +score = 10 +parsers = [] +skip = [] + +[stages.cases.case1.limit] +mem = 32000000 +cpu = 1 +stderr = 800 +stdout = 800 + +[stages.cases.case1.dummy] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case1.result-status] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case1.keyword] +keyword = [] +weight = [] + +[stages.cases.case1.clangtidy] +keyword = [] +weight = [] + +[stages.cases.case1.cppcheck] +keyword = [] +weight = [] + +[stages.cases.case1.cpplint] +keyword = [] +weight = [] + +[stages.cases.case1.result-detail] +time = true +mem = true +stdout = false +stderr = false +exitstatus = false + +[stages.cases.case1.file] + +[stages.cases.case1.cases] +[stages.cases.case1.diff.output] +score = 0 +ignorespaces = true +hide = false +forcequit = false + +[stages.cases.case2] +in = "case2.in" +out = "case2.out" +score = 10 +parsers = [] +skip = [] + +[stages.cases.case2.limit] +mem = 32000000 +cpu = 1 +stderr = 800 +stdout = 800 + +[stages.cases.case2.dummy] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case2.result-status] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case2.keyword] +keyword = [] +weight = [] + +[stages.cases.case2.clangtidy] +keyword = [] +weight = [] + +[stages.cases.case2.cppcheck] +keyword = [] +weight = [] + +[stages.cases.case2.cpplint] +keyword = [] +weight = [] + +[stages.cases.case2.result-detail] +time = true +mem = true +stdout = false +stderr = false +exitstatus = false + +[stages.cases.case2.file] + +[stages.cases.case2.cases] +[stages.cases.case2.diff.output] +score = 0 +ignorespaces = true +hide = false +forcequit = false + +[stages.cases.case3] +in = "case3.in" +out = "case3.out" +score = 10 +parsers = [] +skip = [] + +[stages.cases.case3.limit] +mem = 32000000 +cpu = 1 +stderr = 800 +stdout = 800 + +[stages.cases.case3.dummy] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case3.result-status] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case3.keyword] +keyword = [] +weight = [] + +[stages.cases.case3.clangtidy] +keyword = [] +weight = [] + +[stages.cases.case3.cppcheck] +keyword = [] +weight = [] + +[stages.cases.case3.cpplint] +keyword = [] +weight = [] + +[stages.cases.case3.result-detail] +time = true +mem = true +stdout = false +stderr = false +exitstatus = false + +[stages.cases.case3.file] + +[stages.cases.case3.cases] +[stages.cases.case3.diff.output] +score = 0 +ignorespaces = true +hide = false +forcequit = false + +[stages.cases.case4] +in = "case4.in" +out = "case4.out" +score = 10 +parsers = [] +skip = [] + +[stages.cases.case4.limit] +mem = 32000000 +cpu = 1 +stderr = 800 +stdout = 800 + +[stages.cases.case4.dummy] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case4.result-status] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case4.keyword] +keyword = [] +weight = [] + +[stages.cases.case4.clangtidy] +keyword = [] +weight = [] + +[stages.cases.case4.cppcheck] +keyword = [] +weight = [] + +[stages.cases.case4.cpplint] +keyword = [] +weight = [] + +[stages.cases.case4.result-detail] +time = true +mem = true +stdout = false +stderr = false +exitstatus = false + +[stages.cases.case4.file] + +[stages.cases.case4.cases] +[stages.cases.case4.diff.output] +score = 0 +ignorespaces = true +hide = false +forcequit = false + +[stages.cases.case5] +in = "case5.in" +out = "case5.out" +score = 10 +parsers = [] +skip = [] + +[stages.cases.case5.limit] +mem = 32000000 +cpu = 1 +stderr = 800 +stdout = 800 + +[stages.cases.case5.dummy] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case5.result-status] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case5.keyword] +keyword = [] +weight = [] + +[stages.cases.case5.clangtidy] +keyword = [] +weight = [] + +[stages.cases.case5.cppcheck] +keyword = [] +weight = [] + +[stages.cases.case5.cpplint] +keyword = [] +weight = [] + +[stages.cases.case5.result-detail] +time = true +mem = true +stdout = false +stderr = false +exitstatus = false + +[stages.cases.case5.file] + +[stages.cases.case5.cases] +[stages.cases.case5.diff.output] +score = 0 +ignorespaces = true +hide = false +forcequit = false + +[stages.cases.case6] +in = "case6.in" +out = "case6.out" +score = 10 +parsers = [] +skip = [] + +[stages.cases.case6.limit] +mem = 32000000 +cpu = 1 +stderr = 800 +stdout = 800 + +[stages.cases.case6.dummy] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case6.result-status] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case6.keyword] +keyword = [] +weight = [] + +[stages.cases.case6.clangtidy] +keyword = [] +weight = [] + +[stages.cases.case6.cppcheck] +keyword = [] +weight = [] + +[stages.cases.case6.cpplint] +keyword = [] +weight = [] + +[stages.cases.case6.result-detail] +time = true +mem = true +stdout = false +stderr = false +exitstatus = false + +[stages.cases.case6.file] + +[stages.cases.case6.cases] +[stages.cases.case6.diff.output] +score = 0 +ignorespaces = true +hide = false +forcequit = false + +[stages.cases.case7] +in = "case7.in" +out = "case7.out" +score = 10 +parsers = [] +skip = [] + +[stages.cases.case7.limit] +mem = 32000000 +cpu = 1 +stderr = 800 +stdout = 800 + +[stages.cases.case7.dummy] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case7.result-status] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case7.keyword] +keyword = [] +weight = [] + +[stages.cases.case7.clangtidy] +keyword = [] +weight = [] + +[stages.cases.case7.cppcheck] +keyword = [] +weight = [] + +[stages.cases.case7.cpplint] +keyword = [] +weight = [] + +[stages.cases.case7.result-detail] +time = true +mem = true +stdout = false +stderr = false +exitstatus = false + +[stages.cases.case7.file] + +[stages.cases.case7.cases] +[stages.cases.case7.diff.output] +score = 0 +ignorespaces = true +hide = false +forcequit = false + +[stages.cases.case8] +in = "case8.in" +out = "case8.out" +score = 10 +parsers = [] +skip = [] + +[stages.cases.case8.limit] +mem = 32000000 +cpu = 1 +stderr = 800 +stdout = 800 + +[stages.cases.case8.dummy] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case8.result-status] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case8.keyword] +keyword = [] +weight = [] + +[stages.cases.case8.clangtidy] +keyword = [] +weight = [] + +[stages.cases.case8.cppcheck] +keyword = [] +weight = [] + +[stages.cases.case8.cpplint] +keyword = [] +weight = [] + +[stages.cases.case8.result-detail] +time = true +mem = true +stdout = false +stderr = false +exitstatus = false + +[stages.cases.case8.file] + +[stages.cases.case8.cases] +[stages.cases.case8.diff.output] +score = 0 +ignorespaces = true +hide = false +forcequit = false + +[stages.cases.case9] +in = "case9.in" +out = "case9.out" +score = 10 +parsers = [] +skip = [] + +[stages.cases.case9.limit] +mem = 32000000 +cpu = 1 +stderr = 800 +stdout = 800 + +[stages.cases.case9.dummy] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case9.result-status] +comment = "" +score = 0 +forcequit = false + +[stages.cases.case9.keyword] +keyword = [] +weight = [] + +[stages.cases.case9.clangtidy] +keyword = [] +weight = [] + +[stages.cases.case9.cppcheck] +keyword = [] +weight = [] + +[stages.cases.case9.cpplint] +keyword = [] +weight = [] + +[stages.cases.case9.result-detail] +time = true +mem = true +stdout = false +stderr = false +exitstatus = false + +[stages.cases.case9.file] + +[stages.cases.case9.cases] +[stages.cases.case9.diff.output] +score = 0 +ignorespaces = true +hide = false +forcequit = false [stages.diff.output] score = 0 -ignorespaces = false +ignorespaces = true hide = false -forcequit = true +forcequit = false -[stages.cases] +[task] +type = "" +name = "Blank Task" [release] -deadline = "null" -- 2.30.2 From 979185252d32f7b5309625052a99e20b7bab1c0e Mon Sep 17 00:00:00 2001 From: jon-lee Date: Sun, 23 Feb 2025 21:33:23 +0800 Subject: [PATCH 131/131] fix: path issue --- joj3_config_generator/convert.py | 25 +- joj3_config_generator/main.py | 25 +- joj3_config_generator/models/task.py | 9 +- joj3_config_generator/processers/joj1.py | 6 +- joj3_config_generator/processers/task.py | 45 +- tests/convert/basic/task.json | 1204 +++++++++++++++++++++- tests/convert/basic/task.toml | 4 - tests/convert/utils.py | 3 +- tests/convert_joj1/basic/task.toml | 608 ----------- 9 files changed, 1247 insertions(+), 682 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 5b0ebe3..5e36c77 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -22,19 +22,21 @@ from joj3_config_generator.processers.task import ( ) -def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: +def convert( + repo_conf: repo.Config, task_conf: task.Config, conf_root: Path +) -> result.Config: # Create the base ResultConf object result_conf = result.Config( name=task_conf.task.name, - # TODO: specify the exact folder difference + # exact folder difference specified by type log_path=f"{Path.home()}/.cache/joj3/{task_conf.task.type_}.log", expire_unix_timestamp=( int(task_conf.release.deadline.timestamp()) if task_conf.release.deadline else -1 ), - # FIXME: don't hardcode - actor_csv_path=f"{Path.home()}/.config/joj/students.csv", + actor_csv_path=f"{Path.home()}/.config/joj/students.csv", # students.csv position + max_total_score=repo_conf.max_total_score, stage=result.Stage( stages=[], sandbox_token=repo_conf.sandbox_token, @@ -44,18 +46,19 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: # Construct healthcheck stage healthcheck_stage = get_healthcheck_config(repo_conf) - # teapotcheck_stage = get_teapotcheck_config(repo_conf, task_conf) result_conf.stage.stages.append(healthcheck_stage) - cached: List[str] = [] + stages: List[str] = [] # Convert each stage in the task configuration for task_stage in task_conf.stages: - executor_with_config, cached = get_executorWithConfig(task_stage, cached) + executor_with_config, stages = get_executorWithConfig( + task_stage, stages, conf_root + ) conf_stage = get_conf_stage(task_stage, executor_with_config) conf_stage = fix_result_detail(task_stage, conf_stage) conf_stage = fix_dummy(task_stage, conf_stage) conf_stage = fix_keyword(task_stage, conf_stage) conf_stage = fix_file(task_stage, conf_stage) - conf_stage = fix_diff(task_stage, conf_stage, task_conf) + conf_stage = fix_diff(task_stage, conf_stage, task_conf, conf_root) result_conf.stage.stages.append(conf_stage) return result_conf @@ -72,7 +75,7 @@ def convert_joj1(joj1_conf: joj1.Config) -> task.Config: ) -def distribute_json(folder_path: str, repo_obj: Any) -> None: +def distribute_json(folder_path: str, repo_obj: Any, conf_root: Path) -> None: for root, _, files in os.walk(folder_path): for file in files: if file.endswith(".toml"): @@ -81,7 +84,9 @@ def distribute_json(folder_path: str, repo_obj: Any) -> None: with open(toml_file_path) as toml_file: task_toml = toml_file.read() task_obj = rtoml.loads(task_toml) - result_model = convert(repo.Config(**repo_obj), task.Config(**task_obj)) + result_model = convert( + repo.Config(**repo_obj), task.Config(**task_obj), conf_root + ) result_dict = result_model.model_dump(by_alias=True, exclude_none=True) with open(json_file_path, "w") as result_file: diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 69df193..d1f4f7d 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -36,29 +36,34 @@ def convert( "-c", help="This should be consistent with the root of how you run JOJ3", ), + repo_path: Path = typer.Option( + Path("."), + "--repo-root", + "-r", + help="This would be where you put your repo.toml file", + ), debug: bool = typer.Option( False, "--debug", "-d", help="Enable debug mode for more verbose output" ), ) -> Dict[str, Any]: - logger.info(f"Converting files in {root.absolute()}") - repo_toml_path = os.path.join(root.absolute(), "basic", "repo.toml") - # TODO: loop through all dirs to find all task.toml - task_toml_path = os.path.join(root.absolute(), "basic", "task.toml") - result_json_path = os.path.join(root.absolute(), "basic", "task.json") - with open(repo_toml_path) as repo_file: + logger.info(f"Converting files in {repo_path.absolute()}") + repo_toml_path = os.path.join(repo_path.absolute(), "basic", "repo.toml") + task_toml_path = os.path.join(repo_path.absolute(), "basic", "task.toml") + result_json_path = os.path.join(repo_path.absolute(), "basic", "task.json") + with open(repo_toml_path, encoding=None) as repo_file: repo_toml = repo_file.read() - with open(task_toml_path) as task_file: + with open(task_toml_path, encoding=None) as task_file: task_toml = task_file.read() repo_obj = rtoml.loads(repo_toml) task_obj = rtoml.loads(task_toml) - result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj)) + result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj), root) result_dict = result_model.model_dump(by_alias=True, exclude_none=True) - with open(result_json_path, "w") as result_file: + with open(result_json_path, "w", encoding=None) as result_file: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) result_file.write("\n") # distribution on json # need a get folder path function - # distribute_json(folder_path, repo_obj) + # distribute_json(folder_path, repo_obj, conf_root) return result_dict diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index aba9497..5786234 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -1,7 +1,7 @@ from datetime import datetime from typing import Any, Dict, List, Optional, Type -from pydantic import BaseModel, Field, root_validator +from pydantic import BaseModel, Field, model_validator class ParserResultDetail(BaseModel): @@ -58,8 +58,6 @@ class Limit(BaseModel): class Stage(BaseModel): name: Optional[str] = None # Stage name - group: Optional[str] = None # TODO: may need to formulate this - path: Optional[str] = None # FIXME: this is highly possible to be removed in future env: Optional[list[str]] = None command: Optional[str] = None # Command to run files: Optional[Files] = None @@ -79,6 +77,7 @@ class Stage(BaseModel): ) file: Optional[ParserFile] = ParserFile() skip: Optional[list[str]] = [] + # cases related cases: Optional[Dict[str, "Stage"]] = {} diff: Optional[ParserDiff] = ParserDiff() @@ -86,7 +85,9 @@ class Stage(BaseModel): class Config: extra = "allow" - def gather_cases(self, values: Dict[str, Any]) -> Dict[str, Any]: + @model_validator(mode="before") + @classmethod + def gather_cases(cls: Type["Stage"], values: Dict[str, Any]) -> Dict[str, Any]: cases = {k: v for k, v in values.items() if k.startswith("case")} for key in cases: values.pop(key) diff --git a/joj3_config_generator/processers/joj1.py b/joj3_config_generator/processers/joj1.py index cf24377..c07f018 100644 --- a/joj3_config_generator/processers/joj1.py +++ b/joj3_config_generator/processers/joj1.py @@ -30,7 +30,6 @@ def get_joj1_run_stage(joj1_config: joj1.Config) -> task.Stage: cases_conf[i].out_ = case.output run_config = task.Stage( name="This is the converted joj1 run stage", - group="joj", parsers=["diff", "result-status"], score=100, limit=task.Limit( @@ -45,6 +44,9 @@ def get_joj1_run_stage(joj1_config: joj1.Config) -> task.Stage: else default_mem ), ), - cases={f"case{i}": cases_conf[i] for i, case in enumerate(joj1_config.cases)}, + cases={f"case{i}": cases_conf[i] for i, _ in enumerate(joj1_config.cases)}, ) return run_config + + +# TODO: get formatted joj1 config, match the criterion in the doc diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index fb32a8e..32a422b 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -1,4 +1,6 @@ +import re import shlex +from pathlib import Path from typing import List, Tuple from joj3_config_generator.models import result, task @@ -9,13 +11,12 @@ def get_conf_stage( ) -> result.StageDetail: conf_stage = result.StageDetail( name=task_stage.name if task_stage.name is not None else "", - # FIXME: to be deterined the way - # group=( - # re.search(r'\[([^\[\]]+)\]', task_stage.name).group(1) - # if (task_stage.name is not None and re.search(r'\[([^\[\]]+)\]', task_stage.name)) - # else "" - # ), - group=(task_stage.group if (task_stage.group is not None) else ""), + # 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 "" + ), executor=result.Executor( name="sandbox", with_=executor_with_config, @@ -33,7 +34,7 @@ def get_conf_stage( def get_executorWithConfig( - task_stage: task.Stage, cached: List[str] + task_stage: task.Stage, cached: List[str], conf_root: Path ) -> Tuple[result.ExecutorWith, List[str]]: file_import = ( task_stage.files.import_ @@ -43,7 +44,7 @@ def get_executorWithConfig( and (task_stage.files.import_ is not None) else [] ) - 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 if hasattr(task_stage, "files") @@ -59,16 +60,10 @@ def get_executorWithConfig( if task_stage.command is not None else [] ), - # FIXME: remove this trick copy_in={ - ("./.clang-tidy" if file.endswith("clang-tidy") else file): ( - result.CmdFile(src=f"/home/tt/.config/joj/{file}") - if not file.endswith("main.cpp") - else result.CmdFile( - # src=f"/home/tt/.config/joj/homework/h7/e3/ex3-main.cpp" - src=f"/home/tt/.config/joj/homework/h8/e1/ex1-main.cpp" - ) - ) + file: result.CmdFile(src=f"{Path.home()}/{conf_root}/tools/{file}") + # all copyin files store in this tools folder + # are there any corner cases for file in copy_in_files }, stdin=( @@ -116,7 +111,7 @@ def get_executorWithConfig( ), ), ), - cases=[], # You can add cases if needed + cases=[], ) if file_export is not None: for file in file_export: @@ -239,9 +234,11 @@ def fix_file( return conf_stage -# TODO: add the logic of looping through all the files in the conf-root and generated conf.toml accordingly, while also get the path of the json file. def fix_diff( - task_stage: task.Stage, conf_stage: result.StageDetail, task_conf: task.Config + task_stage: task.Stage, + conf_stage: result.StageDetail, + task_conf: task.Config, + conf_root: Path, ) -> result.StageDetail: if task_stage.parsers is not None and "diff" in task_stage.parsers: diff_parser = next((p for p in conf_stage.parsers if p.name == "diff"), None) @@ -280,8 +277,7 @@ def fix_diff( stage_cases.append( result.OptionalCmd( stdin=result.CmdFile( - src=f"/home/tt/.config/joj/{task_conf.task.type_}/{stdin}" - # src=f"/home/tt/.config/joj/{task_stage.path}/{stdin}" + src=f"{Path.home()}/{conf_root}/{task_conf.task.type_}/{stdin}" ), args=(shlex.split(command) if command is not None else None), cpu_limit=cpu_limit, @@ -304,8 +300,7 @@ def fix_diff( { "score": diff_output.score, "fileName": "stdout", - "answerPath": f"/home/tt/.config/joj/{task_conf.task.type_}/{stdout}", - # "answerPath": f"/home/tt/.config/joj/{task_stage.path}/{stdin}", + "answerPath": f"{Path.home()}/{conf_root}/{task_conf.task.type_}/{stdout}", "forceQuitOnDiff": diff_output.forcequit, "alwaysHide": diff_output.hide, "compareSpace": not diff_output.ignorespaces, diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 692050b..4f06d2f 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -152,7 +152,7 @@ "cpuSetLimit": "", "copyIn": { "tools/compile": { - "src": "/home/tt/.config/joj/tools/compile", + "src": "/home/nuvole0217/./tools/tools/compile", "max": 419430400 } }, @@ -205,7 +205,7 @@ }, { "name": "[cq] Filelength", - "group": "", + "group": "cq", "executor": { "name": "sandbox", "with": { @@ -242,7 +242,7 @@ "cpuSetLimit": "", "copyIn": { "tools/filelength": { - "src": "/home/tt/.config/joj/tools/filelength", + "src": "/home/nuvole0217/./tools/tools/filelength", "max": 419430400 } }, @@ -312,7 +312,7 @@ }, { "name": "[cq] Clang-tidy", - "group": "", + "group": "cq", "executor": { "name": "sandbox", "with": { @@ -350,8 +350,8 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "./.clang-tidy": { - "src": "/home/tt/.config/joj/tests/homework/h7/.clang-tidy", + "tests/homework/h7/.clang-tidy": { + "src": "/home/nuvole0217/./tools/tests/homework/h7/.clang-tidy", "max": 419430400 } }, @@ -447,7 +447,7 @@ }, { "name": "[cq] Cppcheck", - "group": "", + "group": "cq", "executor": { "name": "sandbox", "with": { @@ -554,7 +554,7 @@ }, { "name": "[cq] Cpplint", - "group": "", + "group": "cq", "executor": { "name": "sandbox", "with": { @@ -663,7 +663,7 @@ }, { "name": "[joj] ex2-asan", - "group": "run", + "group": "joj", "executor": { "name": "sandbox", "with": { @@ -712,7 +712,178 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [] + "cases": [ + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case0.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case1.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case2.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case3.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case4.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case5.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case6.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case7.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case8.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case9.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] } }, "parsers": [ @@ -720,7 +891,128 @@ "name": "diff", "with": { "name": "diff", - "cases": [] + "cases": [ + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case0.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case1.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case2.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case3.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case4.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case5.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case6.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case7.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case8.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case9.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + } + ] } }, { @@ -789,7 +1081,178 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [] + "cases": [ + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case0.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case1.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case2.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case3.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case4.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case5.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case6.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case7.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case8.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case9.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] } }, "parsers": [ @@ -797,7 +1260,128 @@ "name": "diff", "with": { "name": "diff", - "cases": [] + "cases": [ + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case0.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case1.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case2.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case3.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case4.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case5.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case6.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case7.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case8.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case9.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + } + ] } }, { @@ -817,7 +1401,7 @@ }, { "name": "[joj] ex2-ubsan", - "group": "", + "group": "joj", "executor": { "name": "sandbox", "with": { @@ -866,7 +1450,178 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [] + "cases": [ + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case0.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case1.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case2.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case3.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case4.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case5.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case6.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case7.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case8.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case9.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] } }, "parsers": [ @@ -874,7 +1629,128 @@ "name": "diff", "with": { "name": "diff", - "cases": [] + "cases": [ + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case0.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case1.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case2.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case3.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case4.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case5.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case6.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case7.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case8.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case9.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + } + ] } }, { @@ -942,7 +1818,178 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [] + "cases": [ + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case0.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case1.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case2.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case3.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case4.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case5.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case6.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case7.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case8.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + }, + { + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "src": "/home/nuvole0217/./homework/h7/e2/case9.in", + "max": 419430400 + }, + "cpuLimit": 1000000000, + "clockLimit": 2000000000, + "memoryLimit": 95656304705536, + "procLimit": 50, + "copyOut": [ + "stdout", + "stderr" + ] + } + ] } }, "parsers": [ @@ -950,7 +1997,128 @@ "name": "diff", "with": { "name": "diff", - "cases": [] + "cases": [ + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case0.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case1.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case2.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 5, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case3.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case4.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 10, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case5.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case6.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case7.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case8.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + }, + { + "outputs": [ + { + "score": 15, + "fileName": "stdout", + "answerPath": "/home/nuvole0217/./homework/h7/e2/case9.out", + "forceQuitOnDiff": false, + "alwaysHide": false, + "compareSpace": false + } + ] + } + ] } }, { diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 98001df..e779d42 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -3,7 +3,6 @@ task.name = "hw7 ex2" # task name task.type = "homework/h7/e2" # remove this task type later release.deadline = 2024-12-30 23:59:59+08:00 -release.stages = [ "compile" ] [[stages]] name = "Compilation" @@ -76,7 +75,6 @@ result-detail.mem = false [[stages]] name = "[joj] ex2-asan" -group = "run" command="./h7/build/ex2-asan -a" files.import = [ "h7/build/ex2-asan" ] limit.mem = 91224961 @@ -168,7 +166,6 @@ case9.in = "case9.in" [[stages]] name = "[joj] ex2-msan" -group = "joj" command="./h7/build/ex2-msan -a" files.import = [ "h7/build/ex2-msan" ] limit.mem = 91224961 @@ -352,7 +349,6 @@ case9.in = "case9.in" [[stages]] name = "[joj] ex2" -group = "joj" command="./h7/build/ex2" files.import = [ "h7/build/ex2" ] score = 10 diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 35fce31..53be84e 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -2,6 +2,7 @@ import json import os from typing import Any, Dict, Tuple +import Path import rtoml from joj3_config_generator.convert import convert @@ -28,7 +29,7 @@ def read_convert_files( def load_case(case_name: str) -> None: repo, task, expected_result = read_convert_files(case_name) - result = convert(repo, task).model_dump( + result = convert(repo, task, conf_root=Path(".")).model_dump( mode="json", by_alias=True, exclude_none=True ) assert result == expected_result diff --git a/tests/convert_joj1/basic/task.toml b/tests/convert_joj1/basic/task.toml index e035351..e69de29 100644 --- a/tests/convert_joj1/basic/task.toml +++ b/tests/convert_joj1/basic/task.toml @@ -1,608 +0,0 @@ -[[stages]] -name = "This is the converted joj1 run stage" -group = "joj" -score = 100 -parsers = ["diff", "result-status"] -skip = [] - -[stages.limit] -mem = 32000000 -cpu = 1 -stderr = 800 -stdout = 800 - -[stages.dummy] -comment = "" -score = 0 -forcequit = false - -[stages.result-status] -comment = "" -score = 0 -forcequit = false - -[stages.keyword] -keyword = [] -weight = [] - -[stages.clangtidy] -keyword = [] -weight = [] - -[stages.cppcheck] -keyword = [] -weight = [] - -[stages.cpplint] -keyword = [] -weight = [] - -[stages.result-detail] -time = true -mem = true -stdout = false -stderr = false -exitstatus = false - -[stages.file] -[stages.cases.case0] -command = "-abcd --aaaa bbbb" -in = "case0.in" -out = "case0.out" -score = 10 -parsers = [] -skip = [] - -[stages.cases.case0.limit] -mem = 32000000 -cpu = 1 -stderr = 800 -stdout = 800 - -[stages.cases.case0.dummy] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case0.result-status] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case0.keyword] -keyword = [] -weight = [] - -[stages.cases.case0.clangtidy] -keyword = [] -weight = [] - -[stages.cases.case0.cppcheck] -keyword = [] -weight = [] - -[stages.cases.case0.cpplint] -keyword = [] -weight = [] - -[stages.cases.case0.result-detail] -time = true -mem = true -stdout = false -stderr = false -exitstatus = false - -[stages.cases.case0.file] - -[stages.cases.case0.cases] -[stages.cases.case0.diff.output] -score = 0 -ignorespaces = true -hide = false -forcequit = false - -[stages.cases.case1] -in = "case1.in" -out = "case1.out" -score = 10 -parsers = [] -skip = [] - -[stages.cases.case1.limit] -mem = 32000000 -cpu = 1 -stderr = 800 -stdout = 800 - -[stages.cases.case1.dummy] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case1.result-status] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case1.keyword] -keyword = [] -weight = [] - -[stages.cases.case1.clangtidy] -keyword = [] -weight = [] - -[stages.cases.case1.cppcheck] -keyword = [] -weight = [] - -[stages.cases.case1.cpplint] -keyword = [] -weight = [] - -[stages.cases.case1.result-detail] -time = true -mem = true -stdout = false -stderr = false -exitstatus = false - -[stages.cases.case1.file] - -[stages.cases.case1.cases] -[stages.cases.case1.diff.output] -score = 0 -ignorespaces = true -hide = false -forcequit = false - -[stages.cases.case2] -in = "case2.in" -out = "case2.out" -score = 10 -parsers = [] -skip = [] - -[stages.cases.case2.limit] -mem = 32000000 -cpu = 1 -stderr = 800 -stdout = 800 - -[stages.cases.case2.dummy] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case2.result-status] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case2.keyword] -keyword = [] -weight = [] - -[stages.cases.case2.clangtidy] -keyword = [] -weight = [] - -[stages.cases.case2.cppcheck] -keyword = [] -weight = [] - -[stages.cases.case2.cpplint] -keyword = [] -weight = [] - -[stages.cases.case2.result-detail] -time = true -mem = true -stdout = false -stderr = false -exitstatus = false - -[stages.cases.case2.file] - -[stages.cases.case2.cases] -[stages.cases.case2.diff.output] -score = 0 -ignorespaces = true -hide = false -forcequit = false - -[stages.cases.case3] -in = "case3.in" -out = "case3.out" -score = 10 -parsers = [] -skip = [] - -[stages.cases.case3.limit] -mem = 32000000 -cpu = 1 -stderr = 800 -stdout = 800 - -[stages.cases.case3.dummy] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case3.result-status] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case3.keyword] -keyword = [] -weight = [] - -[stages.cases.case3.clangtidy] -keyword = [] -weight = [] - -[stages.cases.case3.cppcheck] -keyword = [] -weight = [] - -[stages.cases.case3.cpplint] -keyword = [] -weight = [] - -[stages.cases.case3.result-detail] -time = true -mem = true -stdout = false -stderr = false -exitstatus = false - -[stages.cases.case3.file] - -[stages.cases.case3.cases] -[stages.cases.case3.diff.output] -score = 0 -ignorespaces = true -hide = false -forcequit = false - -[stages.cases.case4] -in = "case4.in" -out = "case4.out" -score = 10 -parsers = [] -skip = [] - -[stages.cases.case4.limit] -mem = 32000000 -cpu = 1 -stderr = 800 -stdout = 800 - -[stages.cases.case4.dummy] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case4.result-status] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case4.keyword] -keyword = [] -weight = [] - -[stages.cases.case4.clangtidy] -keyword = [] -weight = [] - -[stages.cases.case4.cppcheck] -keyword = [] -weight = [] - -[stages.cases.case4.cpplint] -keyword = [] -weight = [] - -[stages.cases.case4.result-detail] -time = true -mem = true -stdout = false -stderr = false -exitstatus = false - -[stages.cases.case4.file] - -[stages.cases.case4.cases] -[stages.cases.case4.diff.output] -score = 0 -ignorespaces = true -hide = false -forcequit = false - -[stages.cases.case5] -in = "case5.in" -out = "case5.out" -score = 10 -parsers = [] -skip = [] - -[stages.cases.case5.limit] -mem = 32000000 -cpu = 1 -stderr = 800 -stdout = 800 - -[stages.cases.case5.dummy] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case5.result-status] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case5.keyword] -keyword = [] -weight = [] - -[stages.cases.case5.clangtidy] -keyword = [] -weight = [] - -[stages.cases.case5.cppcheck] -keyword = [] -weight = [] - -[stages.cases.case5.cpplint] -keyword = [] -weight = [] - -[stages.cases.case5.result-detail] -time = true -mem = true -stdout = false -stderr = false -exitstatus = false - -[stages.cases.case5.file] - -[stages.cases.case5.cases] -[stages.cases.case5.diff.output] -score = 0 -ignorespaces = true -hide = false -forcequit = false - -[stages.cases.case6] -in = "case6.in" -out = "case6.out" -score = 10 -parsers = [] -skip = [] - -[stages.cases.case6.limit] -mem = 32000000 -cpu = 1 -stderr = 800 -stdout = 800 - -[stages.cases.case6.dummy] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case6.result-status] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case6.keyword] -keyword = [] -weight = [] - -[stages.cases.case6.clangtidy] -keyword = [] -weight = [] - -[stages.cases.case6.cppcheck] -keyword = [] -weight = [] - -[stages.cases.case6.cpplint] -keyword = [] -weight = [] - -[stages.cases.case6.result-detail] -time = true -mem = true -stdout = false -stderr = false -exitstatus = false - -[stages.cases.case6.file] - -[stages.cases.case6.cases] -[stages.cases.case6.diff.output] -score = 0 -ignorespaces = true -hide = false -forcequit = false - -[stages.cases.case7] -in = "case7.in" -out = "case7.out" -score = 10 -parsers = [] -skip = [] - -[stages.cases.case7.limit] -mem = 32000000 -cpu = 1 -stderr = 800 -stdout = 800 - -[stages.cases.case7.dummy] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case7.result-status] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case7.keyword] -keyword = [] -weight = [] - -[stages.cases.case7.clangtidy] -keyword = [] -weight = [] - -[stages.cases.case7.cppcheck] -keyword = [] -weight = [] - -[stages.cases.case7.cpplint] -keyword = [] -weight = [] - -[stages.cases.case7.result-detail] -time = true -mem = true -stdout = false -stderr = false -exitstatus = false - -[stages.cases.case7.file] - -[stages.cases.case7.cases] -[stages.cases.case7.diff.output] -score = 0 -ignorespaces = true -hide = false -forcequit = false - -[stages.cases.case8] -in = "case8.in" -out = "case8.out" -score = 10 -parsers = [] -skip = [] - -[stages.cases.case8.limit] -mem = 32000000 -cpu = 1 -stderr = 800 -stdout = 800 - -[stages.cases.case8.dummy] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case8.result-status] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case8.keyword] -keyword = [] -weight = [] - -[stages.cases.case8.clangtidy] -keyword = [] -weight = [] - -[stages.cases.case8.cppcheck] -keyword = [] -weight = [] - -[stages.cases.case8.cpplint] -keyword = [] -weight = [] - -[stages.cases.case8.result-detail] -time = true -mem = true -stdout = false -stderr = false -exitstatus = false - -[stages.cases.case8.file] - -[stages.cases.case8.cases] -[stages.cases.case8.diff.output] -score = 0 -ignorespaces = true -hide = false -forcequit = false - -[stages.cases.case9] -in = "case9.in" -out = "case9.out" -score = 10 -parsers = [] -skip = [] - -[stages.cases.case9.limit] -mem = 32000000 -cpu = 1 -stderr = 800 -stdout = 800 - -[stages.cases.case9.dummy] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case9.result-status] -comment = "" -score = 0 -forcequit = false - -[stages.cases.case9.keyword] -keyword = [] -weight = [] - -[stages.cases.case9.clangtidy] -keyword = [] -weight = [] - -[stages.cases.case9.cppcheck] -keyword = [] -weight = [] - -[stages.cases.case9.cpplint] -keyword = [] -weight = [] - -[stages.cases.case9.result-detail] -time = true -mem = true -stdout = false -stderr = false -exitstatus = false - -[stages.cases.case9.file] - -[stages.cases.case9.cases] -[stages.cases.case9.diff.output] -score = 0 -ignorespaces = true -hide = false -forcequit = false -[stages.diff.output] -score = 0 -ignorespaces = true -hide = false -forcequit = false - -[task] -type = "" -name = "Blank Task" - -[release] -- 2.30.2