Skip to content

Apache DataFusion SQL Query Engine

ARROW-5371: [Release] Add tests for dev/release/00-prepare.sh

Kouhei Sutoub58a984b098c
diff --git a/.travis.yml b/.travis.yml
index 82a88791b9..13175921ff 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -48,7 +48,7 @@ matrix:
- language: r
fast_finish: true
include:
- - name: "Lint C++, Python, R, Docker"
+ - name: "Lint, Release tests"
os: linux
language: python
python: "3.6"
@@ -58,6 +58,7 @@ matrix:
- $TRAVIS_BUILD_DIR/ci/travis_install_clang_tools.sh
script:
- $TRAVIS_BUILD_DIR/ci/travis_lint.sh
+ - $TRAVIS_BUILD_DIR/ci/travis_release_test.sh
- name: "C++ unit tests w/ clang 7.0, system packages"
os: linux
env:
diff --git a/ci/travis_release_test.sh b/ci/travis_release_test.sh
new file mode 100755
index 0000000000..eed8191506
--- /dev/null
+++ b/ci/travis_release_test.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+# 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.
+
+set -eux
+
+dev/release/run-test.rb
diff --git a/dev/release/00-prepare-test.rb b/dev/release/00-prepare-test.rb
new file mode 100644
index 0000000000..423542e40e
--- /dev/null
+++ b/dev/release/00-prepare-test.rb
@@ -0,0 +1,358 @@
+# 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.
+
+class PrepareTest < Test::Unit::TestCase
+ include GitRunnable
+
+ def setup
+ @current_commit = git_current_commit
+ top_dir = Pathname(__dir__).parent.parent
+ @original_git_repository = top_dir + ".git"
+ cpp_cmake_lists = top_dir + "cpp" + "CMakeLists.txt"
+ @snapshot_version = cpp_cmake_lists.read[/ARROW_VERSION "(.+?)"/, 1]
+ r_description = top_dir + "r" + "DESCRIPTION"
+ @previous_version = r_description.read[/^Version: (.+?)\.9000$/, 1]
+ Dir.mktmpdir do |dir|
+ @test_git_repository = Pathname(dir) + "arrow"
+ git("clone", @original_git_repository.to_s, @test_git_repository.to_s)
+ Dir.chdir(@test_git_repository) do
+ @release_version = @snapshot_version.gsub(/-SNAPSHOT\z/, "")
+ @next_version = @release_version.gsub(/\A\d+/) {|major| major.succ}
+ @tag_name = "apache-arrow-#{@release_version}"
+ @release_branch = "release-#{@release_version}-rc0"
+ @script = "dev/release/00-prepare.sh"
+ git("checkout", "-b", @release_branch, @current_commit)
+ yield
+ end
+ end
+ end
+
+ def prepare(*targets)
+ env = {"PREPARE_DEFAULT" => "0"}
+ targets.each do |target|
+ env["PREPARE_#{target}"] = "1"
+ end
+ sh(env, @script, @release_version, @next_version)
+ end
+
+ def parse_patch(patch)
+ diffs = []
+ in_hunk = false
+ patch.each_line do |line|
+ case line
+ when /\A--- a\//
+ path = $POSTMATCH.chomp
+ diffs << {path: path, hunks: []}
+ in_hunk = false
+ when /\A@@/
+ in_hunk = true
+ diffs.last[:hunks] << []
+ when /\A[-+]/
+ next unless in_hunk
+ diffs.last[:hunks].last << line.chomp
+ end
+ end
+ diffs.sort_by do |diff|
+ diff[:path]
+ end
+ end
+
+ def test_update_version_pre_tag
+ prepare("VERSION_PRE_TAG")
+ assert_equal([
+ {
+ path: "c_glib/configure.ac",
+ hunks: [
+ ["-m4_define([arrow_glib_version], #{@snapshot_version})",
+ "+m4_define([arrow_glib_version], #{@release_version})"],
+ ],
+ },
+ {
+ path: "c_glib/meson.build",
+ hunks: [
+ ["-version = '#{@snapshot_version}'",
+ "+version = '#{@release_version}'"],
+ ],
+ },
+ {
+ path: "cpp/CMakeLists.txt",
+ hunks: [
+ ["-set(ARROW_VERSION \"#{@snapshot_version}\")",
+ "+set(ARROW_VERSION \"#{@release_version}\")"],
+ ],
+ },
+ {
+ path: "csharp/Directory.Build.props",
+ hunks: [
+ ["- <Version>#{@snapshot_version}</Version>",
+ "+ <Version>#{@release_version}</Version>"],
+ ],
+ },
+ {
+ path: "js/package.json",
+ hunks: [
+ ["- \"version\": \"#{@snapshot_version}\"",
+ "+ \"version\": \"#{@release_version}\""]
+ ],
+ },
+ {
+ path: "matlab/CMakeLists.txt",
+ hunks: [
+ ["-set(MLARROW_VERSION \"#{@snapshot_version}\")",
+ "+set(MLARROW_VERSION \"#{@release_version}\")"],
+ ],
+ },
+ {
+ path: "python/setup.py",
+ hunks: [
+ ["-default_version = '#{@snapshot_version}'",
+ "+default_version = '#{@release_version}'"],
+ ],
+ },
+ {
+ path: "r/DESCRIPTION",
+ hunks: [
+ ["-Version: #{@previous_version}.9000",
+ "+Version: #{@release_version}"],
+ ],
+ },
+ {
+ path: "r/src/Makevars.win",
+ hunks: [
+ ["-VERSION = #{@previous_version}.9000",
+ "+VERSION = #{@release_version}"],
+ ],
+ },
+ {
+ path: "ruby/red-arrow-cuda/lib/arrow-cuda/version.rb",
+ hunks: [
+ ["- VERSION = \"#{@snapshot_version}\"",
+ "+ VERSION = \"#{@release_version}\""],
+ ],
+ },
+ {
+ path: "ruby/red-arrow/lib/arrow/version.rb",
+ hunks: [
+ ["- VERSION = \"#{@snapshot_version}\"",
+ "+ VERSION = \"#{@release_version}\""],
+ ],
+ },
+ {
+ path: "ruby/red-gandiva/lib/gandiva/version.rb",
+ hunks: [
+ ["- VERSION = \"#{@snapshot_version}\"",
+ "+ VERSION = \"#{@release_version}\""],
+ ],
+ },
+ {
+ path: "ruby/red-parquet/lib/parquet/version.rb",
+ hunks: [
+ ["- VERSION = \"#{@snapshot_version}\"",
+ "+ VERSION = \"#{@release_version}\""],
+ ],
+ },
+ {
+ path: "ruby/red-plasma/lib/plasma/version.rb",
+ hunks: [
+ ["- VERSION = \"#{@snapshot_version}\"",
+ "+ VERSION = \"#{@release_version}\""],
+ ],
+ },
+ {
+ path: "rust/arrow/Cargo.toml",
+ hunks: [
+ ["-version = \"#{@snapshot_version}\"",
+ "+version = \"#{@release_version}\""],
+ ],
+ },
+ {
+ path: "rust/datafusion/Cargo.toml",
+ hunks: [
+ ["-version = \"#{@snapshot_version}\"",
+ "+version = \"#{@release_version}\""],
+ ],
+ },
+ {
+ path: "rust/datafusion/README.md",
+ hunks: [
+ ["-datafusion = \"#{@snapshot_version}\"",
+ "+datafusion = \"#{@release_version}\""],
+ ],
+ },
+ {
+ path: "rust/parquet/Cargo.toml",
+ hunks: [
+ ["-version = \"#{@snapshot_version}\"",
+ "+version = \"#{@release_version}\""],
+ ],
+ },
+ {
+ path: "rust/parquet/README.md",
+ hunks: [
+ ["-parquet = \"#{@snapshot_version}\"",
+ "+parquet = \"#{@release_version}\""],
+ ["-See [crate documentation](https://docs.rs/crate/parquet/#{@snapshot_version}) on available API.",
+ "+See [crate documentation](https://docs.rs/crate/parquet/#{@release_version}) on available API."],
+ ],
+ },
+ ],
+ parse_patch(git("log", "-n", "1", "-p")))
+ end
+
+ def test_update_version_post_tag
+ prepare("VERSION_PRE_TAG",
+ "VERSION_POST_TAG")
+ assert_equal([
+ {
+ path: "c_glib/configure.ac",
+ hunks: [
+ ["-m4_define([arrow_glib_version], #{@release_version})",
+ "+m4_define([arrow_glib_version], #{@next_version}-SNAPSHOT)"],
+ ],
+ },
+ {
+ path: "c_glib/meson.build",
+ hunks: [
+ ["-version = '#{@release_version}'",
+ "+version = '#{@next_version}-SNAPSHOT'"],
+ ],
+ },
+ {
+ path: "cpp/CMakeLists.txt",
+ hunks: [
+ ["-set(ARROW_VERSION \"#{@release_version}\")",
+ "+set(ARROW_VERSION \"#{@next_version}-SNAPSHOT\")"],
+ ],
+ },
+ {
+ path: "csharp/Directory.Build.props",
+ hunks: [
+ ["- <Version>#{@release_version}</Version>",
+ "+ <Version>#{@next_version}-SNAPSHOT</Version>"],
+ ],
+ },
+ {
+ path: "js/package.json",
+ hunks: [
+ ["- \"version\": \"#{@release_version}\"",
+ "+ \"version\": \"#{@next_version}-SNAPSHOT\""],
+ ],
+ },
+ {
+ path: "matlab/CMakeLists.txt",
+ hunks: [
+ ["-set(MLARROW_VERSION \"#{@release_version}\")",
+ "+set(MLARROW_VERSION \"#{@next_version}-SNAPSHOT\")"],
+ ],
+ },
+ {
+ path: "python/setup.py",
+ hunks: [
+ ["-default_version = '#{@release_version}'",
+ "+default_version = '#{@next_version}-SNAPSHOT'"],
+ ],
+ },
+ {
+ path: "r/DESCRIPTION",
+ hunks: [
+ ["-Version: #{@release_version}",
+ "+Version: #{@release_version}.9000"],
+ ],
+ },
+ {
+ path: "r/src/Makevars.win",
+ hunks: [
+ ["-VERSION = #{@release_version}",
+ "+VERSION = #{@release_version}.9000"],
+ ],
+ },
+ {
+ path: "ruby/red-arrow-cuda/lib/arrow-cuda/version.rb",
+ hunks: [
+ ["- VERSION = \"#{@release_version}\"",
+ "+ VERSION = \"#{@next_version}-SNAPSHOT\""],
+ ],
+ },
+ {
+ path: "ruby/red-arrow/lib/arrow/version.rb",
+ hunks: [
+ ["- VERSION = \"#{@release_version}\"",
+ "+ VERSION = \"#{@next_version}-SNAPSHOT\""],
+ ],
+ },
+ {
+ path: "ruby/red-gandiva/lib/gandiva/version.rb",
+ hunks: [
+ ["- VERSION = \"#{@release_version}\"",
+ "+ VERSION = \"#{@next_version}-SNAPSHOT\""],
+ ],
+ },
+ {
+ path: "ruby/red-parquet/lib/parquet/version.rb",
+ hunks: [
+ ["- VERSION = \"#{@release_version}\"",
+ "+ VERSION = \"#{@next_version}-SNAPSHOT\""],
+ ],
+ },
+ {
+ path: "ruby/red-plasma/lib/plasma/version.rb",
+ hunks: [
+ ["- VERSION = \"#{@release_version}\"",
+ "+ VERSION = \"#{@next_version}-SNAPSHOT\""],
+ ],
+ },
+ {
+ path: "rust/arrow/Cargo.toml",
+ hunks: [
+ ["-version = \"#{@release_version}\"",
+ "+version = \"#{@next_version}-SNAPSHOT\""],
+ ],
+ },
+ {
+ path: "rust/datafusion/Cargo.toml",
+ hunks: [
+ ["-version = \"#{@release_version}\"",
+ "+version = \"#{@next_version}-SNAPSHOT\""],
+ ],
+ },
+ {
+ path: "rust/datafusion/README.md",
+ hunks: [
+ ["-datafusion = \"#{@release_version}\"",
+ "+datafusion = \"#{@next_version}-SNAPSHOT\""],
+ ],
+ },
+ {
+ path: "rust/parquet/Cargo.toml",
+ hunks: [
+ ["-version = \"#{@release_version}\"",
+ "+version = \"#{@next_version}-SNAPSHOT\""],
+ ],
+ },
+ {
+ path: "rust/parquet/README.md",
+ hunks: [
+ ["-parquet = \"#{@release_version}\"",
+ "+parquet = \"#{@next_version}-SNAPSHOT\""],
+ ["-See [crate documentation](https://docs.rs/crate/parquet/#{@release_version}) on available API.",
+ "+See [crate documentation](https://docs.rs/crate/parquet/#{@next_version}-SNAPSHOT) on available API."],
+ ],
+ },
+ ],
+ parse_patch(git("log", "-n", "1", "-p")))
+ end
+end
diff --git a/dev/release/00-prepare.sh b/dev/release/00-prepare.sh
index 6d117b179c..8f103443cb 100755
--- a/dev/release/00-prepare.sh
+++ b/dev/release/00-prepare.sh
@@ -17,10 +17,15 @@
# specific language governing permissions and limitations
# under the License.
#
-set -e
+set -ue
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 <version> <next_version>"
+ exit 1
+fi
+
update_versions() {
local base_version=$1
local next_version=$2
@@ -115,9 +120,9 @@ update_versions() {
cd "${SOURCE_DIR}/../../rust"
sed -i.bak -E -e \
"s/^version = \".+\"/version = \"${version}\"/g" \
- arrow/Cargo.toml parquet/Cargo.toml datafusion/Cargo.toml
- rm -f arrow/Cargo.toml.bak parquet/Cargo.toml.bak datafusion/Cargo.toml.bak
- git add arrow/Cargo.toml parquet/Cargo.toml datafusion/Cargo.toml
+ */Cargo.toml
+ rm -f */Cargo.toml.bak
+ git add */Cargo.toml
# Update version number for parquet README
sed -i.bak -E -e \
@@ -141,18 +146,28 @@ update_versions() {
cd -
}
-if [ "$#" -eq 2 ]; then
- ############################## Pre-Tag Commits ##############################
+############################## Pre-Tag Commits ##############################
+
+version=$1
+next_version=$2
+next_version_snapshot=${next_version}-SNAPSHOT
+tag=apache-arrow-${version}
- version=$1
- next_version=$2
- next_version_snapshot=${next_version}-SNAPSHOT
- tag=apache-arrow-${version}
+: ${PREPARE_DEFAULT:=1}
+: ${PREPARE_CHANGELOG:=${PREPARE_DEFAULT}}
+: ${PREPARE_LINUX_PACKAGES:=${PREPARE_DEFAULT}}
+: ${PREPARE_VERSION_PRE_TAG:=${PREPARE_DEFAULT}}
+: ${PREPARE_TAG:=${PREPARE_DEFAULT}}
+: ${PREPARE_VERSION_POST_TAG:=${PREPARE_DEFAULT}}
+: ${PREPARE_DEB_PACKAGE_NAMES:=${PREPARE_DEFAULT}}
+if [ ${PREPARE_CHANGELOG} -gt 0 ]; then
echo "Updating changelog for $version"
# Update changelog
$SOURCE_DIR/update-changelog.sh $version
+fi
+if [ ${PREPARE_LINUX_PACKAGES} -gt 0 ]; then
echo "Updating .deb/.rpm changelogs for $version"
cd $SOURCE_DIR/../tasks/linux-packages
rake \
@@ -162,23 +177,31 @@ if [ "$#" -eq 2 ]; then
git add debian*/changelog yum/*.spec.in
git commit -m "[Release] Update .deb/.rpm changelogs for $version"
cd -
+fi
+if [ ${PREPARE_VERSION_PRE_TAG} -gt 0 ]; then
echo "prepare release ${version} on tag ${tag} then reset to version ${next_version_snapshot}"
update_versions "${version}" "${next_version}" "release"
git commit -m "[Release] Update versions for ${version}"
+fi
+if [ ${PREPARE_TAG} -gt 0 ]; then
cd "${SOURCE_DIR}/../../java"
mvn release:clean
mvn release:prepare -Dtag=${tag} -DreleaseVersion=${version} -DautoVersionSubmodules -DdevelopmentVersion=${next_version_snapshot}
cd -
+fi
- ############################## Post-Tag Commits #############################
+############################## Post-Tag Commits #############################
+if [ ${PREPARE_VERSION_POST_TAG} -gt 0 ]; then
echo "Updating versions for ${next_version_snapshot}"
update_versions "${version}" "${next_version}" "snapshot"
git commit -m "[Release] Update versions for ${next_version_snapshot}"
+fi
+if [ ${PREPARE_DEB_PACKAGE_NAMES} -gt 0 ]; then
echo "Updating .deb package names for ${next_version}"
deb_lib_suffix=$(echo $version | sed -E -e 's/^[0-9]+\.([0-9]+)\.[0-9]+$/\1/')
next_deb_lib_suffix=$(echo $next_version | sed -E -e 's/^[0-9]+\.([0-9]+)\.[0-9]+$/\1/')
@@ -186,8 +209,8 @@ if [ "$#" -eq 2 ]; then
cd $SOURCE_DIR/../tasks/linux-packages/
for target in debian*/lib*${deb_lib_suffix}.install; do
git mv \
- ${target} \
- $(echo $target | sed -e "s/${deb_lib_suffix}/${next_deb_lib_suffix}/")
+ ${target} \
+ $(echo $target | sed -e "s/${deb_lib_suffix}/${next_deb_lib_suffix}/")
done
deb_lib_suffix_substitute_pattern="s/(lib(arrow|gandiva|parquet|plasma)[-a-z]*)${deb_lib_suffix}/\\1${next_deb_lib_suffix}/g"
sed -i.bak -E -e "${deb_lib_suffix_substitute_pattern}" debian*/control
@@ -206,10 +229,6 @@ if [ "$#" -eq 2 ]; then
git commit -m "[Release] Update .deb package names for $next_version"
cd -
fi
-
- echo "Finish staging binary artifacts by running: sh dev/release/01-perform.sh"
-
-else
- echo "Usage: $0 <version> <next_version>"
- exit
fi
+
+echo "Finish staging binary artifacts by running: dev/release/01-perform.sh"
diff --git a/dev/release/run-test.rb b/dev/release/run-test.rb
new file mode 100755
index 0000000000..90df39b13f
--- /dev/null
+++ b/dev/release/run-test.rb
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+#
+# 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.
+
+$VERBOSE = true
+
+require "pathname"
+
+test_dir = Pathname.new(__dir__)
+
+require "test-unit"
+require_relative "test-helper"
+
+ENV["TEST_UNIT_MAX_DIFF_TARGET_STRING_SIZE"] = "10000"
+
+exit(Test::Unit::AutoRunner.run(true, test_dir.to_s))
diff --git a/dev/release/test-helper.rb b/dev/release/test-helper.rb
new file mode 100644
index 0000000000..74cce3fb08
--- /dev/null
+++ b/dev/release/test-helper.rb
@@ -0,0 +1,66 @@
+# 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.
+
+require "English"
+require "tempfile"
+require "tmpdir"
+
+module CommandRunnable
+ class Error < StandardError
+ end
+
+ def sh(*command_line, check_result: true)
+ if command_line[0].is_a?(Hash)
+ env = command_line.shift
+ else
+ env = {}
+ end
+ stdout = Tempfile.new("command-stdout.log")
+ stderr = Tempfile.new("command-stderr.log")
+ success = system(env, *command_line, out: stdout.path, err: stderr.path)
+ if check_result
+ unless success
+ message = "Failed to run: #{command_line.join(" ")}\n"
+ message << "stdout:\n #{stdout.read}\n"
+ message << "stderr:\n #{stderr.read}"
+ raise Error, message
+ end
+ end
+ stdout.read
+ end
+end
+
+module GitRunnable
+ include CommandRunnable
+
+ def git(*args)
+ if args[0].is_a?(Hash)
+ env = args.shift
+ else
+ env = {}
+ end
+ sh(env, "git", *args)
+ end
+
+ def git_current_commit
+ git("rev-parse", "HEAD").chomp
+ end
+
+ def git_tags
+ git("tags").lines(chomp: true)
+ end
+end