pushapp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
1
+ # Pushapp Configuration File
2
+
3
+ # Sample remote definition:
4
+ #
5
+ # remote <remote_name>, <app_location>, [options]
6
+ #
7
+ # The options provided in the target definition will override any
8
+ # options provided in the task call.
9
+ #
10
+ # You can specify multiple remotes in groups
11
+ #
12
+ # group(:production, env: {RAILS_ENV: 'production'})do
13
+ # remote :web, 'app@server1:/home/app/app',
14
+ # web: true, db: true
15
+ #
16
+ # remote :worker, 'app@server2:/home/app/app',
17
+ # worker: true
18
+ # end
19
+
20
+ remote 'staging', 'app@server3:/home/app/app-staging',
21
+ web:true, db: true, env: {RAILS_ENV: 'staging'}
22
+
23
+ on :setup do
24
+ rake('db:create db:migrate db:seed') if options[:db]
25
+ end
26
+
27
+ on :push do
28
+ rake('db:migrate') if options[:db]
29
+ rake('precompile:assets', env: {RAILS_GROUP: :assets}) if options[:web]
30
+ end
@@ -0,0 +1,4 @@
1
+ <%= load_template 'hook/setup' %>
2
+ <%= load_template 'hook/git-reset' %>
3
+ <%= load_template 'hook/bundler' %>
4
+ <%= load_template 'hook/tasks' %>
@@ -0,0 +1,3 @@
1
+ <%= info "Bundling gems" %>
2
+ bundle --deployment --quiet --without test <%= colorize %>
3
+
@@ -0,0 +1,10 @@
1
+ while read oldrev newrev refname
2
+ do
3
+ # Reset so we dont have unstaged changes... and then checkout the pushed ref
4
+ <%= info "Doing a hard reset and checking out #\{ARGV[0]\} since thats what you pushed" %> $refname
5
+ git reset --hard HEAD <%= colorize %>
6
+ git checkout $refname <%= colorize %>
7
+ done
8
+
9
+ unset GIT_DIR
10
+ unset GIT_WORK_TREE
@@ -0,0 +1,11 @@
1
+ #!/bin/bash -l
2
+
3
+ PAP_REMOTE="<%= @remote.full_name %>";
4
+ export PAP_PRE="<%= prefix %>";
5
+
6
+
7
+ <%= info "ENTERING POST RECEIVE HOOK FOR: #{@remote.full_name}" %>
8
+
9
+ cd ..
10
+ GIT_DIR='.git'
11
+
@@ -0,0 +1 @@
1
+ bundle exec pushapp trigger push $PAP_REMOTE --local true <%= colorize %>
File without changes
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+ require 'pushapp/cli'
3
+
4
+ class CLITest < MiniTest::Unit::TestCase
5
+
6
+ def setup
7
+ @cli = Pushapp::CLI.new
8
+ end
9
+
10
+ def test_it_has_init_method
11
+ @cli.respond_to? :init
12
+ end
13
+
14
+ def test_it_has_setup_method
15
+ @cli.respond_to? :setup
16
+ end
17
+
18
+ def test_it_has_update_method
19
+ @cli.respond_to? :update
20
+ end
21
+
22
+ def test_it_has_help_method
23
+ @cli.respond_to? :help
24
+ end
25
+
26
+ end
27
+
@@ -0,0 +1,82 @@
1
+ require 'test_helper'
2
+ require 'pushapp/config'
3
+ require 'pushapp/tasks/foreman_export'
4
+
5
+ class ConfigTest < MiniTest::Unit::TestCase
6
+
7
+ def setup
8
+ @config = Pushapp::Config.new
9
+ end
10
+
11
+ def test_takes_the_path_of_the_config_file_as_an_argument
12
+ config = Pushapp::Config.new('/some/where/config.rb')
13
+ assert_equal '/some/where/config.rb', config.file
14
+ end
15
+
16
+ def test_takes_the_default_config_path_if_no_path_is_specified
17
+ config = Pushapp::Config.new
18
+ assert_equal 'config/pushapp.rb', config.file
19
+ end
20
+
21
+ def test_parse_returns_a_config_object
22
+ assert Pushapp::Config === Pushapp::Config.parse('test/fixtures/empty_config.rb')
23
+ end
24
+
25
+ def test_remotes_dsl
26
+ @config.remote :dev, 'app@host:/home/app/app-dev'
27
+
28
+ assert_equal 1, @config.remotes.length
29
+ assert_equal 'dev', @config.remotes.first.name
30
+ end
31
+
32
+ def test_it_can_group_remotes
33
+ @config.group :dev do
34
+ remote :web, 'app@host1:/home/app/app-dev1'
35
+ remote :worker, 'app@host1:/home/app/app-dev2'
36
+ remote :mailer, 'app@host2:/home/app/app-dev1'
37
+ end
38
+
39
+ assert_equal 3, @config.remotes.length
40
+ @config.remotes.each do |r|
41
+ assert Pushapp::Remote === r
42
+ end
43
+
44
+ assert_equal 'dev-web', @config.remotes[0].full_name
45
+ assert_equal 'dev-worker', @config.remotes[1].full_name
46
+ assert_equal 'dev-mailer', @config.remotes[2].full_name
47
+ end
48
+
49
+ def test_it_cant_have_remotes_with_same_name_and_location
50
+ @config.remote :dev, 'app@host:/home/app/app-dev'
51
+ assert_raises RuntimeError do
52
+ @config.remote :dev, 'app@host:/home/app/app-dev'
53
+ end
54
+ end
55
+
56
+ def test_it_adds_tasks_to_all_remotes
57
+ @config.remote :dev, 'app@host:/home/app/app-dev'
58
+ @config.remote :prod, 'app@host:/home/app/app-prod'
59
+
60
+ @config.on :setup do
61
+ rake 'db:create db:migrate db:seed'
62
+ end
63
+
64
+ @config.on :update do
65
+ rake 'assets_precompile', env: {rails_group: 'assets'}
66
+ task :foreman_export
67
+ end
68
+
69
+ dev = @config.remotes_named_by(:dev).first
70
+ prod = @config.remotes_named_by(:prod).first
71
+
72
+ assert_equal 1, dev.tasks_on(:setup).length
73
+ assert_equal 1, prod.tasks_on(:setup).length
74
+
75
+ assert_equal 2, dev.tasks_on(:update).length
76
+ assert_equal 2, prod.tasks_on(:update).length
77
+
78
+ assert_equal 0, dev.tasks_on(:push).length
79
+ assert_equal 0, prod.tasks_on(:push).length
80
+ end
81
+ end
82
+
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+ require 'pushapp/git'
3
+
4
+ class GitTest < MiniTest::Unit::TestCase
5
+
6
+ def setup
7
+ @git = Pushapp::Git.new
8
+ end
9
+
10
+ def test_it_list_repos
11
+
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+ require 'pushapp/pipe'
3
+
4
+ class PipeTest < MiniTest::Unit::TestCase
5
+
6
+ def test_it_runs_commands
7
+ Pushapp::Pipe.run 'pwd'
8
+ end
9
+
10
+ def test_it_raise_exception_if_command_fails
11
+ assert_raises Errno::ENOENT do
12
+ Pushapp::Pipe.run 'unknown command'
13
+ end
14
+
15
+ assert_raises Errno::ENOENT do
16
+ Pushapp::Pipe.capture 'unknown command'
17
+ end
18
+
19
+ assert_raises RuntimeError do
20
+ Pushapp::Pipe.run 'exit 5'
21
+ end
22
+ end
23
+
24
+ def test_it_captures_output
25
+ assert_equal "nice\n", Pushapp::Pipe.capture("echo 'nice'")
26
+ end
27
+
28
+ end
29
+
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+ require 'pushapp'
3
+
4
+ class PushappTest < MiniTest::Unit::TestCase
5
+
6
+ def test_rmerge_with_empty_values
7
+ assert_equal({}, Pushapp.rmerge(nil, nil))
8
+ assert_equal({}, Pushapp.rmerge({}, nil))
9
+ assert_equal({}, Pushapp.rmerge(nil, {}))
10
+ end
11
+
12
+ def test_rmerge_with_plain_hashes
13
+ assert_equal({a: 1, b: 2}, Pushapp.rmerge({a: 1}, {b: 2}))
14
+ assert_equal({a: 1, b: 2}, Pushapp.rmerge({a: 1, b: 2}, {}))
15
+ assert_equal({a: 1, b: 2}, Pushapp.rmerge({}, {a: 1, b: 2}))
16
+ end
17
+
18
+ def test_rmerge_with_nested_hashes
19
+ assert_equal({a: {b: 1, c: 2}}, Pushapp.rmerge({}, {a: {b: 1, c: 2}}))
20
+ assert_equal({a: {b: 1, c: 2}}, Pushapp.rmerge({a: {b: 1, c: 2}}, {}))
21
+ assert_equal({a: {b: 1, c: 2}}, Pushapp.rmerge({a: {b: 1}}, {a: {c: 2}}))
22
+
23
+ assert_equal({a: {b: 1, c: 2}}, Pushapp.rmerge({a: {b: 2}}, {a: {b: 1, c: 2}}))
24
+ end
25
+ end
26
+
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'pushapp'
3
+
4
+ require 'minitest/autorun'
5
+ require 'minitest/unit'
6
+ require 'minitest/pride'
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pushapp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yury Korolev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
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: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Push your App
70
+ email:
71
+ - yurykorolev@me.com
72
+ executables:
73
+ - pushapp
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - .travis.yml
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/pushapp
84
+ - lib/pushapp.rb
85
+ - lib/pushapp/cli.rb
86
+ - lib/pushapp/commands.rb
87
+ - lib/pushapp/config.rb
88
+ - lib/pushapp/git.rb
89
+ - lib/pushapp/hook.rb
90
+ - lib/pushapp/logger.rb
91
+ - lib/pushapp/pipe.rb
92
+ - lib/pushapp/remote.rb
93
+ - lib/pushapp/tasks/base.rb
94
+ - lib/pushapp/tasks/foreman_export.rb
95
+ - lib/pushapp/tasks/rake.rb
96
+ - lib/pushapp/tasks/script.rb
97
+ - lib/pushapp/version.rb
98
+ - pushapp.gemspec
99
+ - templates/config.rb.erb
100
+ - templates/hook/base.erb
101
+ - templates/hook/bundler.erb
102
+ - templates/hook/git-reset.erb
103
+ - templates/hook/setup.erb
104
+ - templates/hook/tasks.erb
105
+ - test/fixtures/empty_config.rb
106
+ - test/pushapp/cli_test.rb
107
+ - test/pushapp/config_test.rb
108
+ - test/pushapp/git_test.rb
109
+ - test/pushapp/pipe_test.rb
110
+ - test/pushapp_test.rb
111
+ - test/test_helper.rb
112
+ homepage: https://github.com/anjlab/pushapp
113
+ licenses:
114
+ - MIT
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 2.0.3
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: Push your App
136
+ test_files:
137
+ - test/fixtures/empty_config.rb
138
+ - test/pushapp/cli_test.rb
139
+ - test/pushapp/config_test.rb
140
+ - test/pushapp/git_test.rb
141
+ - test/pushapp/pipe_test.rb
142
+ - test/pushapp_test.rb
143
+ - test/test_helper.rb