Skip to content

Instantly share code, notes, and snippets.

@jtimberman
Created January 28, 2013 06:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtimberman/4653557 to your computer and use it in GitHub Desktop.
Save jtimberman/4653557 to your computer and use it in GitHub Desktop.
Simple converter for Kitchenfile -> .jamie.yml. See comments. May open a rift in the space-time continuum.
#!/usr/bin/env ruby
#
# Converts a test-kitchen Kitchenfile to a jamie-ci .jamie.yml. Writes
# out the .jamie.yml file. Once Test Kitchen 1.0 is ready, this file
# will be renamed to .kitchen.yml.
#
# Must be run from a cookbook directory that has been setup with Test
# Kitchen (./test/kitchen/Kitchenfile exists).
#
# Bugs:
# - Doesn't print any information about what it's doing
# - Doesn't support all DSL options in a Kitchenfile
# - Doesn't support "integration_test" projects
# - "Works on my machine" - Ruby 1.9.3p327, etc
#
# Author: Joshua Timberman <joshua@opscode.com>
# Copyright: (c) 2013, Opscode, Inc.
#
# 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 'yaml'
require 'test-kitchen'
tk = TestKitchen::Environment.new.load!
project = tk.project.name
jm = {}
jm['driver_plugin'] = tk.default_runner
jm['platforms'] = []
jm['suites'] = []
tk.platforms.each_key do |p|
tk.platforms[p].versions.each_key do |v|
pv = "#{p}-#{v}"
url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_#{pv}_chef-10.18.2.box"
jm['platforms'] << {'name' => "#{pv}",
'driver_config' => {'box' => "opscode-#{pv}",
'box_url' => url},
'run_list' => [p =~ /ubuntu/ ? 'recipe[apt]' : 'recipe[yum::epel]']}
end
end
tk.project.configurations.each_key do |c|
jm['suites'] << {'name' => c,
'run_list' => ['recipe[minitest-handler]',
"recipe[#{project}_test::#{c}]"]}
end
File.open(".jamie.yml", "w") {|f| f.write(jm.to_yaml)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment