pr-proof 0.0.0-stage → 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/Procfile +2 -0
- package/README.md +300 -2
- package/app/__init__.py +1 -0
- package/app/api/__init__.py +1 -0
- package/app/api/cli.py +35 -0
- package/app/api/github.py +168 -0
- package/app/api/history.py +123 -0
- package/app/api/main.py +95 -0
- package/app/api/queue.py +45 -0
- package/app/api/responses.py +28 -0
- package/app/api/signature.py +19 -0
- package/app/api/sync.py +189 -0
- package/app/api/sync_rules_pure.py +71 -0
- package/app/api/webhook.py +166 -0
- package/app/setup/__init__.py +4 -0
- package/app/setup/cli.py +90 -0
- package/app/setup/configure.py +720 -0
- package/app/setup/files.py +93 -0
- package/app/setup/github_setup.py +149 -0
- package/app/setup/install_hints.json +32 -0
- package/app/setup/setup_pure.py +312 -0
- package/app/setup/start.py +113 -0
- package/app/shared/__init__.py +1 -0
- package/app/shared/comment_pure.py +29 -0
- package/app/shared/config.py +106 -0
- package/app/shared/db_pure.py +339 -0
- package/app/shared/embed_models_pure.py +55 -0
- package/app/shared/feedback_pure.py +84 -0
- package/app/shared/github_auth.py +74 -0
- package/app/shared/job_pure.py +43 -0
- package/app/shared/notify.py +97 -0
- package/app/shared/ops_alert_pure.py +38 -0
- package/app/shared/state_keys_pure.py +24 -0
- package/app/shared/version.py +27 -0
- package/app/worker/__init__.py +1 -0
- package/app/worker/access_pure.py +180 -0
- package/app/worker/ai/__init__.py +1 -0
- package/app/worker/ai/claude_cli.py +684 -0
- package/app/worker/ai/mcp_relay.py +42 -0
- package/app/worker/ai/path_hook.py +103 -0
- package/app/worker/ai/tool_server.py +139 -0
- package/app/worker/ai/workdir.py +333 -0
- package/app/worker/base_config.py +173 -0
- package/app/worker/budget.py +100 -0
- package/app/worker/cache_key_pure.py +34 -0
- package/app/worker/call_budget_pure.py +132 -0
- package/app/worker/checker_authoring_pure.py +599 -0
- package/app/worker/checker_pure.py +196 -0
- package/app/worker/cli.py +97 -0
- package/app/worker/command.py +191 -0
- package/app/worker/command_pure.py +38 -0
- package/app/worker/coverage.py +123 -0
- package/app/worker/coverage_pure.py +202 -0
- package/app/worker/deps.py +22 -0
- package/app/worker/diff_pure.py +419 -0
- package/app/worker/doc_rules_pure.py +201 -0
- package/app/worker/doc_rules_report.py +979 -0
- package/app/worker/eval_run_pure.py +241 -0
- package/app/worker/evaluation.py +151 -0
- package/app/worker/feedback.py +448 -0
- package/app/worker/feedback_pure.py +131 -0
- package/app/worker/feedback_report_pure.py +90 -0
- package/app/worker/feedback_triage.py +85 -0
- package/app/worker/feedback_triage_pure.py +363 -0
- package/app/worker/fix/__init__.py +1 -0
- package/app/worker/fix/decide.py +197 -0
- package/app/worker/fix/feedback_fix_pure.py +125 -0
- package/app/worker/fix/fix_decision_pure.py +386 -0
- package/app/worker/fix/fix_pure.py +70 -0
- package/app/worker/fix/mechanical_fix.py +214 -0
- package/app/worker/fix/model_fix.py +575 -0
- package/app/worker/fix/model_fix_pure.py +593 -0
- package/app/worker/fix/proposal.py +584 -0
- package/app/worker/fix/proposal_pure.py +103 -0
- package/app/worker/fix/scope.py +40 -0
- package/app/worker/fix/scope_pure.py +222 -0
- package/app/worker/generated_tests_pure.py +442 -0
- package/app/worker/github.py +471 -0
- package/app/worker/graph.py +963 -0
- package/app/worker/guard.py +91 -0
- package/app/worker/lang/__init__.py +0 -0
- package/app/worker/lang/install_pure.py +25 -0
- package/app/worker/lang/python.py +862 -0
- package/app/worker/loop.py +200 -0
- package/app/worker/main.py +76 -0
- package/app/worker/markdown_pure.py +29 -0
- package/app/worker/mcp_pure.py +150 -0
- package/app/worker/memory.py +503 -0
- package/app/worker/merged_fix_pure.py +236 -0
- package/app/worker/pr_check_report_pure.py +201 -0
- package/app/worker/pr_description_report_pure.py +112 -0
- package/app/worker/preflight.py +125 -0
- package/app/worker/rag_pure.py +285 -0
- package/app/worker/rag_switch_pure.py +203 -0
- package/app/worker/records.py +207 -0
- package/app/worker/records_pure.py +239 -0
- package/app/worker/repo.py +588 -0
- package/app/worker/repo_config_pure.py +269 -0
- package/app/worker/report.py +300 -0
- package/app/worker/retry.py +65 -0
- package/app/worker/rule_pure.py +223 -0
- package/app/worker/rule_reading_pure.py +503 -0
- package/app/worker/rules/__init__.py +1 -0
- package/app/worker/rules/checkers.py +615 -0
- package/app/worker/rules/detect.py +154 -0
- package/app/worker/rules/doc_rules.py +301 -0
- package/app/worker/rules/doc_sections_pure.py +168 -0
- package/app/worker/rules/judge.py +410 -0
- package/app/worker/rules/judge_pure.py +627 -0
- package/app/worker/rules/pr_check.py +404 -0
- package/app/worker/rules/pr_check_pure.py +922 -0
- package/app/worker/rules/pr_description.py +218 -0
- package/app/worker/rules/pr_description_pure.py +743 -0
- package/app/worker/rules/rules.py +314 -0
- package/app/worker/rules/run_check.py +95 -0
- package/app/worker/rules/run_check_pure.py +219 -0
- package/app/worker/rules/tool_choice_pure.py +135 -0
- package/app/worker/sandbox/__init__.py +1 -0
- package/app/worker/sandbox/checker_runner.py +412 -0
- package/app/worker/sandbox/container.py +130 -0
- package/app/worker/sandbox/docker_cli.py +170 -0
- package/app/worker/sandbox/safe_read.py +32 -0
- package/app/worker/sandbox/toolcache.py +425 -0
- package/app/worker/state.py +602 -0
- package/app/worker/test_lines.py +77 -0
- package/app/worker/test_run_pure.py +133 -0
- package/app/worker/text_edit_pure.py +66 -0
- package/app/worker/tools_pure.py +152 -0
- package/app/worker/update.py +305 -0
- package/app/worker/violation_pure.py +33 -0
- package/bin/pr-proof.js +173 -0
- package/docker/sandbox/Dockerfile +12 -0
- package/docker/sandbox/coveragerc +19 -0
- package/docker-compose.yml +5 -0
- package/package.json +31 -4
- package/pyproject.toml +60 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"""대상 리포의 `.pipeline.yaml` (base 브랜치에서 읽음, docs/DESIGN.md 설정).
|
|
2
|
+
|
|
3
|
+
지금 단계에서 쓰는 항목만 정의한다. 다른 항목은 무시한다 (스키마 초안의 나머지는 그 단계에서).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from collections.abc import Mapping
|
|
7
|
+
from typing import Annotated, Final
|
|
8
|
+
|
|
9
|
+
import yaml
|
|
10
|
+
from pydantic import (
|
|
11
|
+
AfterValidator,
|
|
12
|
+
BaseModel,
|
|
13
|
+
ConfigDict,
|
|
14
|
+
Field,
|
|
15
|
+
StringConstraints,
|
|
16
|
+
ValidationError,
|
|
17
|
+
field_validator,
|
|
18
|
+
model_validator,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from app.worker.rag_switch_pure import DEFAULT_MODE, MODES, RagMode, parse_mode
|
|
22
|
+
|
|
23
|
+
# docker가 받는 최소 메모리보다 넉넉히 크게. 너무 작으면 컨테이너가 뜨지 않아 환경 오류로 보인다
|
|
24
|
+
MIN_MEMORY_GB: Final = 0.5
|
|
25
|
+
DEFAULT_MAX_RETRIES: Final = 3
|
|
26
|
+
# 회차마다 테스트를 다시 돌리므로 리포 설정으로 무한히 늘리지 못하게. 넘는 값은 이 값으로 줄인다
|
|
27
|
+
MAX_RETRIES_CAP: Final = 5
|
|
28
|
+
# claude --model에 넘기는 이름. `-`로 시작하면 옵션으로 읽히므로 막는다
|
|
29
|
+
MODEL_NAME_PATTERN: Final = r"^[A-Za-z0-9][A-Za-z0-9._\[\]-]*$"
|
|
30
|
+
DEFAULT_RULE_DOCS: Final = ("README.md", "CONTRIBUTING.md")
|
|
31
|
+
LINT: Final = "lint"
|
|
32
|
+
# 2단계에 없앤 설정 (10절 "v1 스키마에서 바뀐 키"). 있으면 무시하고 "설정:"에 알린다
|
|
33
|
+
REMOVED_KEYS: Final[Mapping[tuple[str, str], str]] = {
|
|
34
|
+
("skills", "static"): "`skills.static`은 없어졌습니다 (파이프라인 내장 검사기가 없음)",
|
|
35
|
+
("model", "budget_per_pr_usd"): (
|
|
36
|
+
"`model.budget_per_pr_usd`는 없어졌습니다. 호출 수 상한은 `model.calls`입니다"
|
|
37
|
+
),
|
|
38
|
+
}
|
|
39
|
+
# 2026-11-21에 없앤 키 (11.1). 옛 위치 `skills.fix` 아래에 있어도 알린다
|
|
40
|
+
REQUIRE_COVERED_NOTE: Final = (
|
|
41
|
+
"`fix.require_covered`는 없어졌습니다. 테스트가 실행하지 않는 줄의 위반도 고치고, "
|
|
42
|
+
"수정안 PR에 그 사실을 적습니다"
|
|
43
|
+
)
|
|
44
|
+
MAX_RULE_DOCS: Final = 20
|
|
45
|
+
# 유사도 기준값의 기본. 6.7의 측정으로 정했다 (multilingual-e5-small, 2026-11-20, 11.1)
|
|
46
|
+
DEFAULT_MIN_SIMILARITY: Final = 0.91
|
|
47
|
+
# 프롬프트에 넣는 기록 수의 상한. 저장소 설정이 프롬프트를 끝없이 늘리지 못하게
|
|
48
|
+
MAX_RECORDS_CAP: Final = 10
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _check_doc_path(path: str) -> str:
|
|
52
|
+
"""루트 기준 상대 경로만. git 인자와 문서 경계 표시에 그대로 들어가므로 이상한 글자를 막는다."""
|
|
53
|
+
parts = path.split("/")
|
|
54
|
+
if (
|
|
55
|
+
not path
|
|
56
|
+
or path.startswith(("/", "-"))
|
|
57
|
+
or any(part in ("", ".", "..") for part in parts)
|
|
58
|
+
or any(not ch.isprintable() or ch in '\\"' for ch in path)
|
|
59
|
+
):
|
|
60
|
+
raise ValueError(f"루트 기준 상대 경로가 아님: {path!r}")
|
|
61
|
+
return path
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
DocPath = Annotated[str, AfterValidator(_check_doc_path)]
|
|
65
|
+
RuleId = Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class RulesSettings(BaseModel):
|
|
69
|
+
"""규칙 문서와 끈 규칙 (DESIGN.md 4.3, 10절 `rules`). docs를 적으면 기본 목록을 대신한다."""
|
|
70
|
+
|
|
71
|
+
model_config = ConfigDict(extra="ignore")
|
|
72
|
+
docs: list[DocPath] = Field(
|
|
73
|
+
default_factory=lambda: list(DEFAULT_RULE_DOCS), max_length=MAX_RULE_DOCS
|
|
74
|
+
)
|
|
75
|
+
disabled: list[RuleId] = Field(default_factory=list)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class SandboxSettings(BaseModel):
|
|
79
|
+
model_config = ConfigDict(extra="ignore")
|
|
80
|
+
memory_gb: float = Field(default=1, ge=MIN_MEMORY_GB)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class FixSettings(BaseModel):
|
|
84
|
+
"""수정 설정 (DESIGN.md 10절 `fix`). 파이프라인 쪽 최댓값은 `fix_limits`가 적용한다."""
|
|
85
|
+
|
|
86
|
+
model_config = ConfigDict(extra="ignore")
|
|
87
|
+
require_approval: bool = False # 검사 뒤 바로 수정안을 만든다. true면 /fix 승인 후 만든다
|
|
88
|
+
# 모델 수정의 작성 → 검증 회차 상한 (4.7)
|
|
89
|
+
max_retries: int = Field(default=DEFAULT_MAX_RETRIES, ge=1)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class CallSettings(BaseModel):
|
|
93
|
+
"""모델 호출 수 상한 (docs/DESIGN.md 9.2, 10절 `model.calls`). 판단은
|
|
94
|
+
app/worker/call_budget_pure.py."""
|
|
95
|
+
|
|
96
|
+
model_config = ConfigDict(extra="ignore")
|
|
97
|
+
pr_base: int = Field(default=20, ge=0)
|
|
98
|
+
per_violation: int = Field(default=4, ge=0)
|
|
99
|
+
pr_max: int = Field(default=150, ge=0)
|
|
100
|
+
ruleset_base: int = Field(default=10, ge=0)
|
|
101
|
+
per_rule: int = Field(default=4, ge=0)
|
|
102
|
+
ruleset_max: int = Field(default=100, ge=0)
|
|
103
|
+
repo_daily: int = Field(default=500, ge=0)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class ModelSettings(BaseModel):
|
|
107
|
+
"""모델과 호출 상한. 백엔드는 claude CLI만 있다."""
|
|
108
|
+
|
|
109
|
+
model_config = ConfigDict(extra="ignore")
|
|
110
|
+
# 규칙 읽기와 검사기 작성의 모델 (11.2). 검사기 작성은 실패해도 더 높은 모델로 올리지 않는다:
|
|
111
|
+
# 3회 안에 안 되면 "검사하지 못한 규칙"으로 두고 4단계의 모델 판단으로 넘긴다 (11.2 D7)
|
|
112
|
+
rules: str = Field(default="sonnet", pattern=MODEL_NAME_PATTERN)
|
|
113
|
+
checker: str = Field(default="sonnet", pattern=MODEL_NAME_PATTERN)
|
|
114
|
+
decide: str = Field(default="sonnet", pattern=MODEL_NAME_PATTERN) # 수정 판단 (4.6)
|
|
115
|
+
judge: str = Field(default="sonnet", pattern=MODEL_NAME_PATTERN) # 모델의 직접 판단 (4.5)
|
|
116
|
+
# 수정 경로의 모델: 가벼운 모델로 시작하고 실패가 이어지면 무거운 모델로 한 번 올린다
|
|
117
|
+
light: str = Field(default="haiku", pattern=MODEL_NAME_PATTERN)
|
|
118
|
+
heavy: str = Field(default="sonnet", pattern=MODEL_NAME_PATTERN)
|
|
119
|
+
calls: CallSettings = CallSettings()
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class SkillsSettings(BaseModel):
|
|
123
|
+
"""v1의 스킬 설정. 3단계에 v1 lint를 도구 규칙으로 옮겨 스킬이 없어졌다 (10절). 옛 파일을 읽기만
|
|
124
|
+
한다: `enabled`에 lint가 없으면 그 저장소는 ruff를 끈 것이라 도구 설정의 규칙 묶음을 끈다
|
|
125
|
+
(app/worker/base_config.py)."""
|
|
126
|
+
|
|
127
|
+
model_config = ConfigDict(extra="ignore")
|
|
128
|
+
enabled: list[str] | None = None
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class RagSettings(BaseModel):
|
|
132
|
+
"""과거 기록 검색 (DESIGN.md 6.4–6.6, 10절 `rag`). 기록 저장은 이 값과 관계없이 한다."""
|
|
133
|
+
|
|
134
|
+
model_config = ConfigDict(extra="ignore")
|
|
135
|
+
# 검색 결과를 프롬프트에 넣을지. auto는 기록 수와 채택률로 정한다
|
|
136
|
+
# (app/worker/rag_switch_pure.py)
|
|
137
|
+
enabled: RagMode = DEFAULT_MODE
|
|
138
|
+
top_k: int = Field(default=20, ge=1, le=200) # 검색이 가져오는 후보 수
|
|
139
|
+
# 이 유사도 미만의 기록은 넣지 않는다. recall@k와 관련 없는 짝의 분포로 정한 값 (6.7)
|
|
140
|
+
min_similarity: float = Field(default=DEFAULT_MIN_SIMILARITY, ge=-1, le=1)
|
|
141
|
+
# 한 호출의 프롬프트에 넣는 기록 수 상한. top_k와 따로 둔다
|
|
142
|
+
max_records: int = Field(default=3, ge=0, le=MAX_RECORDS_CAP)
|
|
143
|
+
|
|
144
|
+
@field_validator("enabled", mode="before")
|
|
145
|
+
@classmethod
|
|
146
|
+
def _mode(cls, value: object) -> RagMode:
|
|
147
|
+
"""옛 불리언도 읽는다. 모르는 값은 설정 전체를 버리지 않고 이 값만 기본값으로 읽는다
|
|
148
|
+
("설정:"의 알림은 `settings_notes`가 단다)."""
|
|
149
|
+
return parse_mode(value) or DEFAULT_MODE
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class PrDescriptionSettings(BaseModel):
|
|
153
|
+
"""PR 설명 확인 (DESIGN.md 4.5 끝, 10절 `pr_description`): PR 제목·본문·커밋 메시지와 diff를
|
|
154
|
+
모델이 견주어 어긋난 곳을 결과 코멘트에 알린다. 기본은 켬."""
|
|
155
|
+
|
|
156
|
+
model_config = ConfigDict(extra="ignore")
|
|
157
|
+
enabled: bool = True
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class RepoConfig(BaseModel):
|
|
161
|
+
model_config = ConfigDict(extra="ignore")
|
|
162
|
+
rules: RulesSettings = RulesSettings()
|
|
163
|
+
sandbox: SandboxSettings = SandboxSettings()
|
|
164
|
+
skills: SkillsSettings = SkillsSettings()
|
|
165
|
+
model: ModelSettings = ModelSettings()
|
|
166
|
+
fix: FixSettings = FixSettings()
|
|
167
|
+
rag: RagSettings = RagSettings()
|
|
168
|
+
pr_description: PrDescriptionSettings = PrDescriptionSettings()
|
|
169
|
+
|
|
170
|
+
@model_validator(mode="before")
|
|
171
|
+
@classmethod
|
|
172
|
+
def _legacy_fix_key(cls, data: object) -> object:
|
|
173
|
+
"""구현 2단계 동안 옛 키 `skills.fix`도 읽는다 (10절). 새 키 `fix`가 있으면 그것만 쓴다."""
|
|
174
|
+
if isinstance(data, dict) and "fix" not in data:
|
|
175
|
+
skills = data.get("skills")
|
|
176
|
+
if isinstance(skills, dict) and "fix" in skills:
|
|
177
|
+
return {**data, "fix": skills["fix"]}
|
|
178
|
+
return data
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def parse_repo_config(text: str | None) -> tuple[RepoConfig, str | None]:
|
|
182
|
+
"""(설정, 문제). 파일이 없으면 기본값. 읽지 못하면 기본값과 그 이유를 돌려준다.
|
|
183
|
+
|
|
184
|
+
설정 오류로 작업을 멈추지 않는다. 기본값으로 검사하고 코멘트에 이유를 적는다.
|
|
185
|
+
"""
|
|
186
|
+
if text is None:
|
|
187
|
+
return RepoConfig(), None
|
|
188
|
+
try:
|
|
189
|
+
data = yaml.safe_load(text)
|
|
190
|
+
except yaml.YAMLError as e:
|
|
191
|
+
return RepoConfig(), f"YAML 형식 오류 ({_first_line(str(e))})"
|
|
192
|
+
if data is None:
|
|
193
|
+
return RepoConfig(), None
|
|
194
|
+
if not isinstance(data, dict):
|
|
195
|
+
return RepoConfig(), "최상위가 매핑이 아님"
|
|
196
|
+
try:
|
|
197
|
+
return RepoConfig.model_validate(data), None
|
|
198
|
+
except ValidationError as e:
|
|
199
|
+
errors = e.errors()
|
|
200
|
+
where = ".".join(str(p) for p in errors[0]["loc"])
|
|
201
|
+
return RepoConfig(), f"`{where}` 값 오류 ({errors[0]['msg']})"
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def settings_notes(text: str | None) -> list[str]:
|
|
205
|
+
"""코멘트의 "설정:"에 알릴 옛 키 (10절 "v1 스키마에서 바뀐 키"). 읽지 못하는 파일은 빈 목록이다.
|
|
206
|
+
|
|
207
|
+
읽지 못한 이유는 `parse_repo_config`가 따로 알린다.
|
|
208
|
+
"""
|
|
209
|
+
try:
|
|
210
|
+
data = yaml.safe_load(text) if text else None
|
|
211
|
+
except yaml.YAMLError:
|
|
212
|
+
return []
|
|
213
|
+
if not isinstance(data, dict):
|
|
214
|
+
return []
|
|
215
|
+
notes = []
|
|
216
|
+
skills = data.get("skills")
|
|
217
|
+
if isinstance(skills, dict) and "fix" in skills:
|
|
218
|
+
notes.append(
|
|
219
|
+
"`skills.fix`는 `fix`로 바뀌었습니다. "
|
|
220
|
+
"2단계 동안은 `fix`가 없으면 `skills.fix`를 읽습니다"
|
|
221
|
+
)
|
|
222
|
+
for (section, key), note in REMOVED_KEYS.items():
|
|
223
|
+
part = data.get(section)
|
|
224
|
+
if isinstance(part, dict) and key in part:
|
|
225
|
+
notes.append(note)
|
|
226
|
+
fix_parts = [data.get("fix"), skills.get("fix") if isinstance(skills, dict) else None]
|
|
227
|
+
if any(isinstance(part, dict) and "require_covered" in part for part in fix_parts):
|
|
228
|
+
notes.append(REQUIRE_COVERED_NOTE)
|
|
229
|
+
rag = data.get("rag")
|
|
230
|
+
if isinstance(rag, dict) and "enabled" in rag and parse_mode(rag["enabled"]) is None:
|
|
231
|
+
# 받은 값은 적지 않는다. 저장소의 글이 코멘트에 그대로 들어가지 않게
|
|
232
|
+
notes.append(
|
|
233
|
+
f"`rag.enabled`는 {', '.join(MODES)} 중 하나여야 합니다. 기본값 {DEFAULT_MODE}로 "
|
|
234
|
+
"읽었습니다"
|
|
235
|
+
)
|
|
236
|
+
enabled = skills.get("enabled") if isinstance(skills, dict) else None
|
|
237
|
+
if isinstance(enabled, list) and LINT in enabled:
|
|
238
|
+
notes.append(
|
|
239
|
+
"`skills.enabled`는 없어졌습니다. 규칙은 문서와 도구 설정에서 읽고, 끌 규칙은 "
|
|
240
|
+
"`rules.disabled`에 적습니다"
|
|
241
|
+
)
|
|
242
|
+
return notes
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def fix_limits(requested: FixSettings, *, max_retries: int = MAX_RETRIES_CAP) -> FixSettings:
|
|
246
|
+
"""리포가 요청한 수정 설정. 파이프라인 쪽 최댓값을 넘는 값은 그 값으로 줄인다 (9.2, T23)."""
|
|
247
|
+
return requested.model_copy(update={"max_retries": min(requested.max_retries, max_retries)})
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def memory_limit(requested_gb: float, max_gb: float) -> float:
|
|
251
|
+
"""리포가 요청한 메모리 한도. 파이프라인 쪽 상한을 넘으면 상한으로 줄인다."""
|
|
252
|
+
return min(requested_gb, max_gb)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def call_limits(
|
|
256
|
+
requested: CallSettings, *, max_pr_max: int, max_ruleset_max: int, max_repo_daily: int
|
|
257
|
+
) -> CallSettings:
|
|
258
|
+
"""리포가 요청한 호출 상한. 파이프라인 쪽 최댓값을 넘는 값은 그 값으로 줄인다 (9.2)."""
|
|
259
|
+
return requested.model_copy(
|
|
260
|
+
update={
|
|
261
|
+
"pr_max": min(requested.pr_max, max_pr_max),
|
|
262
|
+
"ruleset_max": min(requested.ruleset_max, max_ruleset_max),
|
|
263
|
+
"repo_daily": min(requested.repo_daily, max_repo_daily),
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def _first_line(text: str) -> str:
|
|
269
|
+
return text.strip().splitlines()[0] if text.strip() else text
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"""결과를 PR 코멘트용 마크다운으로 바꾼다. 판정을 새로 내지 않고 모델 값만 보여준다.
|
|
2
|
+
|
|
3
|
+
코멘트 맨 위는 "테스트:" 줄과 결론인 "규칙:" 줄이고, PR 단위 위반이 있으면 "PR 단위:" 줄이, PR 설명
|
|
4
|
+
확인을 했으면 "PR 설명:" 줄이 더 붙는다. 테스트는 글자로만 쓰고, ⚠️/✅는 규칙 줄에만 쓰며 ⚠️는
|
|
5
|
+
"위반 있음"이라는 뜻으로만 쓴다
|
|
6
|
+
(docs/DESIGN.md 4.9). 그 아래에는 위반과 할 일만 펼쳐 두고, 규칙별 확인 방법, 사용량, 테스트 수,
|
|
7
|
+
바뀐 줄 커버리지는 접는 블록 하나에 넣는다. 규칙 줄과 규칙 절은 app/worker/doc_rules_report.py가
|
|
8
|
+
그린다.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from collections.abc import Mapping, Sequence
|
|
12
|
+
from typing import Final
|
|
13
|
+
|
|
14
|
+
from app.worker import doc_rules_report, pr_check_report_pure, pr_description_report_pure
|
|
15
|
+
from app.worker.base_config import PIPELINE_YAML, BaseConfig
|
|
16
|
+
from app.worker.checker_pure import Checker
|
|
17
|
+
from app.worker.coverage import DiffCoverage
|
|
18
|
+
from app.worker.doc_rules_pure import DocRules, Found
|
|
19
|
+
from app.worker.doc_rules_report import FixView
|
|
20
|
+
from app.worker.fix.fix_decision_pure import Decided
|
|
21
|
+
from app.worker.lang.install_pure import InstallFailureKind
|
|
22
|
+
from app.worker.markdown_pure import code_fence, inline_code
|
|
23
|
+
from app.worker.merged_fix_pure import CarriedFrom
|
|
24
|
+
from app.worker.rag_switch_pure import RagSwitch
|
|
25
|
+
from app.worker.rules.pr_check_pure import PrChecks
|
|
26
|
+
from app.worker.rules.pr_description_pure import PrDescription
|
|
27
|
+
from app.worker.sandbox.docker_cli import MEMORY_LIMIT_GB
|
|
28
|
+
from app.worker.test_run_pure import PytestRun
|
|
29
|
+
|
|
30
|
+
MAX_LISTED_FAILURES: Final = 10
|
|
31
|
+
MAX_OUTPUT_CHARS: Final = 1500
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _gb(value: float) -> str:
|
|
35
|
+
return f"{value:g}GB"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# --- 테스트 ---------------------------------------------------------------------
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def format_test_line(run: PytestRun, memory_gb: float = MEMORY_LIMIT_GB) -> str:
|
|
42
|
+
"""'테스트:' 줄의 글자 표시. 기호를 쓰지 않는다."""
|
|
43
|
+
s = run.summary
|
|
44
|
+
match run.status:
|
|
45
|
+
case "passed":
|
|
46
|
+
if run.flaky:
|
|
47
|
+
return f"통과, 불안정한 테스트 {len(run.flaky)}개"
|
|
48
|
+
return f"통과 ({s.total}개)" if s else "통과"
|
|
49
|
+
case "failed":
|
|
50
|
+
if s is None:
|
|
51
|
+
return "실패"
|
|
52
|
+
return f"실패 ({s.total}개 중 {s.failed + s.errors}개)"
|
|
53
|
+
case "no_tests":
|
|
54
|
+
return "실행된 테스트 없음"
|
|
55
|
+
case "timeout":
|
|
56
|
+
return "시간 초과로 중단"
|
|
57
|
+
case "cancelled":
|
|
58
|
+
return "새 커밋이 올라와 중단"
|
|
59
|
+
case "unrunnable":
|
|
60
|
+
if run.memory_exceeded:
|
|
61
|
+
return f"실행 불가 (메모리 한도 {_gb(memory_gb)}를 넘어 종료됨)"
|
|
62
|
+
return f"실행 불가 ({run.unrunnable_reason})"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def memory_hint(memory_gb: float, max_memory_gb: float) -> str:
|
|
66
|
+
"""메모리 초과 안내. 한도는 base 브랜치의 설정에서만 바꿀 수 있다 (DESIGN.md F8)."""
|
|
67
|
+
if memory_gb >= max_memory_gb:
|
|
68
|
+
return (
|
|
69
|
+
f"샌드박스의 메모리 한도는 {_gb(memory_gb)}이며, "
|
|
70
|
+
f"이 파이프라인이 허용하는 상한({_gb(max_memory_gb)})입니다."
|
|
71
|
+
)
|
|
72
|
+
return (
|
|
73
|
+
f"샌드박스의 메모리 한도는 {_gb(memory_gb)}입니다. base 브랜치의 `{PIPELINE_YAML}`에서 "
|
|
74
|
+
f"`sandbox.memory_gb`로 {_gb(max_memory_gb)}까지 늘릴 수 있습니다."
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def format_test_counts(run: PytestRun) -> list[str]:
|
|
79
|
+
"""테스트 수의 상세 (접는 블록 안). 통과·실패는 '테스트:' 줄에 이미 보인다."""
|
|
80
|
+
s = run.summary
|
|
81
|
+
if s is None or not s.total:
|
|
82
|
+
return []
|
|
83
|
+
return ["", f"테스트: 전체 {s.total} · 통과 {s.passed} · 실패 {s.failed} · 오류 {s.errors} · "
|
|
84
|
+
f"건너뜀 {s.skipped}"] # fmt: skip
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def format_test_details(run: PytestRun, memory_gb: float, max_memory_gb: float) -> list[str]:
|
|
88
|
+
"""'테스트:' 줄 아래에 펼쳐 두는 상세 줄들: 할 일이 있는 것만. 비어 있을 수 있다."""
|
|
89
|
+
lines: list[str] = []
|
|
90
|
+
if run.memory_exceeded:
|
|
91
|
+
lines += ["", memory_hint(memory_gb, max_memory_gb)]
|
|
92
|
+
s = run.summary
|
|
93
|
+
if run.flaky:
|
|
94
|
+
lines += ["", "불안정한 테스트 (처음엔 실패, 다시 돌려 통과):"]
|
|
95
|
+
lines += [f"- {inline_code(t, 300)}" for t in run.flaky[:MAX_LISTED_FAILURES]]
|
|
96
|
+
still_failed = [t for t in (s.failed_tests if s else ()) if t not in run.flaky]
|
|
97
|
+
if s is not None and still_failed:
|
|
98
|
+
lines += ["", "실패한 테스트:"]
|
|
99
|
+
lines += [f"- {inline_code(t, 300)}" for t in still_failed[:MAX_LISTED_FAILURES]]
|
|
100
|
+
hidden = len(still_failed) - MAX_LISTED_FAILURES
|
|
101
|
+
if hidden > 0:
|
|
102
|
+
lines.append(f"- 외 {hidden}개")
|
|
103
|
+
if run.status == "unrunnable" and run.output:
|
|
104
|
+
lines += _details("출력", run.output[-MAX_OUTPUT_CHARS:])
|
|
105
|
+
return lines
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# --- PR 코멘트 전체 -------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
HEADER: Final = "### pr-proof"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _details(summary: str, text: str) -> list[str]:
|
|
114
|
+
fence = code_fence(text)
|
|
115
|
+
return ["", f"<details><summary>{summary}</summary>", "", fence, text, fence, "", "</details>"]
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _footer(head_sha: str, seconds: float | None = None, *, from_sync: bool = False) -> str:
|
|
119
|
+
parts = [f"커밋 `{head_sha[:7]}`"]
|
|
120
|
+
if seconds is not None:
|
|
121
|
+
parts.append(f"{seconds:.0f}초")
|
|
122
|
+
if from_sync:
|
|
123
|
+
parts.append("동기화로 처리됨 (웹훅 누락)")
|
|
124
|
+
return "<sub>" + " · ".join(parts) + "</sub>"
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _compose(
|
|
128
|
+
test_line: str,
|
|
129
|
+
details: list[str],
|
|
130
|
+
head_sha: str,
|
|
131
|
+
*,
|
|
132
|
+
base: BaseConfig | None,
|
|
133
|
+
seconds: float | None = None,
|
|
134
|
+
from_sync: bool = False,
|
|
135
|
+
folded: list[str] | None = None,
|
|
136
|
+
doc_rules: DocRules | None = None,
|
|
137
|
+
checkers: Mapping[str, Checker] | None = None,
|
|
138
|
+
decisions: Decided | None = None,
|
|
139
|
+
fixes: Mapping[str, FixView] | None = None,
|
|
140
|
+
rag: RagSwitch | None = None,
|
|
141
|
+
pr: PrChecks | None = None,
|
|
142
|
+
description: PrDescription | None = None,
|
|
143
|
+
) -> str:
|
|
144
|
+
lines = [HEADER, "", f"**테스트:** {test_line}"]
|
|
145
|
+
rules_line = doc_rules_report.title(doc_rules, fixes, pr, decisions)
|
|
146
|
+
if rules_line is not None:
|
|
147
|
+
lines.append(rules_line)
|
|
148
|
+
pr_line = pr_check_report_pure.title(pr) if isinstance(doc_rules, Found) else None
|
|
149
|
+
if pr_line is not None:
|
|
150
|
+
lines.append(pr_line)
|
|
151
|
+
description_line = pr_description_report_pure.title(description)
|
|
152
|
+
if description_line is not None:
|
|
153
|
+
lines.append(description_line)
|
|
154
|
+
lines += details
|
|
155
|
+
lines += pr_description_report_pure.expanded(description)
|
|
156
|
+
more = (folded or []) + pr_description_report_pure.folded(description)
|
|
157
|
+
lines += doc_rules_report.section(
|
|
158
|
+
doc_rules, checkers or {}, decisions, fixes, rag, pr, more=more
|
|
159
|
+
)
|
|
160
|
+
if base is not None and base.problems:
|
|
161
|
+
lines += ["", "설정:"] + [f"- {p}" for p in base.problems]
|
|
162
|
+
lines += ["", _footer(head_sha, seconds, from_sync=from_sync)]
|
|
163
|
+
return "\n".join(lines) + "\n"
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def render_progress(head_sha: str, step: str) -> str:
|
|
167
|
+
return f"{HEADER}\n\n**테스트:** 진행 중 ({step})\n\n{_footer(head_sha)}\n"
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def diff_coverage_line(cov: DiffCoverage | None) -> list[str]:
|
|
171
|
+
"""PR이 바꾼 줄의 커버리지 (참고 지표, F8). 잴 수 없으면 쓰지 않는다. 위반이 아니라 있던
|
|
172
|
+
테스트가 바뀐 코드에 얼마나 닿는지를 알려 주는 값이라 접는 블록에 들어간다 (4.9)."""
|
|
173
|
+
if cov is None:
|
|
174
|
+
return []
|
|
175
|
+
ran = cov.measured_lines - cov.uncovered_lines
|
|
176
|
+
return [
|
|
177
|
+
"",
|
|
178
|
+
f"바뀐 줄 커버리지 {cov.percent:g}% (참고, 위반이 아님): 있던 테스트가 PR이 바꾼 줄 "
|
|
179
|
+
f"{cov.measured_lines}줄 중 {ran}줄을 실행함",
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
_CARRIED_LABEL: Final[Mapping[str, str]] = {"mechanical": "기계적 수정", "model": "모델 수정"}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def carried_lines(carried: CarriedFrom | None) -> list[str]:
|
|
187
|
+
"""수정안을 머지한 커밋이라 다시 검사하지 않고 옮겨 적었다는 안내 (4.9 "수정안 PR 상태
|
|
188
|
+
관리")."""
|
|
189
|
+
if carried is None:
|
|
190
|
+
return []
|
|
191
|
+
n, verified = carried.number, carried.verified_sha[:7]
|
|
192
|
+
label = _CARRIED_LABEL.get(carried.bundle, carried.bundle)
|
|
193
|
+
return [
|
|
194
|
+
"",
|
|
195
|
+
f"이 커밋은 수정안 #{n}({label})을 머지한 커밋이고, 내용이 검증한 수정안과 같아 다시 "
|
|
196
|
+
f"검사하지 않았습니다. 결과는 커밋 `{verified}`의 검사와 수정안 #{n}의 검증에서 옮겨 "
|
|
197
|
+
"적었습니다. 테스트는 수정안을 검증할 때 고친 뒤 다시 돌려 수정 전과 같은 결과를 확인한 "
|
|
198
|
+
"것입니다.",
|
|
199
|
+
*(
|
|
200
|
+
[
|
|
201
|
+
f"수정안이 고친 위반 중 {carried.unverified}건은 모델 판단으로 찾은 것이라 도구로 "
|
|
202
|
+
"재검사하지 못했고, 그 줄이 바뀐 것까지만 확인했습니다."
|
|
203
|
+
]
|
|
204
|
+
if carried.unverified
|
|
205
|
+
else []
|
|
206
|
+
),
|
|
207
|
+
]
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def render_result(
|
|
211
|
+
run: PytestRun,
|
|
212
|
+
head_sha: str,
|
|
213
|
+
seconds: float,
|
|
214
|
+
*,
|
|
215
|
+
base: BaseConfig | None = None,
|
|
216
|
+
diff_coverage: DiffCoverage | None = None,
|
|
217
|
+
from_sync: bool = False,
|
|
218
|
+
doc_rules: DocRules | None = None,
|
|
219
|
+
checkers: Mapping[str, Checker] | None = None,
|
|
220
|
+
decisions: Decided | None = None,
|
|
221
|
+
fixes: Mapping[str, FixView] | None = None,
|
|
222
|
+
rag: RagSwitch | None = None,
|
|
223
|
+
pr: PrChecks | None = None,
|
|
224
|
+
carried: CarriedFrom | None = None,
|
|
225
|
+
description: PrDescription | None = None,
|
|
226
|
+
) -> str:
|
|
227
|
+
"""결과 코멘트. fixes는 묶음마다 수정했으면 그 결과, 아니면 상태(대기, 진행 중 등)다. rag는 이
|
|
228
|
+
검사의 검색 상태다(규칙 절에 한 줄로 보인다). pr은 PR 단위 확인의 결과다. carried는 수정안을
|
|
229
|
+
머지한 커밋이라 결과를 옮겨 적었을 때 그 출처다(테스트 줄 아래에 안내가 붙는다). description은
|
|
230
|
+
PR 설명 확인의 결과다(이 확인을 끈 저장소는 None)."""
|
|
231
|
+
memory_gb = base.memory_gb if base else MEMORY_LIMIT_GB
|
|
232
|
+
max_memory_gb = base.max_memory_gb if base else MEMORY_LIMIT_GB
|
|
233
|
+
return _compose(
|
|
234
|
+
format_test_line(run, memory_gb),
|
|
235
|
+
carried_lines(carried) + format_test_details(run, memory_gb, max_memory_gb),
|
|
236
|
+
head_sha,
|
|
237
|
+
base=base,
|
|
238
|
+
seconds=seconds,
|
|
239
|
+
from_sync=from_sync,
|
|
240
|
+
folded=format_test_counts(run) + diff_coverage_line(diff_coverage),
|
|
241
|
+
doc_rules=doc_rules,
|
|
242
|
+
checkers=checkers,
|
|
243
|
+
decisions=decisions,
|
|
244
|
+
fixes=fixes,
|
|
245
|
+
rag=rag,
|
|
246
|
+
pr=pr,
|
|
247
|
+
description=description,
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def render_install_failure(
|
|
252
|
+
head_sha: str,
|
|
253
|
+
detail: str,
|
|
254
|
+
*,
|
|
255
|
+
base: BaseConfig | None = None,
|
|
256
|
+
doc_rules: DocRules | None = None,
|
|
257
|
+
checkers: Mapping[str, Checker] | None = None,
|
|
258
|
+
kind: InstallFailureKind = "unknown",
|
|
259
|
+
packages: Sequence[str] = (),
|
|
260
|
+
pr: PrChecks | None = None,
|
|
261
|
+
description: PrDescription | None = None,
|
|
262
|
+
) -> str:
|
|
263
|
+
"""의존성 설치 실패. 규칙 검사는 설치와 따로 돌므로 결과가 있으면 같이 보여준다."""
|
|
264
|
+
return _compose(
|
|
265
|
+
f"실행 불가 ({install_failure_reason(kind, packages)})",
|
|
266
|
+
_details("pip 출력", detail[-MAX_OUTPUT_CHARS:]),
|
|
267
|
+
head_sha,
|
|
268
|
+
base=base,
|
|
269
|
+
doc_rules=doc_rules,
|
|
270
|
+
checkers=checkers,
|
|
271
|
+
pr=pr,
|
|
272
|
+
description=description,
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def install_failure_reason(kind: InstallFailureKind, packages: Sequence[str] = ()) -> str:
|
|
277
|
+
if kind == "source_only" and packages:
|
|
278
|
+
names = ", ".join(inline_code(p, 100) for p in packages[:10])
|
|
279
|
+
return f"의존성을 설치하지 못함: 소스 배포본만 있는 패키지 {names}. wheel만 설치합니다"
|
|
280
|
+
if kind == "disallowed":
|
|
281
|
+
return "의존성을 설치하지 못함: wheel만 설치하므로 받지 않는 줄이 의존성 파일에 있음"
|
|
282
|
+
return "의존성을 설치하지 못함"
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def render_environment_wait(head_sha: str, *, final: bool) -> str:
|
|
286
|
+
"""환경 오류. 실패처럼 보이는 표시를 남기지 않는다 (DESIGN.md F9)."""
|
|
287
|
+
if final:
|
|
288
|
+
line = "환경 문제로 검사하지 못함 (다음 커밋에서 다시 검사합니다)"
|
|
289
|
+
else:
|
|
290
|
+
line = "환경 문제로 대기 중 (잠시 뒤 다시 시도합니다)"
|
|
291
|
+
return f"{HEADER}\n\n**테스트:** {line}\n\n{_footer(head_sha)}\n"
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def render_pipeline_error(head_sha: str, *, final: bool) -> str:
|
|
295
|
+
"""환경 오류가 아닌 예외(파이프라인 버그, 작업 시간 초과). PR 코드 탓으로 보이지 않게 쓴다."""
|
|
296
|
+
if final:
|
|
297
|
+
line = "파이프라인 오류로 검사하지 못함 (다음 커밋에서 다시 검사합니다)"
|
|
298
|
+
else:
|
|
299
|
+
line = "파이프라인 오류로 대기 중 (잠시 뒤 다시 시도합니다)"
|
|
300
|
+
return f"{HEADER}\n\n**테스트:** {line}\n\n{_footer(head_sha)}\n"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""재시도와 실패 기록 (docs/DESIGN.md F3·F8).
|
|
2
|
+
|
|
3
|
+
환경 오류는 `env_error`, 그 밖의 예외는 `error`로 runs에 남기고, 예외는 호출한 쪽이 다시 올려
|
|
4
|
+
RQ가 정해진 간격으로 재시도하게 한다. 마지막 시도면 작업 키를 지워 동기화가 판단하게 한다.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
from rq import get_current_job
|
|
10
|
+
|
|
11
|
+
from app.shared.job_pure import PRJob
|
|
12
|
+
from app.worker import graph, report
|
|
13
|
+
from app.worker.ai.claude_cli import AIEnvironmentError
|
|
14
|
+
from app.worker.ai.workdir import WorkdirError
|
|
15
|
+
from app.worker.github import GitHubError
|
|
16
|
+
from app.worker.repo import GitError
|
|
17
|
+
from app.worker.sandbox.docker_cli import SandboxError
|
|
18
|
+
|
|
19
|
+
log = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
# WorkdirError: 모델 전용 폴더를 만들거나 diff를 뽑는 호스트의 git이 실패했다. PR 탓이 아니다
|
|
22
|
+
EnvironmentFailure = (SandboxError, GitError, GitHubError, AIEnvironmentError, WorkdirError)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def attempt() -> tuple[int, bool]:
|
|
26
|
+
"""(이번 시도 번호, 마지막 시도인지). RQ 밖에서 부르면 (1, True)."""
|
|
27
|
+
current = get_current_job()
|
|
28
|
+
if current is None or current.retries_left is None:
|
|
29
|
+
return 1, True
|
|
30
|
+
total = len(current.retry_intervals or []) or 0
|
|
31
|
+
number = total - current.retries_left + 1
|
|
32
|
+
return number, current.retries_left == 0
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def environment_failure(
|
|
36
|
+
job: PRJob, ctx: graph.FlowContext, run_id: int, final: bool, error: Exception
|
|
37
|
+
) -> None:
|
|
38
|
+
"""환경 오류를 기록한다. 마지막 시도면 작업 키를 지워 동기화가 나중에 다시 넣을 수 있게 한다."""
|
|
39
|
+
log.warning("환경 오류 %s#%s: %s", job.repo, job.pr_number, error)
|
|
40
|
+
_show(job, ctx, report.render_environment_wait(job.head_sha, final=final))
|
|
41
|
+
ctx.store.finish_run(run_id, "env_error", comment_id=ctx.comment_id)
|
|
42
|
+
if final:
|
|
43
|
+
ctx.store.release(job) # 지우지 않으면 키 만료(6시간)까지 같은 커밋을 다시 넣지 못한다
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def unexpected_error(
|
|
47
|
+
job: PRJob, ctx: graph.FlowContext, run_id: int, final: bool, error: Exception
|
|
48
|
+
) -> None:
|
|
49
|
+
"""환경 오류가 아닌 예외(파이프라인 버그, rq JobTimeoutException)를 기록한다.
|
|
50
|
+
|
|
51
|
+
runs가 running으로 남으면 동기화가 죽은 워커로 보고 같은 커밋을 계속 다시 넣는다.
|
|
52
|
+
마지막 시도면 작업 키를 지운다 (동기화는 error를 같은 커밋으로 다시 넣지 않는다).
|
|
53
|
+
"""
|
|
54
|
+
log.exception("작업 오류 %s#%s: %s", job.repo, job.pr_number, error)
|
|
55
|
+
_show(job, ctx, report.render_pipeline_error(job.head_sha, final=final))
|
|
56
|
+
ctx.store.finish_run(run_id, "error", comment_id=ctx.comment_id)
|
|
57
|
+
if final:
|
|
58
|
+
ctx.store.release(job)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _show(job: PRJob, ctx: graph.FlowContext, body: str) -> None:
|
|
62
|
+
try:
|
|
63
|
+
ctx.comment_id = ctx.github.upsert_comment(job.repo, job.pr_number, body, ctx.comment_id)
|
|
64
|
+
except GitHubError:
|
|
65
|
+
log.warning("오류 표시를 PR에 남기지 못함") # gh 자체가 원인일 수 있다
|