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: 762df6d0e3348526c7b49929a3a6cdd82db05c80a9d83569a76bd10ddb131ca2
4
- data.tar.gz: 0affeb965dd17cfc202a0b64419d46bb92419a051a70972cbab5d57e5844d027
3
+ metadata.gz: 021f710ca320399402124ec377576c549cb5e323f59da70babd4e70f576cf12f
4
+ data.tar.gz: ef32fd2ac8e127847a7124f73155b8fc0d7397d2d07a563dde469d0f3c08b58d
5
5
  SHA512:
6
- metadata.gz: c703503bc9cf08155d72a0ffc61f7f8cc2c573353d67382e7b4d7b22ea554c2a14ee2e2d04f8804696fa95584843cd4a342cbcdb5e9cb8ac775bd0d36df006b3
7
- data.tar.gz: 2a598ffe29d7382689637c605db8ba721c993e3fc4b033176b273b99515033577b16d82961007bb9e99da3feac5ec2419e58c7a45b354dfd820e4d9bfa9baa4b
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.35.1
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
@@ -1,5 +1,5 @@
1
1
  # DO NOT MANUALLY EDIT; Run ./scripts/update-asdf-version-variables.sh to update this
2
2
  variables:
3
- GL_ASDF_RUBY_VERSION: "3.4.5"
3
+ GL_ASDF_RUBY_VERSION: "3.4.6"
4
4
  GL_ASDF_SHELLCHECK_VERSION: "0.11"
5
5
  GL_ASDF_SHFMT_VERSION: "3.12"
data/.tool-versions CHANGED
@@ -1,3 +1,3 @@
1
- ruby 3.4.5
1
+ ruby 3.4.6
2
2
  shfmt 3.12
3
3
  shellcheck 0.11
@@ -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 (raises `UnstartedError` in development/test environments, or safely ignores in other environments).
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 raise an `UnstartedError` in `development` and `test` environments
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
- err = UnstartedError.new("Covered Experience #{@definition.covered_experience} not started")
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
- err = CompletedError.new("Covered Experience #{@definition.covered_experience} already completed")
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-labkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.41.0
4
+ version: 0.41.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Newdigate