Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/ci-optimization/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ runs:
pytest-workflow:
- ".github/workflows/e2e-tests.yml"
- ".github/workflows/docker-unified.yml"
- ".github/workflows/docker-free-e2e.yml"
- ".github/actions/docker-free-stack/**"
- ".github/actions/ci-optimization/**"
- ".github/actions/smoke-test-retry/**"
- ".github/actions/restore-dependency-caches/**"
Expand Down
2 changes: 2 additions & 0 deletions .github/scripts/send_smart_selection_to_posthog.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def get(name: str) -> str:
"head_sha": get("HEAD_SHA"),
"pr_number": _number(get("PR_NUMBER"), int),
"framework": get("TEST_FRAMEWORK"),
# Which e2e lane planned it (docker, docker-free); empty when unset.
"lane": get("TEST_LANE"),
"mode": get("SMART_MODE"),
"confidence": get("SMART_CONFIDENCE"),
"failsafe_reason": failsafe_reason,
Expand Down
7 changes: 5 additions & 2 deletions .github/scripts/test/test_send_smart_selection_to_posthog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

BASE_ENV = {
"TEST_FRAMEWORK": "pytest",
"TEST_LANE": "docker-free",
"GITHUB_REPOSITORY": "org/repo",
"GITHUB_RUN_ID": "123",
"GITHUB_RUN_ATTEMPT": "2",
Expand Down Expand Up @@ -41,7 +42,7 @@

def test_properties_from_successful_plan() -> None:
props = sender.build_properties(BASE_ENV, PLAN)
assert props["framework"] == "pytest"
assert props["framework"] == "pytest" and props["lane"] == "docker-free"
assert props["tests_selected"] == 40 and props["tests_total"] == 400
assert props["modules_selected"] == 3 and props["modules_total"] == 30
assert props["batch_count"] == 2 and props["plan_ok"] is True
Expand Down Expand Up @@ -81,9 +82,11 @@ def test_missing_classifier_outputs_default_to_empty() -> None:
env = {
k: v
for k, v in BASE_ENV.items()
if k not in ("FAILSAFE_REASON", "PROPOSED_TAGS", "CLASSIFIER_DURATION_S")
if k
not in ("FAILSAFE_REASON", "PROPOSED_TAGS", "CLASSIFIER_DURATION_S", "TEST_LANE")
}
props = sender.build_properties(env, None)
assert props["lane"] == ""
assert props["failsafe_reason"] == ""
assert props["proposed_tags"] == ""
assert props["classifier_duration_s"] is None
Expand Down
2 changes: 2 additions & 0 deletions .github/scripts/validate_post_workflow_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
ALLOWED_NON_PR_WORKFLOWS = {
# docker-unified.yml: release and dispatch runs; PRs and pushes go through E2E Tests.
"Docker Build, Scan, Test",
# docker-free-e2e.yml: dispatch runs; PRs and pushes go through E2E Tests.
"Docker-free E2E",
"Nightly Docker Test",
"Release Tests",
"Release Validation",
Expand Down
16 changes: 14 additions & 2 deletions .github/smart-testing/render_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
* ``compose``: run by ``comment_smart_testing`` with the pytest section and the
Playwright tier plan (either may be absent) to write the whole comment to
``COMMENT_FILE``, which that job upserts onto the PR, found by ``MARKER``.

Another lane (docker-free-e2e.yml) runs both steps too; ``compose --lane`` gives
its comment its own marker (``lane_marker``) so each lane keeps one comment.
"""

import argparse
Expand All @@ -28,6 +31,12 @@
)

MARKER = "<!-- smart-testing-selection -->"


def lane_marker(lane: Optional[str]) -> str:
"""The Docker lane keeps the plain MARKER; any other lane gets its own."""
return f"<!-- smart-testing-selection:{lane} -->" if lane else MARKER

REASONING_MAX_CHARS = 300
MAX_LISTED_SCOPES = 100

Expand Down Expand Up @@ -273,11 +282,13 @@ def compose(
pytest_section: str,
playwright_plan: Optional[Dict[str, Any]],
env: Mapping[str, str],
lane: Optional[str] = None,
) -> str:
sections = [pytest_section] if pytest_section.strip() else []
if playwright_plan:
sections.append(render_playwright_section(playwright_plan))
body = [MARKER, "## Smart test selection", ""]
title = "## Smart test selection" + (f" ({lane} lane)" if lane else "")
body = [lane_marker(lane), title, ""]
body.append(
"\n".join(sections)
if sections
Expand Down Expand Up @@ -310,6 +321,7 @@ def main() -> None:
compose_parser = sub.add_parser("compose")
compose_parser.add_argument("--pytest-section")
compose_parser.add_argument("--playwright-plan")
compose_parser.add_argument("--lane", help="Lane name for its own comment marker")
args = parser.parse_args()

if args.command == "pytest":
Expand All @@ -320,7 +332,7 @@ def main() -> None:
f.write(body)
else:
plan = load_plan(args.playwright_plan)
body = compose(read_text(args.pytest_section), plan, os.environ)
body = compose(read_text(args.pytest_section), plan, os.environ, args.lane)

out = os.environ.get("COMMENT_FILE")
if out:
Expand Down
8 changes: 8 additions & 0 deletions .github/smart-testing/test/test_render_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ def test_compose_handles_missing_sections() -> None:
assert "No test selection was computed" in neither


def test_lane_comment_has_its_own_marker() -> None:
lane = render.compose("### pytest smoke tests\n", None, {}, lane="docker-free")
assert lane.startswith(render.lane_marker("docker-free"))
# The Docker lane's upsert finds its comment by MARKER; it must not match this one.
assert render.MARKER not in lane
assert "(docker-free lane)" in lane


def test_playwright_baseline_only_plan_has_no_table() -> None:
plan = {**P0_PLAN, "specs": [P0_PLAN["specs"][1]]}
body = render.render_playwright_section(plan)
Expand Down
Loading
Loading