From f3c8bb9d6d7d3aab83ba018c9ac83cd3dadb61cf Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Tue, 24 Jan 2023 09:16:17 +0100 Subject: [PATCH] GH-33782: [Release] Vote email number of issues is querying JIRA and producing a wrong number (#33791) ### What changes are included in this PR? Release RC vote email now gets issue number and verify release PR's url from GitHub's GraphQL API. ### Are these changes tested? Changes were tested stand-alone from the rest of this script. ### Are there any user-facing changes? ARROW_GITHUB_API_TOKEN is now mandatory for generating the release vote email. * Closes: #33782 Authored-by: Rok Mihevc Signed-off-by: Sutou Kouhei --- dev/release/02-source-test.rb | 33 +++++++++++++++++++-------------- dev/release/02-source.sh | 10 ++++++---- dev/release/test-helper.rb | 1 + 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/dev/release/02-source-test.rb b/dev/release/02-source-test.rb index 85718b6645f92..1d0fd19d01b84 100644 --- a/dev/release/02-source-test.rb +++ b/dev/release/02-source-test.rb @@ -93,18 +93,23 @@ def test_python_version end def test_vote - jira_url = "https://issues.apache.org/jira" - jql_conditions = [ - "project = ARROW", - "status in (Resolved, Closed)", - "fixVersion = #{@release_version}", - ] - jql = jql_conditions.join(" AND ") - n_resolved_issues = nil - search_url = URI("#{jira_url}/rest/api/2/search?jql=#{CGI.escape(jql)}") - search_url.open do |response| - n_resolved_issues = JSON.parse(response.read)["total"] - end + github_token = ENV["ARROW_GITHUB_API_TOKEN"] + uri = URI.parse("https://api.github.com/graphql") + n_issues_query = { + "query" => <<-QUERY, + query { + search(query: "repo:apache/arrow is:issue is:closed milestone:#{@release_version}", + type: ISSUE) { + issueCount + } + } + QUERY + } + response = Net::HTTP.post(uri, + n_issues_query.to_json, + "Content-Type" => "application/json", + "Authorization" => "Bearer #{github_token}") + n_resolved_issues = JSON.parse(response.body)["data"]["search"]["issueCount"] github_api_url = "https://api.github.com" verify_prs = URI("#{github_api_url}/repos/apache/arrow/pulls" + "?state=open" + @@ -113,7 +118,7 @@ def test_vote headers = { "Accept" => "application/vnd.github+json", } - github_token = ENV["ARROW_GITHUB_API_TOKEN"] + if github_token headers["Authorization"] = "Bearer #{github_token}" end @@ -149,7 +154,7 @@ def test_vote [ ] +0 [ ] -1 Do not release this as Apache Arrow #{@release_version} because... -[1]: https://issues.apache.org/jira/issues/?jql=project%20%3D%20ARROW%20AND%20status%20in%20%28Resolved%2C%20Closed%29%20AND%20fixVersion%20%3D%20#{@release_version} +[1]: https://github.com/apache/arrow/issues?q=is%3Aissue+milestone%3A#{@release_version}+is%3Aclosed [2]: https://github.com/apache/arrow/tree/#{@current_commit} [3]: https://dist.apache.org/repos/dist/dev/arrow/apache-arrow-#{@release_version}-rc0 [4]: https://apache.jfrog.io/artifactory/arrow/almalinux-rc/ diff --git a/dev/release/02-source.sh b/dev/release/02-source.sh index 984d7af5941d0..1e54d6d10db76 100755 --- a/dev/release/02-source.sh +++ b/dev/release/02-source.sh @@ -142,9 +142,11 @@ if [ ${SOURCE_PR} -gt 0 ]; then fi if [ ${SOURCE_VOTE} -gt 0 ]; then - jira_url="https://issues.apache.org/jira" - jql="project%20%3D%20ARROW%20AND%20status%20in%20%28Resolved%2C%20Closed%29%20AND%20fixVersion%20%3D%20${version}" - n_resolved_issues=$(curl "${jira_url}/rest/api/2/search/?jql=${jql}" | jq ".total") + gh_api_url="https://api.github.com/graphql" + curl_options=($gh_api_url) + curl_options+=(--header "Authorization: Bearer ${ARROW_GITHUB_API_TOKEN}") + curl_options+=(--data "{\"query\": \"query {search(query: \\\"repo:apache/arrow is:issue is:closed milestone:${version}\\\", type:ISSUE) {issueCount}}\"}") + n_resolved_issues=$(curl "${curl_options[@]}" | jq ".data.search.issueCount") curl_options=(--header "Accept: application/vnd.github+json") if [ -n "${ARROW_GITHUB_API_TOKEN:-}" ]; then curl_options+=(--header "Authorization: Bearer ${ARROW_GITHUB_API_TOKEN}") @@ -186,7 +188,7 @@ The vote will be open for at least 72 hours. [ ] +0 [ ] -1 Do not release this as Apache Arrow ${version} because... -[1]: ${jira_url}/issues/?jql=${jql} +[1]: https://github.com/apache/arrow/issues?q=is%3Aissue+milestone%3A${version}+is%3Aclosed [2]: https://github.com/apache/arrow/tree/${release_hash} [3]: ${rc_url} [4]: https://apache.jfrog.io/artifactory/arrow/almalinux-rc/ diff --git a/dev/release/test-helper.rb b/dev/release/test-helper.rb index 0111f913561c8..1249961eb8f9c 100644 --- a/dev/release/test-helper.rb +++ b/dev/release/test-helper.rb @@ -19,6 +19,7 @@ require "cgi/util" require "fileutils" require "find" +require 'net/http' require "json" require "open-uri" require "rexml/document"