Skip to content
Draft
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
35 changes: 35 additions & 0 deletions tests/test_plugin_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,41 @@ def test_ci_selection_treats_cargo_lock_change_as_all_plugins(self) -> None:
},
)

def test_ci_selection_keeps_cargo_lock_with_plugin_change_plugin_scoped(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
root = Path(tmpdir)
git = lambda *args: subprocess.run( # noqa: E731
["git", *args],
cwd=root,
text=True,
capture_output=True,
check=True,
)
git("init")
git("config", "user.name", "Test User")
git("config", "user.email", "test@example.com")
(root / "Cargo.toml").write_text(
'[workspace]\nmembers = ["plugins/rust/python-package/rate_limiter", "plugins/rust/python-package/pii_filter"]\n'
)
rate_limiter = self._create_plugin(root, "rate_limiter")
self._create_plugin(root, "pii_filter")
(root / "Cargo.lock").write_text("# seed\n")
git("add", ".")
git("commit", "--no-verify", "-m", "seed layout")
base_sha = git("rev-parse", "HEAD").stdout.strip()

(rate_limiter / "README.md").write_text("# rate_limiter\n\nUpdated docs.\n")
(root / "Cargo.lock").write_text("# updated\n")
git("add", ".")
git("commit", "--no-verify", "-m", "plugin lockfile update")

result = run_catalog("ci-selection", str(root), "diff", base_sha, "HEAD")
self.assertEqual(result.returncode, 0, result.stderr)
payload = json.loads(result.stdout)
self.assertEqual(payload["plugins"], ["rate_limiter"])
self.assertEqual(payload["cargo_packages"], ["rate_limiter"])
self.assertEqual(payload["plugin_count"], 1)

def test_ci_selection_treats_deny_config_change_as_all_plugins(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
root = Path(tmpdir)
Expand Down
6 changes: 5 additions & 1 deletion tools/plugin_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
".config/",
".github/workflows/",
"Cargo.toml",
"Cargo.lock",
"deny.toml",
"crates/",
"README.md",
Expand Down Expand Up @@ -531,7 +530,10 @@ def _changed_plugins_for_records(
changed: set[str] = set()
managed_prefix = f"{MANAGED_ROOT.as_posix()}/"
integration_prefix = "plugins/tests/"
has_lockfile_change = "Cargo.lock" in changed_paths
for path in changed_paths:
if path == "Cargo.lock":
continue
if not path.startswith(managed_prefix):
if not path.startswith(integration_prefix):
continue
Expand All @@ -544,6 +546,8 @@ def _changed_plugins_for_records(
slug = relative.split("/", maxsplit=1)[0]
if slug in plugin_lookup:
changed.add(slug)
if has_lockfile_change and not changed:
return sorted(plugin_lookup)
return sorted(changed)


Expand Down
Loading