Merge pull request #52 from bodepd/get_testable_prs

add task to get all testable pull requests
This commit is contained in:
Dan Bode
2013-02-28 10:53:17 -08:00
2 changed files with 48 additions and 0 deletions

View File

@@ -34,6 +34,17 @@ end
namespace :openstack do
desc 'get testable pull requests'
task :testable_pull_requests do
testable_pull_requests(
['cinder', 'nova', 'glance', 'openstack', 'keystone', 'horizon'],
github_admins,
github_login,
github_password,
'ready_for_testing'
)
end
desc 'clone all required modules'
task :setup do
cmd_system('librarian-puppet install')
@@ -169,6 +180,7 @@ namespace :test do
test_pull_request(
args.repo_name,
args.pull_request_number,
github_admins,
github_login,
github_password,
'spec/test_swift_cluster.rb',
@@ -182,6 +194,7 @@ namespace :test do
test_pull_request(
args.repo_name,
args.pull_request_number,
github_admins,
github_login,
github_password,
'spec/test_two_node.rb',

View File

@@ -209,6 +209,41 @@ module Puppetlabs
'body' => "Test #{outcome}. Results can be found here: #{gist_response.html_url}"
)
end
def testable_pull_requests(
project_names,
admin_users,
github_login,
github_password,
test_message = 'schedule_for_testing'
)
testable_pull_requests = {}
each_repo do |repo_name|
if project_names.include?(repo_name)
options = { :login => github_login, :password => github_password }
prs = ::Github.new(options).pull_requests.list('puppetlabs', "puppetlabs-#{repo_name}")
prs.each do |pr|
# the data structure of pr returned from list (above) appears to be in a different format
# than this get call, therefor, I need to get the number, and make this extra call.
# this seems to justify my experience so far that this github_api plugin may not be worth using.
number = pr['number']
pr = ::Github.new(options).pull_requests.get('puppetlabs', "puppetlabs-#{repo_name}", number)
# I know this is lazy to do b/c it means every pull request will be validated twice based
# on the current workflow with jenkins (where this will populate parameterized builds
# that also check if the pull request is valid
if testable_pull_request?(pr, admin_users + github_login.to_a, test_message, options)
if testable_pull_requests[repo_name]
testable_pull_requests[repo_name].push(number)
else
testable_pull_requests[repo_name] = [number]
end
end
end
end
end
puts testable_pull_requests.inspect
end
end # end Github
end