ultralytics-actions 0.0.85__tar.gz → 0.0.87__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/PKG-INFO +1 -1
  2. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/__init__.py +1 -1
  3. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/summarize_release.py +19 -4
  4. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/utils/common_utils.py +2 -1
  5. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_file_headers.py +22 -1
  6. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_summarize_release.py +41 -35
  7. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_update_markdown_codeblocks.py +8 -0
  8. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/ultralytics_actions.egg-info/PKG-INFO +1 -1
  9. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/LICENSE +0 -0
  10. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/README.md +0 -0
  11. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/dispatch_actions.py +0 -0
  12. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/first_interaction.py +0 -0
  13. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/summarize_pr.py +0 -0
  14. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/update_file_headers.py +0 -0
  15. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/update_markdown_code_blocks.py +0 -0
  16. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/utils/__init__.py +0 -0
  17. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/utils/github_utils.py +0 -0
  18. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/utils/openai_utils.py +0 -0
  19. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/actions/utils/version_utils.py +0 -0
  20. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/pyproject.toml +0 -0
  21. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/setup.cfg +0 -0
  22. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_cli_commands.py +0 -0
  23. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_common_utils.py +0 -0
  24. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_dispatch_actions.py +0 -0
  25. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_first_interaction.py +0 -0
  26. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_github_utils.py +0 -0
  27. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_init.py +0 -0
  28. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_openai_utils.py +0 -0
  29. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_summarize_pr.py +0 -0
  30. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/tests/test_urls.py +0 -0
  31. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/ultralytics_actions.egg-info/SOURCES.txt +0 -0
  32. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/ultralytics_actions.egg-info/dependency_links.txt +0 -0
  33. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/ultralytics_actions.egg-info/entry_points.txt +0 -0
  34. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/ultralytics_actions.egg-info/requires.txt +0 -0
  35. {ultralytics_actions-0.0.85 → ultralytics_actions-0.0.87}/ultralytics_actions.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ultralytics-actions
3
- Version: 0.0.85
3
+ Version: 0.0.87
4
4
  Summary: Ultralytics Actions for GitHub automation and PR management.
5
5
  Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>
6
6
  Maintainer-email: Ultralytics <hello@ultralytics.com>
@@ -22,4 +22,4 @@
22
22
  # ├── test_summarize_pr.py
23
23
  # └── ...
24
24
 
25
- __version__ = "0.0.85"
25
+ __version__ = "0.0.87"
@@ -25,7 +25,15 @@ def get_prs_between_tags(event, previous_tag: str, latest_tag: str) -> list:
25
25
  url = f"{GITHUB_API_URL}/repos/{event.repository}/compare/{previous_tag}...{latest_tag}"
26
26
  r = event.get(url)
27
27
 
28
+ if r.status_code != 200:
29
+ print(f"Failed to get comparison between {previous_tag} and {latest_tag}, status: {r.status_code}")
30
+ return []
31
+
28
32
  data = r.json()
33
+ if "commits" not in data:
34
+ print(f"No commits found in comparison between {previous_tag} and {latest_tag}")
35
+ return []
36
+
29
37
  pr_numbers = set()
30
38
  for commit in data["commits"]:
31
39
  pr_matches = re.findall(r"#(\d+)", commit["commit"]["message"])
@@ -139,9 +147,9 @@ def create_github_release(event, tag_name: str, name: str, body: str):
139
147
  event.post(url, json=data)
140
148
 
141
149
 
142
- def get_previous_tag() -> str:
143
- """Retrieves the previous Git tag, excluding the current tag, using the git describe command."""
144
- cmd = ["git", "describe", "--tags", "--abbrev=0", "--exclude", CURRENT_TAG]
150
+ def get_actual_previous_tag(current_tag: str) -> str:
151
+ """Gets the actual previous tag using git, excluding the current tag."""
152
+ cmd = ["git", "describe", "--tags", "--abbrev=0", "--exclude", current_tag]
145
153
  try:
146
154
  return subprocess.run(cmd, check=True, text=True, capture_output=True).stdout.strip()
147
155
  except subprocess.CalledProcessError:
@@ -156,7 +164,14 @@ def main(*args, **kwargs):
156
164
  if not all([event.token, CURRENT_TAG]):
157
165
  raise ValueError("One or more required environment variables are missing.")
158
166
 
159
- previous_tag = PREVIOUS_TAG or get_previous_tag()
167
+ # Try PREVIOUS_TAG first, fall back to actual previous tag if comparison fails
168
+ previous_tag = PREVIOUS_TAG or get_actual_previous_tag(CURRENT_TAG)
169
+
170
+ # Test if the previous tag works for comparison
171
+ test_url = f"{GITHUB_API_URL}/repos/{event.repository}/compare/{previous_tag}...{CURRENT_TAG}"
172
+ if event.get(test_url).status_code != 200:
173
+ previous_tag = get_actual_previous_tag(CURRENT_TAG)
174
+ print(f"Using actual previous tag: {previous_tag}")
160
175
 
161
176
  # Get the diff between the tags
162
177
  diff = get_release_diff(event, previous_tag, CURRENT_TAG)
@@ -189,7 +189,8 @@ def is_url(url, session=None, check=True, max_attempts=3, timeout=3, return_url=
189
189
  # Try HEAD first, then GET if needed
190
190
  for method in (requester.head, requester.get):
191
191
  response = method(url, stream=method == requester.get, **kwargs)
192
- if redirect and allow_redirect(start=url, end=response.url):
192
+ # Only update URL if there were actual HTTP redirects (indicated by response.history)
193
+ if redirect and response.history and allow_redirect(start=url, end=response.url):
193
194
  url = response.url
194
195
  if response.status_code not in BAD_HTTP_CODES:
195
196
  return (True, url) if return_url else True
@@ -5,8 +5,9 @@
5
5
 
6
6
  from pathlib import Path
7
7
  from tempfile import TemporaryDirectory
8
+ from unittest.mock import patch
8
9
 
9
- from actions.update_file_headers import COMMENT_MAP, IGNORE_PATHS, update_file
10
+ from actions.update_file_headers import COMMENT_MAP, IGNORE_PATHS, main, update_file
10
11
 
11
12
 
12
13
  def test_update_file_python():
@@ -112,3 +113,23 @@ def test_ignore_paths():
112
113
  assert isinstance(IGNORE_PATHS, set)
113
114
  assert ".git" in IGNORE_PATHS
114
115
  assert "__pycache__" in IGNORE_PATHS
116
+
117
+
118
+ def test_main_real_files():
119
+ """Test main function on actual repository files."""
120
+ # Mock update_file to prevent actual file modifications during testing
121
+ with patch("actions.update_file_headers.update_file", return_value=False) as mock_update:
122
+ main()
123
+ # Verify that update_file was called (indicates file processing occurred)
124
+ assert mock_update.call_count > 0
125
+
126
+
127
+ def test_main_with_custom_header():
128
+ """Test main function with custom header environment variable."""
129
+ with patch("actions.update_file_headers.update_file", return_value=False):
130
+ with patch("actions.update_file_headers.HEADER", "Custom Test Header"):
131
+ with patch("actions.update_file_headers.Action") as mock_action:
132
+ mock_event = mock_action.return_value
133
+ mock_event.repository = "test/repo"
134
+ main()
135
+ mock_action.assert_called_once()
@@ -35,45 +35,51 @@ def test_get_prs_between_tags():
35
35
  mock_event = MagicMock()
36
36
  mock_event.repository = "test/repo"
37
37
 
38
- # Mock compare response
39
- mock_compare_response = MagicMock()
40
- mock_compare_response.json.return_value = {
41
- "commits": [{"commit": {"message": "Fix bug #123"}}, {"commit": {"message": "Add feature #456"}}]
42
- }
43
-
44
- # Mock PR responses
45
- mock_pr1_response = MagicMock()
46
- mock_pr1_response.status_code = 200
47
- mock_pr1_response.json.return_value = {
48
- "number": 123,
49
- "title": "Fix bug",
50
- "body": "Fixes a bug",
51
- "user": {"login": "user1"},
52
- "html_url": "https://github.com/test/repo/pull/123",
53
- "merged_at": "2023-01-01T12:00:00Z",
54
- }
55
-
56
- mock_pr2_response = MagicMock()
57
- mock_pr2_response.status_code = 200
58
- mock_pr2_response.json.return_value = {
59
- "number": 456,
60
- "title": "Add feature",
61
- "body": "Adds a new feature",
62
- "user": {"login": "user2"},
63
- "html_url": "https://github.com/test/repo/pull/456",
64
- "merged_at": "2023-01-02T12:00:00Z",
65
- }
66
-
67
- # Set up get method to return different responses
68
- mock_event.get.side_effect = [mock_compare_response, mock_pr1_response, mock_pr2_response]
69
-
70
- # Use patch to skip the sleep
38
+ mock_event.get.side_effect = [
39
+ MagicMock(status_code=200, json=lambda: {"commits": [{"commit": {"message": "Fix bug #123"}}]}),
40
+ MagicMock(
41
+ status_code=200,
42
+ json=lambda: {
43
+ "number": 123,
44
+ "title": "Fix bug",
45
+ "body": "Fix",
46
+ "user": {"login": "user1"},
47
+ "html_url": "url",
48
+ "merged_at": "2023-01-01T12:00:00Z",
49
+ },
50
+ ),
51
+ ]
52
+
71
53
  with patch("time.sleep"):
72
54
  prs = get_prs_between_tags(mock_event, "v1.0.0", "v1.1.0")
73
55
 
74
- assert len(prs) == 2
56
+ assert len(prs) == 1
75
57
  assert prs[0]["number"] == 123
76
- assert prs[1]["number"] == 456
58
+
59
+
60
+ def test_get_prs_between_tags_api_failure():
61
+ """Test API failure returns empty list."""
62
+ mock_event = MagicMock()
63
+ mock_event.get.return_value = MagicMock(status_code=404)
64
+
65
+ assert get_prs_between_tags(mock_event, "v1.0.0", "v1.1.0") == []
66
+
67
+
68
+ def test_get_prs_between_tags_missing_commits():
69
+ """Test missing commits data returns empty list."""
70
+ mock_event = MagicMock()
71
+ mock_event.get.return_value = MagicMock(status_code=200, json=lambda: {"message": "No commits"})
72
+
73
+ assert get_prs_between_tags(mock_event, "v1.0.0", "v1.1.0") == []
74
+
75
+
76
+ def test_get_prs_between_tags_empty_commits():
77
+ """Test empty commits list returns empty list."""
78
+ mock_event = MagicMock()
79
+ mock_event.get.return_value = MagicMock(status_code=200, json=lambda: {"commits": []})
80
+
81
+ with patch("time.sleep"):
82
+ assert get_prs_between_tags(mock_event, "v1.0.0", "v1.1.0") == []
77
83
 
78
84
 
79
85
  @patch("actions.summarize_release.get_completion")
@@ -7,6 +7,7 @@ from actions.update_markdown_code_blocks import (
7
7
  add_indentation,
8
8
  extract_code_blocks,
9
9
  generate_temp_filename,
10
+ main,
10
11
  process_markdown_file,
11
12
  remove_indentation,
12
13
  )
@@ -104,3 +105,10 @@ def test():
104
105
  assert len(temp_files) == 1
105
106
  assert temp_files[0][1] == "def test():\n return True"
106
107
  mock_file.assert_called_once()
108
+
109
+
110
+ def test_main_real_files():
111
+ """Test main function on actual repository markdown files."""
112
+ # Run main on current directory which contains README.md and other markdown files
113
+ # This provides real-world test coverage of the entire pipeline
114
+ main(process_python=True, process_bash=True, verbose=False)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ultralytics-actions
3
- Version: 0.0.85
3
+ Version: 0.0.87
4
4
  Summary: Ultralytics Actions for GitHub automation and PR management.
5
5
  Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>
6
6
  Maintainer-email: Ultralytics <hello@ultralytics.com>