kou commented on code in PR #49249:
URL: https://github.com/apache/arrow/pull/49249#discussion_r2796944467


##########
dev/release/02-source.sh:
##########
@@ -130,6 +130,15 @@ if [ ${SOURCE_VOTE} -gt 0 ]; then
   curl_options+=(--data "head=apache:${rc_branch}")
   curl_options+=(https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls)
   verify_pr_url=$(curl "${curl_options[@]}" | jq -r ".[0].html_url")
+  # Read the checksum so we can include it in the vote thread email
+  # We check if $tarball exists to detect when this script is being run by
+  # 02-source-test.rb and we fill in the hash from the test tarball in that
+  # case.
+  if [ -f "${tarball}" ]; then
+    tarball_hash=$(shasum -a 512 "${tarball}" | awk '{print $1}')
+  else
+    tarball_hash=$(curl -s 
"https://dist.apache.org/repos/dist/dev/arrow/apache-arrow-${version}-rc${rc}/${tarball}.sha512";
 | awk '{print $1}')
+  fi

Review Comment:
   How about assuming `${tarball}.sha512` must exist?
   
   ```suggestion
     # Read the checksum so we can include it in the vote thread email.
     tarball_hash=$(cat "artifacts/${tarball}.sha512" | awk '{print $1}')
   ```
   
   We need the following change for this:
   
   ```diff
   diff --git a/dev/release/02-source-test.rb b/dev/release/02-source-test.rb
   index fe2c7b7759..fcf35bd23e 100644
   --- a/dev/release/02-source-test.rb
   +++ b/dev/release/02-source-test.rb
   @@ -44,6 +44,9 @@ class SourceTest < Test::Unit::TestCase
          env["SOURCE_#{target}"] = "1"
        end
        sh(env, @tarball_script, @release_version, "0")
   +    File.open("#{@archive_name}.sha512", "w") do |sha512|
   +      sha512.puts(sh(env, "shasum", "-a", "512", @archive_name))
   +    end
        output = sh(env, @script, @release_version, "0")
        sh("tar", "xf", @archive_name)
        output
   ```



##########
dev/release/02-source-test.rb:
##########
@@ -106,6 +106,8 @@ def test_vote
       verify_pr_url = (JSON.parse(response.read)[0] || {})["html_url"]
     end
     output = source("VOTE")
+    # Extract the tarball hash from the output
+    tarball_hash = output[/\[11\]: ([a-f0-9]+)/, 1]

Review Comment:
   How about computing it from the tar ball?
   
   ```suggestion
       tarball_hash = Digest::SHA512.file(@archive_name).to_s
   ```
   
   We need additional `require` for it:
   
   ```diff
   diff --git a/dev/release/02-source-test.rb b/dev/release/02-source-test.rb
   index fe2c7b7759..3cab5b0b0e 100644
   --- a/dev/release/02-source-test.rb
   +++ b/dev/release/02-source-test.rb
   @@ -15,6 +15,8 @@
    # specific language governing permissions and limitations
    # under the License.
    
   +require "digest"
   +
    class SourceTest < Test::Unit::TestCase
      include GitRunnable
      include VersionDetectable
   ```



-- 
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]

Reply via email to