cody 0.8.2 → 0.8.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53eb7e5d569f9ac01fc442092dc96b291ecb6769b7a392b24fa3158b62afd294
4
- data.tar.gz: 812af356ba1149b27a0fdd170b66c1b6d0a16257ce4339c46ae25597c22bc0b0
3
+ metadata.gz: bb76da799abde0f40871e41fa9ed6bbcaf655c9b2f5ed4646d8e7288af31d7a8
4
+ data.tar.gz: 7c7c53ed681e4cc7f6cb9441394f6f61c77cc91d4395e408861e73ab1066f0d3
5
5
  SHA512:
6
- metadata.gz: 563fbd9bffdc2a04a7124e6ce363c40a143dec815d382f6ecc05827e10d865eaa64b2793e56a05f28ae5ed18466a1eddb58eb59c2a9c0765184e5dbd4864b5c5
7
- data.tar.gz: 808f60f39fd12071dd5bcc07e110f9b4e735edea2d9096a9fd149bc1ceebc64dc67e54a610aabf419c58ba3846c9e9af7bd919bd551cfa15215efd864efd75e9
6
+ metadata.gz: 5fdb64cd0da4df5de7de9bd90a418ce94f0768d98d483a557909e4090634591cd5f5cbfb40589a75676b3648f1e9edde197578f3f75cf70fa7744811f62b0640
7
+ data.tar.gz: fa7410c0edaf38296f01821d544df72f68ad8035265ad891ac31005a4e66877eb2a07ac7e48f70d019126395f6b5cb50da3976afdad0dd12f20f6863f4f7a6c1
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.8.3]
7
+ - #11 sleep on error for cloudwatch logs
8
+ - also add `-t` alias for `--type` option
9
+
6
10
  ## [0.8.2]
7
11
  - #9 add cody stop command
8
12
  - #10 add evaluate interface methods
data/lib/cody/cli.rb CHANGED
@@ -11,7 +11,7 @@ module Cody
11
11
  register(Init, "init", "init", "Set up initial .cody files.")
12
12
 
13
13
  common_options = Proc.new do
14
- option :type, desc: "folder to use within .cody folder for different build types"
14
+ option :type, aliases: "t", desc: "folder to use within .cody folder for different build types"
15
15
  option :stack_name, desc: "Override the generated stack name. If you use this you must always specify it"
16
16
  option :wait, type: :boolean, default: true, desc: "Wait for operation to complete"
17
17
  end
@@ -49,7 +49,7 @@
49
49
 
50
50
  By default, Cody logs searches only 7 days in the past. This is done for speed. If you have an older build and would like to search further in the past. You can use the `--since option`. Example:
51
51
 
52
- cody logs --since 1m # 1 month ago
52
+ cody logs --since 4w # 4 weeks ago
53
53
 
54
54
  The since format is from the [aws-logs gem](https://github.com/tongueroo/aws-logs). Since formats:
55
55
 
@@ -59,4 +59,4 @@ The since format is from the [aws-logs gem](https://github.com/tongueroo/aws-log
59
59
  * d - days
60
60
  * w - weeks
61
61
 
62
- Since does not support combining the formats. IE: 5m30s.
62
+ Since does not support combining the formats. IE: 5m30s.
data/lib/cody/tailer.rb CHANGED
@@ -13,11 +13,6 @@ module Cody
13
13
  set_trap
14
14
  end
15
15
 
16
- def find_build
17
- resp = codebuild.batch_get_builds(ids: [@build_id])
18
- resp.builds.first
19
- end
20
-
21
16
  def run
22
17
  puts "Showing logs for build #{@build_id}"
23
18
 
@@ -32,16 +27,21 @@ module Cody
32
27
  set_log_group_name(build)
33
28
 
34
29
  complete = build.build_complete
35
- start_cloudwatch_tail unless ENV["CODY_TEST"]
36
- sleep 5 if !@@end_loop_signal && !complete && !ENV["CODY_TEST"]
37
- end
38
30
 
39
- AwsLogs::Tail.stop_follow!
40
- @thread.join if @thread
31
+ next if ENV["CODY_TEST"]
32
+ start_cloudwatch_tail
33
+ sleep 5
34
+ end
41
35
 
36
+ stop_cloudwatch_tail(build)
42
37
  puts "The build took #{build_time(build)} to complete."
43
38
  end
44
39
 
40
+ def find_build
41
+ resp = codebuild.batch_get_builds(ids: [@build_id])
42
+ resp.builds.first
43
+ end
44
+
45
45
  def start_cloudwatch_tail
46
46
  return if @cloudwatch_tail_started
47
47
  return unless @log_group_name && @log_stream_name
@@ -64,6 +64,35 @@ module Cody
64
64
  cw_tail.run
65
65
  end
66
66
 
67
+ def stop_cloudwatch_tail(build)
68
+ return if ENV["CODY_TEST"]
69
+
70
+ # The AwsLogs::Tail.stop_follow! results in a little waiting because it signals to break the polling loop.
71
+ # Since it's in the middle of the loop process, the loop will finish the sleep 5 first.
72
+ # So it can pause from 0-5 seconds.
73
+ #
74
+ # However, this is sometimes not enough of a pause for CloudWatch to receive and send the logs back to us.
75
+ # So additionally pause on a failed build so we can receive the final logs at the end.
76
+ #
77
+ sleep 10 if complete_failed?(build) # provide extra time for cw tail to report error
78
+ AwsLogs::Tail.stop_follow!
79
+ @thread.join if @thread
80
+ end
81
+
82
+ # build.build_status : The current status of the build. Valid values include:
83
+ #
84
+ # FAILED : The build failed.
85
+ # FAULT : The build faulted.
86
+ # IN_PROGRESS : The build is still in progress.
87
+ # STOPPED : The build stopped.
88
+ # SUCCEEDED : The build succeeded.
89
+ # TIMED_OUT : The build timed out.
90
+ #
91
+ def complete_failed?(build)
92
+ return if ENV["CODY_TEST"]
93
+ build.build_complete && build.build_status != "SUCCEEDED"
94
+ end
95
+
67
96
  # Setting enables start_cloudwatch_tail
68
97
  def set_log_group_name(build)
69
98
  logs = build.logs
@@ -111,11 +140,9 @@ module Cody
111
140
  @output.join("\n") + "\n"
112
141
  end
113
142
 
114
- @@end_loop_signal = false
115
143
  def set_trap
116
144
  Signal.trap("INT") {
117
145
  puts "\nCtrl-C detected. Exiting..."
118
- @@end_loop_signal = true # useful to control loop
119
146
  exit # immediate exit
120
147
  }
121
148
  end
data/lib/cody/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cody
2
- VERSION = "0.8.2"
2
+ VERSION = "0.8.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cody
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen