magi 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/Gemfile +2 -4
- data/README.md +9 -5
- data/app/models/job.rb +7 -3
- data/lib/magi/version.rb +1 -1
- data/spec/factories/build.rb +1 -0
- metadata +1 -3
- data/plugins/git/git.rb +0 -92
- data/plugins/simplecov/simplecov.rb +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2232fb038a30303249630f1c9f782240ae5a55f6
|
4
|
+
data.tar.gz: f1ef12fccfa8ffb10151443898de7680cc0f8e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a641d3baa3fd907bcb5b2daa3706916a80a91ac3c517f9e2bec32e20f85ff5b6e6ab4b6351c17a0c1ad31da2c8e6dae79f84425644f7efa694631c6d593e64cd
|
7
|
+
data.tar.gz: 8dbb5cd16914d9ce09cf06ead2cabe14ae25ece7f8d9636c34f4996965503dc461f4aebf8e3100dbda3cb6e1258489badf007e9268ff001288a37e3aad69e672
|
data/Gemfile
CHANGED
@@ -33,7 +33,5 @@ group :assets do
|
|
33
33
|
gem "uglifier"
|
34
34
|
end
|
35
35
|
|
36
|
-
# Put Gemfile
|
37
|
-
|
38
|
-
eval(pathname.read)
|
39
|
-
end
|
36
|
+
# Put Gemfile.local to use arbitrary gems for your use case.
|
37
|
+
eval File.read("Gemfile.local") if File.exist?("Gemfile.local")
|
data/README.md
CHANGED
@@ -21,8 +21,12 @@ Magi is just a rails application with some middlewares.
|
|
21
21
|
* redis: build started/finished notification by pubsub system
|
22
22
|
* autodoc: generate [RESTful API documents](https://github.com/r7kamura/magi/blob/master/doc) from request-specs
|
23
23
|
|
24
|
-
|
25
|
-
*
|
26
|
-
*
|
27
|
-
|
28
|
-
|
24
|
+
## Plugins
|
25
|
+
* [magi-git](https://github.com/r7kamura/magi-git): Git integration plugin
|
26
|
+
* [magi-simple_cov](https://github.com/r7kamura/magi-simple_cov): Save simplecov coverage for each build
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# Put your favorite plugin gems into Gemfile.local
|
30
|
+
gem "magi-git", git: "git@github.com:r7kamura/magi-git"
|
31
|
+
gem "magi-simple_cov", git: "git@github.com:r7kamura/magi-simple_cov"
|
32
|
+
```
|
data/app/models/job.rb
CHANGED
@@ -98,15 +98,19 @@ class Job < ActiveRecord::Base
|
|
98
98
|
@workspace ||= Magi::Workspace.new(workspace_path)
|
99
99
|
end
|
100
100
|
|
101
|
-
private
|
102
|
-
|
103
101
|
def workspace_path
|
104
102
|
Magi.configuration.workspace_path + "jobs/#{id}"
|
105
103
|
end
|
106
104
|
|
107
105
|
def execute
|
108
106
|
execute_before_executes
|
109
|
-
|
107
|
+
execute_without_before_executes.tap { execute_after_executes }
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def execute_without_before_executes
|
113
|
+
workspace.chdir { execute_script }
|
110
114
|
end
|
111
115
|
|
112
116
|
def execute_script
|
data/lib/magi/version.rb
CHANGED
data/spec/factories/build.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
@@ -362,8 +362,6 @@ files:
|
|
362
362
|
- lib/magi/workspace.rb
|
363
363
|
- lib/magi.rb
|
364
364
|
- lib/tasks/resque.rake
|
365
|
-
- plugins/git/git.rb
|
366
|
-
- plugins/simplecov/simplecov.rb
|
367
365
|
- public/404.html
|
368
366
|
- public/422.html
|
369
367
|
- public/500.html
|
data/plugins/git/git.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
require "open3"
|
2
|
-
|
3
|
-
module Magi
|
4
|
-
class Repository
|
5
|
-
attr_reader :job
|
6
|
-
|
7
|
-
def initialize(job)
|
8
|
-
@job = job
|
9
|
-
end
|
10
|
-
|
11
|
-
def before_enqueue
|
12
|
-
if has_repository_url?
|
13
|
-
clone unless cloned?
|
14
|
-
update
|
15
|
-
updated_since_last_finished_build?
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def before_execute
|
20
|
-
if has_repository_url?
|
21
|
-
clone
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def after_execute
|
26
|
-
if has_repository_url?
|
27
|
-
job.current_build.update_properties(revision: revision)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def clone
|
32
|
-
validate_existence_of_repository_url
|
33
|
-
command("git clone #{job.repository_url} #{path}")
|
34
|
-
end
|
35
|
-
|
36
|
-
def update
|
37
|
-
command("cd #{path} && git pull")
|
38
|
-
end
|
39
|
-
|
40
|
-
def revision
|
41
|
-
command("cd #{path} && git rev-parse HEAD").rstrip
|
42
|
-
end
|
43
|
-
|
44
|
-
def updated_since_last_finished_build?
|
45
|
-
revision != job.last_finished_build.try(:revision)
|
46
|
-
end
|
47
|
-
|
48
|
-
def cloned?
|
49
|
-
path.join(".git").exist?
|
50
|
-
end
|
51
|
-
|
52
|
-
def command(script)
|
53
|
-
Open3.capture3(script)[0]
|
54
|
-
end
|
55
|
-
|
56
|
-
def path
|
57
|
-
job.workspace.path + "repository"
|
58
|
-
end
|
59
|
-
|
60
|
-
def has_repository_url?
|
61
|
-
job.repository_url.present?
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def validate_existence_of_repository_url
|
67
|
-
raise RepositoryUrlNotFound unless has_repository_url?
|
68
|
-
end
|
69
|
-
|
70
|
-
class RepositoryUrlNotFound < StandardError
|
71
|
-
def message
|
72
|
-
"You must set `repository_url`"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
Job.class_eval do
|
79
|
-
property(:repository_url)
|
80
|
-
|
81
|
-
before_enqueue { repository.before_enqueue }
|
82
|
-
|
83
|
-
before_execute { repository.before_execute }
|
84
|
-
|
85
|
-
after_execute { repository.after_execute }
|
86
|
-
|
87
|
-
def repository
|
88
|
-
@repository ||= Magi::Repository.new(self)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
Build.property(:revision)
|
@@ -1,98 +0,0 @@
|
|
1
|
-
require "json"
|
2
|
-
require "fileutils"
|
3
|
-
|
4
|
-
module Magi
|
5
|
-
class SimpleCov
|
6
|
-
attr_reader :job
|
7
|
-
|
8
|
-
def initialize(job)
|
9
|
-
@job = job
|
10
|
-
end
|
11
|
-
|
12
|
-
def after_execute
|
13
|
-
save if enabled? && has_coverage?
|
14
|
-
end
|
15
|
-
|
16
|
-
def enabled?
|
17
|
-
!!job.enable_simplecov
|
18
|
-
end
|
19
|
-
|
20
|
-
def workspace_path
|
21
|
-
job.workspace.path + "coverage"
|
22
|
-
end
|
23
|
-
|
24
|
-
def last_coverage
|
25
|
-
JSON.parse(last_run_json)["result"]["covered_percent"]
|
26
|
-
rescue JSON::ParserError, NoMethodError
|
27
|
-
end
|
28
|
-
|
29
|
-
def last_run_json
|
30
|
-
last_run_json_path.read
|
31
|
-
end
|
32
|
-
|
33
|
-
def has_last_run_json?
|
34
|
-
last_run_json_path.exist?
|
35
|
-
end
|
36
|
-
|
37
|
-
def has_coverage?
|
38
|
-
has_last_run_json?
|
39
|
-
end
|
40
|
-
|
41
|
-
def last_run_json_path
|
42
|
-
job.repository.path + "coverage/.last_run.json"
|
43
|
-
end
|
44
|
-
|
45
|
-
def assets_path
|
46
|
-
job.repository.path + "coverage/assets"
|
47
|
-
end
|
48
|
-
|
49
|
-
def assets_relative_path
|
50
|
-
assets_path.relative_path_from(current_build_path)
|
51
|
-
end
|
52
|
-
|
53
|
-
def result_html_path
|
54
|
-
job.repository.path + "coverage/index.html"
|
55
|
-
end
|
56
|
-
|
57
|
-
def current_build_path
|
58
|
-
workspace_path + job.current_build.id.to_s
|
59
|
-
end
|
60
|
-
|
61
|
-
def symlink_assets
|
62
|
-
File.symlink(assets_relative_path, current_build_path + "assets")
|
63
|
-
end
|
64
|
-
|
65
|
-
def copy_result_html
|
66
|
-
FileUtils.cp(result_html_path, current_build_path)
|
67
|
-
end
|
68
|
-
|
69
|
-
def save
|
70
|
-
save_files
|
71
|
-
save_build
|
72
|
-
end
|
73
|
-
|
74
|
-
def save_files
|
75
|
-
current_build_path.mkpath
|
76
|
-
symlink_assets
|
77
|
-
copy_result_html
|
78
|
-
end
|
79
|
-
|
80
|
-
def save_build
|
81
|
-
job.current_build.update_properties(coverage: last_coverage)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
Job.class_eval do
|
87
|
-
property(:enable_simplecov, type: :boolean)
|
88
|
-
|
89
|
-
after_execute { coverage.after_execute }
|
90
|
-
|
91
|
-
def coverage
|
92
|
-
@coverage ||= Magi::SimpleCov.new(self)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
Build.class_eval do
|
97
|
-
property(:coverage)
|
98
|
-
end
|