viirya commented on code in PR #148:
URL: 
https://github.com/apache/spark-connect-rust/pull/148#discussion_r4476248889


##########
dev/spark_jira_utils.py:
##########
@@ -100,6 +118,24 @@ def create_jira_issue(
 
     try:
         new_issue = asf_jira.create_issue(fields=issue_dict)
-        return new_issue.key
+        new_issue.update(fields={"fixVersions": [{"name": version}]})
     except Exception as e:
         fail("Failed to create JIRA issue: %s" % e)
+
+    if not parent:
+        umbrella = find_release_umbrella(asf_jira, version)
+        if umbrella:
+            incorporates = next(

Review Comment:
   `create_issue_link` already resolves the type by name or by its 
outward/inward text, so `asf_jira.create_issue_link("Incorporates", 
inwardIssue=umbrella, outwardIssue=new_issue.key)` is enough. That also drops 
the bare `next()`, which raises `StopIteration` when nothing matches, and the 
fake `issue_link_types`. Separately, a failure from the search or the link here 
escapes to `main`, so `print(jira_id)` never runs. It should warn the way the 
no-umbrella case does.



##########
dev/spark_jira_utils.py:
##########
@@ -53,21 +53,34 @@ def get_jira_client():
     )
 
 
+# spark-connect-rust ships on its own connect-rust-x.y.z version line, so that 
its JIRAs
+# appear in its release notes rather than in core Spark's.
+CONNECT_RUST_VERSION = re.compile(r"connect-rust-(\d+)\.(\d+)\.(\d+)")
+
+
 def detect_affected_version(asf_jira):
-    """Return the latest unreleased x.y.z version, or exit."""
-    versions = asf_jira.project_versions("SPARK")
-    versions = [
-        x
-        for x in versions
-        if not x.raw["released"] and not x.raw["archived"] and 
re.match(r"\d+\.\d+\.\d+", x.name)
-    ]
-    versions = sorted(versions, key=lambda x: x.name, reverse=True)
+    """Return the newest unreleased connect-rust-x.y.z version, or exit."""
+    versions = []
+    for x in asf_jira.project_versions("SPARK"):
+        match = CONNECT_RUST_VERSION.fullmatch(x.name)
+        if match and not x.raw["released"] and not x.raw["archived"]:
+            versions.append((tuple(int(n) for n in match.groups()), x.name))
     if not versions:
         fail(
-            "Cannot detect affected version. "
+            "Cannot detect an unreleased connect-rust-x.y.z version. "
             "Please create the ticket manually at %s" % JIRA_API_BASE
         )
-    return versions[0].name
+    return max(versions)[1]

Review Comment:
   `merge_connect_rust_pr.py` still sorts version names as strings for the 
master default. Once `4.10.0` and `4.9.0` coexist, it will pick a different fix 
version than this one and overwrite it at merge time. Could it reuse this 
function?



##########
dev/spark_jira_utils.py:
##########
@@ -100,6 +118,24 @@ def create_jira_issue(
 
     try:
         new_issue = asf_jira.create_issue(fields=issue_dict)
-        return new_issue.key
+        new_issue.update(fields={"fixVersions": [{"name": version}]})

Review Comment:
   If this update fails, the issue already exists, but we report "Failed to 
create JIRA issue" and exit without printing the key, so a rerun files a 
duplicate. This is likely for contributors who lack permission to set Fix 
Version. Could this warn and continue instead? Also, is it a separate `update` 
because the create screen rejects `fixVersions`? If so, a one-line comment 
would help.



##########
dev/create_spark_jira.py:
##########
@@ -38,6 +38,12 @@ def main():
         help="Issue type (e.g. Bug, Improvement)",
     )
     parser.add_argument("-c", "--component", help="Component for the issue")
+    parser.add_argument(
+        "-v",
+        "--version",

Review Comment:
   What's the use case? It isn't validated: `-v 4.3.0` puts the issue on the 
core Spark line. It also sets Fix Version to the same value, so a released 
version gets a released Fix Version and that release's umbrella. I'd drop it, 
or accept only an unreleased `connect-rust-x.y.z`.



##########
scripts/tests/test_spark_jira_utils.py:
##########
@@ -0,0 +1,134 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Check JIRA versions and umbrella links of dev/spark_jira_utils.py against a 
fake JIRA."""
+
+import contextlib
+import importlib.util
+import io
+import unittest
+from pathlib import Path
+from types import SimpleNamespace
+
+SCRIPT = Path(__file__).resolve().parents[2] / "dev" / "spark_jira_utils.py"
+SPEC = importlib.util.spec_from_file_location("spark_jira_utils", SCRIPT)
+utils = importlib.util.module_from_spec(SPEC)
+SPEC.loader.exec_module(utils)
+
+
+def version(name, released=False, archived=False):
+    return SimpleNamespace(name=name, raw={"released": released, "archived": 
archived})
+
+
+class FakeIssue:
+    def __init__(self, key, summary="", fields=None):
+        self.key = key
+        self.fields = SimpleNamespace(summary=summary)
+        self.created_fields = fields
+        self.updates = []
+
+    def update(self, fields):
+        self.updates.append(fields)
+
+
+class FakeJira:
+    def __init__(self, versions, epics=()):
+        self.versions = versions
+        self.epics = list(epics)
+        self.created = []
+        self.links = []
+
+    def project_versions(self, project):
+        assert project == "SPARK"
+        return self.versions
+
+    def search_issues(self, jql):

Review Comment:
   Since this already filters by substring, the `== summary` check in 
`find_release_umbrella` is never exercised, and neither is the two-umbrellas 
case behind `len(keys) == 1`. One test with a duplicate epic and one with a 
near-match summary would cover both.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to