larrow-runner 0.0.1
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 +7 -0
- data/.gitignore +25 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +80 -0
- data/Rakefile +2 -0
- data/bin/larrow +4 -0
- data/larrow-runner.gemspec +42 -0
- data/lib/larrow/runner/cli/build.rb +41 -0
- data/lib/larrow/runner/cli/main.rb +35 -0
- data/lib/larrow/runner/cli/tools.rb +34 -0
- data/lib/larrow/runner/cli.rb +11 -0
- data/lib/larrow/runner/errors.rb +1 -0
- data/lib/larrow/runner/helper.rb +0 -0
- data/lib/larrow/runner/logger.rb +69 -0
- data/lib/larrow/runner/manager.rb +114 -0
- data/lib/larrow/runner/manifest/adapter/blank.rb +8 -0
- data/lib/larrow/runner/manifest/adapter/larrow.rb +32 -0
- data/lib/larrow/runner/manifest/adapter/travis.rb +73 -0
- data/lib/larrow/runner/manifest/base_loader.rb +21 -0
- data/lib/larrow/runner/manifest/configuration.rb +126 -0
- data/lib/larrow/runner/manifest.rb +48 -0
- data/lib/larrow/runner/model/app.rb +62 -0
- data/lib/larrow/runner/model/node.rb +73 -0
- data/lib/larrow/runner/service/cloud.rb +54 -0
- data/lib/larrow/runner/service/executor.rb +56 -0
- data/lib/larrow/runner/service.rb +8 -0
- data/lib/larrow/runner/session.rb +64 -0
- data/lib/larrow/runner/vcs/base.rb +17 -0
- data/lib/larrow/runner/vcs/file_system.rb +58 -0
- data/lib/larrow/runner/vcs/github.rb +48 -0
- data/lib/larrow/runner/vcs.rb +20 -0
- data/lib/larrow/runner/version.rb +5 -0
- data/lib/larrow/runner.rb +34 -0
- data/spec/fixtures/travis_erlang.yml +8 -0
- data/spec/fixtures/travis_ruby.yml +9 -0
- data/spec/integration/build_cmds_spec.rb +18 -0
- data/spec/integration/test_cmds_spec.rb +13 -0
- data/spec/manifest/travis_spec.rb +42 -0
- data/spec/model/node_spec.rb +18 -0
- data/spec/service/executor_spec.rb +26 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/vcs/github_spec.rb +33 -0
- metadata +340 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 556f8afefdbfa12b93f7c7f3029fcc5bf55b23f9
|
4
|
+
data.tar.gz: 170901120bc4eeec5370639ae6bb00c33c6ebf14
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2b9e24d845add9b4f3e99cb968e5146541f2e8aa025fc20dc97df7aac5d2a85286e318fe10cec77c1dafdf02f95749280eefe55a1183fda70ccf016f8b105789
|
7
|
+
data.tar.gz: 3597ae6bd3f599e1edb2b645fd9b752d46caf9a2b5c865303d1a7b8a10588e71e873b460e056dfca6d10349e8430e8485caecd2a2279dddcdbbd7bc95d11dff9
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.swp
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
*.log
|
5
|
+
.bundle
|
6
|
+
.config
|
7
|
+
.yardoc
|
8
|
+
Gemfile.lock
|
9
|
+
InstalledFiles
|
10
|
+
_yardoc
|
11
|
+
coverage
|
12
|
+
doc/
|
13
|
+
lib/bundler/man
|
14
|
+
pkg
|
15
|
+
rdoc
|
16
|
+
spec/reports
|
17
|
+
test/tmp
|
18
|
+
test/version_tmp
|
19
|
+
tmp
|
20
|
+
*.bundle
|
21
|
+
*.so
|
22
|
+
*.o
|
23
|
+
*.a
|
24
|
+
mkmf.log
|
25
|
+
tags
|
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 lifu
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Larrow::Runner
|
2
|
+
|
3
|
+
It is a command line tool with the following goals:
|
4
|
+
|
5
|
+
* build your application
|
6
|
+
* make a quick image for developer
|
7
|
+
* save best practices on devops of your team
|
8
|
+
* help to build the CI service
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
```
|
14
|
+
$ gem 'larrow-runner'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
```
|
19
|
+
$ bundle
|
20
|
+
```
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
```
|
24
|
+
$ gem install larrow-runner
|
25
|
+
```
|
26
|
+
|
27
|
+
You should setup your cloud access ( why qingcloud ? ) before using larrow
|
28
|
+
|
29
|
+
```
|
30
|
+
$ larrow login
|
31
|
+
please setup your account of Qing Cloud:
|
32
|
+
access id: ******
|
33
|
+
secret key: ******
|
34
|
+
keypair id: ******
|
35
|
+
zone_id(default: pek1): pek1
|
36
|
+
Congratulation! Now you can use larrow to help your develop works.
|
37
|
+
```
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
### testing
|
42
|
+
|
43
|
+
unit test, integration test, system test, etc.)
|
44
|
+
```
|
45
|
+
$ larrow go <source_url>
|
46
|
+
```
|
47
|
+
|
48
|
+
### application startup
|
49
|
+
|
50
|
+
make a standalone application and start it(if necessary)
|
51
|
+
```
|
52
|
+
$ larrow build server <source_url>
|
53
|
+
```
|
54
|
+
|
55
|
+
### build image
|
56
|
+
|
57
|
+
use image to speed-up your development
|
58
|
+
|
59
|
+
* build a image of your application
|
60
|
+
```
|
61
|
+
$ larrow build image <source_url>
|
62
|
+
```
|
63
|
+
|
64
|
+
* build a image from local LarrowFile
|
65
|
+
```
|
66
|
+
$ larrow build image <larrow_file_path>
|
67
|
+
```
|
68
|
+
|
69
|
+
## Larrow File
|
70
|
+
|
71
|
+
Larrow need to know how to setup/make/install/start... your application. So developer could write a `Larrow File` to declare these things.
|
72
|
+
|
73
|
+
Larrow can be used as a CI worker like travis.
|
74
|
+
## Contributing
|
75
|
+
|
76
|
+
1. Fork it ( http://github.com/fsword/larrow-core/fork )
|
77
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
78
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
79
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
80
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/larrow
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'larrow/runner/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "larrow-runner"
|
8
|
+
spec.version = Larrow::Runner::VERSION
|
9
|
+
spec.authors = ["fsword"]
|
10
|
+
spec.email = ["li.jianye@gmail.com"]
|
11
|
+
spec.summary = %q{Core application of larrow, CLI based}
|
12
|
+
spec.description = %q{Automatically build your app from source code}
|
13
|
+
spec.homepage = "http://github.com/fsword/larrow-core"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency 'rake', '~> 10'
|
23
|
+
spec.add_development_dependency "rspec",'~> 3.0'
|
24
|
+
spec.add_development_dependency "simplecov", '~> 0.9'
|
25
|
+
spec.add_development_dependency "parallel_tests", '~> 1.0'
|
26
|
+
|
27
|
+
spec.add_runtime_dependency 'tilt', '~> 2'
|
28
|
+
spec.add_runtime_dependency 'thor', '~> 0.19'
|
29
|
+
spec.add_runtime_dependency "activesupport", "~> 4.1"
|
30
|
+
spec.add_runtime_dependency "pry", '~> 0.10', '0.10.0'
|
31
|
+
spec.add_runtime_dependency "pry-nav", '~> 0.2', '0.2.4'
|
32
|
+
spec.add_runtime_dependency "minitest", '~> 5.4', '5.4.1'
|
33
|
+
|
34
|
+
spec.add_runtime_dependency 'net-ssh', '~> 2.9'
|
35
|
+
spec.add_runtime_dependency 'net-scp', '~> 1.2'
|
36
|
+
|
37
|
+
spec.add_runtime_dependency "faraday", '~> 0.9'
|
38
|
+
|
39
|
+
spec.add_runtime_dependency 'larrow-qingcloud', '~> 0'
|
40
|
+
spec.add_runtime_dependency 'promising', '~> 0.3'
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Larrow::Runner
|
2
|
+
module Cli
|
3
|
+
class Build < ::Thor
|
4
|
+
|
5
|
+
desc 'server <URL/path>','build the server'
|
6
|
+
long_desc <<-EOF.gsub("\n", "\x5")
|
7
|
+
Setup a server for application:
|
8
|
+
* assign resource
|
9
|
+
* init environment
|
10
|
+
* prepare server
|
11
|
+
* start server
|
12
|
+
EOF
|
13
|
+
option :debug
|
14
|
+
option :nocolor
|
15
|
+
def server url
|
16
|
+
RunOption.update options
|
17
|
+
RunOption[:keep] = true
|
18
|
+
RunLogger.nocolor if RunOption.key? :nocolor
|
19
|
+
Manager.new(url).build_server
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'image <URL/path>', 'build a base image'
|
23
|
+
long_desc <<-EOF.gsub("\n", "\x5")
|
24
|
+
Reduce the time is very important for CI or other develop activity.
|
25
|
+
There is a best practise to build a image as base system for the project.
|
26
|
+
Larrow will help you to make it simple and reuse the configuration items.
|
27
|
+
|
28
|
+
Your can use a single Larrowfile as the argument.
|
29
|
+
EOF
|
30
|
+
option :debug
|
31
|
+
option :nocolor
|
32
|
+
def image url
|
33
|
+
RunOption.update options
|
34
|
+
RunLogger.nocolor if RunOption.key? :nocolor
|
35
|
+
Manager.new(url).build_image
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Larrow::Runner
|
2
|
+
module Cli
|
3
|
+
class Main < ::Thor
|
4
|
+
desc 'version','show version of larrow-runner'
|
5
|
+
def version
|
6
|
+
puts VERSION
|
7
|
+
end
|
8
|
+
|
9
|
+
desc 'go [URL]','execute your app'
|
10
|
+
long_desc <<-EOF
|
11
|
+
larrow will build a whole world for your application
|
12
|
+
EOF
|
13
|
+
option :debug
|
14
|
+
option :nocolor
|
15
|
+
def go url
|
16
|
+
RunOption.update options
|
17
|
+
RunLogger.nocolor if RunOption.key? :nocolor
|
18
|
+
Manager.new(url).go
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'login', 'log into Qingcloud service'
|
22
|
+
option :force
|
23
|
+
def login
|
24
|
+
RunOption.update options
|
25
|
+
Session.login
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'build [SUBCOMMAND]', 'build your server or images'
|
29
|
+
subcommand 'build', Build
|
30
|
+
|
31
|
+
desc 'tools [SUBCOMMAND]', 'some tools'
|
32
|
+
subcommand 'tools', Tools
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Larrow::Runner
|
2
|
+
module Cli
|
3
|
+
class Tools < ::Thor
|
4
|
+
desc 'dump [URL]','convert and dump configuration of the project'
|
5
|
+
long_desc <<-EOF.gsub("\n", "\x5")
|
6
|
+
Read other CI file(eg:.travis.yml), conert to larrow style and dump to STDOUT.
|
7
|
+
You can save it as .larrow.yml on the project root folder.
|
8
|
+
EOF
|
9
|
+
def dump url
|
10
|
+
vcs = Vcs.detect url
|
11
|
+
configuration = vcs.configuration false
|
12
|
+
puts configuration.dump
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'resource','show all resource in Resource.yml'
|
16
|
+
long_desc <<-EOF.gsub("\n", "\x5")
|
17
|
+
Read .larrow.resource from current directory, show information.
|
18
|
+
resource: instance, eip, etc...
|
19
|
+
EOF
|
20
|
+
def resource
|
21
|
+
Manager.resource
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'cleanup','cleanup all resource in Resource.yml'
|
25
|
+
long_desc <<-EOF.gsub("\n", "\x5")
|
26
|
+
Read .larrow.resource from current directory, and release all resources.
|
27
|
+
resource: instance, eip, etc...
|
28
|
+
EOF
|
29
|
+
def cleanup
|
30
|
+
Manager.cleanup
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
ExecutionError = Class.new StandardError
|
File without changes
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Larrow::Runner
|
4
|
+
# usage:
|
5
|
+
# logger = Larrow::Runner::Logger filename
|
6
|
+
# logger.level(3).color('red').info 'hello'
|
7
|
+
# logger.level(3).title 'hello'
|
8
|
+
# logger.level(3).detail 'hello'
|
9
|
+
class Logger
|
10
|
+
def initialize logger, level:nil, color:'magenta'
|
11
|
+
@inner_logger = if logger.is_a? ::Logger
|
12
|
+
logger
|
13
|
+
else
|
14
|
+
::Logger.new logger
|
15
|
+
end
|
16
|
+
@inner_logger.formatter = proc do |_severity, datetime, _progname, msg|
|
17
|
+
"[#{datetime.strftime('%H:%M:%S')}] #{msg}\n"
|
18
|
+
end
|
19
|
+
@level = level
|
20
|
+
@color = color
|
21
|
+
end
|
22
|
+
|
23
|
+
def nocolor
|
24
|
+
@color = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def level level
|
28
|
+
Logger.new @inner_logger, level: level, color: @color
|
29
|
+
end
|
30
|
+
|
31
|
+
def color color
|
32
|
+
return self if RunOption.key? :nocolor # skip color when no color
|
33
|
+
Logger.new @inner_logger, level: @level, color: color
|
34
|
+
end
|
35
|
+
|
36
|
+
def info msg
|
37
|
+
indent = " " * (@level || 0)
|
38
|
+
wrapped = wrap_color msg
|
39
|
+
@inner_logger.info "#{indent}#{wrapped}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def title msg
|
43
|
+
color('yellow').info msg
|
44
|
+
end
|
45
|
+
|
46
|
+
def detail msg
|
47
|
+
color('green').info msg
|
48
|
+
end
|
49
|
+
|
50
|
+
def err msg
|
51
|
+
color('red').info msg
|
52
|
+
end
|
53
|
+
|
54
|
+
def wrap_color msg
|
55
|
+
return msg if @color.nil?
|
56
|
+
code = case @color.downcase
|
57
|
+
when 'black' then '30'
|
58
|
+
when 'red' then '31'
|
59
|
+
when 'green' then '32'
|
60
|
+
when 'yellow' then '33'
|
61
|
+
when 'blue' then '34'
|
62
|
+
when 'magenta' then '35'
|
63
|
+
when 'cyan' then '36'
|
64
|
+
when 'white' then '37'
|
65
|
+
end
|
66
|
+
"\033[#{code}m#{msg}\033[0m"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
gem 'pry', '0.10.0'
|
2
|
+
gem 'pry-nav', '0.2.4'
|
3
|
+
require 'pry'
|
4
|
+
require 'pry-nav'
|
5
|
+
module Larrow::Runner
|
6
|
+
class Manager
|
7
|
+
include Service
|
8
|
+
|
9
|
+
attr_accessor :vcs
|
10
|
+
attr_accessor :app
|
11
|
+
def initialize target_url
|
12
|
+
signal_trap
|
13
|
+
self.vcs = Vcs.detect target_url
|
14
|
+
self.app = Model::App.new vcs
|
15
|
+
end
|
16
|
+
|
17
|
+
def signal_trap
|
18
|
+
trap('INT') do
|
19
|
+
RunLogger.title 'try to release'
|
20
|
+
release
|
21
|
+
::Kernel.exit
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def go
|
26
|
+
handle_exception do
|
27
|
+
app.allocate
|
28
|
+
app.action :all
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def build_image
|
33
|
+
handle_exception do
|
34
|
+
app.allocate
|
35
|
+
app.build_image
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_server
|
40
|
+
handle_exception do
|
41
|
+
app.allocate
|
42
|
+
app.deploy
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def handle_exception
|
47
|
+
yield
|
48
|
+
rescue => e
|
49
|
+
RunOption[:keep] = true if e.is_a?(ExecutionError)
|
50
|
+
if e.is_a?(ExecutionError) && !debug?
|
51
|
+
data = eval(e.message)
|
52
|
+
RunLogger.level(1).err "Execute fail: #{data[:status]}"
|
53
|
+
RunLogger.level(1).err "-> #{data[:errmsg]}"
|
54
|
+
else
|
55
|
+
debug? ? binding.pry : raise(e)
|
56
|
+
end
|
57
|
+
ensure
|
58
|
+
if keep?
|
59
|
+
store_resource
|
60
|
+
else
|
61
|
+
release
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def debug?
|
66
|
+
RunOption.key? :debug
|
67
|
+
end
|
68
|
+
|
69
|
+
def keep?
|
70
|
+
RunOption.key? :keep
|
71
|
+
end
|
72
|
+
|
73
|
+
def store_resource
|
74
|
+
resource = app.dump
|
75
|
+
File.write '.larrow.resource', YAML.dump(resource)
|
76
|
+
RunLogger.title 'store resource'
|
77
|
+
end
|
78
|
+
|
79
|
+
def release
|
80
|
+
RunLogger.title 'release resource'
|
81
|
+
begin_at = Time.new
|
82
|
+
if app && app.node
|
83
|
+
app.node.destroy if @state != :release
|
84
|
+
end
|
85
|
+
during = sprintf('%.2f', Time.new - begin_at)
|
86
|
+
RunLogger.level(1).detail "released(#{during}s)"
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.resource
|
90
|
+
resource_iterator do |clazz, array|
|
91
|
+
RunLogger.detail clazz.name.split("::").last
|
92
|
+
clazz.show array, 1
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.cleanup
|
97
|
+
resource_iterator do |clazz, array|
|
98
|
+
clazz.cleanup array
|
99
|
+
end
|
100
|
+
RunLogger.title 'resource cleaned'
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.resource_iterator
|
104
|
+
resource = YAML.load(File.read '.larrow.resource') rescue nil
|
105
|
+
return if resource.nil?
|
106
|
+
resource.each_pair do |k,array|
|
107
|
+
case k
|
108
|
+
when :nodes
|
109
|
+
yield Model::Node, array
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Larrow::Runner::Manifest
|
2
|
+
class Larrow < BaseLoader
|
3
|
+
def config_file
|
4
|
+
source_accessor.larrow_file || '.larrow.yml'
|
5
|
+
end
|
6
|
+
|
7
|
+
# TODO manifest validation
|
8
|
+
def parse content
|
9
|
+
data = YAML.load(content).with_indifferent_access
|
10
|
+
if data.is_a? Array # stages as a Array
|
11
|
+
# TODO
|
12
|
+
elsif data.is_a? Hash # steps as a Hash
|
13
|
+
configuration.image = data[:image]
|
14
|
+
Configuration::DEFINED_GROUPS[:custom].each do |title|
|
15
|
+
v = data[title]
|
16
|
+
build_step title,v if v
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_step title, lines
|
22
|
+
source_dir = if title == :init
|
23
|
+
nil
|
24
|
+
else
|
25
|
+
configuration.source_dir
|
26
|
+
end
|
27
|
+
scripts = lines.map{|s| Script.new s, base_dir: source_dir}
|
28
|
+
configuration.put_to_step title, scripts
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Larrow::Runner::Manifest
|
4
|
+
class Travis < BaseLoader
|
5
|
+
CONFIG_FILE='.travis.yml'
|
6
|
+
attr_accessor :data
|
7
|
+
|
8
|
+
def parse content
|
9
|
+
self.data = YAML.load(content).with_indifferent_access
|
10
|
+
build_language
|
11
|
+
map_step :prepare, :before_script
|
12
|
+
map_step :functional_test, :script
|
13
|
+
end
|
14
|
+
|
15
|
+
def map_step title, travis_title
|
16
|
+
source_dir = configuration.source_dir
|
17
|
+
scripts = (data[travis_title] || []).map do |cmd|
|
18
|
+
Script.new cmd, base_dir: source_dir
|
19
|
+
end
|
20
|
+
return nil if scripts.empty?
|
21
|
+
|
22
|
+
configuration.put_to_step title, scripts
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_language
|
26
|
+
return if data[:language].nil?
|
27
|
+
clazz = eval data[:language].camelize
|
28
|
+
clazz.fulfill(data,configuration)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
class Erlang
|
32
|
+
TEMPLATE_PATH='/opt/install/erlang/%s'
|
33
|
+
def self.fulfill data, configuration
|
34
|
+
revision = case data[:otp_release].last
|
35
|
+
when /R15/ then 'R15B03'
|
36
|
+
when /R16/ then 'R16B03'
|
37
|
+
when /17/ then '17.1'
|
38
|
+
end rescue '17'
|
39
|
+
install_dir = sprintf(TEMPLATE_PATH,revision.downcase)
|
40
|
+
lines = <<-EOF
|
41
|
+
echo '-s' >> .curlrc
|
42
|
+
curl https://raw.githubusercontent.com/spawngrid/kerl/master/kerl -o /usr/local/bin/kerl
|
43
|
+
chmod a+x /usr/local/bin/kerl
|
44
|
+
kerl update releases
|
45
|
+
kerl build #{revision} #{revision}
|
46
|
+
kerl install #{revision} #{install_dir}
|
47
|
+
echo 'source #{install_dir}/activate' >> $HOME/.bashrc
|
48
|
+
EOF
|
49
|
+
lines.split(/\n/).each do |line|
|
50
|
+
s = Script.new line
|
51
|
+
configuration.put_to_step :init, s
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Ruby
|
57
|
+
def self.fulfill data, configuration
|
58
|
+
return unless data[:rvm] # only rvm is supported for ruby
|
59
|
+
version = data[:rvm].last
|
60
|
+
lines = <<-EOF
|
61
|
+
echo '-s' >> .curlrc
|
62
|
+
curl -sSL https://get.rvm.io | bash -s stable
|
63
|
+
echo 'source /etc/profile.d/rvm.sh' >> .bashrc
|
64
|
+
rvm install #{version}
|
65
|
+
EOF
|
66
|
+
lines.split(/\n/).each do |line|
|
67
|
+
s = Script.new line
|
68
|
+
configuration.put_to_step :init, s
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Larrow::Runner::Manifest
|
2
|
+
class BaseLoader
|
3
|
+
attr_accessor :source_accessor,:configuration
|
4
|
+
def initialize source_accessor
|
5
|
+
self.source_accessor = source_accessor
|
6
|
+
end
|
7
|
+
|
8
|
+
def load
|
9
|
+
content = source_accessor.get config_file
|
10
|
+
return nil if content.nil?
|
11
|
+
|
12
|
+
self.configuration = Configuration.new
|
13
|
+
parse content
|
14
|
+
self.configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def config_file
|
18
|
+
self.class.const_get('CONFIG_FILE')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|