avodeploy 0.4.2 → 0.5

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.
@@ -17,57 +17,78 @@
17
17
  =end
18
18
 
19
19
  module AvoDeploy
20
- module ScmProvider
21
- class GitScmProvider
20
+ module ScmProvider
21
+ class GitScmProvider < ScmProvider
22
22
 
23
- # Initializes the provider
24
- #
25
- # @param env [TaskExecutionEnvironment] Environment for the commands to be executed in
26
- def initialize(env)
27
- raise ArgumentError, "env must be a TaskExecutionEnvironment" unless env.kind_of?(AvoDeploy::Task::TaskExecutionEnvironment)
23
+ # Initializes the provider
24
+ #
25
+ # @param env [TaskExecutionEnvironment] Environment for the commands to be executed in
26
+ def initialize(env)
27
+ super(env)
28
+ end
28
29
 
29
- @env = env
30
- end
31
-
32
- # Checks out repository code from a system and switches to the given branch
33
- #
34
- # @param url [String] the repository location
35
- # @param local_dir [String] path to the working copy
36
- # @param branch [String] the branch to check out
37
- def checkout_from_remote(url, local_dir, branch)
38
- res = @env.command("git clone #{url} #{local_dir}")
39
- raise RuntimeError, "Could not clone from git url #{url}" unless res.retval == 0
30
+ # Checks out repository code from a system and switches to the given branch
31
+ #
32
+ # @param url [String] the repository location
33
+ # @param local_dir [String] path to the working copy
34
+ # @param branch [String] the branch to check out
35
+ # @param tag [String] tag to check out
36
+ def checkout_from_remote(url, local_dir, branch, tag = nil)
37
+ res = @env.command("git clone #{url} #{local_dir}")
38
+ raise RuntimeError, "Could not clone from git url #{url}" unless res.retval == 0
40
39
 
41
- @env.chdir(local_dir)
42
- res = @env.command("git checkout #{branch}")
43
- @env.chdir('../')
44
-
45
- raise RuntimeError, "could not switch to branch #{branch}" unless res.retval == 0
46
- end
40
+ branch = tag if tag.nil? == false
47
41
 
48
- # Returns the current revision of the working copy
49
- #
50
- # @return [String] the current revision of the working copy
51
- def revision
52
- res = @env.command("git rev-parse HEAD")
42
+ @env.chdir(local_dir)
43
+ res = @env.command("git checkout #{branch}")
44
+ @env.chdir('../')
53
45
 
54
- res.stdout.gsub("\n", "")
55
- end
46
+ raise RuntimeError, "could not switch to branch #{branch}" unless res.retval == 0
47
+ end
56
48
 
57
- # Returns scm files to be executed in the deployment process
58
- #
59
- # @return [Array] array of scm control files
60
- def scm_files
61
- [ '.git', '.gitignore' ]
62
- end
49
+ # Returns the current revision of the working copy
50
+ #
51
+ # @return [String] the current revision of the working copy
52
+ def revision
53
+ res = @env.command('git rev-parse HEAD')
54
+ res.stdout.gsub("\n", '')
55
+ end
63
56
 
64
- # Returns the scm tools that have to be installed on specific systems
65
- #
66
- # @return [Array] array of utilities
67
- def cli_utils
68
- [ 'git' ]
69
- end
57
+ # Finds files that differ between two revisions and returns them
58
+ # as a array
59
+ #
60
+ # @param rev1 [String] sha1
61
+ # @param rev2 [String] sha1
62
+ #
63
+ # @return [Array]
64
+ def diff_files_between_revisions(rev1, rev2)
65
+ res = @env.command("git diff --name-only #{rev1} #{rev2}")
66
+ res.stdout.lines
67
+ end
70
68
 
71
- end
72
- end
69
+ # Finds files unknown file in the working directory and returns them
70
+ # as a array
71
+ #
72
+ # @return [Array]
73
+ def unknown_files_in_workdir
74
+ res = @env.command("git status -s | grep '^??' | awk '/^?? (.*)$/ {print $2}'")
75
+ res.stdout.lines
76
+ end
77
+
78
+ # Returns scm files to be executed in the deployment process
79
+ #
80
+ # @return [Array] array of scm control files
81
+ def scm_files
82
+ ['.git', '.gitignore']
83
+ end
84
+
85
+ # Returns the scm tools that have to be installed on specific systems
86
+ #
87
+ # @return [Array] array of utilities
88
+ def cli_utils
89
+ ['git', 'awk', 'grep']
90
+ end
91
+
92
+ end
93
+ end
73
94
  end
@@ -17,54 +17,68 @@
17
17
  =end
18
18
 
19
19
  module AvoDeploy
20
- module ScmProvider
21
- # scm provider facade
22
- class ScmProvider
20
+ module ScmProvider
21
+ # scm provider base class
22
+ class ScmProvider
23
23
 
24
- # Initializes the scm provider
25
- #
26
- # @param env [TaskExecutionEnvironment] env for the commands to be executed in
27
- # @param scm [Symbol] the scm provider to user
28
- def initialize(env, scm)
29
- raise ArgumentError, 'env must be a TaskExecutionEnvironment' unless env.is_a?(AvoDeploy::Task::TaskExecutionEnvironment)
24
+ # Initializes the scm provider
25
+ #
26
+ # @param env [TaskExecutionEnvironment] env for the commands to be executed in
27
+ def initialize(env)
28
+ raise ArgumentError, 'env must be a TaskExecutionEnvironment' unless env.is_a?(AvoDeploy::Task::TaskExecutionEnvironment)
30
29
 
31
- @env = env
32
- @real_provider = nil
30
+ @env = env
31
+ end
33
32
 
34
- if scm == :git
35
- @real_provider = GitScmProvider.new(env)
36
- end
37
- end
33
+ # Checks out repository code from a system and switches to the given branch
34
+ #
35
+ # @param url [String] the repository location
36
+ # @param local_dir [String] path to the working copy
37
+ # @param branch [String] the branch to check out
38
+ # @param tag [String] tag to check out
39
+ def checkout_from_remote(url, local_dir, branch, tag = nil)
40
+ raise NotImplementedError
41
+ end
38
42
 
39
- # Checks out repository code from a system and switches to the given branch
40
- #
41
- # @param url [String] the repository location
42
- # @param local_dir [String] path to the working copy
43
- # @param branch [String] the branch to check out
44
- def checkout_from_remote(url, local_dir, branch)
45
- @real_provider.checkout_from_remote(url, local_dir, branch)
46
- end
43
+ # Finds files that differ between two revisions and returns them
44
+ # as a array
45
+ #
46
+ # @param rev1 [String] sha1
47
+ # @param rev2 [String] sha1
48
+ #
49
+ # @return [Array]
50
+ def diff_files_between_revisions(rev1, rev2)
51
+ raise NotImplementedError
52
+ end
47
53
 
48
- # Returns the current revision of the working copy
49
- #
50
- # @return [String] the current revision of the working copy
51
- def scm_files
52
- @real_provider.scm_files
53
- end
54
+ # Finds files unknown file in the working directory and returns them
55
+ # as a array
56
+ #
57
+ # @return [Array]
58
+ def unknown_files_in_workdir
59
+ raise NotImplementedError
60
+ end
54
61
 
55
- # Returns scm files to be executed in the deployment process
56
- #
57
- # @return [Array] array of scm control files
58
- def cli_utils
59
- @real_provider.cli_utils
60
- end
62
+ # Returns the current revision of the working copy
63
+ #
64
+ # @return [String] the current revision of the working copy
65
+ def scm_files
66
+ raise NotImplementedError
67
+ end
61
68
 
62
- # Returns the scm tools that have to be installed on specific systems
63
- #
64
- # @return [Array] array of utilities
65
- def revision
66
- @real_provider.revision
67
- end
68
- end
69
- end
69
+ # Returns scm files to be executed in the deployment process
70
+ #
71
+ # @return [Array] array of scm control files
72
+ def cli_utils
73
+ raise NotImplementedError
74
+ end
75
+
76
+ # Returns the scm tools that have to be installed on specific systems
77
+ #
78
+ # @return [Array] array of utilities
79
+ def revision
80
+ raise NotImplementedError
81
+ end
82
+ end
83
+ end
70
84
  end
@@ -1,117 +1,128 @@
1
- AvoDeploy::Deployment.configure do
2
-
3
- # AVOCADO
4
- # The flexible and easy to use deployment framework for web applications
5
- #
6
- # Welcome to your deployment manifest. Here you can configure the
7
- # whole deployment process of your application to various target systems.
8
- # This is a example file that has been created by `avo install`.
9
- # While you are presented with the common configuration options for
10
- # most common use cases, there are plenty more available and you might want
11
- # to check them out. Because of the fact, that, currently, there is no
12
- # official documentation, you have to lookup all the configuration options
13
- # right in the applications' source code. But don't be afraid, you'll find
14
- # them all in one place. Just take a look in the `config.rb` file at the
15
- # method called `setup_config_defaults`.
16
- #
17
-
18
- # =============== GENERAL PROJECT CONFIGURATION ==================
19
- # Set your project name here. This is not used right now but may
20
- # be used for various purposes in future releases.
21
- #
22
- set :project_name, 'myproject'
23
-
24
- # ===================== SCM CONFIGURATION ========================
25
- # Configure the version control software you use for your project.
26
- # Currently the only supported provider is Git, but this will change
27
- # in the future.
28
- #
29
- # Valid options:
30
- # :git
31
- #
32
- set :scm, :git
33
-
34
- # This is your repository url in the following format:
35
- # username@host:repository
36
- #
37
- set :repo_url, 'foo@github.com:foo/myproject.git'
38
-
39
- # Specify the branch you'd like to deploy here. By default this is
40
- # set to :master but could be every branch you wish. If your branch
41
- # name contains special characters like slashes, just use a
42
- # string rather than a symbol.
43
- #
44
- # Examples:
45
- # :master
46
- # :develop
47
- # 'feature/AVO-123_manifest'
48
- #
49
- set :branch, :master
50
-
51
- # ==================== DEPLOYMENT STRATEGY =======================
52
- # Set your deployment strategy here. Currently only `local_copy`
53
- # is implemented. The additional configuration values depend on
54
- # the selected strategy.
55
- #
56
- # `local_copy`: Files are checked out of version control into a
57
- # local directory, eventually preprocess and then
58
- # packed (tarball), uploaded (via scp) and unpacked
59
- # on the target system.
60
- #
61
- # Valid options:
62
- # : local_copy
63
- #
64
- set :strategy, :local_copy
65
-
66
- # Files to be ignored for the deployment process. Those files will
67
- # not be overwritten on the target system
68
- #
69
- set :ignore_files, [ '.htaccess' ]
70
-
71
- # ================= ADDITIONAL TASK DEFINITION ====================
72
- # Avocado consists of a task system. Every step that is done while
73
- # the deployment process is represented as a task definition.
74
- # Due to the fact that most of the tasks depend on each other
75
- # tasks can be related into a chain of tasks. When you call a task
76
- # from the CLI utility, the whole chain for this task will be executed.
77
- # This is a powerful tool for you to customize the deployment process
78
- # for your needs. A full list of which tasks are defined and where you
79
- # can hook on to do this or that can be found in the definition of each
80
- # strategy in the `strategy/` directory.
81
- #
82
- # A basic task definition can look like that:
83
- #
84
- # task :do_that do
85
- # command "echo 'foo'"
86
- # end
87
- #
88
- # This task has no relations and therefore has to be called directly via
89
- # the CLI interface. When you call `avo start staging do_that` this task
90
- # would execute the command `echo 'foo'` LOCALLY, because no `scope` is defined.
91
- # Take a look at the following code to see a fully featured example in action.
92
- #
93
- # task :install_composer, before: :create_deployment_tarball, scope: :local, desc: "installs the composer" do
94
- # command "php composer.phar install"
95
- # end
96
-
97
- # ==================== STAGES CONFIGURATION =======================
98
- <% stages.each do |stage| %>
99
- setup_stage :<%= stage %>, desc: "Configuration for <%= stage %>" do
100
- # In this section you can overwrite every configuration choice
101
- # you have made above. You can define additional tasks, that
102
- # are only usable within the current scope or change the
103
- # repository url or branch for your current needs.
104
- #
105
-
106
- # ============== TARGET SYSTEM CONFIGURATION =================
107
- # Files are transmitted over SCP. Therefore you must configure
108
- # your target systems' SSH access credentials.
109
- #
110
-
111
- # Currently only pubkey-auth is supported
112
- #
113
- target :web, host: 'my.host.tld', user: 'deploy', auth: :pubkey, deploy_dir: '/var/www/staging/'
114
- end
115
- <% end %>
116
-
1
+ AvoDeploy::Deployment.configure do
2
+
3
+ # AVOCADO
4
+ # The flexible and easy to use deployment framework for web applications
5
+ #
6
+ # Welcome to your deployment manifest. Here you can configure the
7
+ # whole deployment process of your application to various target systems.
8
+ # This is a example file that has been created by `avo install`.
9
+ # While you are presented with the common configuration options for
10
+ # most common use cases, there are plenty more available and you might want
11
+ # to check them out. Because of the fact, that, currently, there is no
12
+ # official documentation, you have to lookup all the configuration options
13
+ # right in the applications' source code. But don't be afraid, you'll find
14
+ # them all in one place. Just take a look in the `config.rb` file at the
15
+ # method called `setup_config_defaults`.
16
+ #
17
+
18
+ # =============== GENERAL PROJECT CONFIGURATION ==================
19
+ # Set your project name here. This is not used right now but may
20
+ # be used for various purposes in future releases.
21
+ #
22
+ set :project_name, 'myproject'
23
+
24
+ # ===================== SCM CONFIGURATION ========================
25
+ # Configure the version control software you use for your project.
26
+ # Currently only Git and Bazaar are supported, but this will change
27
+ # in the future.
28
+ #
29
+ # Valid options:
30
+ # :git
31
+ # :bzr
32
+ #
33
+ set :scm, :git
34
+
35
+ # This is your repository url
36
+ #
37
+ set :repo_url, 'foo@github.com:foo/myproject.git'
38
+
39
+ # Specify the branch you'd like to deploy here. By default this is
40
+ # set to :master but could be every branch you wish. If your branch
41
+ # name contains special characters like slashes, just use a
42
+ # string rather than a symbol.
43
+ #
44
+ # Examples:
45
+ # :master
46
+ # :develop
47
+ # 'feature/AVO-123_manifest'
48
+ #
49
+ set :branch, :master
50
+
51
+ # ==================== DEPLOYMENT STRATEGY =======================
52
+ # Set your deployment strategy here. Currently only `local_copy`
53
+ # is implemented. The additional configuration values depend on
54
+ # the selected strategy.
55
+ #
56
+ # >= 0.5: To use multiple strategies, use
57
+ # `inherit_strategy :local_copy
58
+ # inherit_strategy :some_other_strategy`
59
+ #
60
+ # `local_copy`: Files are checked out of version control into a
61
+ # local directory, eventually preprocess and then
62
+ # packed (tarball), uploaded (via scp) and unpacked
63
+ # on the target system.
64
+ #
65
+ # `local_copy_partial`: Same as `local_copy` but uploads only files
66
+ # that have changed since the last deployment
67
+ # to the specific target system.
68
+ #
69
+ # Valid options:
70
+ # :local_copy
71
+ # :local_copy_partial
72
+ #
73
+ set :strategy, :local_copy
74
+
75
+ # Files to be ignored for the deployment process. Those files will
76
+ # not be overwritten on the target system
77
+ #
78
+ set :ignore_files, ['.htaccess']
79
+
80
+ # ================= ADDITIONAL TASK DEFINITION ====================
81
+ # Avocado consists of a task system. Every step that is done while
82
+ # the deployment process is represented as a task definition.
83
+ # Due to the fact that most of the tasks depend on each other
84
+ # tasks can be related into a chain of tasks. When you call a task
85
+ # from the CLI utility, the whole chain for this task will be executed.
86
+ # This is a powerful tool for you to customize the deployment process
87
+ # for your needs. A full list of which tasks are defined and where you
88
+ # can hook on to do this or that can be found in the definition of each
89
+ # strategy in the `strategy/` directory.
90
+ #
91
+ # A basic task definition can look like that:
92
+ #
93
+ # task :do_that do
94
+ # command "echo 'foo'"
95
+ # end
96
+ #
97
+ # This task has no relations and therefore has to be called directly via
98
+ # the CLI interface. When you call `avo start staging do_that` this task
99
+ # would execute the command `echo 'foo'` LOCALLY, because no `scope` is defined.
100
+ # Take a look at the following code to see a fully featured example in action.
101
+ #
102
+ # task :install_composer, before: :create_deployment_tarball, scope: :local, desc: "installs the composer" do
103
+ # command "php composer.phar install"
104
+ # end
105
+
106
+ # ==================== STAGES CONFIGURATION =======================
107
+
108
+ <% stages.each do |stage| %>
109
+ setup_stage :<%= stage %>, desc: "Configuration for '<%= stage %>'" do
110
+ # In this section you can overwrite every configuration choice
111
+ # you have made above. You can define additional tasks, that
112
+ # are only usable within the current scope or change the
113
+ # repository url or branch for your current needs.
114
+ #
115
+
116
+ # ============== TARGET SYSTEM CONFIGURATION =================
117
+ # Files are transmitted over SCP. Therefore you must configure
118
+ # your target systems' SSH access credentials.
119
+ #
120
+
121
+ # Currently only pubkey-auth is supported
122
+ #
123
+ target :web, host: 'my.host.tld', port: 22, user: 'deploy', auth: :pubkey, deploy_dir: '/var/www/staging/'
124
+ end
125
+ <% end %>
126
+
127
+
117
128
  end