You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2022/06/07 23:37:45 UTC
[arrow] branch master updated: ARROW-16767: [Archery] Refactor archery.release submodule to its own subpackage (#13326)
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 3000397ad2 ARROW-16767: [Archery] Refactor archery.release submodule to its own subpackage (#13326)
3000397ad2 is described below
commit 3000397ad2bd183be7ed8448b8899100c625c091
Author: Krisztián Szűcs <sz...@gmail.com>
AuthorDate: Wed Jun 8 01:37:38 2022 +0200
ARROW-16767: [Archery] Refactor archery.release submodule to its own subpackage (#13326)
Authored-by: Krisztián Szűcs <sz...@gmail.com>
Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
dev/archery/archery/cli.py | 130 +------------------
dev/archery/archery/release/__init__.py | 18 +++
dev/archery/archery/release/cli.py | 139 +++++++++++++++++++++
.../archery/{release.py => release/core.py} | 32 +----
dev/archery/archery/release/reports.py | 45 +++++++
.../archery/{ => release}/tests/test_release.py | 2 +-
6 files changed, 208 insertions(+), 158 deletions(-)
diff --git a/dev/archery/archery/cli.py b/dev/archery/archery/cli.py
index 1607bcff02..dcf15afafe 100644
--- a/dev/archery/archery/cli.py
+++ b/dev/archery/archery/cli.py
@@ -786,134 +786,6 @@ def trigger_bot(event_name, event_payload, arrow_token):
bot.handle(event_name, event_payload)
-@archery.group('release')
-@click.option("--src", metavar="<arrow_src>", default=None,
- callback=validate_arrow_sources,
- help="Specify Arrow source directory.")
-@click.option("--jira-cache", type=click.Path(), default=None,
- help="File path to cache queried JIRA issues per version.")
-@click.pass_obj
-def release(obj, src, jira_cache):
- """Release releated commands."""
- from .release import Jira, CachedJira
-
- jira = Jira()
- if jira_cache is not None:
- jira = CachedJira(jira_cache, jira=jira)
-
- obj['jira'] = jira
- obj['repo'] = src.path
-
-
-@release.command('curate', help="Lists release related Jira issues.")
-@click.argument('version')
-@click.option('--minimal/--full', '-m/-f',
- help="Only show actionable Jira issues.", default=False)
-@click.pass_obj
-def release_curate(obj, version, minimal):
- """Release curation."""
- from .release import Release
-
- release = Release.from_jira(version, jira=obj['jira'], repo=obj['repo'])
- curation = release.curate(minimal)
-
- click.echo(curation.render('console'))
-
-
-@release.group('changelog')
-def release_changelog():
- """Release changelog."""
- pass
-
-
-@release_changelog.command('add')
-@click.argument('version')
-@click.pass_obj
-def release_changelog_add(obj, version):
- """Prepend the changelog with the current release"""
- from .release import Release
-
- jira, repo = obj['jira'], obj['repo']
-
- # just handle the current version
- release = Release.from_jira(version, jira=jira, repo=repo)
- if release.is_released:
- raise ValueError('This version has been already released!')
-
- changelog = release.changelog()
- changelog_path = pathlib.Path(repo) / 'CHANGELOG.md'
-
- current_content = changelog_path.read_text()
- new_content = changelog.render('markdown') + current_content
-
- changelog_path.write_text(new_content)
- click.echo("CHANGELOG.md is updated!")
-
-
-@release_changelog.command('generate')
-@click.argument('version')
-@click.argument('output', type=click.File('w', encoding='utf8'), default='-')
-@click.pass_obj
-def release_changelog_generate(obj, version, output):
- """Generate the changelog of a specific release."""
- from .release import Release
-
- jira, repo = obj['jira'], obj['repo']
-
- # just handle the current version
- release = Release.from_jira(version, jira=jira, repo=repo)
-
- changelog = release.changelog()
- output.write(changelog.render('markdown'))
-
-
-@release_changelog.command('regenerate')
-@click.pass_obj
-def release_changelog_regenerate(obj):
- """Regeneretate the whole CHANGELOG.md file"""
- from .release import Release
-
- jira, repo = obj['jira'], obj['repo']
- changelogs = []
-
- for version in jira.project_versions('ARROW'):
- if not version.released:
- continue
- release = Release.from_jira(version, jira=jira, repo=repo)
- click.echo('Querying changelog for version: {}'.format(version))
- changelogs.append(release.changelog())
-
- click.echo('Rendering new CHANGELOG.md file...')
- changelog_path = pathlib.Path(repo) / 'CHANGELOG.md'
- with changelog_path.open('w') as fp:
- for cl in changelogs:
- fp.write(cl.render('markdown'))
-
-
-@release.command('cherry-pick')
-@click.argument('version')
-@click.option('--dry-run/--execute', default=True,
- help="Display the git commands instead of executing them.")
-@click.option('--recreate/--continue', default=True,
- help="Recreate the maintenance branch or only apply unapplied "
- "patches.")
-@click.pass_obj
-def release_cherry_pick(obj, version, dry_run, recreate):
- """
- Cherry pick commits.
- """
- from .release import Release
-
- release = Release.from_jira(version, jira=obj['jira'], repo=obj['repo'])
-
- if not dry_run:
- release.cherry_pick_commits(recreate_branch=recreate)
- else:
- click.echo(f'git checkout -b {release.branch} {release.base_branch}')
- for commit in release.commits_to_pick():
- click.echo('git cherry-pick {}'.format(commit.hexsha))
-
-
@archery.group("linking")
@click.pass_obj
def linking(obj):
@@ -944,6 +816,8 @@ def linking_check_dependencies(obj, allowed, disallowed, paths):
add_optional_command("docker", module=".docker.cli", function="docker",
parent=archery)
+add_optional_command("release", module=".release.cli", function="release",
+ parent=archery)
add_optional_command("crossbow", module=".crossbow.cli", function="crossbow",
parent=archery)
diff --git a/dev/archery/archery/release/__init__.py b/dev/archery/archery/release/__init__.py
new file mode 100644
index 0000000000..a902c99088
--- /dev/null
+++ b/dev/archery/archery/release/__init__.py
@@ -0,0 +1,18 @@
+# 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.
+
+from .core import Release, MajorRelease, MinorRelease, PatchRelease # noqa
diff --git a/dev/archery/archery/release/cli.py b/dev/archery/archery/release/cli.py
new file mode 100644
index 0000000000..4fbf93861e
--- /dev/null
+++ b/dev/archery/archery/release/cli.py
@@ -0,0 +1,139 @@
+# 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.
+
+import pathlib
+
+import click
+
+from ..utils.cli import validate_arrow_sources
+from .core import Jira, CachedJira, Release
+
+
+@click.group('release')
+@click.option("--src", metavar="<arrow_src>", default=None,
+ callback=validate_arrow_sources,
+ help="Specify Arrow source directory.")
+@click.option("--jira-cache", type=click.Path(), default=None,
+ help="File path to cache queried JIRA issues per version.")
+@click.pass_obj
+def release(obj, src, jira_cache):
+ """Release releated commands."""
+ jira = Jira()
+ if jira_cache is not None:
+ jira = CachedJira(jira_cache, jira=jira)
+
+ obj['jira'] = jira
+ obj['repo'] = src.path
+
+
+@release.command('curate', help="Lists release related Jira issues.")
+@click.argument('version')
+@click.option('--minimal/--full', '-m/-f',
+ help="Only show actionable Jira issues.", default=False)
+@click.pass_obj
+def release_curate(obj, version, minimal):
+ """Release curation."""
+ release = Release.from_jira(version, jira=obj['jira'], repo=obj['repo'])
+ curation = release.curate(minimal)
+
+ click.echo(curation.render('console'))
+
+
+@release.group('changelog')
+def release_changelog():
+ """Release changelog."""
+ pass
+
+
+@release_changelog.command('add')
+@click.argument('version')
+@click.pass_obj
+def release_changelog_add(obj, version):
+ """Prepend the changelog with the current release"""
+ jira, repo = obj['jira'], obj['repo']
+
+ # just handle the current version
+ release = Release.from_jira(version, jira=jira, repo=repo)
+ if release.is_released:
+ raise ValueError('This version has been already released!')
+
+ changelog = release.changelog()
+ changelog_path = pathlib.Path(repo) / 'CHANGELOG.md'
+
+ current_content = changelog_path.read_text()
+ new_content = changelog.render('markdown') + current_content
+
+ changelog_path.write_text(new_content)
+ click.echo("CHANGELOG.md is updated!")
+
+
+@release_changelog.command('generate')
+@click.argument('version')
+@click.argument('output', type=click.File('w', encoding='utf8'), default='-')
+@click.pass_obj
+def release_changelog_generate(obj, version, output):
+ """Generate the changelog of a specific release."""
+ jira, repo = obj['jira'], obj['repo']
+
+ # just handle the current version
+ release = Release.from_jira(version, jira=jira, repo=repo)
+
+ changelog = release.changelog()
+ output.write(changelog.render('markdown'))
+
+
+@release_changelog.command('regenerate')
+@click.pass_obj
+def release_changelog_regenerate(obj):
+ """Regeneretate the whole CHANGELOG.md file"""
+ jira, repo = obj['jira'], obj['repo']
+ changelogs = []
+
+ for version in jira.project_versions('ARROW'):
+ if not version.released:
+ continue
+ release = Release.from_jira(version, jira=jira, repo=repo)
+ click.echo('Querying changelog for version: {}'.format(version))
+ changelogs.append(release.changelog())
+
+ click.echo('Rendering new CHANGELOG.md file...')
+ changelog_path = pathlib.Path(repo) / 'CHANGELOG.md'
+ with changelog_path.open('w') as fp:
+ for cl in changelogs:
+ fp.write(cl.render('markdown'))
+
+
+@release.command('cherry-pick')
+@click.argument('version')
+@click.option('--dry-run/--execute', default=True,
+ help="Display the git commands instead of executing them.")
+@click.option('--recreate/--continue', default=True,
+ help="Recreate the maintenance branch or only apply unapplied "
+ "patches.")
+@click.pass_obj
+def release_cherry_pick(obj, version, dry_run, recreate):
+ """
+ Cherry pick commits.
+ """
+ release = Release.from_jira(version, jira=obj['jira'], repo=obj['repo'])
+
+ if not dry_run:
+ release.cherry_pick_commits(recreate_branch=recreate)
+ else:
+ click.echo(f'git checkout -b {release.branch} {release.base_branch}')
+ for commit in release.commits_to_pick():
+ click.echo('git cherry-pick {}'.format(commit.hexsha))
diff --git a/dev/archery/archery/release.py b/dev/archery/archery/release/core.py
similarity index 96%
rename from dev/archery/archery/release.py
rename to dev/archery/archery/release/core.py
index c496b25497..2c775c7506 100644
--- a/dev/archery/archery/release.py
+++ b/dev/archery/archery/release/core.py
@@ -27,9 +27,9 @@ from git import Repo
from jira import JIRA
from semver import VersionInfo as SemVer
-from .utils.source import ArrowSources
-from .utils.report import JinjaReport
-from .utils.logger import logger
+from ..utils.source import ArrowSources
+from ..utils.logger import logger
+from .reports import ReleaseCuration, JiraChangelog
def cached_property(fn):
@@ -227,32 +227,6 @@ class Commit:
return self._title
-class ReleaseCuration(JinjaReport):
- templates = {
- 'console': 'release_curation.txt.j2'
- }
- fields = [
- 'release',
- 'within',
- 'outside',
- 'nojira',
- 'parquet',
- 'nopatch',
- 'minimal'
- ]
-
-
-class JiraChangelog(JinjaReport):
- templates = {
- 'markdown': 'release_changelog.md.j2',
- 'html': 'release_changelog.html.j2'
- }
- fields = [
- 'release',
- 'categories'
- ]
-
-
class Release:
def __new__(self, version, jira=None, repo=None):
diff --git a/dev/archery/archery/release/reports.py b/dev/archery/archery/release/reports.py
new file mode 100644
index 0000000000..43093487c0
--- /dev/null
+++ b/dev/archery/archery/release/reports.py
@@ -0,0 +1,45 @@
+# 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.
+
+
+from ..utils.report import JinjaReport
+
+
+class ReleaseCuration(JinjaReport):
+ templates = {
+ 'console': 'release_curation.txt.j2'
+ }
+ fields = [
+ 'release',
+ 'within',
+ 'outside',
+ 'nojira',
+ 'parquet',
+ 'nopatch',
+ 'minimal'
+ ]
+
+
+class JiraChangelog(JinjaReport):
+ templates = {
+ 'markdown': 'release_changelog.md.j2',
+ 'html': 'release_changelog.html.j2'
+ }
+ fields = [
+ 'release',
+ 'categories'
+ ]
diff --git a/dev/archery/archery/tests/test_release.py b/dev/archery/archery/release/tests/test_release.py
similarity index 99%
rename from dev/archery/archery/tests/test_release.py
rename to dev/archery/archery/release/tests/test_release.py
index 5cea163a64..1283b4bcb4 100644
--- a/dev/archery/archery/tests/test_release.py
+++ b/dev/archery/archery/release/tests/test_release.py
@@ -17,7 +17,7 @@
import pytest
-from archery.release import (
+from archery.release.core import (
Release, MajorRelease, MinorRelease, PatchRelease,
Jira, Version, Issue, CommitTitle, Commit
)