diff options
-rw-r--r-- | .expeditor/update_dep.sh | 14 | ||||
-rwxr-xr-x | .expeditor/update_dockerfile.sh | 10 | ||||
-rwxr-xr-x | .expeditor/update_version.sh | 13 | ||||
-rw-r--r-- | Rakefile | 21 | ||||
-rw-r--r-- | chef-config/Rakefile | 6 | ||||
-rw-r--r-- | chef-config/lib/chef-config/package_task.rb | 289 | ||||
-rwxr-xr-x | ci/dependency_update.sh | 2 | ||||
-rwxr-xr-x | ci/version_bump.sh | 11 | ||||
-rwxr-xr-x | ci/version_show.sh | 3 |
9 files changed, 42 insertions, 327 deletions
diff --git a/.expeditor/update_dep.sh b/.expeditor/update_dep.sh index baaedb90c5..14ef80463b 100644 --- a/.expeditor/update_dep.sh +++ b/.expeditor/update_dep.sh @@ -1,5 +1,14 @@ #!/bin/bash +############################################################################ +# What is this script? +# +# Chef uses a workflow tool called Expeditor to manage version bumps, changelogs +# and releases. When a dependency of chef is released, expeditor is triggered +# against this repository to run this script. It bumps our gem lock files and opens +# a PR. That way humans can do hard work and bots can open gem bump PRs. +############################################################################ + set -evx branch="expeditor/${GEM_NAME}_${VERSION}" @@ -9,7 +18,10 @@ bundle install bundle exec rake dependencies:update git add . -git commit --message "Bump $GEM_NAME to $VERSION" --message "This pull request was triggered automatically via Expeditor when $GEM_NAME $VERSION was promoted to Rubygems." --message "Signed-off-by: Chef CI <oss@chef.io>" + +# give a friendly message for the commit and make sure it's noted for any future audit of our codebase that no +# DCO sign-off is needed for this sort of PR since it contains no intellectual property +git commit --message "Bump $GEM_NAME to $VERSION" --message "This pull request was triggered automatically via Expeditor when $GEM_NAME $VERSION was promoted to Rubygems." --message "This change falls under the obvious fix policy so no Developer Certificate of Origin (DCO) sign-off is required." open_pull_request diff --git a/.expeditor/update_dockerfile.sh b/.expeditor/update_dockerfile.sh index 9ae260fcb8..3ed0ed186a 100755 --- a/.expeditor/update_dockerfile.sh +++ b/.expeditor/update_dockerfile.sh @@ -1,7 +1,13 @@ #!/bin/sh + +############################################################################ +# What is this script? # -# This file updates the default VERSION build argument in the Dockerfile to the -# VERSION passed in to the file via environment variables. +# Chef uses a workflow tool called Expeditor to manage version bumps, changelogs +# and releases. When the current release of Chef is promoted to stable this script +# is run by Expeditor to update the version in the Dockerfile to match the stable +# release. +############################################################################ set -evx diff --git a/.expeditor/update_version.sh b/.expeditor/update_version.sh index b2d76bc336..222ae5cf27 100755 --- a/.expeditor/update_version.sh +++ b/.expeditor/update_version.sh @@ -1,8 +1,13 @@ #!/bin/sh + +############################################################################ +# What is this script? # -# After a PR merge, Chef Expeditor will bump the PATCH version in the VERSION file. -# It then executes this file to update any other files/components with that new version. -# +# Chef uses a workflow tool called Expeditor to manage version bumps, changelogs +# and releases. After a PR is merged in Chef Expeditor calls this script to update +# the PATCH version in the VERSION file as well as the version.rb file in both chef +# and chef-config. When that's done it bundle updates to pull in that new chef-config. +############################################################################ set -evx @@ -10,7 +15,7 @@ sed -i -r "s/^(\s*)VERSION = \".+\"/\1VERSION = \"$(cat VERSION)\"/" chef-config sed -i -r "s/VersionString\.new\(\".+\"\)/VersionString.new(\"$(cat VERSION)\")/" lib/chef/version.rb # Update the version inside Gemfile.lock -bundle update chef chef-config +bundle update chef chef-config --jobs=7 # Once Expeditor finshes executing this script, it will commit the changes and push # the commit as a new tag corresponding to the value in the VERSION file. @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2018, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,24 +17,23 @@ # limitations under the License. # -VERSION = IO.read(File.expand_path("../VERSION", __FILE__)).strip - -require "rubygems" -require "chef/version" -require "chef-config/package_task" -require "rdoc/task" require_relative "tasks/rspec" require_relative "tasks/maintainers" require_relative "tasks/cbgb" require_relative "tasks/dependencies" require_relative "tasks/announce" -ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "Chef", "chef") do |package| - package.component_paths = ["chef-config"] - package.generate_version_class = true - package.use_versionstring = true +# hack the chef-config install to runon before the traditional install task +task :super_install do + chef_config_path = ::File.join(::File.dirname(__FILE__), "chef-config") + Dir.chdir(chef_config_path) + sh("rake install") end +task install: :super_install + +Bundler::GemHelper.install_tasks name: "chef" + task :pedant, :chef_zero_spec task :build_eventlog do diff --git a/chef-config/Rakefile b/chef-config/Rakefile index 324dbbdcf4..df2f59e298 100644 --- a/chef-config/Rakefile +++ b/chef-config/Rakefile @@ -1,8 +1,4 @@ -require "chef-config/package_task" - -ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "ChefConfig", "chef-config") do |package| - package.module_path = "chef-config" -end +require "bundler/gem_tasks" task default: :spec diff --git a/chef-config/lib/chef-config/package_task.rb b/chef-config/lib/chef-config/package_task.rb deleted file mode 100644 index e44ec71508..0000000000 --- a/chef-config/lib/chef-config/package_task.rb +++ /dev/null @@ -1,289 +0,0 @@ -# -# Author:: Kartik Null Cating-Subramanian (<ksubramanian@chef.io>) -# Copyright:: Copyright 2015-2016, Chef, 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" -require "rubygems" -require "rubygems/package_task" - -module ChefConfig - class PackageTask < Rake::TaskLib - - # Full path to root of top-level repository. All other files (like VERSION or - # lib/<module_path>/version.rb are rooted at this path). - attr_accessor :root_path - - # Name of the top-level module/library build built. This is used to define - # the top level module which contains VERSION and MODULE_ROOT. - attr_accessor :module_name - - # Name of the gem being built. This is used to find the lines to fix in - # Gemfile.lock. - attr_accessor :gem_name - - # Should the generated version.rb be in a class or module? Default is false (module). - attr_accessor :generate_version_class - - # Paths to the roots of any components that also support ChefPackageTask. - # If relative paths are provided, they are rooted against root_path. - attr_accessor :component_paths - - # This is the module name as it appears on the path "lib/module/". - # e.g. for module_name "ChefDK", you'd want module_path to be "chef-dk". - # The default is module_name but lower-cased. - attr_writer :module_path - - def module_path - @module_path || module_name.downcase - end - - # Directory used to store package files and output that is generated. - # This has the same meaning (or lack thereof) as package_dir in - # rake/packagetask. - attr_accessor :package_dir - - # Name of git remote used to push tags during a release. Default is origin. - attr_accessor :git_remote - - # True if should use Chef::VersionString. - attr_accessor :use_versionstring - - def initialize(root_path = nil, module_name = nil, gem_name = nil) - init(root_path, module_name, gem_name) - yield self if block_given? - define unless root_path.nil? || module_name.nil? - end - - def init(root_path, module_name, gem_name) - @root_path = root_path - @module_name = module_name - @gem_name = gem_name - @component_paths = [] - @module_path = nil - @package_dir = "pkg" - @git_remote = "origin" - @generate_version_class = false - end - - def component_full_paths - component_paths.map { |path| File.expand_path(path, root_path) } - end - - def version_rb_path - File.expand_path("lib/#{module_path}/version.rb", root_path) - end - - def chef_root_path - module_name == "Chef" ? root_path : File.dirname(root_path) - end - - def version_file_path - File.join(chef_root_path, "VERSION") - end - - def gemfile_lock_path - File.join(root_path, "Gemfile.lock") - end - - def version - IO.read(version_file_path).strip - end - - def full_package_dir - File.expand_path(package_dir, root_path) - end - - def class_or_module - generate_version_class ? "class" : "module" - end - - def with_clean_env(&block) - if defined?(Bundler) - Bundler.with_clean_env(&block) - else - yield - end - end - - def define - raise "Need to provide package root and module name" if root_path.nil? || module_name.nil? - - desc "Build Gems of component dependencies" - task :package_components do - component_full_paths.each do |component_path| - Dir.chdir(component_path) do - sh "rake package" - end - end - end - - task package: :package_components - - desc "Build and install component dependencies" - task install_components: :package_components do - component_full_paths.each do |component_path| - Dir.chdir(component_path) do - sh "rake install" - end - end - end - - task install: :install_components - - desc "Clean up builds of component dependencies" - task :clobber_component_packages do - component_full_paths.each do |component_path| - Dir.chdir(component_path) do - sh "rake clobber_package" - end - end - end - - task clobber_package: :clobber_component_packages - - desc "Update the version number for component dependencies" - task :update_components_versions do - component_full_paths.each do |component_path| - Dir.chdir(component_path) do - sh "rake version" - end - end - end - - namespace :version do - desc "Regenerate lib/#{module_path}/version.rb from VERSION file" - task update: :update_components_versions do - update_version_rb - update_gemfile_lock - end - - task bump: %w{version:bump_patch version:update} - - task :show do - puts version - end - - # Add 1 to the current patch version in the VERSION file, and write it back out. - task :bump_patch do - current_version = version - new_version = current_version.sub(/^(\d+\.\d+\.)(\d+)/) { "#{$1}#{$2.to_i + 1}" } - puts "Updating version in #{version_rb_path} from #{current_version.chomp} to #{new_version.chomp}" - IO.write(version_file_path, new_version) - end - - task :bump_minor do - current_version = version - new_version = current_version.sub(/^(\d+)\.(\d+)\.(\d+)/) { "#{$1}.#{$2.to_i + 1}.0" } - puts "Updating version in #{version_rb_path} from #{current_version.chomp} to #{new_version.chomp}" - IO.write(version_file_path, new_version) - end - - task :bump_major do - current_version = version - new_version = current_version.sub(/^(\d+)\.(\d+\.\d+)/) { "#{$1.to_i + 1}.0.0" } - puts "Updating version in #{version_rb_path} from #{current_version.chomp} to #{new_version.chomp}" - IO.write(version_file_path, new_version) - end - - def update_version_rb # rubocop:disable Lint/NestedMethodDefinition - puts "Updating #{version_rb_path} to include version #{version} ..." - contents = <<~VERSION_RB - # Copyright:: Copyright 2010-2016, 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. - - # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - # NOTE: This file is generated by running `rake version` in the top level of - # this repo. Do not edit this manually. Edit the VERSION file and run the rake - # task instead. - # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - #{"\nrequire \"chef/version_string\"\n" if use_versionstring} - #{class_or_module} #{module_name} - #{module_name.upcase}_ROOT = File.expand_path("../..", __FILE__) - VERSION = #{use_versionstring ? "Chef::VersionString.new(\"#{version}\")" : "\"#{version}\""} - end - - # - # NOTE: the Chef::Version class is defined in version_class.rb - # - # NOTE: DO NOT Use the Chef::Version class on #{module_name}::VERSIONs. The - # Chef::Version class is for _cookbooks_ only, and cannot handle - # pre-release versions like "10.14.0.rc.2". Please use Rubygem's - # Gem::Version class instead. - # - VERSION_RB - IO.write(version_rb_path, contents) - end - - def update_gemfile_lock # rubocop:disable Lint/NestedMethodDefinition - if File.exist?(gemfile_lock_path) - puts "Updating #{gemfile_lock_path} to include version #{version} ..." - contents = IO.read(gemfile_lock_path) - contents.gsub!(/^\s*(chef|chef-config)\s*\((= )?\S+\)\s*$/) do |line| - line.gsub(/\((= )?\d+(\.\d+)+/) { "(#{$1}#{version}" } - end - IO.write(gemfile_lock_path, contents) - end - end - end - - task version: "version:update" - - gemspec_platform_to_install = "" - Dir[File.expand_path("*.gemspec", root_path)].reverse_each do |gemspec_path| - gemspec = eval(IO.read(gemspec_path)) - Gem::PackageTask.new(gemspec) do |task| - task.package_dir = full_package_dir - end - gemspec_platform_to_install = "-#{gemspec.platform}" if gemspec.platform != Gem::Platform::RUBY && Gem::Platform.match(gemspec.platform) - end - - desc "Build and install a #{module_path} gem" - task install: [:package] do - with_clean_env do - full_module_path = File.join(full_package_dir, module_path) - sh %{gem install #{full_module_path}-#{version}#{gemspec_platform_to_install}.gem --no-rdoc --no-ri} - end - end - - task :uninstall do - sh %{gem uninstall #{module_path} -x -v #{version} } - end - - desc "Build it, tag it and ship it" - task ship: [:clobber_package, :gem] do - sh("git tag #{version}") - sh("git push #{git_remote} --tags") - Dir[File.expand_path("*.gem", full_package_dir)].reverse_each do |built_gem| - sh("gem push #{built_gem}") - end - end - end - end - -end diff --git a/ci/dependency_update.sh b/ci/dependency_update.sh index 100e2513ec..d90d41d91c 100755 --- a/ci/dependency_update.sh +++ b/ci/dependency_update.sh @@ -4,6 +4,6 @@ set -evx -bundle install --without omnibus_package test pry integration docgen maintenance travis aix bsd linux mac_os_x solaris windows development +bundle install --without omnibus_package test pry integration docgen maintenance travis aix bsd linux mac_os_x solaris windows bundle exec rake dependencies_ci diff --git a/ci/version_bump.sh b/ci/version_bump.sh deleted file mode 100755 index f0a635843f..0000000000 --- a/ci/version_bump.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# FIXME: this seems uselessly trivial, replace with a rake task and have ci call the rake task? - -set -evx - -export LANG=en_US.UTF-8 - -bundle install --without omnibus_package test pry integration docgen maintenance travis aix bsd linux mac_os_x solaris windows development - -bundle exec rake ci_version_bump diff --git a/ci/version_show.sh b/ci/version_show.sh deleted file mode 100755 index 5348f6f090..0000000000 --- a/ci/version_show.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -cat VERSION |