Skip to content

Commit 22e3bed

Browse files
authored
apacheGH-33782: [Release] Vote email number of issues is querying JIRA and producing a wrong number (apache#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: apache#33782 Authored-by: Rok Mihevc <rok@mihevc.org> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 3cf0b4d commit 22e3bed

3 files changed

Lines changed: 26 additions & 18 deletions

File tree

dev/release/02-source-test.rb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,23 @@ def test_python_version
9393
end
9494

9595
def test_vote
96-
jira_url = "https://issues.apache.org/jira"
97-
jql_conditions = [
98-
"project = ARROW",
99-
"status in (Resolved, Closed)",
100-
"fixVersion = #{@release_version}",
101-
]
102-
jql = jql_conditions.join(" AND ")
103-
n_resolved_issues = nil
104-
search_url = URI("#{jira_url}/rest/api/2/search?jql=#{CGI.escape(jql)}")
105-
search_url.open do |response|
106-
n_resolved_issues = JSON.parse(response.read)["total"]
107-
end
96+
github_token = ENV["ARROW_GITHUB_API_TOKEN"]
97+
uri = URI.parse("https://api.github.com/graphql")
98+
n_issues_query = {
99+
"query" => <<-QUERY,
100+
query {
101+
search(query: "repo:apache/arrow is:issue is:closed milestone:#{@release_version}",
102+
type: ISSUE) {
103+
issueCount
104+
}
105+
}
106+
QUERY
107+
}
108+
response = Net::HTTP.post(uri,
109+
n_issues_query.to_json,
110+
"Content-Type" => "application/json",
111+
"Authorization" => "Bearer #{github_token}")
112+
n_resolved_issues = JSON.parse(response.body)["data"]["search"]["issueCount"]
108113
github_api_url = "https://api.github.com"
109114
verify_prs = URI("#{github_api_url}/repos/apache/arrow/pulls" +
110115
"?state=open" +
@@ -113,7 +118,7 @@ def test_vote
113118
headers = {
114119
"Accept" => "application/vnd.github+json",
115120
}
116-
github_token = ENV["ARROW_GITHUB_API_TOKEN"]
121+
117122
if github_token
118123
headers["Authorization"] = "Bearer #{github_token}"
119124
end
@@ -149,7 +154,7 @@ def test_vote
149154
[ ] +0
150155
[ ] -1 Do not release this as Apache Arrow #{@release_version} because...
151156
152-
[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}
157+
[1]: https://github.com/apache/arrow/issues?q=is%3Aissue+milestone%3A#{@release_version}+is%3Aclosed
153158
[2]: https://github.com/apache/arrow/tree/#{@current_commit}
154159
[3]: https://dist.apache.org/repos/dist/dev/arrow/apache-arrow-#{@release_version}-rc0
155160
[4]: https://apache.jfrog.io/artifactory/arrow/almalinux-rc/

dev/release/02-source.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ if [ ${SOURCE_PR} -gt 0 ]; then
142142
fi
143143

144144
if [ ${SOURCE_VOTE} -gt 0 ]; then
145-
jira_url="https://issues.apache.org/jira"
146-
jql="project%20%3D%20ARROW%20AND%20status%20in%20%28Resolved%2C%20Closed%29%20AND%20fixVersion%20%3D%20${version}"
147-
n_resolved_issues=$(curl "${jira_url}/rest/api/2/search/?jql=${jql}" | jq ".total")
145+
gh_api_url="https://api.github.com/graphql"
146+
curl_options=($gh_api_url)
147+
curl_options+=(--header "Authorization: Bearer ${ARROW_GITHUB_API_TOKEN}")
148+
curl_options+=(--data "{\"query\": \"query {search(query: \\\"repo:apache/arrow is:issue is:closed milestone:${version}\\\", type:ISSUE) {issueCount}}\"}")
149+
n_resolved_issues=$(curl "${curl_options[@]}" | jq ".data.search.issueCount")
148150
curl_options=(--header "Accept: application/vnd.github+json")
149151
if [ -n "${ARROW_GITHUB_API_TOKEN:-}" ]; then
150152
curl_options+=(--header "Authorization: Bearer ${ARROW_GITHUB_API_TOKEN}")
@@ -186,7 +188,7 @@ The vote will be open for at least 72 hours.
186188
[ ] +0
187189
[ ] -1 Do not release this as Apache Arrow ${version} because...
188190
189-
[1]: ${jira_url}/issues/?jql=${jql}
191+
[1]: https://github.com/apache/arrow/issues?q=is%3Aissue+milestone%3A${version}+is%3Aclosed
190192
[2]: https://github.com/apache/arrow/tree/${release_hash}
191193
[3]: ${rc_url}
192194
[4]: https://apache.jfrog.io/artifactory/arrow/almalinux-rc/

dev/release/test-helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
require "cgi/util"
2020
require "fileutils"
2121
require "find"
22+
require 'net/http'
2223
require "json"
2324
require "open-uri"
2425
require "rexml/document"

0 commit comments

Comments
 (0)