capistrano-stopwatch 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 +11 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +143 -0
- data/Rakefile +6 -0
- data/capistrano-stopwatch.gemspec +21 -0
- data/lib/capistrano/stopwatch.rb +1 -0
- data/lib/capistrano/stopwatch/stopwatch.rb +1 -0
- data/lib/capistrano/tasks/stopwatch.rake +52 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d40f306569044f14b61f564b95015268db06a7a414df135f4f93104df9718f50
|
4
|
+
data.tar.gz: 7f19751aa93bdea498de242180c728db833038262f929125184e764ef92f908e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8b069d78a042c4d4aec02d6c461c899a5eb4b5955051d7c967a13dfcd62b2aaaacc1b3ad80967d953a7d48f4b8a13309bf600342e2dc9c89af17e7d0993e003c
|
7
|
+
data.tar.gz: 491a9b2acee78e44329e6a76327e88ccda9b678dcc0ea5948681410d1032de9da7b2d2b32c143ce598df2c9c8639fb75e3b4b26e978b09f2d820d77fe1657794
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at shuhei.kitagawa@c-fo.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Shuhei Kitagawa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
# Capistrano::Stopwatch
|
2
|
+
|
3
|
+
`Capistrano::Stopwatch` is a gem to measure the execution time of each Capistrano tasks. `Capistrano::Stopwatch` requires Capistrano v3 or above.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'capistrano-stopwatch'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install capistrano-stopwatch
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Takes four simple steps to run `Capistrano::Stopwatch` on your environment.
|
24
|
+
|
25
|
+
### 1. Require `Capistrano::Stopwatch` in Capfile
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# Capfile
|
29
|
+
require 'capistrano-stopwatch'
|
30
|
+
```
|
31
|
+
|
32
|
+
### 2. Specify the tasks you want to measure
|
33
|
+
|
34
|
+
Right now, you need to manually specify tasks you want to measure execution time. All you need to do is just call `measure_duration` method in `config/deploy.rb` and hand it name of tasks.
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
# config/deploy.rb
|
38
|
+
['deploy:starting', 'deploy:updating'].each do |n|
|
39
|
+
measure_duration(n)
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
### 3. Specify when to finish
|
44
|
+
|
45
|
+
Specify when to run `stopwatch:finish` task and execute `finish_stopwatch` lambda function. Usually, it is safe to run `stopwatch:finish` after the very last task in your Capistrano deploy flow.
|
46
|
+
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
# config/deploy.rb
|
50
|
+
after 'test:stop', 'stopwatch:finish'
|
51
|
+
```
|
52
|
+
|
53
|
+
### 4. Specify how to handle the output
|
54
|
+
|
55
|
+
Override `finish_stopwatch` and specify how to handle the output, which is a hash of task name and execution time. By default, `finish_stopwatch` simply prints the output to stdout.
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
# config/deploy.rb
|
59
|
+
set :finish_stopwatch, lambda { |durations|
|
60
|
+
File.open("durations.json", "w") {|f| f.puts(durations.to_json) }
|
61
|
+
}
|
62
|
+
```
|
63
|
+
|
64
|
+
## Example
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
# Capfile
|
68
|
+
require 'capistrano-stopwatch'
|
69
|
+
```
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
# config/deploy.rb
|
73
|
+
require 'json'
|
74
|
+
|
75
|
+
set :finish_stopwatch, lambda { |durations|
|
76
|
+
File.open("durations.json", "w") {|f| f.puts(durations.to_json) }
|
77
|
+
puts durations
|
78
|
+
}
|
79
|
+
|
80
|
+
namespace :example do
|
81
|
+
task :first do
|
82
|
+
run_locally do
|
83
|
+
info 'Running first task'
|
84
|
+
sleep 1
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
task :second do
|
89
|
+
run_locally do
|
90
|
+
info 'Running second task'
|
91
|
+
sleep 2
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
task :third do
|
96
|
+
run_locally do
|
97
|
+
info 'Running third task'
|
98
|
+
sleep 3
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
['example:first', 'example:second', 'example:third'].each do |task|
|
104
|
+
measure_duration(task)
|
105
|
+
end
|
106
|
+
|
107
|
+
after 'example:third', 'stopwatch:finish'
|
108
|
+
```
|
109
|
+
|
110
|
+
```bash
|
111
|
+
$ bundle ex cap development example:first example:second example:third
|
112
|
+
00:00 example:first
|
113
|
+
Running first task
|
114
|
+
00:01 example:second
|
115
|
+
Running second task
|
116
|
+
00:03 example:third
|
117
|
+
Running third task
|
118
|
+
00:06 stopwatch:finish
|
119
|
+
Finishing stopwatch
|
120
|
+
{"example:first"=>1.001629, "example:second"=>2.002746, "example:third"=>3.004129}
|
121
|
+
|
122
|
+
$ cat durations.json
|
123
|
+
{"example:first":1.001246,"example:second":2.004474,"example:third":3.00379}
|
124
|
+
```
|
125
|
+
|
126
|
+
## Other options
|
127
|
+
|
128
|
+
### CloudWatch Logs Insights
|
129
|
+
|
130
|
+
[AWS CloudWatch Logs Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html) might be another good option to gether information about task execution time, even though you need to set how to parse Capistrano logs.
|
131
|
+
|
132
|
+
|
133
|
+
## Contributing
|
134
|
+
|
135
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/shuheiktgw/capistrano-stopwatch. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
136
|
+
|
137
|
+
## License
|
138
|
+
|
139
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
140
|
+
|
141
|
+
## Code of Conduct
|
142
|
+
|
143
|
+
Everyone interacting in the Capistrano::Stopwatch project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/shuheiktgw/capistrano-stopwatch/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'capistrano-stopwatch'
|
6
|
+
spec.version = '0.0.1'
|
7
|
+
spec.authors = ['Shuhei Kitagawa']
|
8
|
+
spec.email = ['shuhei.kitagawa@gmail.com']
|
9
|
+
|
10
|
+
spec.summary = %q{Capistrano tasks to measure task execution time}
|
11
|
+
spec.description = %q{Capistrano tasks to measure task execution time}
|
12
|
+
spec.homepage = 'https://github.com/shuheiktgw/capistrano-stopwatch'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
16
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
end
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_dependency 'capistrano', '~> 3.0'
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'capistrano/stopwatch/stopwatch'
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path('../../tasks/stopwatch.rake', __FILE__)
|
@@ -0,0 +1,52 @@
|
|
1
|
+
set :ex_durations, {}
|
2
|
+
|
3
|
+
set :finish_stopwatch, lambda { |durations|
|
4
|
+
puts durations
|
5
|
+
}
|
6
|
+
|
7
|
+
namespace :stopwatch do
|
8
|
+
desc 'Finish stopwatch'
|
9
|
+
task :finish do
|
10
|
+
run_locally do
|
11
|
+
info 'Finishing stopwatch'
|
12
|
+
fetch(:finish_stopwatch).call(fetch(:ex_durations))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def measure_duration(task)
|
18
|
+
define_start(task)
|
19
|
+
define_stop(task)
|
20
|
+
|
21
|
+
before task, "stopwatch:#{ task }_start"
|
22
|
+
after task, "stopwatch:#{ task }_stop"
|
23
|
+
end
|
24
|
+
|
25
|
+
def define_start(task)
|
26
|
+
namespace :stopwatch do
|
27
|
+
desc 'Start stopwatch'
|
28
|
+
task "#{ task }_start" do
|
29
|
+
run_locally do
|
30
|
+
debug "Starting stopwatch for #{ task }"
|
31
|
+
set "#{ task }_timer_started_at", Time.now
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def define_stop(task)
|
38
|
+
namespace :stopwatch do
|
39
|
+
desc 'Stop stopwatch'
|
40
|
+
task "#{ task }_stop" do
|
41
|
+
run_locally do
|
42
|
+
debug "Stopping stopwatch for #{ task }"
|
43
|
+
|
44
|
+
started_at = fetch("#{ task }_timer_started_at")
|
45
|
+
durations = fetch(:ex_durations)
|
46
|
+
durations[task] = Time.now - started_at
|
47
|
+
|
48
|
+
set :ex_durations, durations
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-stopwatch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shuhei Kitagawa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-07-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
description: Capistrano tasks to measure task execution time
|
28
|
+
email:
|
29
|
+
- shuhei.kitagawa@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- CODE_OF_CONDUCT.md
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE.txt
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- capistrano-stopwatch.gemspec
|
41
|
+
- lib/capistrano/stopwatch.rb
|
42
|
+
- lib/capistrano/stopwatch/stopwatch.rb
|
43
|
+
- lib/capistrano/tasks/stopwatch.rake
|
44
|
+
homepage: https://github.com/shuheiktgw/capistrano-stopwatch
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubygems_version: 3.0.3
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Capistrano tasks to measure task execution time
|
67
|
+
test_files: []
|