jobs-api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +55 -0
  3. data/Rakefile +6 -0
  4. data/app/channels/application_cable/channel.rb +4 -0
  5. data/app/channels/application_cable/connection.rb +4 -0
  6. data/app/clients/bitbucket_client.rb +31 -0
  7. data/app/clients/github_client.rb +100 -0
  8. data/app/controllers/application_controller.rb +23 -0
  9. data/app/controllers/events_controller.rb +12 -0
  10. data/app/controllers/hooks_controller.rb +32 -0
  11. data/app/controllers/jobs_controller.rb +20 -0
  12. data/app/controllers/pipelines_controller.rb +11 -0
  13. data/app/controllers/projects_controller.rb +39 -0
  14. data/app/controllers/sessions_controller.rb +17 -0
  15. data/app/controllers/users_controller.rb +15 -0
  16. data/app/jobs/application_job.rb +2 -0
  17. data/app/jobs/pipeline_runner_job.rb +106 -0
  18. data/app/mailers/application_mailer.rb +4 -0
  19. data/app/models/application_record.rb +3 -0
  20. data/app/models/basic_pipeline.rb +73 -0
  21. data/app/models/event.rb +24 -0
  22. data/app/models/job.rb +27 -0
  23. data/app/models/pipeline.rb +21 -0
  24. data/app/models/pipeline_definition.rb +98 -0
  25. data/app/models/project.rb +45 -0
  26. data/app/models/team.rb +11 -0
  27. data/app/models/user.rb +43 -0
  28. data/app/models/user_team.rb +4 -0
  29. data/app/serializers/job_serializer.rb +12 -0
  30. data/app/serializers/pipeline_serializer.rb +3 -0
  31. data/app/serializers/project_serializer.rb +4 -0
  32. data/app/serializers/team_serializer.rb +3 -0
  33. data/app/serializers/user_serializer.rb +3 -0
  34. data/app/views/layouts/mailer.html.erb +13 -0
  35. data/app/views/layouts/mailer.text.erb +1 -0
  36. data/config/application.rb +37 -0
  37. data/config/boot.rb +3 -0
  38. data/config/cable.yml +9 -0
  39. data/config/database.yml +16 -0
  40. data/config/environment.rb +5 -0
  41. data/config/environments/development.rb +47 -0
  42. data/config/environments/production.rb +78 -0
  43. data/config/environments/test.rb +42 -0
  44. data/config/initializers/app_setup.rb +46 -0
  45. data/config/initializers/backtrace_silencers.rb +7 -0
  46. data/config/initializers/filter_parameter_logging.rb +4 -0
  47. data/config/initializers/inflections.rb +16 -0
  48. data/config/initializers/mime_types.rb +4 -0
  49. data/config/initializers/new_framework_defaults.rb +18 -0
  50. data/config/initializers/wrap_parameters.rb +14 -0
  51. data/config/locales/en.yml +23 -0
  52. data/config/puma.rb +47 -0
  53. data/config/routes.rb +23 -0
  54. data/config/secrets.yml +22 -0
  55. data/config/spring.rb +6 -0
  56. data/db/migrate/20161107155702_create_projects.rb +15 -0
  57. data/db/migrate/20161108233030_create_pipelines.rb +15 -0
  58. data/db/migrate/20161108233304_create_jobs.rb +16 -0
  59. data/db/migrate/20161109203929_create_users.rb +15 -0
  60. data/db/migrate/20161109203949_create_teams.rb +11 -0
  61. data/db/migrate/20161109204011_create_user_teams.rb +10 -0
  62. data/db/migrate/20161109205639_add_references_to_projects.rb +6 -0
  63. data/db/migrate/20161110154413_create_delayed_jobs.rb +22 -0
  64. data/db/schema.rb +111 -0
  65. data/db/seeds.rb +7 -0
  66. data/lib/jobs_api.rb +13 -0
  67. metadata +255 -0
data/config/spring.rb ADDED
@@ -0,0 +1,6 @@
1
+ %w(
2
+ .ruby-version
3
+ .rbenv-vars
4
+ tmp/restart.txt
5
+ tmp/caching-dev.txt
6
+ ).each { |path| Spring.watch(path) }
@@ -0,0 +1,15 @@
1
+ class CreateProjects < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :projects do |t|
4
+ t.string :name
5
+ t.string :repo_provider
6
+ t.string :repo_owner
7
+ t.string :repo_name
8
+ t.string :repo_id
9
+ t.json :enabled_pipelines
10
+ t.boolean :enabled
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class CreatePipelines < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :pipelines do |t|
4
+ t.references :project, foreign_key: true, null: true
5
+ t.string :definition
6
+ t.json :event
7
+ t.text :variables
8
+ t.string :stage
9
+ t.string :status
10
+ t.string :error
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ class CreateJobs < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :jobs do |t|
4
+ t.references :pipeline, foreign_key: true, null: false
5
+ t.string :pipeline_stage
6
+ t.string :key, null: false
7
+ t.string :status, null: false, default: 'PENDING'
8
+ t.string :commit
9
+ t.string :branch
10
+ t.string :worker
11
+ t.json :spec
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ class CreateUsers < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :name
5
+ t.string :provider, null: false
6
+ t.string :provider_id, null: false
7
+ t.string :email
8
+ t.string :username
9
+ t.string :token
10
+ t.string :refresh_token
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ class CreateTeams < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :teams do |t|
4
+ t.string :name
5
+ t.string :provider
6
+ t.string :provider_id
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ class CreateUserTeams < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :user_teams do |t|
4
+ t.references :user, foreign_key: true
5
+ t.references :team, foreign_key: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ class AddReferencesToProjects < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_reference :projects, :team, foreign_key: true, null: true
4
+ add_reference :projects, :user, foreign_key: true, null: true
5
+ end
6
+ end
@@ -0,0 +1,22 @@
1
+ class CreateDelayedJobs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :delayed_jobs, force: true do |table|
4
+ table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
5
+ table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
6
+ table.text :handler, null: false # YAML-encoded string of the object that will do work
7
+ table.text :last_error # reason for last failure (See Note below)
8
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
9
+ table.datetime :locked_at # Set when a client is working on this object
10
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
11
+ table.string :locked_by # Who is working on this object (if locked)
12
+ table.string :queue # The name of the queue this job is in
13
+ table.timestamps null: true
14
+ end
15
+
16
+ add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority"
17
+ end
18
+
19
+ def self.down
20
+ drop_table :delayed_jobs
21
+ end
22
+ end
data/db/schema.rb ADDED
@@ -0,0 +1,111 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 20161110154413) do
14
+
15
+ create_table "delayed_jobs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
16
+ t.integer "priority", default: 0, null: false
17
+ t.integer "attempts", default: 0, null: false
18
+ t.text "handler", limit: 65535, null: false
19
+ t.text "last_error", limit: 65535
20
+ t.datetime "run_at"
21
+ t.datetime "locked_at"
22
+ t.datetime "failed_at"
23
+ t.string "locked_by"
24
+ t.string "queue"
25
+ t.datetime "created_at"
26
+ t.datetime "updated_at"
27
+ t.index ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
28
+ end
29
+
30
+ create_table "jobs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
31
+ t.integer "pipeline_id", null: false
32
+ t.integer "project_id"
33
+ t.string "pipeline_stage"
34
+ t.string "key", null: false
35
+ t.string "status", default: "PENDING", null: false
36
+ t.string "commit"
37
+ t.string "branch"
38
+ t.string "worker"
39
+ t.json "spec"
40
+ t.datetime "created_at", null: false
41
+ t.datetime "updated_at", null: false
42
+ t.index ["pipeline_id"], name: "index_jobs_on_pipeline_id", using: :btree
43
+ t.index ["project_id"], name: "index_jobs_on_project_id", using: :btree
44
+ end
45
+
46
+ create_table "pipelines", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
47
+ t.integer "project_id"
48
+ t.string "definition"
49
+ t.json "event"
50
+ t.text "variables", limit: 65535
51
+ t.string "stage"
52
+ t.string "status"
53
+ t.string "error"
54
+ t.datetime "created_at", null: false
55
+ t.datetime "updated_at", null: false
56
+ t.index ["project_id"], name: "index_pipelines_on_project_id", using: :btree
57
+ end
58
+
59
+ create_table "projects", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
60
+ t.string "name"
61
+ t.string "repo_provider"
62
+ t.string "repo_owner"
63
+ t.string "repo_name"
64
+ t.string "repo_id"
65
+ t.json "enabled_pipelines"
66
+ t.boolean "enabled"
67
+ t.datetime "created_at", null: false
68
+ t.datetime "updated_at", null: false
69
+ t.integer "team_id"
70
+ t.integer "user_id"
71
+ t.index ["team_id"], name: "index_projects_on_team_id", using: :btree
72
+ t.index ["user_id"], name: "index_projects_on_user_id", using: :btree
73
+ end
74
+
75
+ create_table "teams", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
76
+ t.string "name"
77
+ t.string "provider"
78
+ t.string "provider_id"
79
+ t.datetime "created_at", null: false
80
+ t.datetime "updated_at", null: false
81
+ end
82
+
83
+ create_table "user_teams", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
84
+ t.integer "user_id"
85
+ t.integer "team_id"
86
+ t.datetime "created_at", null: false
87
+ t.datetime "updated_at", null: false
88
+ t.index ["team_id"], name: "index_user_teams_on_team_id", using: :btree
89
+ t.index ["user_id"], name: "index_user_teams_on_user_id", using: :btree
90
+ end
91
+
92
+ create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
93
+ t.string "name"
94
+ t.string "provider", null: false
95
+ t.string "provider_id", null: false
96
+ t.string "email"
97
+ t.string "username"
98
+ t.string "token"
99
+ t.string "refresh_token"
100
+ t.datetime "created_at", null: false
101
+ t.datetime "updated_at", null: false
102
+ end
103
+
104
+ add_foreign_key "jobs", "pipelines"
105
+ add_foreign_key "jobs", "projects"
106
+ add_foreign_key "pipelines", "projects"
107
+ add_foreign_key "projects", "teams"
108
+ add_foreign_key "projects", "users"
109
+ add_foreign_key "user_teams", "teams"
110
+ add_foreign_key "user_teams", "users"
111
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7
+ # Character.create(name: 'Luke', movie: movies.first)
data/lib/jobs_api.rb ADDED
@@ -0,0 +1,13 @@
1
+ module JobsApi
2
+ VERSION = '0.1.0'
3
+
4
+ def self.pipeline_definitions
5
+ @pipeline_definitions ||= []
6
+ @pipeline_definitions
7
+ end
8
+
9
+ def self.register_pipeline_definition(definition)
10
+ pipeline_definitions << definition
11
+ end
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,255 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jobs-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Colin Walker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.0.0.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 5.0.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.0.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: mysql2
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: puma
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: bcrypt
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 3.1.7
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 3.1.7
75
+ - !ruby/object:Gem::Dependency
76
+ name: rack-cors
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '='
80
+ - !ruby/object:Gem::Version
81
+ version: 0.4.0
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '='
87
+ - !ruby/object:Gem::Version
88
+ version: 0.4.0
89
+ - !ruby/object:Gem::Dependency
90
+ name: active_model_serializers
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '='
94
+ - !ruby/object:Gem::Version
95
+ version: 0.10.2
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '='
101
+ - !ruby/object:Gem::Version
102
+ version: 0.10.2
103
+ - !ruby/object:Gem::Dependency
104
+ name: omniauth
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.3.1
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '='
115
+ - !ruby/object:Gem::Version
116
+ version: 1.3.1
117
+ - !ruby/object:Gem::Dependency
118
+ name: omniauth-bitbucket
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '='
122
+ - !ruby/object:Gem::Version
123
+ version: 0.0.2
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '='
129
+ - !ruby/object:Gem::Version
130
+ version: 0.0.2
131
+ - !ruby/object:Gem::Dependency
132
+ name: omniauth-github
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - '='
136
+ - !ruby/object:Gem::Version
137
+ version: 1.1.2
138
+ type: :runtime
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - '='
143
+ - !ruby/object:Gem::Version
144
+ version: 1.1.2
145
+ - !ruby/object:Gem::Dependency
146
+ name: delayed_job_active_record
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - '='
150
+ - !ruby/object:Gem::Version
151
+ version: 4.1.1
152
+ type: :runtime
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - '='
157
+ - !ruby/object:Gem::Version
158
+ version: 4.1.1
159
+ description:
160
+ email:
161
+ - colinwalker270@gmail.com
162
+ executables: []
163
+ extensions: []
164
+ extra_rdoc_files: []
165
+ files:
166
+ - README.md
167
+ - Rakefile
168
+ - app/channels/application_cable/channel.rb
169
+ - app/channels/application_cable/connection.rb
170
+ - app/clients/bitbucket_client.rb
171
+ - app/clients/github_client.rb
172
+ - app/controllers/application_controller.rb
173
+ - app/controllers/events_controller.rb
174
+ - app/controllers/hooks_controller.rb
175
+ - app/controllers/jobs_controller.rb
176
+ - app/controllers/pipelines_controller.rb
177
+ - app/controllers/projects_controller.rb
178
+ - app/controllers/sessions_controller.rb
179
+ - app/controllers/users_controller.rb
180
+ - app/jobs/application_job.rb
181
+ - app/jobs/pipeline_runner_job.rb
182
+ - app/mailers/application_mailer.rb
183
+ - app/models/application_record.rb
184
+ - app/models/basic_pipeline.rb
185
+ - app/models/event.rb
186
+ - app/models/job.rb
187
+ - app/models/pipeline.rb
188
+ - app/models/pipeline_definition.rb
189
+ - app/models/project.rb
190
+ - app/models/team.rb
191
+ - app/models/user.rb
192
+ - app/models/user_team.rb
193
+ - app/serializers/job_serializer.rb
194
+ - app/serializers/pipeline_serializer.rb
195
+ - app/serializers/project_serializer.rb
196
+ - app/serializers/team_serializer.rb
197
+ - app/serializers/user_serializer.rb
198
+ - app/views/layouts/mailer.html.erb
199
+ - app/views/layouts/mailer.text.erb
200
+ - config/application.rb
201
+ - config/boot.rb
202
+ - config/cable.yml
203
+ - config/database.yml
204
+ - config/environment.rb
205
+ - config/environments/development.rb
206
+ - config/environments/production.rb
207
+ - config/environments/test.rb
208
+ - config/initializers/app_setup.rb
209
+ - config/initializers/backtrace_silencers.rb
210
+ - config/initializers/filter_parameter_logging.rb
211
+ - config/initializers/inflections.rb
212
+ - config/initializers/mime_types.rb
213
+ - config/initializers/new_framework_defaults.rb
214
+ - config/initializers/wrap_parameters.rb
215
+ - config/locales/en.yml
216
+ - config/puma.rb
217
+ - config/routes.rb
218
+ - config/secrets.yml
219
+ - config/spring.rb
220
+ - db/migrate/20161107155702_create_projects.rb
221
+ - db/migrate/20161108233030_create_pipelines.rb
222
+ - db/migrate/20161108233304_create_jobs.rb
223
+ - db/migrate/20161109203929_create_users.rb
224
+ - db/migrate/20161109203949_create_teams.rb
225
+ - db/migrate/20161109204011_create_user_teams.rb
226
+ - db/migrate/20161109205639_add_references_to_projects.rb
227
+ - db/migrate/20161110154413_create_delayed_jobs.rb
228
+ - db/schema.rb
229
+ - db/seeds.rb
230
+ - lib/jobs_api.rb
231
+ homepage: https://github.org/coldog/jobs-api
232
+ licenses:
233
+ - MIT
234
+ metadata: {}
235
+ post_install_message:
236
+ rdoc_options: []
237
+ require_paths:
238
+ - lib
239
+ required_ruby_version: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ required_rubygems_version: !ruby/object:Gem::Requirement
245
+ requirements:
246
+ - - ">="
247
+ - !ruby/object:Gem::Version
248
+ version: '0'
249
+ requirements: []
250
+ rubyforge_project:
251
+ rubygems_version: 2.5.1
252
+ signing_key:
253
+ specification_version: 4
254
+ summary: Job api server
255
+ test_files: []