summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2019-12-02 10:43:22 -0800
committerTim Smith <tsmith84@gmail.com>2019-12-02 10:43:22 -0800
commit1fd65e645492f8ee386dbc324c4d2b400c74c194 (patch)
tree34638ac10b2c8741cdf29dd07c7e295d40f07027
parent166c2971cb4f19a2ee7a028f031b7967b04df010 (diff)
downloadchef-1fd65e645492f8ee386dbc324c4d2b400c74c194.tar.gz
Cleanup the rake tasks
Remove the unused maintainers task and the pre-release announcement task Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--tasks/announce.rb15
-rw-r--r--tasks/maintainers.rb211
-rw-r--r--tasks/templates/prerelease.md.erb35
3 files changed, 4 insertions, 257 deletions
diff --git a/tasks/announce.rb b/tasks/announce.rb
index b6b701f04b..c898e80ed8 100644
--- a/tasks/announce.rb
+++ b/tasks/announce.rb
@@ -41,18 +41,11 @@ class ReleaseAnnouncement
end
def release_notes_from_file
- File.read("RELEASE_NOTES.md").match(/^# Chef Client Release Notes #{@maj_minor}:\n\n(.*)/m)[1]
+ File.read("RELEASE_NOTES.md").match(/^# Chef Infra Client Release Notes #{@maj_minor}:\n\n(.*)/m)[1]
end
end
-namespace :announce do
- desc "Generate the Prerelease Announcement (version: X.Y.Z, release_date: YYYY-MM-DD)"
- task :prerelease, :version, :release_date do |t, args|
- ReleaseAnnouncement.new(args[:version], args[:release_date], "prerelease").render
- end
-
- desc "Generate the Release Announcement (version: X.Y.Z)"
- task :release, :version do |t, args|
- ReleaseAnnouncement.new(args[:version], nil, "release").render
- end
+desc "Generate the Release Announcement (version: X.Y.Z)"
+task :announce_release, :version do |t, args|
+ ReleaseAnnouncement.new(args[:version], nil, "release").render
end
diff --git a/tasks/maintainers.rb b/tasks/maintainers.rb
deleted file mode 100644
index 7465f7ba9e..0000000000
--- a/tasks/maintainers.rb
+++ /dev/null
@@ -1,211 +0,0 @@
-#
-# Copyright:: Copyright 2015-2018, Chef Software Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require "rake"
-
-SOURCE = File.join(File.dirname(__FILE__), "..", "MAINTAINERS.toml")
-TARGET = File.join(File.dirname(__FILE__), "..", "MAINTAINERS.md")
-
-# The list of repositories that teams should own
-REPOSITORIES = ["chef/chef", "chef/chef-dk", "chef/chef-census", "chef/chef-repo",
- "chef/client-docs", "chef/ffi-yajl", "chef/libyajl2-gem",
- "chef/mixlib-authentication", "chef/mixlib-cli",
- "chef/mixlib-config", "chef/mixlib-install", "chef/mixlib-log",
- "chef/mixlib-shellout", "chef/ohai", "chef/omnibus-chef"].freeze
-
-begin
- require "tomlrb"
- require "octokit"
- require "pp"
-
- namespace :maintainers do
- task default: :generate
-
- desc "Generate MarkDown version of MAINTAINERS file"
- task :generate do
- out = "<!-- This is a generated file. Please do not edit directly -->\n\n"
- out << "# " + source["Preamble"]["title"] + "\n\n"
- out << source["Preamble"]["text"] + "\n"
-
- # The project lead is a special case
- out << "# " + source["Org"]["Lead"]["title"] + "\n\n"
- out << format_person(source["Org"]["Lead"]["person"]) + "\n\n"
-
- out << format_components(source["Org"]["Components"])
- File.open(TARGET, "w") do |fn|
- fn.write out
- end
- end
-
- desc "Synchronize GitHub teams"
- # there's a special @chef/client-maintainers team that's everyone
- # and then there's a team per component
- task :synchronize do
- Octokit.auto_paginate = true
- get_github_teams
- prepare_teams(source["Org"]["Components"].dup)
- sync_teams!
- end
- end
-
- def github
- @github ||= Octokit::Client.new(netrc: true)
- end
-
- def source
- @source ||= Tomlrb.load_file SOURCE
- end
-
- def teams
- @teams ||= { "client-maintainers" => { "title" => "Client Maintainers" } }
- end
-
- def add_members(team, name)
- teams["client-maintainers"]["members"] ||= []
- teams["client-maintainers"]["members"] << name
- teams[team] ||= {}
- teams[team]["members"] ||= []
- teams[team]["members"] << name
- end
-
- def set_team_title(team, title)
- teams[team] ||= {}
- teams[team]["title"] = title
- end
-
- def gh_teams
- @gh_teams ||= {}
- end
-
- # we have to resolve team names to ids. While we're at it, we can get the privacy
- # setting, so we know whether we need to update it
- def get_github_teams
- github.org_teams("chef").each do |team|
- gh_teams[team[:slug]] = { "id" => team[:id], "privacy" => team[:privacy] }
- end
- end
-
- def get_github_team(team)
- github.team_members(gh_teams[team]["id"]).map do |member|
- member[:login]
- end.sort.uniq.map(&:downcase)
- rescue
- []
- end
-
- def create_team(team)
- puts "creating new github team: #{team} with title: #{teams[team]["title"]} "
- t = github.create_team("chef", name: team, description: teams[team]["title"],
- privacy: "closed", repo_names: REPOSITORIES,
- accept: "application/vnd.github.ironman-preview+json")
- gh_teams[team] = { "id" => t[:id], "privacy" => t[:privacy] }
- end
-
- def compare_teams(current, desired)
- # additions are the subtraction of the current state from the desired state
- # deletions are the subtraction of the desired state from the current state
- [desired - current, current - desired]
- end
-
- def prepare_teams(cmp)
- %w{text paths}.each { |k| cmp.delete(k) }
- if cmp.key?("team")
- team = cmp.delete("team")
- add_members(team, cmp.delete("lieutenant")) if cmp.key?("lieutenant")
- add_members(team, cmp.delete("maintainers")) if cmp.key?("maintainers")
- set_team_title(team, cmp.delete("title"))
- else
- %w{maintainers lieutenant title}.each { |k| cmp.delete(k) }
- end
- cmp.each_value { |v| prepare_teams(v) }
- end
-
- def update_team(team, additions, deletions)
- create_team(team) unless gh_teams.key?(team)
- update_team_privacy(team)
- add_team_members(team, additions)
- remove_team_members(team, deletions)
- rescue => e
- puts "failed for #{team}: #{e.message}"
- end
-
- def update_team_privacy(team)
- return if gh_teams[team]["privacy"] == "closed"
- puts "Setting #{team} privacy to closed from #{gh_teams[team]["privacy"]}"
- github.update_team(gh_teams[team]["id"], privacy: "closed",
- accept: "application/vnd.github.ironman-preview+json")
- end
-
- def add_team_members(team, additions)
- additions.each do |member|
- puts "Adding #{member} to #{team}"
- github.add_team_membership(gh_teams[team]["id"], member, role: "member",
- accept: "application/vnd.github.ironman-preview+json")
- end
- end
-
- def remove_team_members(team, deletions)
- deletions.each do |member|
- puts "Removing #{member} from #{team}"
- github.remove_team_membership(gh_teams[team]["id"], member,
- accept: "application/vnd.github.ironman-preview+json")
- end
- end
-
- def sync_teams!
- teams.each do |name, details|
- current = get_github_team(name)
- desired = details["members"].flatten.sort.uniq.map(&:downcase)
- additions, deletions = compare_teams(current, desired)
- update_team(name, additions, deletions)
- end
- end
-
- def get_person(person)
- source["people"][person]
- end
-
- def format_components(cmp)
- out = "## " + cmp.delete("title") + "\n\n"
- out << cmp.delete("text") + "\n" if cmp.key?("text")
- out << "To mention the team, use @chef/#{cmp.delete("team")}\n\n" if cmp.key?("team")
- if cmp.key?("lieutenant")
- out << "### Lieutenant\n\n"
- out << format_person(cmp.delete("lieutenant")) + "\n\n"
- end
- out << format_maintainers(cmp.delete("maintainers")) + "\n" if cmp.key?("maintainers")
- cmp.delete("paths")
- cmp.each_value { |v| out << format_components(v) }
- out
- end
-
- def format_maintainers(people)
- o = "### Maintainers\n\n"
- people.each do |p|
- o << format_person(p) + "\n"
- end
- o
- end
-
- def format_person(person)
- mnt = get_person(person)
- "* [#{mnt["Name"]}](https://github.com/#{mnt["GitHub"]})"
- end
-
-rescue LoadError
- STDERR.puts "\n*** TomlRb not available.\n\n"
-end
diff --git a/tasks/templates/prerelease.md.erb b/tasks/templates/prerelease.md.erb
deleted file mode 100644
index cab7f11fff..0000000000
--- a/tasks/templates/prerelease.md.erb
+++ /dev/null
@@ -1,35 +0,0 @@
-Ohai Chefs!
-
-We have selected <%= @version %> as our Chef v<%= @maj_minor %> release candidate which is scheduled for release on <%= @date.strftime('%A %B %-d, %Y') %>.
-
-# Release Highlights
-
-<%= @release_notes %>
-
-Please see the [CHANGELOG](https://github.com/chef/chef/blob/master/CHANGELOG.md) for the complete list of changes.
-
-# Get the Build
-As always, you can download binaries directly from [downloads.chef.io](https://downloads.chef.io/chef/current/<%= @version %>) or by using the `mixlib-install` command line utility:
-
-```shell
-$ mixlib-install download chef -v <%= @version %> -c current
-```
-
-Alternatively, you can install Chef using one of the following command options:
-
-```shell
-# In Shell
-$ curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chef -v <%= @version %> -c current
-
-# In Windows PowerShell
-. { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install -project chef -version <%= @version %> -channel current
-```
-
-If you want to give this version a spin in Test Kitchen, create or add the following to your `kitchen.yml` file:
-
-```yaml
-provisioner:
- product_name: chef
- channel: current
- product_version: <%= @version %>
-```