From c7917efac776ac820501e4925209eaefcc201e9c Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sat, 1 Mar 2025 13:00:43 -0500 Subject: [PATCH] feat: force skip teapot on test --- joj3_config_generator/convert.py | 14 ++--- joj3_config_generator/models/repo.py | 1 + joj3_config_generator/models/result.py | 4 +- joj3_config_generator/processers/repo.py | 1 - joj3_config_generator/processers/task.py | 1 - tests/convert/basic/task.json | 3 +- tests/convert/clang-tidy/repo.toml | 1 + tests/convert/clang-tidy/task.json | 58 +------------------ tests/convert/cppcheck/repo.toml | 1 + tests/convert/cppcheck/task.json | 58 +------------------ tests/convert/cpplint/repo.toml | 1 + tests/convert/cpplint/task.json | 58 +------------------ tests/convert/diff/repo.toml | 1 + tests/convert/diff/task.json | 58 +------------------ tests/convert/keyword/repo.toml | 1 + tests/convert/keyword/task.json | 58 +------------------ tests/convert_joj1/test_convert_joj1_cases.py | 2 - 17 files changed, 27 insertions(+), 294 deletions(-) diff --git a/joj3_config_generator/convert.py b/joj3_config_generator/convert.py index 86b44a7..3544601 100644 --- a/joj3_config_generator/convert.py +++ b/joj3_config_generator/convert.py @@ -34,17 +34,15 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: stage=result.Stage( stages=[], sandbox_token=repo_conf.sandbox_token, - poststages=[get_teapot_stage(repo_conf)], + post_stages=[], ), ) + current_test = os.environ.get("PYTEST_CURRENT_TEST") is not None # Construct healthcheck stage - if ( - not repo_conf.force_skip_health_check_on_test - or os.environ.get("PYTEST_CURRENT_TEST") is None - ): - healthcheck_stage = get_healthcheck_config(repo_conf) - result_conf.stage.stages.append(healthcheck_stage) + print(current_test) + if not repo_conf.force_skip_health_check_on_test or not current_test: + result_conf.stage.stages.append(get_healthcheck_config(repo_conf)) stages: List[str] = [] # Convert each stage in the task configuration for task_stage in task_conf.stages: @@ -56,6 +54,8 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: 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) + if not repo_conf.force_skip_teapot_on_test or not current_test: + result_conf.stage.post_stages.append(get_teapot_stage(repo_conf)) return result_conf diff --git a/joj3_config_generator/models/repo.py b/joj3_config_generator/models/repo.py index 2ea9a8a..1014925 100644 --- a/joj3_config_generator/models/repo.py +++ b/joj3_config_generator/models/repo.py @@ -21,6 +21,7 @@ class Config(BaseModel): sandbox_token: str = Field("") max_total_score: int = Field(100) force_skip_health_check_on_test: bool = False + force_skip_teapot_on_test: bool = False groups: Groups = Groups() root: Path = Path(".") path: Path = Path("repo.toml") diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index 1f77d28..a8623a3 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -142,8 +142,8 @@ class Stage(BaseModel): "/tmp/joj3_result.json", serialization_alias="outputPath" ) # nosec: B108 stages: List[StageDetail] - prestages: Optional[List[StageDetail]] = None - poststages: List[StageDetail] + pre_stages: List[StageDetail] = Field([], serialization_alias="preStages") + post_stages: List[StageDetail] = Field([], serialization_alias="postStages") class Config(BaseModel): diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index b6b74c7..cbc1d4c 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 diff --git a/joj3_config_generator/processers/task.py b/joj3_config_generator/processers/task.py index 5f2b0fb..3d6637f 100644 --- a/joj3_config_generator/processers/task.py +++ b/joj3_config_generator/processers/task.py @@ -1,6 +1,5 @@ import re import shlex -from pathlib import Path from typing import List, Tuple from joj3_config_generator.models import result, task diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 3e50cb9..61a8a4c 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -765,7 +765,8 @@ ] } ], - "poststages": [ + "preStages": [], + "postStages": [ { "name": "teapot", "group": "", diff --git a/tests/convert/clang-tidy/repo.toml b/tests/convert/clang-tidy/repo.toml index e2a5774..2858724 100644 --- a/tests/convert/clang-tidy/repo.toml +++ b/tests/convert/clang-tidy/repo.toml @@ -1 +1,2 @@ force_skip_health_check_on_test = true +force_skip_teapot_on_test = true diff --git a/tests/convert/clang-tidy/task.json b/tests/convert/clang-tidy/task.json index dd429c0..9d47190 100644 --- a/tests/convert/clang-tidy/task.json +++ b/tests/convert/clang-tidy/task.json @@ -141,61 +141,7 @@ ] } ], - "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", - "ece280-joj", - "--max-total-score", - "100" - ], - "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" - ], - "cpuLimit": 0, - "realCpuLimit": 0, - "clockLimit": 2, - "memoryLimit": 128000000, - "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" - } - } - ] - } - ] + "preStages": [], + "postStages": [] } } diff --git a/tests/convert/cppcheck/repo.toml b/tests/convert/cppcheck/repo.toml index e2a5774..2858724 100644 --- a/tests/convert/cppcheck/repo.toml +++ b/tests/convert/cppcheck/repo.toml @@ -1 +1,2 @@ force_skip_health_check_on_test = true +force_skip_teapot_on_test = true diff --git a/tests/convert/cppcheck/task.json b/tests/convert/cppcheck/task.json index 4d4ba43..2531d29 100644 --- a/tests/convert/cppcheck/task.json +++ b/tests/convert/cppcheck/task.json @@ -111,61 +111,7 @@ ] } ], - "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", - "ece280-joj", - "--max-total-score", - "100" - ], - "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" - ], - "cpuLimit": 0, - "realCpuLimit": 0, - "clockLimit": 2, - "memoryLimit": 128000000, - "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" - } - } - ] - } - ] + "preStages": [], + "postStages": [] } } diff --git a/tests/convert/cpplint/repo.toml b/tests/convert/cpplint/repo.toml index e2a5774..2858724 100644 --- a/tests/convert/cpplint/repo.toml +++ b/tests/convert/cpplint/repo.toml @@ -1 +1,2 @@ force_skip_health_check_on_test = true +force_skip_teapot_on_test = true diff --git a/tests/convert/cpplint/task.json b/tests/convert/cpplint/task.json index 1dcc5f4..3beef8e 100644 --- a/tests/convert/cpplint/task.json +++ b/tests/convert/cpplint/task.json @@ -113,61 +113,7 @@ ] } ], - "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", - "ece280-joj", - "--max-total-score", - "100" - ], - "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" - ], - "cpuLimit": 0, - "realCpuLimit": 0, - "clockLimit": 2, - "memoryLimit": 128000000, - "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" - } - } - ] - } - ] + "preStages": [], + "postStages": [] } } diff --git a/tests/convert/diff/repo.toml b/tests/convert/diff/repo.toml index e2a5774..2858724 100644 --- a/tests/convert/diff/repo.toml +++ b/tests/convert/diff/repo.toml @@ -1 +1,2 @@ force_skip_health_check_on_test = true +force_skip_teapot_on_test = true diff --git a/tests/convert/diff/task.json b/tests/convert/diff/task.json index 133b245..30651fa 100644 --- a/tests/convert/diff/task.json +++ b/tests/convert/diff/task.json @@ -138,61 +138,7 @@ ] } ], - "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", - "ece280-joj", - "--max-total-score", - "100" - ], - "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" - ], - "cpuLimit": 0, - "realCpuLimit": 0, - "clockLimit": 2, - "memoryLimit": 128000000, - "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" - } - } - ] - } - ] + "preStages": [], + "postStages": [] } } diff --git a/tests/convert/keyword/repo.toml b/tests/convert/keyword/repo.toml index e2a5774..2858724 100644 --- a/tests/convert/keyword/repo.toml +++ b/tests/convert/keyword/repo.toml @@ -1 +1,2 @@ force_skip_health_check_on_test = true +force_skip_teapot_on_test = true diff --git a/tests/convert/keyword/task.json b/tests/convert/keyword/task.json index d02b703..f1f1327 100644 --- a/tests/convert/keyword/task.json +++ b/tests/convert/keyword/task.json @@ -110,61 +110,7 @@ ] } ], - "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", - "ece280-joj", - "--max-total-score", - "100" - ], - "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" - ], - "cpuLimit": 0, - "realCpuLimit": 0, - "clockLimit": 2, - "memoryLimit": 128000000, - "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" - } - } - ] - } - ] + "preStages": [], + "postStages": [] } } diff --git a/tests/convert_joj1/test_convert_joj1_cases.py b/tests/convert_joj1/test_convert_joj1_cases.py index d67709f..8ac3fd8 100644 --- a/tests/convert_joj1/test_convert_joj1_cases.py +++ b/tests/convert_joj1/test_convert_joj1_cases.py @@ -1,5 +1,3 @@ -import pytest - from tests.convert_joj1.utils import load_case