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
50 changes: 26 additions & 24 deletions .github/actions/plan-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,30 @@ runs:
plan_json=$(jq -c . ci-plan.json)
plan_digest=$(printf '%s' "$plan_json" | sha256sum | awk '{print $1}')
jq -e '.schema_version == 1' ci-plan.json >/dev/null
quality_lane_plan=$(jq -ce '
{
lane: "quality",
required: (([.required_slices[] | select(. == "quality" or . == "runner-contract")] | length) > 0),
profile,
domains,
required_slices,
signals,
budgets,
matrices: {clippy: .matrices.clippy}
}
' ci-plan.json)
website_lane_plan=$(jq -ce '
{
lane: "website",
required: ((.required_slices | index("web")) != null),
profile,
domains,
required_slices,
signals,
budgets,
matrices: {}
}
' ci-plan.json)
{
echo "plan_path=ci-plan.json"
echo "plan_json=$plan_json"
Expand Down Expand Up @@ -221,30 +245,8 @@ runs:
echo "macos_max_parallel=$(jq -r '.budgets.macos_max_parallel' ci-plan.json)"
echo "windows_max_parallel=$(jq -r '.budgets.windows_max_parallel' ci-plan.json)"
echo "total_max_workers=$(jq -r '.budgets.total_max_workers' ci-plan.json)"
echo "quality_lane_plan=$(jq -c '
{
lane: "quality",
required: ([.required_slices[] | select(. == "quality" or . == "runner-contract")] | length) > 0,
profile,
domains,
required_slices,
signals,
budgets,
matrices: {clippy: .matrices.clippy}
}
' ci-plan.json)"
echo "website_lane_plan=$(jq -c '
{
lane: "website",
required: (.required_slices | index("web")) != null,
profile,
domains,
required_slices,
signals,
budgets,
matrices: {}
}
' ci-plan.json)"
echo "quality_lane_plan=$quality_lane_plan"
echo "website_lane_plan=$website_lane_plan"
echo "linux_lane_plan=$(jq -c '
{
lane: "linux",
Expand Down
61 changes: 60 additions & 1 deletion scripts/tests/test_ci_lane_workflows.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from __future__ import annotations

import json
from pathlib import Path
import re
import subprocess
import unittest


Expand Down Expand Up @@ -131,10 +134,66 @@ def test_lane_plans_are_bounded_platform_projections(self) -> None:
"windows_lane_plan",
):
self.assertIn(f"{output}:", action)
self.assertIn(f'echo "{output}=$(jq -c', action)
self.assertIn(f'echo "{output}=$', action)
for platform in ("linux", "macos", "windows"):
self.assertIn(f'select(.platform == "{platform}")', action)

def test_topic_lane_projections_are_valid_jq(self) -> None:
action = (ROOT / ".github/actions/plan-ci/action.yml").read_text(
encoding="utf-8"
)
plans = (
{
"profile": "pr-ready",
"domains": ["ci-control"],
"required_slices": ["quality", "runner-contract", "web"],
"signals": {"rust_changed": True},
"budgets": {"total_max_workers": 10},
"matrices": {"clippy": [{"id": "batch-0"}]},
},
{
"profile": "pr-ready",
"domains": ["docs"],
"required_slices": [],
"signals": {"rust_changed": False},
"budgets": {"total_max_workers": 2},
"matrices": {"clippy": []},
},
)
for output, lane in (
("quality_lane_plan", "quality"),
("website_lane_plan", "website"),
):
match = re.search(
rf"{output}=\$\(jq -ce '(.*?)' ci-plan\.json\)",
action,
re.DOTALL,
)
self.assertIsNotNone(match)
for required, plan in zip((True, False), plans, strict=True):
with self.subTest(output=output, required=required):
result = subprocess.run(
["jq", "-ce", match.group(1)],
input=json.dumps(plan),
text=True,
capture_output=True,
check=True,
)
projection = json.loads(result.stdout)
self.assertEqual(lane, projection["lane"])
self.assertIs(required, projection["required"])
self.assertEqual(
plan["required_slices"], projection["required_slices"]
)
self.assertEqual(plan["signals"], projection["signals"])
self.assertEqual(plan["budgets"], projection["budgets"])
expected_matrices = (
{"clippy": plan["matrices"]["clippy"]}
if lane == "quality"
else {}
)
self.assertEqual(expected_matrices, projection["matrices"])

Comment thread
coderabbitai[bot] marked this conversation as resolved.
def test_dispatched_pr_lanes_receive_no_hugging_face_credential(self) -> None:
controller = self.workflow("ci-control.yml")
self.assertNotIn("HF_TOKEN", controller)
Expand Down
Loading