Skip to content

Instantly share code, notes, and snippets.

@mostlyobvious
Created April 29, 2012 23:37
Show Gist options
  • Save mostlyobvious/2554034 to your computer and use it in GitHub Desktop.
Save mostlyobvious/2554034 to your computer and use it in GitHub Desktop.
longer_build_script = <<END
export WEIRD_VAR=3
export GIT_SSH=ssh-with-another-identity-hack
git clone strange_dependency_repo.git somewhere
bundle exec rake test
END
Citrus::Config.new do |c|
# how many isolated VMs to start for each build step,
# split based purely on test file count like TDDium
#
# in fact this will work only with "knowledgeable" runners,
c.build_concurrency = 2
# how many builds to store (probably also with provisioned VMs)
c.keep_builds = 3
# valid Ruby code goes here
#
# run indicates build step, where bang version is
# asynchronous (another build step will not wait for it's result)
#
# build steps are enumerated in order they're executed
# (enumeration for notification purposes)
c.build :bash do |shell|
if shell.run "bundle exec rake test"
shell.run! "EVIL_VAR=13 bundle exec rake test"
shell.run! longer_build_script
# an example of non-dumb test runner,
# which does round robin on test files
#
# shell.minitest! "test/**/*_test.rb"
end
end
c.provision :chef_solo do |chef|
# chef.cookbooks_path = "../my-recipes/cookbooks"
# chef.roles_path = "../my-recipes/roles"
# chef.data_bags_path = "../my-recipes/data_bags"
chef.add_recipe "mysql"
chef.add_role "web"
end
end
class MinitestRunner < Citrus::TestRunner
def split
test_files = Dir[@args.first]
return test_files.each_slice(test_files.count / concurrency).to_a
end
# items is an item from collection returned in split
# execute is called async for each split item
def execute(items)
"ruby -Ilib -Itest #{items}"
end
end
class MinitestHistoricalRunner < MinitestRunner
def split
# make an api call to CI and get each test files run time
# from previous build to make better worker scheduling
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment