Repository navigation
feat(devtools): open a standalone litellm catalog PR before the version bump #8799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+197
−43
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| """Phase 0 of ``devtools release`` opens a catalog PR only when the catalog changed.""" | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| from crewai_devtools import cli | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def calls(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> list[list[str]]: | ||
| """Record git/gh commands; ``git status --porcelain`` output is set per test.""" | ||
| recorded: list[list[str]] = [] | ||
| monkeypatch.setattr(cli, "update_catalog", lambda root: root / cli.CATALOG_RELATIVE) | ||
| monkeypatch.setattr( | ||
| cli, | ||
| "create_or_reset_branch", | ||
| lambda branch: recorded.append(["branch", branch]), | ||
| ) | ||
| return recorded | ||
|
|
||
|
|
||
| def _fake_run(recorded: list[list[str]], status: str): | ||
| def run(cmd: list[str], cwd: Path | None = None) -> str: | ||
| recorded.append(cmd) | ||
| if cmd[:3] == ["git", "status", "--porcelain"]: | ||
| return status | ||
| if cmd[:3] == ["gh", "pr", "create"]: | ||
| return "https://github.com/o/r/pull/1" | ||
| return "" | ||
|
|
||
| return run | ||
|
|
||
|
|
||
| def test_unchanged_catalog_creates_no_branch_or_pr( | ||
| monkeypatch: pytest.MonkeyPatch, tmp_path: Path, calls: list[list[str]] | ||
| ) -> None: | ||
| monkeypatch.setattr(cli, "run_command", _fake_run(calls, status="")) | ||
|
|
||
| assert cli._update_catalog_and_create_pr(tmp_path, "1.2.3", dry_run=False) is None | ||
|
|
||
| assert not any(c[0] == "branch" for c in calls) | ||
| assert not any(c[:2] == ["gh", "pr"] for c in calls) | ||
|
|
||
|
|
||
| def test_changed_catalog_opens_a_pr_from_its_own_branch( | ||
| monkeypatch: pytest.MonkeyPatch, tmp_path: Path, calls: list[list[str]] | ||
| ) -> None: | ||
| monkeypatch.setattr(cli, "run_command", _fake_run(calls, status=" M catalog.json")) | ||
|
|
||
| branch = cli._update_catalog_and_create_pr(tmp_path, "1.2.3", dry_run=False) | ||
|
|
||
| assert branch == "chore/update-litellm-catalog-v1.2.3" | ||
| assert ["branch", branch] in calls | ||
| pr = next(c for c in calls if c[:3] == ["gh", "pr", "create"]) | ||
| assert "chore: update litellm model catalog for v1.2.3" in pr | ||
|
|
||
|
|
||
| def test_declining_the_branch_reset_restores_the_catalog( | ||
| monkeypatch: pytest.MonkeyPatch, tmp_path: Path, calls: list[list[str]] | ||
| ) -> None: | ||
| monkeypatch.setattr(cli, "run_command", _fake_run(calls, status=" M catalog.json")) | ||
|
|
||
| def decline(branch: str) -> None: | ||
| raise SystemExit(1) | ||
|
|
||
| monkeypatch.setattr(cli, "create_or_reset_branch", decline) | ||
|
|
||
| with pytest.raises(SystemExit): | ||
| cli._update_catalog_and_create_pr(tmp_path, "1.2.3", dry_run=False) | ||
|
|
||
| assert any(c[:3] == ["git", "checkout", "--"] for c in calls) | ||
| assert not any(c[:2] == ["gh", "pr"] for c in calls) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.