foreman_pipeline 0.0.11 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +2 -1
  4. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/jenkins-instance-details-info.controller.js +23 -2
  5. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/jenkins-instance-details.controller.js +1 -23
  6. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details-info.html +31 -0
  7. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details-users.html +17 -14
  8. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details.html +3 -10
  9. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/jenkins-instances.module.js +4 -1
  10. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/new/new-jenkins-instance.controller.js +4 -7
  11. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/new/views/new-jenkins-instance-form.html +18 -3
  12. data/app/assets/javascripts/foreman_pipeline/jenkins-users/new/new-jenkins-user.controller.js +5 -5
  13. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-content-views.controller.js +3 -3
  14. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-hostgroups.controller.js +3 -5
  15. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-jenkins-projects.controller.js +2 -2
  16. data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/job-projects-discovery.controller.js +10 -1
  17. data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/views/job-projects-discovery.html +20 -12
  18. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-content-views.html +12 -8
  19. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-environments.html +10 -6
  20. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-hostgroups.html +6 -2
  21. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-jenkins-projects.html +7 -6
  22. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-jenkins.html +15 -11
  23. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-resources.html +16 -12
  24. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-to-environments.html +11 -7
  25. data/app/assets/javascripts/foreman_pipeline/jobs/jobs.module.js +4 -1
  26. data/app/assets/stylesheets/foreman_pipeline/foreman_pipeline.css +4 -0
  27. data/app/controllers/foreman_pipeline/api/jenkins_instances_controller.rb +10 -3
  28. data/app/controllers/foreman_pipeline/api/jenkins_projects_controller.rb +1 -1
  29. data/app/controllers/foreman_pipeline/api/jenkins_users_controller.rb +1 -1
  30. data/app/controllers/foreman_pipeline/api/jobs_controller.rb +44 -48
  31. data/app/lib/actions/foreman_pipeline/jenkins/build.rb +9 -3
  32. data/app/lib/actions/foreman_pipeline/jenkins/build_project.rb +2 -0
  33. data/app/lib/actions/foreman_pipeline/jenkins/bulk_build.rb +4 -0
  34. data/app/lib/actions/foreman_pipeline/jenkins/list.rb +4 -0
  35. data/app/lib/actions/foreman_pipeline/jenkins_instance/create_jenkins_instance_keys.rb +1 -1
  36. data/app/lib/actions/foreman_pipeline/job/create_host.rb +2 -2
  37. data/app/lib/actions/foreman_pipeline/job/cv_promote_job_hook.rb +1 -3
  38. data/app/lib/actions/foreman_pipeline/job/cv_publish_job_hook.rb +1 -3
  39. data/app/lib/actions/foreman_pipeline/job/job_hook.rb +4 -3
  40. data/app/lib/actions/foreman_pipeline/job/repo_sync_job_hook.rb +4 -17
  41. data/app/lib/actions/foreman_pipeline/job/run_job_manually.rb +2 -11
  42. data/app/lib/actions/foreman_pipeline/job/wait_until_provisioned.rb +4 -1
  43. data/app/lib/actions/foreman_pipeline/mixins/uri_extension.rb +1 -1
  44. data/app/models/foreman_pipeline/jenkins_instance.rb +8 -6
  45. data/app/models/foreman_pipeline/jenkins_project.rb +2 -4
  46. data/app/models/foreman_pipeline/jenkins_project_param.rb +0 -1
  47. data/app/models/foreman_pipeline/jenkins_user.rb +0 -2
  48. data/app/models/foreman_pipeline/job.rb +24 -8
  49. data/app/models/foreman_pipeline/job_to_environment.rb +0 -2
  50. data/app/services/foreman_pipeline/job_filter.rb +34 -0
  51. data/app/views/foreman/unattended/snippets/_jenkins_instance_pubkey.erb +3 -3
  52. data/app/views/foreman_pipeline/api/jenkins_instances/show.json.rabl +1 -1
  53. data/config/routes.rb +2 -7
  54. data/db/migrate/20150209160604_add_jenkins_home_to_jenkins_instance_table.rb +1 -1
  55. data/db/migrate/20150213095447_add_cert_path_to_jenkins_instances.rb +1 -1
  56. data/db/migrate/20150223142315_change_jenkins_instance_cert_path_column.rb +1 -1
  57. data/db/migrate/20150224090100_create_jenkins_projects_table.rb +4 -4
  58. data/db/migrate/20160404102405_update_projects_table.rb +9 -0
  59. data/db/migrate/20160404133012_drop_job_jenkins_project.rb +30 -0
  60. data/db/migrate/20160629085119_add_timeout_to_jenkins_instance.rb +9 -0
  61. data/db/seeds.d/location.rb +9 -0
  62. data/db/seeds.d/snippets.rb +11 -0
  63. data/lib/foreman_pipeline/engine.rb +1 -2
  64. data/lib/foreman_pipeline/plugin.rb +1 -1
  65. data/lib/foreman_pipeline/roles.rb +3 -3
  66. data/lib/foreman_pipeline/skip_tests.rb +22 -6
  67. data/lib/foreman_pipeline/tasks/{foreman_pipeline_test.rake → test.rake} +3 -2
  68. data/lib/foreman_pipeline/version.rb +1 -1
  69. data/test/fixtures/jenkins_instances.yml +8 -0
  70. data/test/fixtures/jenkins_projects.yml +9 -0
  71. data/test/fixtures/jenkins_users.yml +4 -0
  72. data/test/fixtures/jobs.yml +47 -0
  73. data/test/fixtures/pipeline_compute_attributes.yml +20 -0
  74. data/test/fixtures/pipeline_compute_profiles.yml +5 -0
  75. data/test/fixtures/pipeline_hostgroups.yml +25 -0
  76. data/test/fixtures_support.rb +17 -0
  77. data/test/{foreman_pipeline_plugin_test_helper.rb → foreman_pipeline_test_helper.rb} +17 -8
  78. data/test/functional/foreman_pipeline/api/jenkins_users_controller_test.rb +47 -0
  79. data/test/functional/foreman_pipeline/api/jobs_controller_test.rb +186 -0
  80. data/test/{unit → models}/jenkins_instance_test.rb +1 -1
  81. data/test/{unit → models}/job_test.rb +111 -55
  82. data/test/services/job_filter_test.rb +59 -0
  83. metadata +37 -16
  84. data/app/models/foreman_pipeline/job_jenkins_project.rb +0 -27
  85. data/lib/foreman_pipeline/tasks/foreman_pipeline_seed.rake +0 -28
  86. data/test/factories/hostgroup_factory.rb +0 -5
  87. data/test/unit/sanity_test.rb +0 -12
@@ -0,0 +1,59 @@
1
+ require 'foreman_pipeline_test_helper'
2
+
3
+ class JobFilterTest < ActiveSupport::TestCase
4
+ def setup
5
+ @organization = get_organization
6
+ @filter = ForemanPipeline::JobFilter.new
7
+ @job = ForemanPipeline::Job.find(jobs(:valid).id)
8
+ @dev = Katello::KTEnvironment.find(katello_environments(:dev).id)
9
+ end
10
+
11
+ test "allowed? is true for properly configured job" do
12
+ @job.update(:name => "allowed_job",
13
+ :to_environments => [@dev])
14
+ assert @filter.allowed?(@job)
15
+ end
16
+
17
+ test "allowed? is false for job already promoted to all to_envs" do
18
+ @job.update(:name => "promoted_job",
19
+ :content_view => Katello::ContentView.find(katello_content_views(:library_dev_view).id),
20
+ :to_environments => [@dev])
21
+ refute @filter.allowed?(@job)
22
+ end
23
+
24
+ test "allowed? is false for misconfigured job" do
25
+ @job.update(:name => "allowed_job",
26
+ :jenkins_instance => nil)
27
+ refute @filter.allowed?(@job)
28
+ end
29
+
30
+ test "job is allowed to run if target cv version is available" do
31
+ @job.update(:name => "allowed_job",
32
+ :to_environments => [@dev])
33
+ assert @filter.allow_run_for?(@job)
34
+ end
35
+
36
+ test "only jobs with repo in associated cv are allowed to run on repo sync" do
37
+ fedora_repo = Katello::Repository.find(katello_repositories(:fedora_17_x86_64).id)
38
+ job = ForemanPipeline::Job.find(jobs(:runs_on_sync).id)
39
+ allowed_jobs = @filter.allowed_jobs_for_repo(fedora_repo)
40
+ assert_equal 1, allowed_jobs.count
41
+ assert_equal job, allowed_jobs.first
42
+ end
43
+
44
+ test "only jobs with appropriate cv are allowed to run when cv published/promoted" do
45
+ cvv = Katello::ContentViewVersion.find(katello_content_view_versions(:library_view_version_2).id)
46
+ job = ForemanPipeline::Job.find(jobs(:runs_on_levelup).id)
47
+ allowed_jobs = @filter.allowed_jobs_for_cvv(cvv)
48
+ assert_equal 1, allowed_jobs.count
49
+ assert_equal job, allowed_jobs.first
50
+ end
51
+
52
+ test "only jobs in library are allowed to run for cvs published for the first time" do
53
+ job = ForemanPipeline::Job.find(jobs(:runs_on_first_publish).id)
54
+ cv = Katello::ContentView.find(katello_content_views(:no_environment_view).id)
55
+ allowed_jobs = @filter.allowed_jobs_for_cv(cv)
56
+ assert_equal 1, allowed_jobs.count
57
+ assert_equal job, allowed_jobs.first
58
+ end
59
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Pražák
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-02 00:00:00.000000000 Z
11
+ date: 2016-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jenkins_api_client
@@ -167,8 +167,8 @@ files:
167
167
  - app/models/foreman_pipeline/jenkins_project_param.rb
168
168
  - app/models/foreman_pipeline/jenkins_user.rb
169
169
  - app/models/foreman_pipeline/job.rb
170
- - app/models/foreman_pipeline/job_jenkins_project.rb
171
170
  - app/models/foreman_pipeline/job_to_environment.rb
171
+ - app/services/foreman_pipeline/job_filter.rb
172
172
  - app/views/foreman/unattended/snippets/_jenkins_instance_pubkey.erb
173
173
  - app/views/foreman_pipeline/api/common/async.json.rabl
174
174
  - app/views/foreman_pipeline/api/common/index.json.rabl
@@ -230,6 +230,11 @@ files:
230
230
  - db/migrate/20150408143011_remove_cv_promote_from_job.rb
231
231
  - db/migrate/20150408145022_rename_job_path.rb
232
232
  - db/migrate/20150923073033_drop_orphaned_table.rb
233
+ - db/migrate/20160404102405_update_projects_table.rb
234
+ - db/migrate/20160404133012_drop_job_jenkins_project.rb
235
+ - db/migrate/20160629085119_add_timeout_to_jenkins_instance.rb
236
+ - db/seeds.d/location.rb
237
+ - db/seeds.d/snippets.rb
233
238
  - lib/foreman_pipeline.rb
234
239
  - lib/foreman_pipeline/engine.rb
235
240
  - lib/foreman_pipeline/monkeys.rb
@@ -243,16 +248,24 @@ files:
243
248
  - lib/foreman_pipeline/plugin.rb
244
249
  - lib/foreman_pipeline/roles.rb
245
250
  - lib/foreman_pipeline/skip_tests.rb
246
- - lib/foreman_pipeline/tasks/foreman_pipeline_seed.rake
247
- - lib/foreman_pipeline/tasks/foreman_pipeline_test.rake
251
+ - lib/foreman_pipeline/tasks/test.rake
248
252
  - lib/foreman_pipeline/version.rb
249
253
  - script/rails
250
- - test/factories/hostgroup_factory.rb
251
254
  - test/factories/jenkins_instance_related_factory.rb
252
- - test/foreman_pipeline_plugin_test_helper.rb
253
- - test/unit/jenkins_instance_test.rb
254
- - test/unit/job_test.rb
255
- - test/unit/sanity_test.rb
255
+ - test/fixtures/jenkins_instances.yml
256
+ - test/fixtures/jenkins_projects.yml
257
+ - test/fixtures/jenkins_users.yml
258
+ - test/fixtures/jobs.yml
259
+ - test/fixtures/pipeline_compute_attributes.yml
260
+ - test/fixtures/pipeline_compute_profiles.yml
261
+ - test/fixtures/pipeline_hostgroups.yml
262
+ - test/fixtures_support.rb
263
+ - test/foreman_pipeline_test_helper.rb
264
+ - test/functional/foreman_pipeline/api/jenkins_users_controller_test.rb
265
+ - test/functional/foreman_pipeline/api/jobs_controller_test.rb
266
+ - test/models/jenkins_instance_test.rb
267
+ - test/models/job_test.rb
268
+ - test/services/job_filter_test.rb
256
269
  homepage: https://github.com/xprazak2/foreman-pipeline
257
270
  licenses: []
258
271
  metadata: {}
@@ -277,10 +290,18 @@ signing_key:
277
290
  specification_version: 4
278
291
  summary: Makes Foreman talk to Jenkins CI server.
279
292
  test_files:
280
- - test/factories/hostgroup_factory.rb
293
+ - test/functional/foreman_pipeline/api/jobs_controller_test.rb
294
+ - test/functional/foreman_pipeline/api/jenkins_users_controller_test.rb
281
295
  - test/factories/jenkins_instance_related_factory.rb
282
- - test/foreman_pipeline_plugin_test_helper.rb
283
- - test/unit/jenkins_instance_test.rb
284
- - test/unit/sanity_test.rb
285
- - test/unit/job_test.rb
286
- has_rdoc:
296
+ - test/models/jenkins_instance_test.rb
297
+ - test/models/job_test.rb
298
+ - test/foreman_pipeline_test_helper.rb
299
+ - test/fixtures/jenkins_projects.yml
300
+ - test/fixtures/pipeline_hostgroups.yml
301
+ - test/fixtures/jenkins_users.yml
302
+ - test/fixtures/pipeline_compute_profiles.yml
303
+ - test/fixtures/jobs.yml
304
+ - test/fixtures/pipeline_compute_attributes.yml
305
+ - test/fixtures/jenkins_instances.yml
306
+ - test/fixtures_support.rb
307
+ - test/services/job_filter_test.rb
@@ -1,27 +0,0 @@
1
- module ForemanPipeline
2
- class JobJenkinsProject < Katello::Model
3
- self.include_root_in_json = false
4
-
5
- belongs_to :job, :inverse_of => :job_jenkins_projects, :class_name => 'ForemanPipeline::Job'
6
- belongs_to :jenkins_project, :inverse_of => :job_jenkins_projects, :class_name => 'ForemanPipeline::JenkinsProject'
7
- belongs_to :organization
8
- validate :org_membership
9
-
10
- after_destroy :remove_orphaned_projects
11
-
12
- attr_accessible :job_id, :jenkins_project_id
13
-
14
- private
15
-
16
- def org_membership
17
- unless self.job.organization == self.jenkins_project.organization
18
- errors.add(:base, "Cannot add a project from different organization than #{job.organization.name}")
19
- end
20
- end
21
-
22
- def remove_orphaned_projects
23
- JenkinsProject.all.map { |p| p.destroy if p.jobs.empty? }
24
- end
25
-
26
- end
27
- end
@@ -1,28 +0,0 @@
1
- namespace :foreman_pipeline do
2
-
3
- desc "seeding the database"
4
- task :seed => :environment do
5
- defaults = {:default => true, :locked => false}
6
- ProvisioningTemplate.without_auditing do
7
- [
8
- {:name => "foreman_pipeline_jenkins_pubkey", :source => "snippets/_jenkins_instance_pubkey.erb", :snippet => true}
9
- ].each do |template|
10
- template[:template] = File.read(File.join(ForemanPipeline::Engine.root, "app/views/foreman/unattended", template.delete(:source)))
11
-
12
- ProvisioningTemplate.find_or_create_by_name(template) do |tmplt|
13
- tmplt.update_attributes(defaults.merge(template))
14
- end
15
- end
16
- end
17
-
18
- loc = Location.new(:name => "foreman_pipeline")
19
- loc.organizations = Organization.all
20
- loc.environments = Environment.all
21
- loc.domains = Domain.all
22
- loc.media = Medium.all
23
- loc.subnets = Subnet.all
24
- loc.compute_resources = ComputeResource.all
25
- loc.smart_proxies = SmartProxy.all
26
- loc.save!
27
- end
28
- end
@@ -1,5 +0,0 @@
1
- FactoryGirl.define do
2
- factory :pipeline_hostgroup, :class => Hostgroup do
3
- sequence(:name) { |n| "hostgroup#{n}" }
4
- end
5
- end
@@ -1,12 +0,0 @@
1
- require 'foreman_pipeline_plugin_test_helper'
2
-
3
- class IntegrationTest < ActiveSupport::TestCase
4
- # setup do
5
- # User.current = User.admin
6
- # end
7
-
8
- test "the truth" do
9
- assert true
10
- end
11
-
12
- end