|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +class VoteEmailTest < Test::Unit::TestCase |
| 19 | + include GitRunnable |
| 20 | + include VersionDetectable |
| 21 | + |
| 22 | + def setup |
| 23 | + @current_commit = git_current_commit |
| 24 | + detect_versions |
| 25 | + @tag_name_no_rc = "apache-arrow-#{@release_version}" |
| 26 | + @archive_name = "apache-arrow-#{@release_version}.tar.gz" |
| 27 | + @script = File.expand_path("dev/release/09-vote-email.sh") |
| 28 | + @tarball_script = File.expand_path("dev/release/utils-create-release-tarball.sh") |
| 29 | + @env = File.expand_path("dev/release/.env") |
| 30 | + |
| 31 | + Dir.mktmpdir do |dir| |
| 32 | + Dir.chdir(dir) do |
| 33 | + yield |
| 34 | + end |
| 35 | + end |
| 36 | + end |
| 37 | + |
| 38 | + def vote_email(*targets) |
| 39 | + env = { |
| 40 | + "VOTE_DEFAULT" => "0", |
| 41 | + "release_hash" => @current_commit, |
| 42 | + } |
| 43 | + targets.each do |target| |
| 44 | + env["VOTE_#{target}"] = "1" |
| 45 | + end |
| 46 | + sh(env, @tarball_script, @release_version, "0") |
| 47 | + FileUtils.mkdir_p("artifacts") |
| 48 | + sh("mv", @archive_name, "artifacts/") |
| 49 | + Dir.chdir("artifacts") do |
| 50 | + File.write("#{@archive_name}.sha512", |
| 51 | + sh(env, "shasum", "-a", "512", @archive_name)) |
| 52 | + end |
| 53 | + sh(env, @script, @release_version, "0") |
| 54 | + end |
| 55 | + |
| 56 | + def test_template |
| 57 | + github_token = File.read(@env)[/^GH_TOKEN=(.*)$/, 1] |
| 58 | + uri = URI.parse("https://api.github.com/graphql") |
| 59 | + n_issues_query = { |
| 60 | + "query" => <<-QUERY, |
| 61 | + query { |
| 62 | + search(query: "repo:apache/arrow is:issue is:closed milestone:#{@release_version}", |
| 63 | + type: ISSUE) { |
| 64 | + issueCount |
| 65 | + } |
| 66 | + } |
| 67 | + QUERY |
| 68 | + } |
| 69 | + response = Net::HTTP.post(uri, |
| 70 | + n_issues_query.to_json, |
| 71 | + "Content-Type" => "application/json", |
| 72 | + "Authorization" => "Bearer #{github_token}") |
| 73 | + n_resolved_issues = JSON.parse(response.body)["data"]["search"]["issueCount"] |
| 74 | + github_repository = ENV["GITHUB_REPOSITORY"] || "apache/arrow" |
| 75 | + github_api_url = "https://api.github.com" |
| 76 | + verify_prs = URI("#{github_api_url}/repos/#{github_repository}/pulls" + |
| 77 | + "?state=open" + |
| 78 | + "&head=apache:release-#{@release_version}-rc0") |
| 79 | + verify_pr_url = nil |
| 80 | + headers = { |
| 81 | + "Accept" => "application/vnd.github+json", |
| 82 | + } |
| 83 | + |
| 84 | + if github_token |
| 85 | + headers["Authorization"] = "Bearer #{github_token}" |
| 86 | + end |
| 87 | + verify_prs.open(headers) do |response| |
| 88 | + verify_pr_url = (JSON.parse(response.read)[0] || {})["html_url"] |
| 89 | + end |
| 90 | + output = vote_email("TEMPLATE") |
| 91 | + tarball_hash = Digest::SHA512.file("artifacts/#{@archive_name}").to_s |
| 92 | + assert_equal(<<-TEMPLATE.strip, output[/^-+$(.+?)^-+$/m, 1].strip) |
| 93 | +To: dev@arrow.apache.org |
| 94 | +Subject: [VOTE] Release Apache Arrow #{@release_version} - RC0 |
| 95 | +
|
| 96 | +Hi, |
| 97 | +
|
| 98 | +I would like to propose the following release candidate (RC0) of Apache |
| 99 | +Arrow version #{@release_version}. This is a release consisting of #{n_resolved_issues} |
| 100 | +resolved GitHub issues[1]. |
| 101 | +
|
| 102 | +This release candidate is based on commit: |
| 103 | +#{@current_commit} [2] |
| 104 | +
|
| 105 | +The source release rc0 is hosted at [3]. |
| 106 | +The binary artifacts are hosted at [4][5][6][7][8][9]. |
| 107 | +The changelog is located at [10]. |
| 108 | +
|
| 109 | +Please download, verify checksums and signatures, run the unit tests, |
| 110 | +and vote on the release. See [11] for the SHA-512 checksum for this RC and [12] |
| 111 | +for how to validate a release candidate. |
| 112 | +
|
| 113 | +See also a verification result on GitHub pull request [13]. |
| 114 | +
|
| 115 | +The vote will be open for at least 72 hours. |
| 116 | +
|
| 117 | +[ ] +1 Release this as Apache Arrow #{@release_version} |
| 118 | +[ ] +0 |
| 119 | +[ ] -1 Do not release this as Apache Arrow #{@release_version} because... |
| 120 | +
|
| 121 | +[1]: https://github.com/apache/arrow/issues?q=is%3Aissue+milestone%3A#{@release_version}+is%3Aclosed |
| 122 | +[2]: https://github.com/apache/arrow/tree/#{@current_commit} |
| 123 | +[3]: https://dist.apache.org/repos/dist/dev/arrow/apache-arrow-#{@release_version}-rc0 |
| 124 | +[4]: https://packages.apache.org/artifactory/arrow/almalinux-rc/ |
| 125 | +[5]: https://packages.apache.org/artifactory/arrow/amazon-linux-rc/ |
| 126 | +[6]: https://packages.apache.org/artifactory/arrow/centos-rc/ |
| 127 | +[7]: https://packages.apache.org/artifactory/arrow/debian-rc/ |
| 128 | +[8]: https://packages.apache.org/artifactory/arrow/ubuntu-rc/ |
| 129 | +[9]: https://github.com/apache/arrow/releases/tag/apache-arrow-#{@release_version}-rc0 |
| 130 | +[10]: https://github.com/apache/arrow/blob/#{@current_commit}/CHANGELOG.md |
| 131 | +[11]: #{tarball_hash} |
| 132 | +[12]: https://arrow.apache.org/docs/developers/release_verification.html |
| 133 | +[13]: #{verify_pr_url || "null"} |
| 134 | + TEMPLATE |
| 135 | + end |
| 136 | +end |
0 commit comments