gitlab-labkit 0.41.0 → 0.41.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 021f710ca320399402124ec377576c549cb5e323f59da70babd4e70f576cf12f
|
4
|
+
data.tar.gz: ef32fd2ac8e127847a7124f73155b8fc0d7397d2d07a563dde469d0f3c08b58d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6fa54d12f6fc16838d116316ca612ec5bc243e282b5b24ffca56547f9a4192e2ae59db05499cf18d4bb2d2f97c4295bb424dffadaa47f760c3614f8f6099e17
|
7
|
+
data.tar.gz: 6ed7ef8bc8a7fa9cfe212ef1329c4dd86ec5613db5e6b80b42cc8e432ba49f10b6af200fdd10a46fd0e63198be4fd061a3555627002de158950adf1a2060ae47
|
data/.copier-answers.yml
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# See the project for instructions on how to update the project
|
4
4
|
#
|
5
5
|
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
|
6
|
-
_commit: v1.
|
6
|
+
_commit: v1.36.0
|
7
7
|
_src_path: https://gitlab.com/gitlab-com/gl-infra/common-template-copier.git
|
8
8
|
ee_licensed: false
|
9
9
|
golang: false
|
data/.tool-versions
CHANGED
@@ -149,7 +149,7 @@ experience.checkpoint
|
|
149
149
|
experience.complete
|
150
150
|
```
|
151
151
|
|
152
|
-
**Note:** The `resume` method loads the start time from the Labkit context. If no covered experience data exists in the context, it behaves the same as calling methods on an unstarted experience
|
152
|
+
**Note:** The `resume` method loads the start time from the Labkit context. If no covered experience data exists in the context, it behaves the same as calling methods on an unstarted experience and safely ignores the operation.
|
153
153
|
|
154
154
|
### Error Handling
|
155
155
|
|
@@ -182,4 +182,4 @@ end
|
|
182
182
|
|
183
183
|
- In `development` and `test` environments, accessing a non-existent covered experience will raise a `NotFoundError`
|
184
184
|
- In other environments, a null object is returned that safely ignores all method calls
|
185
|
-
- Attempting to checkpoint or complete an unstarted experience will
|
185
|
+
- Attempting to checkpoint or complete an unstarted experience will safely ignore the operation
|
@@ -3,8 +3,6 @@
|
|
3
3
|
module Labkit
|
4
4
|
module CoveredExperience
|
5
5
|
CoveredExperienceError = Class.new(StandardError)
|
6
|
-
UnstartedError = Class.new(CoveredExperienceError)
|
7
|
-
CompletedError = Class.new(CoveredExperienceError)
|
8
6
|
NotFoundError = Class.new(CoveredExperienceError)
|
9
7
|
ReservedKeywordError = Class.new(CoveredExperienceError)
|
10
8
|
end
|
@@ -90,10 +90,9 @@ module Labkit
|
|
90
90
|
# Checkpoint the Covered Experience.
|
91
91
|
#
|
92
92
|
# @param extra [Hash] Additional data to include in the log event
|
93
|
-
# @raise [UnstartedError] If the experience has not been started and RAILS_ENV is development or test.
|
94
93
|
# @return [self]
|
95
94
|
def checkpoint(**extra)
|
96
|
-
return unless ensure_started!
|
95
|
+
return self unless ensure_started!
|
97
96
|
|
98
97
|
@checkpoint_time = Time.now.utc
|
99
98
|
checkpoint_counter.increment(checkpoint: "intermediate", **base_labels)
|
@@ -107,7 +106,7 @@ module Labkit
|
|
107
106
|
# @yield [self] When a block is provided, the experience will be completed automatically.
|
108
107
|
# @param extra [Hash] Additional data to include in the log
|
109
108
|
def resume(**extra, &)
|
110
|
-
return unless ensure_started!
|
109
|
+
return self unless ensure_started!
|
111
110
|
|
112
111
|
checkpoint(checkpoint_action: 'resume', **extra)
|
113
112
|
|
@@ -119,11 +118,9 @@ module Labkit
|
|
119
118
|
# Complete the Covered Experience.
|
120
119
|
#
|
121
120
|
# @param extra [Hash] Additional data to include in the log event
|
122
|
-
# @raise [UnstartedError] If the experience has not been started and RAILS_ENV is development or test.
|
123
121
|
# @return [self]
|
124
122
|
def complete(**extra)
|
125
|
-
return unless ensure_started!
|
126
|
-
return unless ensure_incomplete!
|
123
|
+
return self unless ensure_started! && ensure_incomplete!
|
127
124
|
|
128
125
|
begin
|
129
126
|
@end_time = Time.now.utc
|
@@ -166,10 +163,8 @@ module Labkit
|
|
166
163
|
def ensure_started!
|
167
164
|
return @start_time unless @start_time.nil?
|
168
165
|
|
169
|
-
|
170
|
-
|
171
|
-
warn(err)
|
172
|
-
raise(err) if %w[development test].include?(ENV['RAILS_ENV'])
|
166
|
+
warn("Covered Experience #{@definition.covered_experience} not started")
|
167
|
+
false
|
173
168
|
end
|
174
169
|
|
175
170
|
def completable(**extra, &)
|
@@ -188,10 +183,8 @@ module Labkit
|
|
188
183
|
def ensure_incomplete!
|
189
184
|
return true if @end_time.nil?
|
190
185
|
|
191
|
-
|
192
|
-
|
193
|
-
warn(err)
|
194
|
-
raise(err) if %w[development test].include?(ENV['RAILS_ENV'])
|
186
|
+
warn("Covered Experience #{@definition.covered_experience} already completed")
|
187
|
+
false
|
195
188
|
end
|
196
189
|
|
197
190
|
def urgency_threshold
|
@@ -199,6 +192,8 @@ module Labkit
|
|
199
192
|
end
|
200
193
|
|
201
194
|
def elapsed_time
|
195
|
+
return 0 unless @start_time
|
196
|
+
|
202
197
|
last_time = @end_time || @checkpoint_time || @start_time
|
203
198
|
last_time - @start_time
|
204
199
|
end
|