Repository: tattle-made/feluda
Pull request #532: Fix: Unit test fix and Bug fix
Author: login: PinrLi
Created: 2025-04-07T20:25:39Z | Merged: 2025-04-21T03:56:16Z

Based on Issue #465
The current unit test and the semantic workflow code have a few errors. This PR fixes:
1. _discover_packages uses the operators_path incorrectly, fixed for general cases
2. get_package_commits didn't check if a commit is the initial commit, which might cause an edge case error
3. Several tests using incorrect paths for operators, ie: 
![image](https://github.com/user-attachments/assets/83371eda-233e-49e5-b03c-5d9c9975b782)
4. update_package_versions has a different logic between the code and the unit test for existing tags, modified the original code to match the unit test.
5. test_multiple_breaking_changes test needs more inspection on changing the test or the code. One of the messages was "feat: new feature without breaking change", while this message would be recognized as **Breaking** by _parse_conventional_commit. Not sure what is the best solution to this, skip for now.

Current Status
![image](https://github.com/user-attachments/assets/ce21bb8b-e077-498d-b01b-4e71fa79c887)




Diff:
diff --git a/scripts/semantic_release_workflow.py b/scripts/semantic_release_workflow.py
index a308a272..5dcc22ca 100644
--- a/scripts/semantic_release_workflow.py
+++ b/scripts/semantic_release_workflow.py
@@ -52,7 +52,7 @@ def _validate_pyproject(self, pyproject_data, pyproject_path):
             raise ValueError(f"Missing required fields in {pyproject_path}")
         return True
 
-    def _discover_packages(self):
+    def _discover_packages(self, package_roots=["feluda"], operators_path="operators"):
         """
         Discover all packages in the monorepo with their pyproject.toml.
 
@@ -64,11 +64,7 @@ def _discover_packages(self):
         """
         packages = {}
 
-        # Root package (feluda)
-        package_roots = ["feluda"]
-
         # Discover packages inside 'operators' directory using glob
-        operators_path = "operators"
         if os.path.isdir(operators_path):
             for folder in glob.glob(f"{operators_path}/*/pyproject.toml"):
                 package_roots.append(os.path.dirname(folder))
@@ -535,4 +531,4 @@ def update_package_versions(self):
 
     except Exception as e:
         print(f"An error occurred during the version update process: {e}")
-        sys.exit(1)
+        sys.exit(1)
\ No newline at end of file
diff --git a/tests/scripts/test_semantic_release_workflow.py b/tests/scripts/test_semantic_release_workflow.py
index b89ddce2..1d0165b8 100644
--- a/tests/scripts/test_semantic_release_workflow.py
+++ b/tests/scripts/test_semantic_release_workflow.py
@@ -16,12 +16,13 @@ def setUp(self):
         """Set up a temporary directory structure simulating a monorepo."""
         # Create a temporary directory to simulate the repo
         self.temp_dir = tempfile.mkdtemp()
-
         # Create the basic structure
         os.makedirs(os.path.join(self.temp_dir, "feluda"))
+        self.temp_dir = os.path.join(self.temp_dir, "feluda")
+        os.makedirs(os.path.join(self.temp_dir, "feluda"))
         os.makedirs(os.path.join(self.temp_dir, "operators", "operator1"))
         os.makedirs(os.path.join(self.temp_dir, "operators", "operator2"))
-
+        # make feluda the root path
         # Create git repo
         self._setup_git_repo()
 
@@ -30,6 +31,9 @@ def setUp(self):
 
         # Set up initial commit
         self._create_initial_commit()
+        
+        
+        
 
     def tearDown(self):
         """Clean up the temporary directory."""
@@ -129,7 +133,7 @@ def _create_file_and_commit(self, path, content, commit_message):
 
     def _get_current_version(self, package_path):
         """Get the current version from a package's pyproject.toml."""
-        if package_path == "feluda":
+        if package_path.endswith("feluda"):
             pyproject_path = os.path.join(self.temp_dir, "pyproject.toml")
         else:
             pyproject_path = os.path.join(self.temp_dir, package_path, "pyproject.toml")
@@ -149,14 +153,15 @@ def test_discover_packages(self):
         manager = PackageVersionManager(
             self.temp_dir, self.initial_commit, self.initial_commit
         )
-
+        manager.packages = manager._discover_packages([self.temp_dir], os.path.join(self.temp_dir, "operators"))
+        
         # Check that we have exactly 3 packages discovered
         self.assertEqual(len(manager.packages), 3)
         # Check for the root package 'feluda'
-        self.assertIn("feluda", manager.packages)
+        self.assertIn(self.temp_dir, manager.packages)
         self.assertEqual(
-            manager.packages["feluda"]["package_path"],
-            os.path.join(self.temp_dir, "feluda"),
+            manager.packages[self.temp_dir]["package_path"],
+            self.temp_dir
         )
         # Check for operator1 and operator2 by their absolute paths
         op1_path = os.path.join(self.temp_dir, "operators", "operator1")
@@ -165,7 +170,7 @@ def test_discover_packages(self):
         self.assertIn(op2_path, manager.packages)
         # Additional checks to verify the version and package name
         self.assertEqual(
-            manager.packages["feluda"]["pyproject_data"]["project"]["name"], "feluda"
+            manager.packages[self.temp_dir]["pyproject_data"]["project"]["name"], "feluda"
         )
         self.assertEqual(
             manager.packages[op1_path]["pyproject_data"]["project"]["name"], "operator1"
@@ -265,7 +270,7 @@ def test_package_commits_detection(self):
     def test_determine_package_bump(self):
         """Test determination of version bump type based on commits."""
         # Create a series of commits affecting different packages
-        self._create_file_and_commit(
+        commit1 = self._create_file_and_commit(
             "feluda/example1.py", "print('hello')", "feat: added feature to feluda"
         )
 
@@ -281,7 +286,7 @@ def test_determine_package_bump(self):
             "fix: fixed bug in operator2",
         )
 
-        manager = PackageVersionManager(self.temp_dir, self.initial_commit, commit3)
+        manager = PackageVersionManager(self.temp_dir, commit1, commit3)
 
         # Test feluda bump (should be minor)
         self.assertEqual(
@@ -305,20 +310,100 @@ def test_determine_package_bump(self):
             "patch",
         )
 
+        # Test non-existent package (should return None)
+        self.assertIsNone(
+            manager.determine_package_bump(
+                os.path.join(self.temp_dir, "nonexistent_package")
+            )
+        )
+
+    def test_determine_package_bump_no_update(self):
+        """Test that no version bump occurs if no commits affect the package."""
+        # Create a commit affecting only one package
+        self._create_file_and_commit(
+            "feluda/example1.py", "print('hello')", "feat: added feature to feluda"
+        )
+
+        # Create the version manager
+        manager = PackageVersionManager(
+            self.temp_dir, self.initial_commit, self.initial_commit
+        )
+
+        # Test operator1 bump (should be None since no commits)
+        self.assertIsNone(
+            manager.determine_package_bump(
+                os.path.join(self.temp_dir, "operators/operator1")
+            )
+        )
+
+    def test_get_tag_format(self):
+        """Test the tag format generation."""
+        manager = PackageVersionManager(
+            self.temp_dir, self.initial_commit, self.initial_commit
+        )
+        manager.packages = manager._discover_packages(
+            [self.temp_dir], os.path.join(self.temp_dir, "operators")
+        )
+        feluda_path = os.path.join(self.temp_dir, "feluda")
+        expected_tag = manager.packages[self.temp_dir].get("pyproject_data", {}).get(
+            "tool", {}
+        ).get("semantic_release", {}).get("branches", {}).get("main", {}).get(
+            "tag_format", "{name}-v{version}"
+        )
+
+        self.assertEqual(
+            manager._get_tag_format(manager.packages[self.temp_dir]), expected_tag
+        )
+
     def test_tag_exists(self):
         """Test detection of existing tags."""
         manager = PackageVersionManager(
             self.temp_dir, self.initial_commit, self.initial_commit
         )
+        manager.packages = manager._discover_packages(
+            [self.temp_dir], os.path.join(self.temp_dir, "operators")
+        )
 
         # Create a tag
         subprocess.run(["git", "tag", "feluda-v0.2.0"], cwd=self.temp_dir, check=True)
 
         # Test tag exists
-        self.assertTrue(manager.tag_exists(manager.packages["feluda"], "0.2.0"))
+        self.assertTrue(manager.tag_exists(manager.packages[self.temp_dir], "0.2.0"))
 
         # Test tag doesn't exist
-        self.assertFalse(manager.tag_exists(manager.packages["feluda"], "0.3.0"))
+        self.assertFalse(manager.tag_exists(manager.packages[self.temp_dir], "0.3.0"))
+
+    def test_create_tag(self):
+        """Test creation of tags."""
+        manager = PackageVersionManager(
+            self.temp_dir, self.initial_commit, self.initial_commit
+        )
+        manager.packages = manager._discover_packages(
+            [self.temp_dir], os.path.join(self.temp_dir, "operators")
+        )
+        
+        manager.create_tag(manager.packages[self.temp_dir], "0.2.0")
+
+        tags = subprocess.run(
+            ["git", "tag"],
+            cwd=self.temp_dir,
+            capture_output=True,
+            text=True,
+            check=True,
+        ).stdout.splitlines()
+        self.assertIn("feluda-v0.2.0", tags)
+        self.assertNotIn("feluda-v0.3.0", tags)
+
+        # Check if the tag was created
+        manager.create_tag(manager.packages[self.temp_dir], "0.3.0")
+        tags = subprocess.run(  
+            ["git", "tag"],
+            cwd=self.temp_dir,
+            capture_output=True,
+            text=True,
+            check=True,
+        ).stdout.splitlines()
+        self.assertIn("feluda-v0.3.0", tags)
 
     def test_update_package_versions_no_changes(self):
         """Test that no version updates occur when there are no changes."""
@@ -332,7 +417,7 @@ def test_update_package_versions_no_changes(self):
     def test_update_package_versions_with_changes(self):
         """Test version updates based on commits."""
         # Create a series of commits affecting different packages
-        self._create_file_and_commit(
+        commit1 = self._create_file_and_commit(
             "feluda/example1.py", "print('hello')", "feat: added feature to feluda"
         )
 
@@ -349,7 +434,10 @@ def test_update_package_versions_with_changes(self):
         )
 
         # Create the version manager
-        manager = PackageVersionManager(self.temp_dir, self.initial_commit, commit3)
+        manager = PackageVersionManager(self.temp_dir, commit1, commit3)
+        manager.packages = manager._discover_packages(
+            [self.temp_dir], os.path.join(self.temp_dir, "operators")
+        )
 
         # Update versions
         updated_versions = manager.update_package_versions()
@@ -357,31 +445,33 @@ def test_update_package_versions_with_changes(self):
         # Check that all packages were updated
         self.assertEqual(len(updated_versions), 3)
 
-        # Check feluda version (should be minor bump from 0.1.0 to 0.2.0)
-        self.assertEqual(updated_versions["feluda"]["old_version"], "0.1.0")
-        self.assertEqual(updated_versions["feluda"]["new_version"], "0.2.0")
-        self.assertEqual(updated_versions["feluda"]["bump_type"], "minor")
-
+        # Check feluda version (should be major bump from 0.1.0 to 1.0.0)
+        
+        operator1_path = os.path.join(self.temp_dir, "operators", "operator1")
+        operator2_path = os.path.join(self.temp_dir, "operators", "operator2")
+        self.assertEqual(updated_versions[self.temp_dir]["old_version"], "0.1.0")
+        self.assertEqual(updated_versions[self.temp_dir]["new_version"], "1.0.0")
+        self.assertEqual(updated_versions[self.temp_dir]["bump_type"], "major")
         # Check operator1 version (should be major bump from 0.1.0 to 1.0.0)
         self.assertEqual(
-            updated_versions["operators/operator1"]["old_version"], "0.1.0"
+            updated_versions[operator1_path]["old_version"], "0.1.0"
         )
         self.assertEqual(
-            updated_versions["operators/operator1"]["new_version"], "1.0.0"
+            updated_versions[operator1_path]["new_version"], "1.0.0"
         )
-        self.assertEqual(updated_versions["operators/operator1"]["bump_type"], "major")
+        self.assertEqual(updated_versions[operator1_path]["bump_type"], "major")
 
         # Check operator2 version (should be patch bump from 0.1.0 to 0.1.1)
         self.assertEqual(
-            updated_versions["operators/operator2"]["old_version"], "0.1.0"
+            updated_versions[operator2_path]["old_version"], "0.1.0"
         )
         self.assertEqual(
-            updated_versions["operators/operator2"]["new_version"], "0.1.1"
+            updated_versions[operator2_path]["new_version"], "0.1.1"
         )
-        self.assertEqual(updated_versions["operators/operator2"]["bump_type"], "patch")
+        self.assertEqual(updated_versions[operator2_path]["bump_type"], "patch")
 
         # Verify that the versions were updated in the pyproject.toml files
-        self.assertEqual(self._get_current_version("feluda"), "0.2.0")
+        self.assertEqual(self._get_current_version("feluda"), "1.0.0")
         self.assertEqual(self._get_current_version("operators/operator1"), "1.0.0")
         self.assertEqual(self._get_current_version("operators/operator2"), "0.1.1")
 
@@ -394,7 +484,7 @@ def test_update_package_versions_with_changes(self):
             check=True,
         ).stdout.splitlines()
 
-        self.assertIn("feluda-v0.2.0", tags)
+        self.assertIn("feluda-v1.0.0", tags)
         self.assertIn("operator1-v1.0.0", tags)
         self.assertIn("operator2-v0.1.1", tags)
 
@@ -404,33 +494,27 @@ def test_version_bump_with_existing_tag(self):
         commit1 = self._create_file_and_commit(
             "feluda/example1.py", "print('hello')", "feat: added feature to feluda"
         )
+        # Create a commit affecting operator1
+        commit2 = self._create_file_and_commit(
+            "feluda/example1.py",
+            "print('world')",
+            "feat: added feature to feluda",
+        )
 
         # Create a tag for feluda-v0.2.0
         subprocess.run(["git", "tag", "feluda-v0.2.0"], cwd=self.temp_dir, check=True)
 
         # Create the version manager
-        manager = PackageVersionManager(self.temp_dir, self.initial_commit, commit1)
+        manager = PackageVersionManager(self.temp_dir, commit1, commit2)
 
         # Update versions
         updated_versions = manager.update_package_versions()
-
-        # Check that feluda was updated to 0.2.1 (since 0.2.0 tag already exists)
-        self.assertEqual(updated_versions["feluda"]["old_version"], "0.1.0")
-        self.assertEqual(updated_versions["feluda"]["new_version"], "0.2.1")
+        
+        # Check that feluda was skipped (since 0.2.0 tag already exists)
+        self.assertEqual(len(updated_versions), 0)
 
         # Verify that the version was updated in the pyproject.toml file
-        self.assertEqual(self._get_current_version("feluda"), "0.2.1")
-
-        # Verify that the new tag was created
-        tags = subprocess.run(
-            ["git", "tag"],
-            cwd=self.temp_dir,
-            capture_output=True,
-            text=True,
-            check=True,
-        ).stdout.splitlines()
-
-        self.assertIn("feluda-v0.2.1", tags)
+        self.assertEqual(self._get_current_version("feluda"), "0.1.0")
 
     def test_package_without_pyproject_toml(self):
         """Test handling of a package without pyproject.toml."""
@@ -443,12 +527,16 @@ def test_package_without_pyproject_toml(self):
         manager = PackageVersionManager(
             self.temp_dir, self.initial_commit, self.initial_commit
         )
-
+        manager.packages = manager._discover_packages(
+            [self.temp_dir], os.path.join(self.temp_dir, "operators")
+        )
+        operator1_path = os.path.join(self.temp_dir, "operators", "operator1")
+        operator2_path = os.path.join(self.temp_dir, "operators", "operator2")
         # Check that only two packages were discovered
         self.assertEqual(len(manager.packages), 2)
-        self.assertIn("feluda", manager.packages)
-        self.assertIn("operators/operator1", manager.packages)
-        self.assertNotIn("operators/operator2", manager.packages)
+        self.assertIn(self.temp_dir, manager.packages)
+        self.assertIn(operator1_path, manager.packages)
+        self.assertNotIn(operator2_path, manager.packages)
 
     def test_invalid_pyproject_toml(self):
         """Test handling of a package with invalid pyproject.toml."""
@@ -462,12 +550,17 @@ def test_invalid_pyproject_toml(self):
         manager = PackageVersionManager(
             self.temp_dir, self.initial_commit, self.initial_commit
         )
+        manager.packages = manager._discover_packages(
+            [self.temp_dir], os.path.join(self.temp_dir, "operators")
+        )
 
+        operator1_path = os.path.join(self.temp_dir, "operators", "operator1")
+        operator2_path = os.path.join(self.temp_dir, "operators", "operator2")
         # Check that only two packages were discovered
         self.assertEqual(len(manager.packages), 2)
-        self.assertIn("feluda", manager.packages)
-        self.assertIn("operators/operator1", manager.packages)
-        self.assertNotIn("operators/operator2", manager.packages)
+        self.assertIn(self.temp_dir, manager.packages)
+        self.assertIn(operator1_path, manager.packages)
+        self.assertNotIn(operator2_path, manager.packages)
 
     def test_missing_required_fields_in_pyproject(self):
         """Test handling of a package with missing required fields in pyproject.toml."""
@@ -486,17 +579,21 @@ def test_missing_required_fields_in_pyproject(self):
         manager = PackageVersionManager(
             self.temp_dir, self.initial_commit, self.initial_commit
         )
-
+        manager.packages = manager._discover_packages(
+            [self.temp_dir], os.path.join(self.temp_dir, "operators")
+        )
+        operator1_path = os.path.join(self.temp_dir, "operators", "operator1")
+        operator2_path = os.path.join(self.temp_dir, "operators", "operator2")
         # Check that only two packages were discovered
         self.assertEqual(len(manager.packages), 2)
-        self.assertIn("feluda", manager.packages)
-        self.assertIn("operators/operator1", manager.packages)
-        self.assertNotIn("operators/operator2", manager.packages)
+        self.assertIn(self.temp_dir, manager.packages)
+        self.assertIn(operator1_path, manager.packages)
+        self.assertNotIn(operator2_path, manager.packages)
 
     def test_mixed_commit_types(self):
         """Test version bump selection with mixed commit types."""
         # Create a series of commits with different types
-        self._create_file_and_commit(
+        commit1 = self._create_file_and_commit(
             "feluda/example1.py", "print('hello')", "feat: new feature"
         )
 
@@ -509,7 +606,7 @@ def test_mixed_commit_types(self):
         )
 
         # Create the version manager
-        manager = PackageVersionManager(self.temp_dir, self.initial_commit, commit3)
+        manager = PackageVersionManager(self.temp_dir, commit1, commit3)
 
         # Determine the bump type (should be minor due to feat commit)
         bump_type = manager.determine_package_bump(
@@ -525,7 +622,7 @@ def test_non_conventional_commits(self):
         )
 
         # Create the version manager
-        manager = PackageVersionManager(self.temp_dir, self.initial_commit, commit)
+        manager = PackageVersionManager(self.temp_dir, commit, commit)
 
         # Determine the bump type (should be patch for non-conventional commits)
         bump_type = manager.determine_package_bump(
@@ -536,7 +633,7 @@ def test_non_conventional_commits(self):
     def test_multiple_package_updates(self):
         """Test updating versions for multiple packages with multiple commits."""
         # Create a series of commits affecting different packages
-        self._create_file_and_commit(
+        commit1 = self._create_file_and_commit(
             "feluda/file1.py", "print('hello')", "feat: new feature in feluda"
         )
 
@@ -560,29 +657,32 @@ def test_multiple_package_updates(self):
         )
 
         # Create the version manager
-        manager = PackageVersionManager(self.temp_dir, self.initial_commit, commit4)
+        manager = PackageVersionManager(self.temp_dir, commit1, commit4)
+        manager.packages = manager._discover_packages(
+            [self.temp_dir], os.path.join(self.temp_dir, "operators")
+        )
 
         # Update versions
         updated_versions = manager.update_package_versions()
 
         # Check that both packages were updated
         self.assertEqual(len(updated_versions), 2)
-
+        operator1_path = os.path.join(self.temp_dir, "operators", "operator1")
         # Check feluda version (should be major bump due to BREAKING CHANGE)
-        self.assertEqual(updated_versions["feluda"]["old_version"], "0.1.0")
-        self.assertEqual(updated_versions["feluda"]["new_version"], "1.0.0")
-        self.assertEqual(updated_versions["feluda"]["bump_type"], "major")
+        self.assertEqual(updated_versions[self.temp_dir]["old_version"], "0.1.0")
+        self.assertEqual(updated_versions[self.temp_dir]["new_version"], "1.0.0")
+        self.assertEqual(updated_versions[self.temp_dir]["bump_type"], "major")
 
         # Check operator1 version (should be minor bump due to feat commit)
         self.assertEqual(
-            updated_versions["operators/operator1"]["old_version"], "0.1.0"
+            updated_versions[operator1_path]["old_version"], "0.1.0"
         )
         self.assertEqual(
-            updated_versions["operators/operator1"]["new_version"], "0.2.0"
+            updated_versions[operator1_path]["new_version"], "0.2.0"
         )
-        self.assertEqual(updated_versions["operators/operator1"]["bump_type"], "minor")
+        self.assertEqual(updated_versions[operator1_path]["bump_type"], "minor")
 
-    @patch("package_version_manager.subprocess.run")
+    @patch("scripts.semantic_release_workflow.subprocess.run")
     def test_git_command_failure(self, mock_run):
         """Test handling of git command failures."""
         # Setup the mock to raise an exception when getting commits
@@ -606,3 +706,32 @@ def test_git_command_failure(self, mock_run):
         # Update package versions should not raise an exception
         updated_versions = manager.update_package_versions()
         self.assertEqual(len(updated_versions), 0)
+
+    @skip # See Todo message
+    def test_multiple_breaking_changes(self):
+        """Test that the highest bump type is selected when multiple breaking changes exist."""
+        # Create commits with breaking changes in different packages
+        self._create_file_and_commit(
+            "feluda/breaking.py", "print('break')", "feat: breaking change in feluda\n\nBREAKING CHANGE: API change"
+        )
+        
+        self._create_file_and_commit(
+            "operators/operator1/breaking.py", 
+            "print('break')",
+            "fix: minor fix with BREAKING CHANGE"
+        )
+        
+        # TODO: This test fails because _parse_conventional_commit detects the "breaking change" in the message and marks this as major
+        commit3 = self._create_file_and_commit(
+            "operators/operator2/normal.py",
+            "print('normal')",
+            "feat: new feature without breaking change"
+        )
+        
+        manager = PackageVersionManager(self.temp_dir, self.initial_commit, commit3)
+        updated_versions = manager.update_package_versions()
+        
+        # Check that feluda and operator1 got major bumps, and operator2 got a minor bump
+        self.assertEqual(updated_versions["feluda"]["bump_type"], "major")
+        self.assertEqual(updated_versions[f"{self.temp_dir}/operators/operator1"]["bump_type"], "major")
+        self.assertEqual(updated_versions[f"{self.temp_dir}/operators/operator2"]["bump_type"], "minor")
\ No newline at end of file


Reviews:
user: login: aatmanvaidya
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-09T18:44:51Z
user: login: PinrLi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-09T18:48:10Z
user: login: aatmanvaidya
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-09T18:50:02Z
user: login: PinrLi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-09T18:52:51Z
user: login: aatmanvaidya
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-04-20T21:00:19Z

Review comments:
diff_hunk: @@ -68,10 +68,11 @@ def _discover_packages(self):
         package_roots = ["feluda"]
 
         # Discover packages inside 'operators' directory using glob
-        operators_path = "operators"
+        operators_path = f"{self.repo_root}/operators"
path: scripts/semantic_release_workflow.py
user: login: aatmanvaidya
body: also if changes like this are absolutely important, then do let me know
we will have to modify the script in that case and not so much the test

because I understand how `f"{self.repo_root}/operators"` would be needed for the discover package function to find the folder in a `tmp` directory. 
created_at: 2025-04-09T18:44:51Z
author_association: COLLABORATOR
diff_hunk: @@ -68,10 +68,11 @@ def _discover_packages(self):
         package_roots = ["feluda"]
 
         # Discover packages inside 'operators' directory using glob
-        operators_path = "operators"
+        operators_path = f"{self.repo_root}/operators"
path: scripts/semantic_release_workflow.py
user: login: PinrLi
body: Yes I was just thinking about this, since the current implementation is hardcoded and would never check the tmp file, but all other changes could be reflected in the unit test file.
created_at: 2025-04-09T18:48:10Z
author_association: CONTRIBUTOR
diff_hunk: @@ -68,10 +68,11 @@ def _discover_packages(self):
         package_roots = ["feluda"]
 
         # Discover packages inside 'operators' directory using glob
-        operators_path = "operators"
+        operators_path = f"{self.repo_root}/operators"
path: scripts/semantic_release_workflow.py
user: login: aatmanvaidya
body: right right that make's sense
so now you tell me what are some must have changes that need to be made
created_at: 2025-04-09T18:50:02Z
author_association: COLLABORATOR
diff_hunk: @@ -68,10 +68,11 @@ def _discover_packages(self):
         package_roots = ["feluda"]
 
         # Discover packages inside 'operators' directory using glob
-        operators_path = "operators"
+        operators_path = f"{self.repo_root}/operators"
path: scripts/semantic_release_workflow.py
user: login: PinrLi
body: I think just this, and everything else I should be able to fix the test
created_at: 2025-04-09T18:52:51Z
author_association: CONTRIBUTOR

PR comments:
user: login: aatmanvaidya
created_at: 2025-04-08T06:16:46Z
body: hi @PinrLi thank you for your work, do give me sometime to review it

The test was written not properly earlier, so we should make changes to the test only and **NOT the script**, the script is working fine. We know that because we have written a lot of automated tests to make sure the script works. 

Is it possible for you to undo the changes made to `scripts/semantic_release_workflow.py` in this PR? and modify the test accordingly, for instance, if you feel `update_package_versions()` has a different logic, then change the test function and not the script, or remove this function from the test. 

Also great catching the issue in `test_multiple_breaking_changes`, we can fix the bug in `_parse_conventional_commit` later on
author_association: COLLABORATOR
user: login: PinrLi
created_at: 2025-04-08T17:16:48Z
body: > hi @PinrLi thank you for your work, do give me sometime to review it
> 
> The test was written not properly earlier, so we should make changes to the test only and **NOT the script**, the script is working fine. We know that because we have written a lot of automated tests to make sure the script works.
> 
> Is it possible for you to undo the changes made to `scripts/semantic_release_workflow.py` in this PR? and modify the test accordingly, for instance, if you feel `update_package_versions()` has a different logic, then change the test function and not the script, or remove this function from the test.
> 
> Also great catching the issue in `test_multiple_breaking_changes`, we can fix the bug in `_parse_conventional_commit` later on

Sure I will work on it
author_association: CONTRIBUTOR
user: login: PinrLi
created_at: 2025-04-09T20:25:38Z
body: Updated, fixed more path errors in test and in the workflow.
Also, fixed the test that works different from the code.
author_association: CONTRIBUTOR
user: login: aatmanvaidya
created_at: 2025-04-09T21:58:19Z
body: perfect thanks, testing it out on my end too!
so the only change now in the semantic script is appending `{self.repo_root}` to the path's right?
author_association: COLLABORATOR
user: login: PinrLi
created_at: 2025-04-09T22:11:16Z
body: > perfect thanks, testing it out on my end too! so the only change now in the semantic script is appending `{self.repo_root}` to the path's right?

That's right!
author_association: CONTRIBUTOR
user: login: aatmanvaidya
created_at: 2025-04-10T05:31:50Z
body: hi @PinrLi I pulled the PR on my end, and ran the test like this
```sh
uv run -m unittest tests/scripts/test_semantic_release_workflow.py
```

I am getting the following errors
```sh
======================================================================
ERROR: test_get_tag_format (tests.scripts.test_semantic_release_workflow.TestPackageVersionManager)
Test the tag format generation.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/aatman/Aatman/Tattle/feluda/tests/scripts/test_semantic_release_workflow.py", line 342, in test_get_tag_format
    expected_tag = manager.packages["feluda"].get("pyproject_data", {}).get(
KeyError: 'feluda'

======================================================================
ERROR: test_tag_exists (tests.scripts.test_semantic_release_workflow.TestPackageVersionManager)
Test detection of existing tags.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/aatman/Aatman/Tattle/feluda/tests/scripts/test_semantic_release_workflow.py", line 362, in test_tag_exists
    self.assertTrue(manager.tag_exists(manager.packages["feluda"], "0.2.0"))
KeyError: 'feluda'

======================================================================
FAIL: test_determine_package_bump (tests.scripts.test_semantic_release_workflow.TestPackageVersionManager)
Test determination of version bump type based on commits.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/aatman/Aatman/Tattle/feluda/tests/scripts/test_semantic_release_workflow.py", line 289, in test_determine_package_bump
    self.assertEqual(
AssertionError: None != 'minor'

----------------------------------------------------------------------
Ran 21 tests in 0.712s

FAILED (failures=1, errors=2, skipped=2)
```

did I do something wrong?
author_association: COLLABORATOR
user: login: PinrLi
created_at: 2025-04-10T16:38:21Z
body: > hi @PinrLi I pulled the PR on my end, and ran the test like this
> 
> ```shell
> uv run -m unittest tests/scripts/test_semantic_release_workflow.py
> ```
> 
> I am getting the following errors
> 
> ```shell
> ======================================================================
> ERROR: test_get_tag_format (tests.scripts.test_semantic_release_workflow.TestPackageVersionManager)
> Test the tag format generation.
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/home/aatman/Aatman/Tattle/feluda/tests/scripts/test_semantic_release_workflow.py", line 342, in test_get_tag_format
>     expected_tag = manager.packages["feluda"].get("pyproject_data", {}).get(
> KeyError: 'feluda'
> 
> ======================================================================
> ERROR: test_tag_exists (tests.scripts.test_semantic_release_workflow.TestPackageVersionManager)
> Test detection of existing tags.
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/home/aatman/Aatman/Tattle/feluda/tests/scripts/test_semantic_release_workflow.py", line 362, in test_tag_exists
>     self.assertTrue(manager.tag_exists(manager.packages["feluda"], "0.2.0"))
> KeyError: 'feluda'
> 
> ======================================================================
> FAIL: test_determine_package_bump (tests.scripts.test_semantic_release_workflow.TestPackageVersionManager)
> Test determination of version bump type based on commits.
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/home/aatman/Aatman/Tattle/feluda/tests/scripts/test_semantic_release_workflow.py", line 289, in test_determine_package_bump
>     self.assertEqual(
> AssertionError: None != 'minor'
> 
> ----------------------------------------------------------------------
> Ran 21 tests in 0.712s
> 
> FAILED (failures=1, errors=2, skipped=2)
> ```
> 
> did I do something wrong?

Seemed like I didn't fix these 3, can you retry my latest commit?
I got 
----------------------------------------------------------------------
Ran 21 tests in 1.216s

OK (skipped=2)
author_association: CONTRIBUTOR
user: login: aatmanvaidya
created_at: 2025-04-10T18:23:09Z
body: @PinrLi it works now, will merge the PR soon!
author_association: COLLABORATOR
user: login: aatmanvaidya
created_at: 2025-04-11T09:02:08Z
body: hi @PinrLi I have a [dummy repo](https://github.com/aatmanvaidya/feluda-versioning-check/) where I have written some [automated tests](https://github.com/aatmanvaidya/feluda-versioning-check/tree/main/automate_testing) to test out the semantic versioning workflow. 

Now I made a PR with a change in the `feluda/` folder ([commit](https://github.com/aatmanvaidya/feluda-versioning-check/commit/b68abf57dfcd8e5fe4001e0961cf26aa7ac74687)), and the script gave this error in the in when the [github action ran](https://github.com/aatmanvaidya/feluda-versioning-check/actions/runs/14399441415/job/40381726182)
```
Error discovering package at /home/runner/work/feluda-versioning-check/feluda-versioning-check/feluda: pyproject.toml not found in /home/runner/work/feluda-versioning-check/feluda-versioning-check/feluda
```

I think appending `self.repo_root` is causing the double repo name `feluda-versioning-check/feluda-versioning-check/feluda` and this is breaking the action. 

Apologies if I am being too nit-picky, since this workflow is very crucial part of `feluda`, I want to make sure all checks and automated tests pass
author_association: COLLABORATOR
user: login: PinrLi
created_at: 2025-04-11T14:56:31Z
body: > hi @PinrLi I have a [dummy repo](https://github.com/aatmanvaidya/feluda-versioning-check/) where I have written some [automated tests](https://github.com/aatmanvaidya/feluda-versioning-check/tree/main/automate_testing) to test out the semantic versioning workflow.
> 
> Now I made a PR with a change in the `feluda/` folder ([commit](https://github.com/aatmanvaidya/feluda-versioning-check/commit/b68abf57dfcd8e5fe4001e0961cf26aa7ac74687)), and the script gave this error in the in when the [github action ran](https://github.com/aatmanvaidya/feluda-versioning-check/actions/runs/14399441415/job/40381726182)
> 
> ```
> Error discovering package at /home/runner/work/feluda-versioning-check/feluda-versioning-check/feluda: pyproject.toml not found in /home/runner/work/feluda-versioning-check/feluda-versioning-check/feluda
> ```
> 
> I think appending `self.repo_root` is causing the double repo name `feluda-versioning-check/feluda-versioning-check/feluda` and this is breaking the action.
> 
> Apologies if I am being too nit-picky, since this workflow is very crucial part of `feluda`, I want to make sure all checks and automated tests pass

I agree, I will try to resolve this
author_association: CONTRIBUTOR
user: login: PinrLi
created_at: 2025-04-13T18:45:42Z
body: @aatmanvaidya Can you try the current version if this works?


author_association: CONTRIBUTOR
user: login: aatmanvaidya
created_at: 2025-04-14T03:27:42Z
body: hi @PinrLi I was testing on my end and faced an issue when we make any change to the root `pyproejct.toml` file, whenever any change is made to the root [`pyproejct.toml`](https://github.com/tattle-made/feluda/blob/main/pyproject.toml) file, the semantic version should be applied to `felulda`. 

So in my test, I made [this commit](https://github.com/aatmanvaidya/feluda-versioning-check/commit/5f4d696e021c7b5236c9ac507c83819b7e84ede3) to the pyproject.toml file - then the [github action gave this output](https://github.com/aatmanvaidya/feluda-versioning-check/actions/runs/14436724272/job/40478989436). 
Here is the output of the script
```sh
No changes found for /home/runner/work/feluda-versioning-check/feluda-versioning-check/feluda. Skipping version bump.
No changes found for /home/runner/work/feluda-versioning-check/feluda-versioning-check/operators/image_vec_rep_resnet. Skipping version bump.
No changes found for /home/runner/work/feluda-versioning-check/feluda-versioning-check/operators/vid_vec_rep_clip. Skipping version bump.
```

I think this issue is coming form these lines in the code - https://github.com/tattle-made/feluda/blob/4f176dcc2bcd286956c7fc4eea52586140cd3575/scripts/semantic_release_workflow.py#L84-L89
author_association: COLLABORATOR
user: login: PinrLi
created_at: 2025-04-16T15:11:41Z
body: > hi @PinrLi I was testing on my end and faced an issue when we make any change to the root `pyproejct.toml` file, whenever any change is made to the root [`pyproejct.toml`](https://github.com/tattle-made/feluda/blob/main/pyproject.toml) file, the semantic version should be applied to `felulda`.
> 
> So in my test, I made [this commit](https://github.com/aatmanvaidya/feluda-versioning-check/commit/5f4d696e021c7b5236c9ac507c83819b7e84ede3) to the pyproject.toml file - then the [github action gave this output](https://github.com/aatmanvaidya/feluda-versioning-check/actions/runs/14436724272/job/40478989436). Here is the output of the script
> 
> ```shell
> No changes found for /home/runner/work/feluda-versioning-check/feluda-versioning-check/feluda. Skipping version bump.
> No changes found for /home/runner/work/feluda-versioning-check/feluda-versioning-check/operators/image_vec_rep_resnet. Skipping version bump.
> No changes found for /home/runner/work/feluda-versioning-check/feluda-versioning-check/operators/vid_vec_rep_clip. Skipping version bump.
> ```
> 
> I think this issue is coming form these lines in the code -
> 
> https://github.com/tattle-made/feluda/blob/4f176dcc2bcd286956c7fc4eea52586140cd3575/scripts/semantic_release_workflow.py#L84-L89

Hey I cloned your feluda-visioning-check, may I know how I should recreate this error? thanks
author_association: CONTRIBUTOR
user: login: aatmanvaidya
created_at: 2025-04-16T16:26:24Z
body: > Hey I cloned your feluda-visioning-check, may I know how I should recreate this error? thanks

Hi, so I have a folder called [automated_testing](https://github.com/aatmanvaidya/feluda-versioning-check/tree/main/automate_testing), in this folder you will find a lot of `.sh` files that run end to end tests. But for this you will need [github cli](https://cli.github.com/) installed and then to replicate the error you will have to run - [02_feluda_pyproject_changes.sh](https://github.com/aatmanvaidya/feluda-versioning-check/blob/main/automate_testing/02_feluda_pyproject_changes.sh) file

if setting up github cli and doing things is an headache, do the following
1 Clone the repo
2. Make sure your latest [semantic version script](https://github.com/aatmanvaidya/feluda-versioning-check/blob/main/scripts/semantic_release_workflow.py) code is updated and pushed.
3. Then create a new branch, in this branch just make any change to the [root pyproject.toml](https://github.com/aatmanvaidya/feluda-versioning-check/blob/main/pyproject.toml) file.
4. Then create a PR from this branch, and merge the PR into main
5. After this in the Github Actions tab, you will see the action running and monitor the logs there, you will notice this error  
author_association: COLLABORATOR
user: login: aatmanvaidya
created_at: 2025-04-19T15:47:19Z
body: hi @PinrLi I understand that this small change and fix could be getting hetic, 

here is another suggestion - we don't make any changes to the script, instead we re-write the entire test. like in the test, we don't create a dummy git repo, we can discard it, we can just write 4-5 test functions that run unit test for some core semantic script function, this way we don't get into the mess of creating a dummy git repo etc. 
author_association: COLLABORATOR
user: login: PinrLi
created_at: 2025-04-19T17:08:55Z
body: > hi @PinrLi I understand that this small change and fix could be getting hetic,
> 
> here is another suggestion - we don't make any changes to the script, instead we re-write the entire test. like in the test, we don't create a dummy git repo, we can discard it, we can just write 4-5 test functions that run unit test for some core semantic script function, this way we don't get into the mess of creating a dummy git repo etc.

I was trying to modify slightly the semantic code, changing the package_root as a parameter and taht way I could overwrite the default path in the unittest, I think this method works without changing too much of the code, but I am still working on adjusting the unit test code.
`def _discover_packages(self, package_roots=["feluda"], operators_path="operators"):
  ...`
author_association: CONTRIBUTOR
user: login: aatmanvaidya
created_at: 2025-04-19T18:23:19Z
body: > > hi @PinrLi I understand that this small change and fix could be getting hetic,
> > here is another suggestion - we don't make any changes to the script, instead we re-write the entire test. like in the test, we don't create a dummy git repo, we can discard it, we can just write 4-5 test functions that run unit test for some core semantic script function, this way we don't get into the mess of creating a dummy git repo etc.
> 
> I was trying to modify slightly the semantic code, changing the package_root as a parameter and taht way I could overwrite the default path in the unittest, I think this method works without changing too much of the code, but I am still working on adjusting the unit test code. `def _discover_packages(self, package_roots=["feluda"], operators_path="operators"): ...`

ahh noted, please carry on, I was just suggesting that as an alternative. 
author_association: COLLABORATOR
user: login: PinrLi
created_at: 2025-04-20T20:23:23Z
body: @aatmanvaidya Hey can you verify if the current version works? My unittest outputs:
`Ran 21 tests in 3.395s

OK (skipped=2)`

And I forked the versionning check repo and it looks good to me
author_association: CONTRIBUTOR
user: login: aatmanvaidya
created_at: 2025-04-20T20:26:11Z
body: hi @PinrLi yes testing it on my end now
author_association: COLLABORATOR
user: login: aatmanvaidya
created_at: 2025-04-20T21:01:14Z
body: hi @PinrLi I have tested it out, both the unit test and automated tests work perfectly,

this is great work, thank you for your patience and consistent efforts on this, I will merge the PR by tomorrow.
author_association: COLLABORATOR