Skip to content

Commit

Permalink
Merge pull request #563 from cncf/remove_redundant_snapshot_issues#527
Browse files Browse the repository at this point in the history
Update release manager to fetch notes from latest snapshot
  • Loading branch information
agentpoyo authored Jan 12, 2021
2 parents b4502fa + cfae999 commit a443919
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions spec/utils/release_manager_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ describe "ReleaseManager" do
end
end

it "'#ReleaseManager.latest_snapshot' should return the latest snapshot", tags: "release" do
if ENV["GITHUB_USER"]?.nil?
puts "Warning: Set GITHUB_USER and GITHUB_TOKEN to activate release manager tests!".colorize(:red)
else
issues = ReleaseManager.latest_snapshot
# https://github.com/semver/semver/blob/master/semver.md#is-v123-a-semantic-version
(issues.match(/(?i)(master)/)).should_not be_nil
end
end


it "'#ReleaseManager.issue_title' should return issue title", tags: "release" do
if ENV["GITHUB_USER"]?.nil?
puts "Warning: Set GITHUB_USER and GITHUB_TOKEN to activate release manager tests!".colorize(:red)
Expand Down
14 changes: 13 additions & 1 deletion src/tasks/utils/release_manager.cr
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ module ReleaseManager
found_release = release_resp.find {|x| x["tag_name"] == upsert_version}
LOGGING.info "find found_release?: #{found_release}"

issues = ReleaseManager.commit_message_issues(ReleaseManager.latest_release, "HEAD")
if upsert_version =~ /(?i)(master)/
issues = ReleaseManager.commit_message_issues(ReleaseManager.latest_snapshot, "HEAD")
else
issues = ReleaseManager.commit_message_issues(ReleaseManager.latest_release, "HEAD")
end
titles = issues.reduce("") do |acc, x|
acc + "- #{x} - #{ReleaseManager.issue_title(x)}\n"
end
Expand Down Expand Up @@ -260,6 +264,14 @@ TEMPLATE
parsed_resp["tag_name"]?.not_nil!.to_s
end

def self.latest_snapshot
resp = `curl -u #{ENV["GITHUB_USER"]}:#{ENV["GITHUB_TOKEN"]} --silent "https://api.github.com/repos/cncf/cnf-conformance/releases"`
LOGGING.info "latest_release: #{resp}"
parsed_resp = JSON.parse(resp)
latest_snapshot = parsed_resp.as_a.select{ | x | x["prerelease"]==true }.sort { |a, b| Time.parse(b["published_at"].as_s, "%Y-%m-%dT%H:%M:%SZ", Time::Location::UTC) <=> Time.parse(a["published_at"].as_s, "%Y-%m-%dT%H:%M:%SZ", Time::Location::UTC) }
latest_snapshot[0]["tag_name"]?.not_nil!.to_s
end

def self.issue_title(issue_number)
pure_issue = issue_number.gsub("#", "")
resp = `curl -u #{ENV["GITHUB_USER"]}:#{ENV["GITHUB_TOKEN"]} "https://api.github.com/repos/cncf/cnf-conformance/issues/#{pure_issue}"`
Expand Down

0 comments on commit a443919

Please sign in to comment.