pipely-generators 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 027a3c870e6754434a2760a0a7f5cc15f0916196
4
+ data.tar.gz: 44de677290bbffaa02e061849c399d8026ca7b9d
5
+ SHA512:
6
+ metadata.gz: 321c1fb57252994570c39e7f3093b0f165629cb51dd08fd7ca404fe296d9d9781cd1d81e65f462a68737cf3f3662a95f39a3bae0745155c0e423ba2732302c94
7
+ data.tar.gz: f55423acc0a81f970b12a25970b8f7e2d19d3cf1fab20b07882b35705096769f759aa56e2a776a9a4ee6e8064b8cfccc65c5b29120fd5db179f92869eab59c85
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pipely-generators.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Matt Gillooly
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,29 @@
1
+ # Pipely::Generators
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'pipely-generators'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pipely-generators
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ begin
6
+ require 'bundler/setup'
7
+ rescue LoadError
8
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
9
+ end
10
+
11
+ Bundler::GemHelper.install_tasks
12
+
13
+ require 'cane/rake_task'
14
+
15
+ Cane::RakeTask.new(:quality) do |cane|
16
+ cane.canefile = '.cane'
17
+ end
18
+
19
+ task :default => [:quality]
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'active_support/core_ext/string/inflections'
5
+
6
+ class PipelyGenerator < Thor::Group
7
+ include Thor::Actions
8
+
9
+ # Define arguments and options
10
+ argument :name
11
+ class_option :config, :default => "~/.pipely-generate/config/"
12
+
13
+ def self.source_root
14
+ File.join(File.dirname(__FILE__), '..', 'templates')
15
+ end
16
+
17
+ def create_gemfile
18
+ copy_file "Gemfile", "#{name}/Gemfile"
19
+ end
20
+
21
+ def create_rakefile
22
+ copy_file "Rakefile", "#{name}/Rakefile"
23
+ end
24
+
25
+ def create_template
26
+ directory "lib", "#{name}/lib"
27
+ directory "templates", "#{name}/templates"
28
+ directory "script", "#{name}/script"
29
+ directory "steps", "#{name}/steps"
30
+ end
31
+
32
+ def create_config
33
+ config_path = File.expand_path(options[:config])
34
+ config_path = "config" unless File.directory?(config_path)
35
+
36
+ directory config_path, "#{name}/config"
37
+ end
38
+
39
+ end
40
+
41
+ PipelyGenerator.start(ARGV)
@@ -0,0 +1,5 @@
1
+ module Pipely
2
+ module Generators
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "pipely/generators/version"
2
+
3
+ module Pipely
4
+ module Generators
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pipely/generators/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pipely-generators"
8
+ spec.version = Pipely::Generators::VERSION
9
+ spec.authors = ["Matt Gillooly"]
10
+ spec.email = ["matt@swipely.com"]
11
+ spec.description = %q{Helpers for generating new Pipely projects}
12
+ spec.summary = %q{Helpers for generating new Pipely projects}
13
+ spec.homepage = "http://github.com/swipely/pipely-generators"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "cane"
24
+ spec.add_dependency "thor"
25
+ end
data/templates/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ if !File.exists?('packed_flag')
2
+ source 'https://rubygems.org'
3
+ end
4
+
5
+ gem 'fog'
6
+ gem "rake", '~> 10.1.0'
7
+ gem "streamingly", '~> 0.0.4'
8
+ gem "pipely", '~> 0.2.1'
9
+
10
+ group :development, :test do
11
+ gem "rspec"
12
+ end
@@ -0,0 +1,51 @@
1
+ require 'fog'
2
+ require 'rake'
3
+ require 'rspec/core/rake_task'
4
+ require 'pipely/tasks'
5
+ require_relative 'lib/template'
6
+
7
+ RSpec::Core::RakeTask.new do |t|
8
+ t.pattern = File.join(File.dirname(__FILE__), 'spec', '**', '*_spec.rb')
9
+ end
10
+
11
+ template = Template.new
12
+ environment = ENV['env'] || 'staging'
13
+
14
+ definition = Pipely::Build.build_definition(
15
+ template,
16
+ environment,
17
+ File.join(File.dirname(__FILE__), 'config', 'config.yml')
18
+ )
19
+
20
+ Pipely::Tasks::UploadSteps.new do |t|
21
+ t.s3_path = definition.s3_prefix
22
+ t.s3_bucket_name = definition.s3_path_builder.steps_bucket
23
+ t.local_path = File.join(File.dirname(__FILE__), 'steps')
24
+ end
25
+
26
+ Pipely::Tasks::Deploy.new do |t|
27
+ t.definition = definition
28
+ end
29
+
30
+ Pipely::Tasks::Graph.new do |t|
31
+ t.definition = definition
32
+ end
33
+
34
+ Pipely::Tasks::Definition.new do |t|
35
+ t.definition = definition
36
+ end
37
+
38
+ namespace :build do
39
+ desc "Copy pipeline definitions to dist/"
40
+ task :dist do
41
+ dist_dir = File.join(File.dirname(__FILE__), 'dist')
42
+ mkdir_p(dist_dir)
43
+
44
+ Rake::Task["definition"].invoke(dist_dir)
45
+ end
46
+
47
+ desc "Run all tests for CI"
48
+ task :continuous => [:spec, :dist]
49
+ end
50
+
51
+ task :default => :spec
@@ -0,0 +1,27 @@
1
+ --- !map:HashWithIndifferentAccess
2
+
3
+ common: &common
4
+ name: <%= name.camelize %>
5
+ namespace: <%= name %>
6
+
7
+ s3:
8
+ logs: 'bucket-of-logs'
9
+ steps: 'bucket-of-steps'
10
+ assets: 'bucket-of-assets'
11
+
12
+ security_groups:
13
+ - 'such-secure'
14
+
15
+ database_config:
16
+ swipely:
17
+ database: 'database'
18
+ username: 'username'
19
+ password: 'password'
20
+ port: '3306'
21
+ host: 'my.db.host'
22
+
23
+ staging:
24
+ <<: *common
25
+
26
+ production:
27
+ <<: *common
@@ -0,0 +1,33 @@
1
+ require 'pipely/build'
2
+
3
+ class Template < Pipely::Build::Template
4
+
5
+ DEFINITION_PATH = File.join(File.dirname(__FILE__), '..', 'templates', 'pipeline.json.erb')
6
+ LOCAL_STEPS_PATH = File.join(File.dirname(__FILE__), '..', 'steps')
7
+
8
+ def initialize
9
+ super(File.read(DEFINITION_PATH))
10
+ end
11
+
12
+ def s3_step_path(filename)
13
+ ensure_step_file_exists(filename)
14
+ s3_step_prefix + filename
15
+ end
16
+
17
+ private
18
+
19
+ def s3n_step_path(path)
20
+ if '/' == path[0]
21
+ ensure_step_file_exists(path)
22
+ s3n_step_prefix + path
23
+ else
24
+ path
25
+ end
26
+ end
27
+
28
+ def ensure_step_file_exists(filename)
29
+ full_path = File.join(LOCAL_STEPS_PATH, filename)
30
+ raise "Missing step file: #{full_path}" unless File.exist?(full_path)
31
+ end
32
+
33
+ end
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ rm -rf tmp
4
+
5
+ [ -z "$BUNDLE_INSTALL" ] && BUNDLE_INSTALL="bundle install"
6
+
7
+ $BUNDLE_INSTALL
8
+
@@ -0,0 +1,54 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ # Install rbenv
6
+ curl --silent -L https://github.com/sstephenson/rbenv/archive/master.zip -o ~/rbenv.zip
7
+ unzip ~/rbenv.zip -d ~
8
+ mv ~/rbenv-master ~/rbenv
9
+ ln -s ~/rbenv ~/.rbenv
10
+ rm -rf ~/rbenv/versions
11
+
12
+ # Set up rbenv
13
+ export PATH="~/rbenv/bin:$PATH"
14
+ eval "$(rbenv init -)"
15
+ rbenv rehash
16
+ rbenv global 1.9.3-p327
17
+
18
+ # Set up rbenv for future logins
19
+ cat >> ~/.bash_profile << 'EOF'
20
+ if [ -d ~/rbenv ]; then
21
+ export PATH="~/rbenv/bin:$PATH"
22
+ eval "$(rbenv init -)"
23
+ fi
24
+ EOF
25
+
26
+ # Install bundler
27
+ gem install bundler --no-ri --no-rdoc
28
+ rbenv rehash
29
+
30
+ # Set up ssh access
31
+ if [ ! -f ~/.ssh/id_rsa ]; then
32
+ mkdir -p ~/.ssh
33
+ ssh-keygen -P '' -f ~/.ssh/id_rsa
34
+ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
35
+ chmod 600 ~/.ssh/authorized_keys
36
+ fi
37
+
38
+ # Use ssh to bypass the sudo "require tty" setting
39
+ ssh -o "StrictHostKeyChecking no" -t -t ec2-user@localhost <<- EOF
40
+ sudo su -;
41
+ yum -y install gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel make mysql mysql-devel;
42
+ ln -s /home/ec2-user/rbenv ~/rbenv;
43
+ ln -s /home/ec2-user/rbenv ~/.rbenv;
44
+ export PATH="/home/ec2-user/rbenv/bin:\$PATH";
45
+ eval "\$(rbenv init -)";
46
+ exit;
47
+ exit;
48
+ EOF
49
+ # ^^^ Double exit above is on purpose. (1) exit su, (2) exit ssh.
50
+
51
+ # Install fog. Has to happen after libxml2-devel
52
+ rbenv rehash
53
+ gem install fog --no-ri --no-rdoc
54
+ rbenv rehash
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ sudo apt-get -y install rubygems
3
+ sudo gem install streamingly --no-ri --no-rdoc --source http://rubygems.org
4
+
5
+ # TODO: install any gems that will be needed by streaming EMR activities
6
+
7
+ exit
@@ -0,0 +1,93 @@
1
+ {
2
+ "objects": [
3
+ {
4
+ "id": "Default",
5
+ "role": "role-aggregator",
6
+ "resourceRole": "role-aggregator",
7
+ "failureAndRerunMode": "cascade",
8
+ "scheduleType": "cron",
9
+ "onFail": { "ref": "FailureNotify" }
10
+ },
11
+
12
+ {
13
+ "id": "Nightly",
14
+ "type": "Schedule",
15
+ "startDateTime": "<%%= start_date_time %>",
16
+ "period": "<%%= period %>"
17
+ },
18
+
19
+ {
20
+ "id": "SuccessNotify",
21
+ "type": "SnsAlarm",
22
+ "topicArn": "<%%= arn_topic %>",
23
+ "subject": "[<%%= environment %> pipelines] SUCCESS: <%= name.camelize %> pipeline step #{node.name}",
24
+ "message": "<%= name.camelize %> pipeline step SUCCESS\n\nScheduled start: #{node.@scheduledStartTime}\nActual start: #{node.@actualStartTime}\nActual end:\n#{node.@actualEndTime}"
25
+ },
26
+
27
+ {
28
+ "id": "FailureNotify",
29
+ "type": "SnsAlarm",
30
+ "topicArn": "<%%= arn_topic %>",
31
+ "subject": "[<%%= environment %> pipelines] FAILURE: <%= name.camelize %> pipeline step #{node.name}",
32
+ "message": "<%= name.camelize %> pipeline step FAILED #{node.name}\n\nScheduled start: #{node.@scheduledStartTime}\nError message:\n#{node.errorMessage}\nError stack trace:\n#{node.errorStackTrace}"
33
+ },
34
+
35
+ {
36
+ "id": "<%= name.camelize %>EC2Resource",
37
+ "type": "Ec2Resource",
38
+ "instanceType": "m1.large",
39
+ "schedule": { "ref": "Nightly" },
40
+ "logUri": "<%%= s3_log_prefix %>/<%= name.camelize %>EC2Resource",
41
+ "terminateAfter": "6 hours",
42
+ "keyPair": "pipeline-debug",
43
+ "securityGroups": <%%= security_groups %>
44
+ },
45
+
46
+ {
47
+ "id": "<%= name.camelize %>EMRCluster",
48
+ "type": "EmrCluster",
49
+ "masterInstanceType": "m1.large",
50
+ "taskInstanceType": "m1.large",
51
+ "coreInstanceType": "m1.large",
52
+ "coreInstanceCount": "2",
53
+ "terminateAfter": "6 hours",
54
+ "schedule": { "ref": "Nightly" },
55
+ "enableDebugging": "true",
56
+ "bootstrapAction": "<%%= s3_step_path('/bootstrap_emr.sh') %>",
57
+ "emrLogUri": "<%%= s3_log_prefix %>/<%= name.camelize %>EMRLogs",
58
+ "logUri": "<%%= s3_log_prefix %>/<%= name.camelize %>EMRCluster"
59
+ },
60
+
61
+ {
62
+ "id": "BootstrapEnvironment",
63
+ "type": "ShellCommandActivity",
64
+ "onFail": { "ref": "FailureNotify" },
65
+ "stdout": "<%%= s3_log_prefix %>/BootstrapEnvironment/stdout",
66
+ "stderr": "<%%= s3_log_prefix %>/BootstrapEnvironment/stderr",
67
+ "schedule": { "ref": "Nightly" },
68
+ "runsOn": { "ref": "<%= name.camelize %>EC2Resource" },
69
+ "scriptUri": "<%%= s3_step_path('/bootstrap_ec2.sh') %>"
70
+ },
71
+
72
+ {
73
+ "id": "TouchEMRCluster",
74
+ "type": "ShellCommandActivity",
75
+ "onFail": { "ref": "FailureNotify" },
76
+ "schedule": { "ref": "Nightly" },
77
+ "runsOn": { "ref": "<%= name.camelize %>EMRCluster" },
78
+ "command": "true"
79
+ },
80
+
81
+ {
82
+ "id": "Complete",
83
+ "type": "ShellCommandActivity",
84
+ "onFail": { "ref": "FailureNotify" },
85
+ "schedule": { "ref": "Nightly" },
86
+ "onSuccess": { "ref": "SuccessNotify" },
87
+ "runsOn": { "ref": "<%= name.camelize %>EC2Resource" },
88
+ "dependsOn": { "ref": "TouchEMRCluster" },
89
+ "command": "true"
90
+ }
91
+
92
+ ]
93
+ }
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pipely-generators
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matt Gillooly
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cane
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Helpers for generating new Pipely projects
70
+ email:
71
+ - matt@swipely.com
72
+ executables:
73
+ - pipely-generate
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/pipely-generate
83
+ - lib/pipely/generators.rb
84
+ - lib/pipely/generators/version.rb
85
+ - pipely-generators.gemspec
86
+ - templates/Gemfile
87
+ - templates/Rakefile
88
+ - templates/config/config.yml.tt
89
+ - templates/lib/template.rb
90
+ - templates/script/build_bootstrap
91
+ - templates/steps/bootstrap_ec2.sh
92
+ - templates/steps/bootstrap_emr.sh
93
+ - templates/templates/pipeline.json.erb.tt
94
+ homepage: http://github.com/swipely/pipely-generators
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.0.14
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Helpers for generating new Pipely projects
118
+ test_files: []