diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index f7d281d..2ff3fc6 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: https://gitea.com/BoYanZh/checkout@focs + uses: actions/checkout@focs - name: Display Python3 version run: python3 --version - name: Install PDM diff --git a/README.md b/README.md index 631d344..8ad7169 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,25 @@ 3. Change dir to the repo, `cd JOJ3-config-generator` 4. Install deps by `pdm install && pdm run pre-commit install` 5. Run the cli app by `pdm run app --help` +6. Check other commands or scripts with `pdm run --list` ## How to use? -- `joj3-config-generator convert` function is now supported, currently support three flags: +- `joj3-config-generator convert` function is now supported, currently support one argument as input, it indicates the **convert root** + - default value on the server can be given as `/home/tt/.config/joj` + - **NOTE:** the user should ensure that the ideal `repo.toml` file is in the sub-directory of the **convert root** + - the intended immutable files should be placed at a sub-directory named `immutable_files` at same position as the `repo.toml` file - - `-d/--distribute`: Add it without other input, it indicates script is ready to convert things other than testcases within the project - - `-c/--conf-root`: This is where you want to put all your 'task.toml' type folders, default choice for your input can be '/home/tt/.config/joj/' - - `-r/--repo-root`: This would be where you put your 'repo.toml' file as well as your 'immutable files', they should all be at same place, default choice for your input can be 'immutable_files', which is the folder at the position '/home/tt/.config/joj/' +```shell +[nuvole0217@Nuvole test]$ tree . +. +|- immutable_files +| |-- push.yaml +| |-- release.yaml +|-- repo.toml +``` - sample command on the server ```shell -joj3-config-generator convert -d -c /home/tt/.config/joj/ -r immutable_files +joj3-config-generator convert /home/tt/.config/joj ``` diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index a878291..c683ddc 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -22,9 +22,7 @@ from joj3_config_generator.processers.task import ( ) -def convert( - repo_conf: repo.Config, task_conf: task.Config, repo_root: Path -) -> result.Config: +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.name, @@ -49,7 +47,7 @@ def convert( not repo_conf.force_skip_heatlh_check_on_test or os.environ.get("PYTEST_CURRENT_TEST") is None ): - healthcheck_stage = get_healthcheck_config(repo_conf, repo_root) + healthcheck_stage = get_healthcheck_config(repo_conf) result_conf.stage.stages.append(healthcheck_stage) stages: List[str] = [] # Convert each stage in the task configuration @@ -75,26 +73,3 @@ def convert_joj1(joj1_conf: joj1.Config) -> task.Config: release=task.Release(deadline=None, begin_time=None), stages=[], ) - - -def distribute_json(folder_path: str, repo_obj: Any, repo_conf: Path) -> None: - for root, _, files in os.walk(folder_path): - for file in files: - if file.endswith(".toml"): # to pass test here - 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), repo_conf - ) - 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!" diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index ec30f68..027a716 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -1,21 +1,37 @@ import json -import os from pathlib import Path -from typing import Any, Dict +import inquirer import rtoml import typer import yaml +from typing_extensions import Annotated 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 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: """ @@ -31,54 +47,39 @@ def convert_joj1(yaml_file: typer.FileText, toml_file: typer.FileTextWrite) -> N @app.command() def convert( - root: Path = typer.Option( - Path("."), - "--conf-root", - "-c", - help="This is where you want to put all your 'task.toml' type folders, default choice for your input can be '/home/tt/.config/joj/'", - ), - repo_path: Path = typer.Option( - Path("."), - "--repo-root", - "-r", - help="This would be where you put your 'repo.toml' file as well as your 'immutable files', they should all be at same place, default choice for your input can be 'immutable_files', which is the folder at the position '/home/tt/.config/joj/'", - ), - distribute: bool = typer.Option( - False, "--distribute", "-d", help="This flag determine whether to distribute" - ), + root: Annotated[ + Path, + typer.Argument( + help="root directory of config files, " + "located at /home/tt/.config/joj in JTC" + ), + ] = Path(".") ) -> None: + """ + Convert given dir of JOJ3 toml config files to JOJ3 json config files + """ logger.info(f"Converting files in {root.absolute()}") - if distribute is False: - repo_toml_path = os.path.join(repo_path.absolute(), "basic", "repo.toml") - else: - repo_toml_path = os.path.join("/home/tt/.config/joj", repo_path, "repo.toml") - repo_toml_path = os.path.join(repo_path, "repo.toml") - with open(repo_toml_path, encoding=None) as repo_file: - repo_toml = repo_file.read() - repo_obj = rtoml.loads(repo_toml) - if distribute is False: - task_toml_path = os.path.join(root.absolute(), "basic", "task.toml") - result_json_path = os.path.join(root.absolute(), "basic", "task.json") - - with open(task_toml_path, encoding=None) as task_file: - task_toml = task_file.read() - - task_obj = rtoml.loads(task_toml) - result_model = convert_conf( - repo.Config(**repo_obj), task.Config(**task_obj), repo_path - ) - result_dict = result_model.model_dump(by_alias=True, exclude_none=True) - - 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 - else: - folder_path = "/home/tt/.config/joj" - folder_path = f"{Path.home()}/Desktop/engr151-joj/home/tt/.config/joj/homework" - folder_path = f"{Path.home()}/Desktop/FOCS/JOJ3-config-generator/tests/convert/" - # to be used in real action - folder_path = f"{root}" - distribute_json(folder_path, repo_obj, repo_path) + root = root.absolute() + for repo_toml_path in root.glob("**/repo.toml"): + repo_path = repo_toml_path.parent + repo_obj = rtoml.loads(repo_toml_path.read_text()) + for task_toml_path in repo_path.glob("**/*.toml"): + if repo_toml_path == task_toml_path: + continue + toml_name = task_toml_path.name.removesuffix(".toml") + result_json_path = task_toml_path.parent / f"{toml_name}.json" + logger.info( + f"Converting {repo_toml_path} & {task_toml_path} to {result_json_path}" + ) + task_obj = rtoml.loads(task_toml_path.read_text()) + repo_conf = repo.Config(**repo_obj) + repo_conf.root = root + repo_conf.path = repo_toml_path.relative_to(root) + task_conf = task.Config(**task_obj) + task_conf.root = root + task_conf.path = task_toml_path.relative_to(root) + result_model = convert_conf(repo_conf, task_conf) + result_dict = result_model.model_dump(by_alias=True, exclude_none=True) + with result_json_path.open("w") as result_file: + json.dump(result_dict, result_file, ensure_ascii=False, indent=4) + result_file.write("\n") diff --git a/joj3_config_generator/models/repo.py b/joj3_config_generator/models/repo.py index 9c55201..94ea8fe 100644 --- a/joj3_config_generator/models/repo.py +++ b/joj3_config_generator/models/repo.py @@ -1,4 +1,5 @@ -from typing import List +from pathlib import Path +from typing import List, Optional from pydantic import BaseModel, Field @@ -21,3 +22,5 @@ class Config(BaseModel): max_total_score: int = Field(100) force_skip_heatlh_check_on_test: bool = False groups: Groups = Groups() + root: Path = Path(".") + path: Path = Path("repo.toml") diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 87c5b40..bcc59c7 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -1,7 +1,8 @@ from datetime import datetime +from pathlib import Path from typing import Any, Dict, List, Optional, Type -from pydantic import BaseModel, Field, model_serializer, model_validator +from pydantic import BaseModel, Field, model_validator class ParserResultDetail(BaseModel): @@ -107,6 +108,8 @@ class Task(BaseModel): class Config(BaseModel): - task: Task - release: Release + root: Optional[Path] = None + path: Optional[Path] = None + task: Task # Task name (e.g., hw3 ex5) + 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 b72ff8d..b6b74c7 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -37,7 +37,7 @@ def get_teapot_stage(repo_conf: repo.Config) -> result.StageDetail: return stage_conf -def get_healthcheck_args(repo_conf: repo.Config, repo_root: Path) -> str: +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,7 +59,7 @@ def get_healthcheck_args(repo_conf: repo.Config, repo_root: Path) -> str: for meta in required_files: args = args + meta - args = args + get_hash(immutable, repo_root) + args = args + get_hash(immutable, repo_conf) args = args + immutable_files @@ -84,9 +84,7 @@ def get_debug_args(repo_conf: repo.Config) -> str: return args -def get_healthcheck_config( - repo_conf: repo.Config, repo_root: Path -) -> result.StageDetail: +def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail: healthcheck_stage = result.StageDetail( name="healthcheck", group="", @@ -96,7 +94,7 @@ def get_healthcheck_config( default=result.Cmd(), cases=[ result.OptionalCmd( - args=shlex.split(get_healthcheck_args(repo_conf, repo_root)), + args=shlex.split(get_healthcheck_args(repo_conf)), ), result.OptionalCmd( args=shlex.split(get_debug_args(repo_conf)), @@ -113,7 +111,7 @@ def get_healthcheck_config( return healthcheck_stage -def calc_sha256sum(file_path: str) -> str: +def calc_sha256sum(file_path: Path) -> str: sha256_hash = hashlib.sha256() with open(file_path, "rb") as f: for byte_block in iter(lambda: f.read(65536 * 2), b""): @@ -122,22 +120,17 @@ def calc_sha256sum(file_path: str) -> str: def get_hash( - immutable_files: list[str], repo_root: Path + immutable_files: list[str], repo_conf: repo.Config ) -> 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] - # FIXME: givin the path - file_path = f"{project_root}/tests/immutable_file/" - # file_path = "{Path.home()}/.cache/immutable" - # to be use - # file_path = f"/home/tt/.config/joj/{repo_root}/" + repo_path = (repo_conf.root / repo_conf.path).parent + file_path = Path(f"{repo_path}/immutable_files") immutable_hash = [] + immutable_files_ = [] for i, file in enumerate(immutable_files): - immutable_files[i] = file_path + file.rsplit("/", 1)[-1] + immutable_files_.append(file_path.joinpath(file.rsplit("/", 1)[-1])) - for i, file in enumerate(immutable_files): - immutable_hash.append(calc_sha256sum(file)) + for i, file_ in enumerate(immutable_files_): + immutable_hash.append(calc_sha256sum(file_)) hash_check = "-checkFileSumList=" diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 7248394..b2894b4 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -276,7 +276,13 @@ def fix_diff( stage_cases.append( result.OptionalCmd( stdin=result.CmdFile( - src=f"/home/tt/.config/joj/{task_conf.task.type_}/{stdin}" + src=( + (task_conf.root / task_conf.path) + .parent.joinpath(stdin) + .name + if task_conf.root is not None and task_conf.path is not None + else f"/home/tt/.config/joj/{task_conf.task.type_}/{stdin}" + ) ), args=(shlex.split(command) if command is not None else None), cpu_limit=cpu_limit, @@ -299,7 +305,16 @@ def fix_diff( { "score": diff_output.score, "fileName": "stdout", - "answerPath": f"/home/tt/.config/joj/{task_conf.task.type_}/{stdout}", + "answerPath": ( + (task_conf.root / task_conf.path) + .parent.joinpath(stdout) + .name + if ( + task_conf.root is not None + and task_conf.path is not None + ) + else 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/immutable_file/.gitattributes b/tests/convert/basic/immutable_files/.gitattributes similarity index 100% rename from tests/immutable_file/.gitattributes rename to tests/convert/basic/immutable_files/.gitattributes diff --git a/tests/immutable_file/.gitignore b/tests/convert/basic/immutable_files/.gitignore similarity index 100% rename from tests/immutable_file/.gitignore rename to tests/convert/basic/immutable_files/.gitignore diff --git a/tests/immutable_file/push.yaml b/tests/convert/basic/immutable_files/push.yaml similarity index 100% rename from tests/immutable_file/push.yaml rename to tests/convert/basic/immutable_files/push.yaml diff --git a/tests/immutable_file/release.yaml b/tests/convert/basic/immutable_files/release.yaml similarity index 100% rename from tests/immutable_file/release.yaml rename to tests/convert/basic/immutable_files/release.yaml diff --git a/tests/convert/clang-tidy/immutable_files/.gitattributes b/tests/convert/clang-tidy/immutable_files/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/convert/clang-tidy/immutable_files/.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/convert/clang-tidy/immutable_files/.gitignore b/tests/convert/clang-tidy/immutable_files/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/convert/clang-tidy/immutable_files/.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/convert/clang-tidy/immutable_files/push.yaml b/tests/convert/clang-tidy/immutable_files/push.yaml new file mode 100644 index 0000000..664f371 --- /dev/null +++ b/tests/convert/clang-tidy/immutable_files/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/convert/clang-tidy/immutable_files/release.yaml b/tests/convert/clang-tidy/immutable_files/release.yaml new file mode 100644 index 0000000..e740403 --- /dev/null +++ b/tests/convert/clang-tidy/immutable_files/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/convert/clang-tidy/task.json b/tests/convert/clang-tidy/task.json index 386df1d..5c68e1b 100644 --- a/tests/convert/clang-tidy/task.json +++ b/tests/convert/clang-tidy/task.json @@ -7,117 +7,9 @@ "maxTotalScore": 100, "stage": { "sandboxExecServer": "172.17.0.1:5051", - "sandboxToken": "test", + "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "local", - "with": { - "default": { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "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": [ - { - "args": [ - "/usr/local/bin/repo-health-checker", - "-root=.", - "-repoSize=50.5", - "-meta=README.md", - "-meta=Changelog.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,f6740081487ca34963a005209e2e9adfdf6f3561719af082d40fe80145e0cceb,bbeca1491c2f8364821a328a6677c0c5d59ccd60250abac3cec0887eeb9bde3e", - "-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", - "ece280-joj", - "--group-config", - "joj=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": 0 - } - } - ] - }, { "name": "[cq] Clang-tidy", "group": "cq", @@ -159,11 +51,11 @@ "cpuSetLimit": "", "copyIn": { "tests/homework/h7/.clang-tidy": { - "src": "/home/tt/.config/joj/tools/tests/homework/h7/.clang-tidy", + "src": "/home/tt/.config/joj/tests/homework/h7/.clang-tidy", "max": 419430400 }, "h7/build/compile_commands.json": { - "src": "/home/tt/.config/joj/tools/h7/build/compile_commands.json", + "src": "/home/tt/.config/joj/h7/build/compile_commands.json", "max": 419430400 } }, diff --git a/tests/convert/cppcheck/immutable_files/.gitattributes b/tests/convert/cppcheck/immutable_files/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/convert/cppcheck/immutable_files/.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/convert/cppcheck/immutable_files/.gitignore b/tests/convert/cppcheck/immutable_files/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/convert/cppcheck/immutable_files/.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/convert/cppcheck/immutable_files/push.yaml b/tests/convert/cppcheck/immutable_files/push.yaml new file mode 100644 index 0000000..664f371 --- /dev/null +++ b/tests/convert/cppcheck/immutable_files/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/convert/cppcheck/immutable_files/release.yaml b/tests/convert/cppcheck/immutable_files/release.yaml new file mode 100644 index 0000000..e740403 --- /dev/null +++ b/tests/convert/cppcheck/immutable_files/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/convert/cppcheck/task.json b/tests/convert/cppcheck/task.json index 17aa510..f88faff 100644 --- a/tests/convert/cppcheck/task.json +++ b/tests/convert/cppcheck/task.json @@ -7,117 +7,9 @@ "maxTotalScore": 100, "stage": { "sandboxExecServer": "172.17.0.1:5051", - "sandboxToken": "test", + "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "local", - "with": { - "default": { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "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": [ - { - "args": [ - "/usr/local/bin/repo-health-checker", - "-root=.", - "-repoSize=50.5", - "-meta=README.md", - "-meta=Changelog.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,f6740081487ca34963a005209e2e9adfdf6f3561719af082d40fe80145e0cceb,bbeca1491c2f8364821a328a6677c0c5d59ccd60250abac3cec0887eeb9bde3e", - "-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", - "ece280-joj", - "--group-config", - "joj=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": 0 - } - } - ] - }, { "name": "[cq] Cppcheck", "group": "cq", diff --git a/tests/convert/cpplint/immutable_files/.gitattributes b/tests/convert/cpplint/immutable_files/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/convert/cpplint/immutable_files/.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/convert/cpplint/immutable_files/.gitignore b/tests/convert/cpplint/immutable_files/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/convert/cpplint/immutable_files/.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/convert/cpplint/immutable_files/push.yaml b/tests/convert/cpplint/immutable_files/push.yaml new file mode 100644 index 0000000..664f371 --- /dev/null +++ b/tests/convert/cpplint/immutable_files/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/convert/cpplint/immutable_files/release.yaml b/tests/convert/cpplint/immutable_files/release.yaml new file mode 100644 index 0000000..e740403 --- /dev/null +++ b/tests/convert/cpplint/immutable_files/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/convert/cpplint/task.json b/tests/convert/cpplint/task.json index b15c928..59fffc3 100644 --- a/tests/convert/cpplint/task.json +++ b/tests/convert/cpplint/task.json @@ -7,117 +7,9 @@ "maxTotalScore": 100, "stage": { "sandboxExecServer": "172.17.0.1:5051", - "sandboxToken": "test", + "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "local", - "with": { - "default": { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "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": [ - { - "args": [ - "/usr/local/bin/repo-health-checker", - "-root=.", - "-repoSize=50.5", - "-meta=README.md", - "-meta=Changelog.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,f6740081487ca34963a005209e2e9adfdf6f3561719af082d40fe80145e0cceb,bbeca1491c2f8364821a328a6677c0c5d59ccd60250abac3cec0887eeb9bde3e", - "-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", - "ece280-joj", - "--group-config", - "joj=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": 0 - } - } - ] - }, { "name": "[cq] Cpplint", "group": "cq", diff --git a/tests/convert/diff/immutable_files/.gitattributes b/tests/convert/diff/immutable_files/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/convert/diff/immutable_files/.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/convert/diff/immutable_files/.gitignore b/tests/convert/diff/immutable_files/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/convert/diff/immutable_files/.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/convert/diff/immutable_files/push.yaml b/tests/convert/diff/immutable_files/push.yaml new file mode 100644 index 0000000..664f371 --- /dev/null +++ b/tests/convert/diff/immutable_files/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/convert/diff/immutable_files/release.yaml b/tests/convert/diff/immutable_files/release.yaml new file mode 100644 index 0000000..e740403 --- /dev/null +++ b/tests/convert/diff/immutable_files/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/convert/diff/task.json b/tests/convert/diff/task.json index db59026..d5d5773 100644 --- a/tests/convert/diff/task.json +++ b/tests/convert/diff/task.json @@ -7,117 +7,9 @@ "maxTotalScore": 100, "stage": { "sandboxExecServer": "172.17.0.1:5051", - "sandboxToken": "test", + "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "local", - "with": { - "default": { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "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": [ - { - "args": [ - "/usr/local/bin/repo-health-checker", - "-root=.", - "-repoSize=50.5", - "-meta=README.md", - "-meta=Changelog.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,f6740081487ca34963a005209e2e9adfdf6f3561719af082d40fe80145e0cceb,bbeca1491c2f8364821a328a6677c0c5d59ccd60250abac3cec0887eeb9bde3e", - "-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", - "ece280-joj", - "--group-config", - "joj=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": 0 - } - } - ] - }, { "name": "[joj] ex2-asan", "group": "joj", @@ -150,7 +42,7 @@ "cpuSetLimit": "", "copyIn": { "h7/build/ex2-asan": { - "src": "/home/tt/.config/joj/tools/h7/build/ex2-asan", + "src": "/home/tt/.config/joj/h7/build/ex2-asan", "max": 419430400 } }, diff --git a/tests/convert/keyword/immutable_files/.gitattributes b/tests/convert/keyword/immutable_files/.gitattributes new file mode 100644 index 0000000..b910c4a --- /dev/null +++ b/tests/convert/keyword/immutable_files/.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/convert/keyword/immutable_files/.gitignore b/tests/convert/keyword/immutable_files/.gitignore new file mode 100644 index 0000000..754f776 --- /dev/null +++ b/tests/convert/keyword/immutable_files/.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/convert/keyword/immutable_files/push.yaml b/tests/convert/keyword/immutable_files/push.yaml new file mode 100644 index 0000000..664f371 --- /dev/null +++ b/tests/convert/keyword/immutable_files/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/convert/keyword/immutable_files/release.yaml b/tests/convert/keyword/immutable_files/release.yaml new file mode 100644 index 0000000..e740403 --- /dev/null +++ b/tests/convert/keyword/immutable_files/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/convert/keyword/task.json b/tests/convert/keyword/task.json index a4e3e2c..3ba8c53 100644 --- a/tests/convert/keyword/task.json +++ b/tests/convert/keyword/task.json @@ -7,117 +7,9 @@ "maxTotalScore": 100, "stage": { "sandboxExecServer": "172.17.0.1:5051", - "sandboxToken": "test", + "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "local", - "with": { - "default": { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "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": [ - { - "args": [ - "/usr/local/bin/repo-health-checker", - "-root=.", - "-repoSize=50.5", - "-meta=README.md", - "-meta=Changelog.md", - "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,f6740081487ca34963a005209e2e9adfdf6f3561719af082d40fe80145e0cceb,bbeca1491c2f8364821a328a6677c0c5d59ccd60250abac3cec0887eeb9bde3e", - "-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", - "ece280-joj", - "--group-config", - "joj=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": 0 - } - } - ] - }, { "name": "[cq] Filelength", "group": "cq", @@ -157,7 +49,7 @@ "cpuSetLimit": "", "copyIn": { "tools/filelength": { - "src": "/home/tt/.config/joj/tools/tools/filelength", + "src": "/home/tt/.config/joj/tools/filelength", "max": 419430400 } }, diff --git a/tests/convert/utils.py b/tests/convert/utils.py index 7efa4be..0a458a1 100644 --- a/tests/convert/utils.py +++ b/tests/convert/utils.py @@ -1,5 +1,4 @@ import json -import os from pathlib import Path from typing import Any, Dict, Tuple @@ -12,24 +11,22 @@ from joj3_config_generator.models import repo, task 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") - with open(repo_toml_path) as f: - repo_toml = f.read() - 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, case_name, "task.json") - with open(result_json_path) as f: - result: Dict[str, Any] = json.load(f) - repo_obj = rtoml.loads(repo_toml) - task_obj = rtoml.loads(task_toml) - return repo.Config(**repo_obj), task.Config(**task_obj), result + root = Path(__file__).resolve().parent / case_name + repo_toml_path = root / "repo.toml" + repo_toml = repo_toml_path.read_text() if repo_toml_path.exists() else "" + task_toml_path = root / "task.toml" + task_toml = task_toml_path.read_text() if task_toml_path.exists() else "" + result = json.loads((root / "task.json").read_text()) + return ( + repo.Config(root=root, **rtoml.loads(repo_toml)), + task.Config(root=root, **rtoml.loads(task_toml)), + result, + ) def load_case(case_name: str) -> None: repo, task, expected_result = read_convert_files(case_name) - result = convert(repo, task, repo_root=Path(".")).model_dump( + result = convert(repo, task).model_dump( mode="json", by_alias=True, exclude_none=True ) assert result == expected_result diff --git a/tests/convert_joj1/utils.py b/tests/convert_joj1/utils.py index f936fbc..947c5c2 100644 --- a/tests/convert_joj1/utils.py +++ b/tests/convert_joj1/utils.py @@ -1,4 +1,4 @@ -import os +from pathlib import Path from typing import Any, Dict, Tuple import rtoml @@ -9,19 +9,15 @@ from joj3_config_generator.models import joj1 def read_convert_joj1_files(case_name: str) -> Tuple[joj1.Config, Dict[str, Any]]: - root = os.path.dirname(os.path.realpath(__file__)) - task_yaml_path = os.path.join(root, case_name, "task.yaml") - with open(task_yaml_path) as f: - task_yaml = f.read() - task_toml_path = os.path.join(root, case_name, "task.toml") - with open(task_toml_path) as f: - task_toml = f.read() - joj1_obj = yaml.safe_load(task_yaml) - task_obj = rtoml.loads(task_toml) - return joj1.Config(**joj1_obj), task_obj + root = Path(__file__).resolve().parent + task_yaml_path = root / case_name / "task.yaml" + task_yaml = task_yaml_path.read_text() + task_toml_path = root / case_name / "task.toml" + task_toml = task_toml_path.read_text() + return joj1.Config(**yaml.safe_load(task_yaml)), rtoml.loads(task_toml) def load_case(case_name: str) -> None: - joj1, expected_result = read_convert_joj1_files(case_name) - result = convert_joj1(joj1).model_dump(by_alias=True, exclude_none=True) + joj1_, expected_result = read_convert_joj1_files(case_name) + result = convert_joj1(joj1_).model_dump(by_alias=True, exclude_none=True) assert result == expected_result diff --git a/tests/utils.py b/tests/utils.py deleted file mode 100644 index 7eda07e..0000000 --- a/tests/utils.py +++ /dev/null @@ -1,7 +0,0 @@ -from typing import Any - - -def safe_id(x: Any) -> str: - if not x or not isinstance(x, (tuple, list)) or len(x) == 0: - return "no_test_cases" - return str(x[0])