Skip to content

Commit

Permalink
apacheGH-33782: [Release] Vote email number of issues is querying JIR…
Browse files Browse the repository at this point in the history
…A 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>
  • Loading branch information
rok authored and sjperkins committed Feb 10, 2023
1 parent 9e3fcb2 commit f3c8bb9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
33 changes: 19 additions & 14 deletions dev/release/02-source-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand All @@ -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
Expand Down Expand Up @@ -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/
Expand Down
10 changes: 6 additions & 4 deletions dev/release/02-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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/
Expand Down
1 change: 1 addition & 0 deletions dev/release/test-helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require "cgi/util"
require "fileutils"
require "find"
require 'net/http'
require "json"
require "open-uri"
require "rexml/document"
Expand Down

0 comments on commit f3c8bb9

Please sign in to comment.