mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-10-07 16:19:05 +08:00
fix(ci): prevent issue readiness workflow from failing on not-ready issues (#16514)
This commit is contained in:
@@ -13,6 +13,7 @@ from check_issue_readiness import (
|
||||
references_run_method,
|
||||
has_checklist_item,
|
||||
visible_text,
|
||||
main,
|
||||
BUG_LABEL,
|
||||
ENHANCEMENT_LABEL,
|
||||
)
|
||||
@@ -278,3 +279,120 @@ I ran `npm run dev` and saw the crash above.
|
||||
sections = extract_sections(body)
|
||||
assert {"relevant logs", "actual behavior", "acceptance criteria"} <= set(sections)
|
||||
assert evaluate_readiness(body, [BUG_LABEL]).ready
|
||||
|
||||
def test_main_json_not_ready(tmp_path, capsys, monkeypatch):
|
||||
import json
|
||||
body_file = tmp_path / "issue.md"
|
||||
body_file.write_text(BUG_BODY_NO_SCREENSHOT)
|
||||
monkeypatch.setattr(
|
||||
"sys.argv",
|
||||
[
|
||||
"check_issue_readiness.py",
|
||||
"--body-file",
|
||||
str(body_file),
|
||||
"--labels",
|
||||
"bug",
|
||||
"--json",
|
||||
],
|
||||
)
|
||||
exit_code = main()
|
||||
assert exit_code == 1
|
||||
captured = capsys.readouterr()
|
||||
data = json.loads(captured.out)
|
||||
assert data["ready"] is False
|
||||
assert len(data["reasons"]) > 0
|
||||
|
||||
|
||||
def test_main_json_ready(tmp_path, capsys, monkeypatch):
|
||||
import json
|
||||
|
||||
body_file = tmp_path / "issue.md"
|
||||
body_file.write_text(BUG_BODY_READY)
|
||||
monkeypatch.setattr(
|
||||
"sys.argv",
|
||||
[
|
||||
"check_issue_readiness.py",
|
||||
"--body-file",
|
||||
str(body_file),
|
||||
"--labels",
|
||||
"bug",
|
||||
"--json",
|
||||
],
|
||||
)
|
||||
exit_code = main()
|
||||
assert exit_code == 0
|
||||
captured = capsys.readouterr()
|
||||
data = json.loads(captured.out)
|
||||
assert data["ready"] is True
|
||||
assert len(data["reasons"]) == 0
|
||||
|
||||
|
||||
def test_main_text_ready(tmp_path, capsys, monkeypatch):
|
||||
body_file = tmp_path / "issue.md"
|
||||
body_file.write_text(BUG_BODY_READY)
|
||||
monkeypatch.setattr(
|
||||
"sys.argv",
|
||||
[
|
||||
"check_issue_readiness.py",
|
||||
"--body-file",
|
||||
str(body_file),
|
||||
"--labels",
|
||||
"bug",
|
||||
],
|
||||
)
|
||||
exit_code = main()
|
||||
assert exit_code == 0
|
||||
captured = capsys.readouterr()
|
||||
assert "Issue meets ready-for-dev criteria." in captured.out
|
||||
|
||||
|
||||
def test_main_text_not_ready(tmp_path, capsys, monkeypatch):
|
||||
body_file = tmp_path / "issue.md"
|
||||
body_file.write_text(BUG_BODY_NO_SCREENSHOT)
|
||||
monkeypatch.setattr(
|
||||
"sys.argv",
|
||||
[
|
||||
"check_issue_readiness.py",
|
||||
"--body-file",
|
||||
str(body_file),
|
||||
"--labels",
|
||||
"bug",
|
||||
],
|
||||
)
|
||||
exit_code = main()
|
||||
assert exit_code == 1
|
||||
captured = capsys.readouterr()
|
||||
assert "Issue does not meet ready-for-dev criteria:" in captured.out
|
||||
|
||||
|
||||
def test_main_event_path_json_ready(tmp_path, capsys, monkeypatch):
|
||||
import json
|
||||
|
||||
event_file = tmp_path / "event.json"
|
||||
event_file.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"issue": {
|
||||
"body": BUG_BODY_READY,
|
||||
"labels": [{"name": "bug"}],
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"sys.argv",
|
||||
[
|
||||
"check_issue_readiness.py",
|
||||
"--event-path",
|
||||
str(event_file),
|
||||
"--json",
|
||||
],
|
||||
)
|
||||
exit_code = main()
|
||||
assert exit_code == 0
|
||||
captured = capsys.readouterr()
|
||||
data = json.loads(captured.out)
|
||||
assert data["ready"] is True
|
||||
assert len(data["reasons"]) == 0
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ from check_pr_description import (
|
||||
validate_bug_fix_evidence,
|
||||
BUG_LABEL,
|
||||
ENHANCEMENT_LABEL,
|
||||
READY_FOR_DEV_LABEL,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
GITHUB_EVENT_PATH: ${{ github.event_path }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
python .github/scripts/check_issue_readiness.py --json > /tmp/result.json
|
||||
python .github/scripts/check_issue_readiness.py --json > /tmp/result.json || true
|
||||
echo "ready=$(jq -r '.ready' /tmp/result.json)" >> "$GITHUB_OUTPUT"
|
||||
# Write reasons to a file so the comment step can read them
|
||||
# without shell-escaping multiline text.
|
||||
|
||||
Reference in New Issue
Block a user