Merge pull request #52 from bodepd/get_testable_prs
add task to get all testable pull requests
This commit is contained in:
13
Rakefile
13
Rakefile
@@ -34,6 +34,17 @@ end
|
|||||||
|
|
||||||
namespace :openstack do
|
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'
|
desc 'clone all required modules'
|
||||||
task :setup do
|
task :setup do
|
||||||
cmd_system('librarian-puppet install')
|
cmd_system('librarian-puppet install')
|
||||||
@@ -169,6 +180,7 @@ namespace :test do
|
|||||||
test_pull_request(
|
test_pull_request(
|
||||||
args.repo_name,
|
args.repo_name,
|
||||||
args.pull_request_number,
|
args.pull_request_number,
|
||||||
|
github_admins,
|
||||||
github_login,
|
github_login,
|
||||||
github_password,
|
github_password,
|
||||||
'spec/test_swift_cluster.rb',
|
'spec/test_swift_cluster.rb',
|
||||||
@@ -182,6 +194,7 @@ namespace :test do
|
|||||||
test_pull_request(
|
test_pull_request(
|
||||||
args.repo_name,
|
args.repo_name,
|
||||||
args.pull_request_number,
|
args.pull_request_number,
|
||||||
|
github_admins,
|
||||||
github_login,
|
github_login,
|
||||||
github_password,
|
github_password,
|
||||||
'spec/test_two_node.rb',
|
'spec/test_two_node.rb',
|
||||||
|
|||||||
@@ -209,6 +209,41 @@ module Puppetlabs
|
|||||||
'body' => "Test #{outcome}. Results can be found here: #{gist_response.html_url}"
|
'body' => "Test #{outcome}. Results can be found here: #{gist_response.html_url}"
|
||||||
)
|
)
|
||||||
end
|
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 # end Github
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user