HyukjinKwon commented on code in PR #148:
URL:
https://github.com/apache/spark-connect-rust/pull/148#discussion_r4476571489
##########
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:
Done in 72631b6. Once the issue exists, a failure to set the Fix Version
only warns, and the key is still printed. It is a separate `update` on purpose:
setting a Fix Version can need a permission that contributors lack, and JIRA
then omits the field from their create screen (it is on mine), which would make
the whole create fail. There is a comment saying so now.
##########
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:
Done in 72631b6: it calls `create_issue_link("Incorporates", ...)` directly,
so the `next()` and the fake `issue_link_types` are gone. A failure of the
umbrella search or of the link now warns like the no-umbrella case, and the key
is still printed.
##########
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:
Done in 72631b6. `unreleased_connect_rust_versions` returns the unreleased
versions newest first, compared numerically, and `merge_connect_rust_pr.py` now
uses it. Its branch default takes the smallest candidate, which the string sort
also got wrong (`connect-rust-4.3.10` before `4.3.9`).
##########
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:
It is for a maintenance line, for example filing for `connect-rust-4.2.1`
while `connect-rust-4.3.0` is the newest. In 72631b6 it accepts only an
unreleased, unarchived `connect-rust-x.y.z` version and exits before creating
anything otherwise, so `-v 4.3.0` and released versions are rejected.
##########
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:
Done in 72631b6. The fake search now returns every Epic, as JIRA's fuzzy
`summary ~` can, and a test covers no Epic, a near-match summary, two Epics
with the exact summary, and a near-match next to the real one. Another test
covers the failures after creation.
--
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]