gitlab-labkit 5.1.2 → 5.7.0

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.
@@ -12,27 +12,49 @@ module Labkit
12
12
  # - any plain value (String, Symbol, Integer, ...) -> :eq matcher
13
13
  # - a Regexp instance -> :re matcher (Ruby convenience)
14
14
  # - { eq: <value> } -> :eq matcher (canonical, YAML-compatible)
15
+ # - { ne: <value> } -> :ne matcher (complement of :eq)
15
16
  # - { re: <String|Regexp> } -> :re matcher (canonical, YAML-compatible)
17
+ # - { nre: <String|Regexp> } -> :nre matcher (complement of :re)
16
18
  # - { oneOf: <Array> } -> :oneOf matcher (set membership, YAML-compatible)
19
+ # - { noneOf: <Array> } -> :noneOf matcher (complement of :oneOf)
20
+ # - [ <matcher>, <matcher>, ... ] -> :all matcher (every entry must match)
17
21
  #
18
- # A bare Array is rejected rather than treated as :oneOf, so a value that
19
- # was meant as a single matcher hash but arrived as an Array fails loudly
20
- # instead of silently becoming a membership test.
22
+ # An Array means AND, so several predicates can apply to one identifier key.
23
+ # Its entries must be matcher Hashes or bare Regexps, the two shapes that
24
+ # already mean "a matcher" on their own. An Array of plain values is
25
+ # rejected, so a value that was meant as a single matcher but arrived as a
26
+ # list fails loudly instead of silently becoming a membership test. An Array
27
+ # holds matchers rather than other Arrays, so a match value nests at most
28
+ # MAX_NESTING_DEPTH deep; see too_deeply_nested?.
21
29
  #
22
- # :oneOf membership is Set#include? (eql?/hash equality), not :eq's ==, so
23
- # cross-type numerics differ (1 == 1.0, but {oneOf: [1]} does not match 1.0).
30
+ # :oneOf and :noneOf membership is Set#include? (eql?/hash equality), not
31
+ # :eq's ==, so cross-type numerics differ (1 == 1.0, but {oneOf: [1]} does
32
+ # not match 1.0).
24
33
  #
25
34
  # Hash-key naming follows the metrics-catalog selector pattern. Glob,
26
35
  # prefix, and other matcher kinds are intentionally out of scope here; see
27
36
  # gitlab-com/gl-infra/production-engineering#28853 for that follow-up.
28
37
  #
29
- # An :re matcher coerces the identifier value via #to_s before applying
30
- # the regex, so callers can match non-String identifier values such as
31
- # Integer status codes (e.g. {status: { re: "^5" }} against status: 503).
38
+ # The :re and :nre matchers coerce the identifier value via #to_s before
39
+ # applying the regex, so callers can match non-String identifier values such
40
+ # as Integer status codes (e.g. {status: { re: "^5" }} against status: 503).
41
+ #
42
+ # Each negation matcher is the plain complement of its positive form, with
43
+ # no special case for a missing key. Evaluator passes identifier[key], so an
44
+ # absent key arrives as nil, and the complement is therefore usually true
45
+ # for one: a request with no path is not a request to an excluded path. A
46
+ # rule that should apply only when the key is present says so, by adding a
47
+ # presence matcher alongside the exclusions:
48
+ #
49
+ # path: [/./, { nre: '\A/api/' }]
32
50
  class Matcher < Data.define(:type, :value)
33
- KNOWN_HASH_KEYS = %i[eq re oneOf].freeze
34
- MAX_REGEX_SOURCE_LENGTH = 200
51
+ KNOWN_HASH_KEYS = %i[eq ne re nre oneOf noneOf].freeze
35
52
  ERROR_INSPECT_LIMIT = 80
53
+ # No Hash or Array may sit this many levels below the match value, which
54
+ # is level 0. The deepest valid shape is an Array (0) holding a matcher
55
+ # Hash (1) whose :oneOf list (2) holds plain values; see
56
+ # too_deeply_nested?.
57
+ MAX_NESTING_DEPTH = 3
36
58
 
37
59
  # Wall-clock budget for a single #match? call. Without it a match is
38
60
  # bounded only by whatever global the host sets (40s in GitLab Rails,
@@ -45,16 +67,23 @@ module Labkit
45
67
  # timeouts were wall-clock stalls, since Ruby counts real time and GC
46
68
  # pauses on GitLab's git fleet have a p50 of ~72ms. Under 4x CPU
47
69
  # oversubscription 50ms still fires on 0.16% of those matches, 5ms 1.33%.
70
+ #
71
+ # This timeout is the only bound on a pattern. There is no cap on regex
72
+ # source length: rules are written by operators rather than end users, and
73
+ # a cap that applied to {re: "..."} but not to a bare Regexp bounded
74
+ # nothing in practice, since callers pass Regexp constants.
48
75
  MATCH_TIMEOUT_SECONDS = 0.05
49
76
 
50
77
  def self.build(input)
78
+ raise ArgumentError, nesting_error(input) if too_deeply_nested?(input)
79
+
51
80
  case input
52
81
  when Regexp
53
- new(type: :re, value: with_match_timeout(input))
82
+ new(type: :re, value: with_match_timeout(:re, input))
54
83
  when Hash
55
84
  from_hash(input)
56
85
  when Array
57
- raise ArgumentError, invalid_shape_error(input)
86
+ compose(input)
58
87
  else
59
88
  new(type: :eq, value: input)
60
89
  end
@@ -64,6 +93,15 @@ module Labkit
64
93
  raise ArgumentError, invalid_shape_error(input) if input.size != 1
65
94
 
66
95
  type, source = input.first
96
+
97
+ # Identifier rejects keys the same way. Without this, a key such as an
98
+ # Integer or nil leaves NoMethodError for the caller instead of the
99
+ # ArgumentError every other bad shape raises.
100
+ unless type.respond_to?(:to_sym)
101
+ raise ArgumentError,
102
+ "rate-limit match value type key #{truncate_for_error(type)} must be a String or Symbol"
103
+ end
104
+
67
105
  type_sym = type.to_sym
68
106
 
69
107
  unless KNOWN_HASH_KEYS.include?(type_sym)
@@ -77,31 +115,45 @@ module Labkit
77
115
 
78
116
  def self.compile(type_sym, source)
79
117
  case type_sym
80
- when :eq
81
- new(type: :eq, value: source)
82
- when :oneOf
118
+ when :eq, :ne
119
+ new(type: type_sym, value: source)
120
+ when :oneOf, :noneOf
83
121
  unless source.is_a?(Array)
84
122
  raise ArgumentError,
85
- "rate-limit match value {oneOf: ...} must be an Array, got #{truncate_for_error(source)}"
123
+ "rate-limit match value {#{type_sym}: ...} must be an Array, got #{truncate_for_error(source)}"
86
124
  end
87
125
 
88
- new(type: :oneOf, value: Set.new(source).freeze)
89
- when :re
90
- if source.to_s.length > MAX_REGEX_SOURCE_LENGTH
126
+ # {oneOf: []} matches nothing, so the rule never applies and no harm
127
+ # follows. Its complement matches everything, which is an exclusion
128
+ # that excludes nothing: rejected for the same reason an empty Array
129
+ # of matchers is.
130
+ if type_sym == :noneOf && source.empty?
91
131
  raise ArgumentError,
92
- "rate-limit match value {re: ...} source exceeds #{MAX_REGEX_SOURCE_LENGTH} characters"
132
+ "rate-limit match value {noneOf: []} must not be empty, it matches everything"
93
133
  end
94
134
 
95
- begin
96
- new(type: :re, value: with_match_timeout(source))
97
- rescue RegexpError, TypeError => e
98
- raise ArgumentError,
99
- "rate-limit match value {re: #{truncate_for_error(source)}} failed to compile: #{e.message}"
100
- end
135
+ new(type: type_sym, value: Set.new(source).freeze)
136
+ when :re, :nre
137
+ new(type: type_sym, value: with_match_timeout(type_sym, source))
101
138
  end
102
139
  end
103
140
  private_class_method :compile
104
141
 
142
+ # Builds the :all matcher behind the Array form. Entries go back through
143
+ # .build, which is what keeps a nested regex bounded by the match timeout.
144
+ def self.compose(input)
145
+ raise ArgumentError, "rate-limit match value [] must not be empty" if input.empty?
146
+
147
+ unless input.all? { |entry| entry.is_a?(Hash) || entry.is_a?(Regexp) }
148
+ raise ArgumentError,
149
+ "rate-limit match value Array entries must each be a matcher Hash or Regexp, " \
150
+ "got #{truncate_for_error(input)}"
151
+ end
152
+
153
+ new(type: :all, value: input.map { |entry| build(entry) }.freeze)
154
+ end
155
+ private_class_method :compose
156
+
105
157
  # Compiles +source+ (a String pattern or an existing Regexp) into a
106
158
  # Regexp bounded by MATCH_TIMEOUT_SECONDS.
107
159
  #
@@ -116,7 +168,7 @@ module Labkit
116
168
  # Recompiling an existing Regexp preserves its source and options
117
169
  # (including the fixed-encoding flags) and therefore +#==+; only object
118
170
  # identity changes.
119
- def self.with_match_timeout(source)
171
+ def self.with_match_timeout(key, source)
120
172
  return source if source.is_a?(Regexp) && source.timeout
121
173
 
122
174
  if source.is_a?(Regexp)
@@ -124,12 +176,19 @@ module Labkit
124
176
  else
125
177
  Regexp.new(source, timeout: MATCH_TIMEOUT_SECONDS)
126
178
  end
179
+ rescue RegexpError, TypeError => e
180
+ raise ArgumentError,
181
+ "rate-limit match value {#{key}: #{truncate_for_error(source)}} failed to compile: #{e.message}"
127
182
  end
128
183
 
129
184
  private_class_method :with_match_timeout
130
185
 
131
186
  def self.invalid_shape_error(input)
132
- "rate-limit match value must be a single-key Hash like {re: \"...\"}, {eq: ...} or {oneOf: [...]}, " \
187
+ # No key list here: this fires on the shape, and from_hash names the
188
+ # accepted keys when the shape is right but the key is not. Keeping the
189
+ # fixed part short is also what lets truncate_for_error bound the whole
190
+ # message.
191
+ "rate-limit match value must be a single-key Hash, or an Array of matchers, " \
133
192
  "got #{truncate_for_error(input)}"
134
193
  end
135
194
  private_class_method :invalid_shape_error
@@ -140,14 +199,65 @@ module Labkit
140
199
  end
141
200
  private_class_method :truncate_for_error
142
201
 
202
+ def self.nesting_error(input)
203
+ # Does not inspect the input: it is too deep to render, which is the
204
+ # reason this fires. The class is the only hint available cheaply, and
205
+ # the nesting may be in a key or a value.
206
+ "rate-limit match value nests deeper than #{MAX_NESTING_DEPTH} levels (#{input.class})"
207
+ end
208
+ private_class_method :nesting_error
209
+
210
+ # A valid match value nests three deep at most: an Array of matcher
211
+ # Hashes whose :oneOf value is an Array of plain values. Anything past
212
+ # MAX_NESTING_DEPTH is rejected rather than built.
213
+ #
214
+ # The check is iterative because the alternative is finding out through
215
+ # #inspect, which recurses once per level while rendering an error
216
+ # message. Rules are built at boot and SystemStackError is not a
217
+ # StandardError, so that would take the process down rather than reject
218
+ # one rule, and rescuing it is not an option either: the VM aborts on a
219
+ # second overflow in the same process.
220
+ def self.too_deeply_nested?(input)
221
+ # A flat stack of node, depth pairs, so a visit allocates no Array. The
222
+ # pops must mirror the pushes: depth comes off first, then its node.
223
+ stack = [input, 0]
224
+
225
+ until stack.empty?
226
+ depth = stack.pop
227
+ node = stack.pop
228
+ next unless node.is_a?(Hash) || node.is_a?(Array)
229
+ return true if depth >= MAX_NESTING_DEPTH
230
+
231
+ # Keys as well as values: #inspect renders both, so a deeply nested
232
+ # key overflows the same way a deeply nested value does.
233
+ if node.is_a?(Hash)
234
+ node.each { |key, value| stack.push(key, depth + 1, value, depth + 1) }
235
+ else
236
+ node.each { |child| stack.push(child, depth + 1) }
237
+ end
238
+ end
239
+
240
+ false
241
+ end
242
+ private_class_method :too_deeply_nested?
243
+
143
244
  def match?(identifier_value)
144
245
  case type
145
246
  when :eq
146
247
  value == identifier_value
248
+ when :ne
249
+ value != identifier_value
147
250
  when :oneOf
148
251
  value.include?(identifier_value)
252
+ when :noneOf
253
+ # exclude? is ActiveSupport, and nothing in rate_limit requires it.
254
+ !value.include?(identifier_value) # rubocop:disable Rails/NegateInclude
149
255
  when :re
150
256
  value.match?(identifier_value.to_s)
257
+ when :nre
258
+ !value.match?(identifier_value.to_s)
259
+ when :all
260
+ value.all? { |matcher| matcher.match?(identifier_value) }
151
261
  else
152
262
  raise ArgumentError, "unknown matcher type: #{type.inspect}"
153
263
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "time" # Time#httpdate
4
+
3
5
  module Labkit
4
6
  module RateLimit
5
7
  # Result is the return value of Limiter#check.
@@ -113,18 +115,13 @@ module Labkit
113
115
  @most_constraining ||= @evaluations.min
114
116
  end
115
117
 
116
- # Returns RFC-compliant rate limit response headers, or {} when no rule matched or an error occurred.
117
- # Keys: RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset (Unix timestamp).
118
- # remaining is coerced to Integer for header output even when info.remaining is fractional;
119
- # the RateLimit header spec requires integer values.
118
+ # Returns the rate limit response headers of the most constraining
119
+ # evaluation, or {} when no rule matched, a :skip rule matched, or an
120
+ # error occurred. See Result::Evaluation#to_response_headers for the keys.
120
121
  def to_response_headers
121
122
  return {} unless matched? && !error? && info
122
123
 
123
- {
124
- "RateLimit-Limit" => info.resolved_limit.to_i.to_s,
125
- "RateLimit-Remaining" => info.remaining.to_i.to_s,
126
- "RateLimit-Reset" => info.reset_at.to_i.to_s
127
- }
124
+ most_constraining.to_response_headers
128
125
  end
129
126
  end
130
127
 
@@ -155,6 +152,32 @@ module Labkit
155
152
  constraint_rank <=> other.constraint_rank
156
153
  end
157
154
 
155
+ # Returns the rate limit response headers for this evaluation. Values are
156
+ # Strings, and counts are coerced to Integer because the RateLimit header
157
+ # spec requires integer values even when count is fractional.
158
+ #
159
+ # RateLimit-Name (the rule name), RateLimit-Limit, RateLimit-Observed,
160
+ # RateLimit-Remaining and RateLimit-Reset (Unix timestamp) are always
161
+ # present. Limit, Observed and Remaining all count within the rule's own
162
+ # period. A blocking evaluation also gets Retry-After (seconds) and
163
+ # RateLimit-ResetTime (HTTP date), which belong on the 429.
164
+ def to_response_headers
165
+ headers = {}
166
+ headers["RateLimit-Name"] = rule.name
167
+ # Floored at 0 like remaining: a callable limit can resolve below zero
168
+ # to deny all, and an older client could credit a counter below zero.
169
+ headers["RateLimit-Limit"] = [info.resolved_limit.to_i, 0].max.to_s
170
+ headers["RateLimit-Observed"] = [info.count.to_i, 0].max.to_s
171
+ headers["RateLimit-Remaining"] = info.remaining.to_i.to_s
172
+ headers["RateLimit-Reset"] = info.reset_at.to_i.to_s
173
+ return headers unless block?
174
+
175
+ # Rounded up so a client that honours it does not retry before the reset.
176
+ headers["Retry-After"] = [(info.reset_at - Time.now.utc).ceil, 0].max.to_s
177
+ headers["RateLimit-ResetTime"] = info.reset_at.httpdate
178
+ headers
179
+ end
180
+
158
181
  protected
159
182
 
160
183
  def constraint_rank
@@ -10,8 +10,8 @@ module Labkit
10
10
  # name - stable identifier used in Redis keys and log entries
11
11
  # match - hash of identifier key/value pairs that must all match for
12
12
  # the rule to apply; empty hash matches any identifier
13
- # limit - request threshold; may be a callable (resolved per check)
14
- # period - window in seconds; may be a callable (resolved per check)
13
+ # limit - request threshold, at least 1; may be a callable (resolved per check)
14
+ # period - window in seconds, at least 1; may be a callable (resolved per check)
15
15
  # action - :limit (enforce; the result blocks when the rule is over
16
16
  # its limit, which also terminates evaluation), :log (count
17
17
  # and log only, never blocks and never terminates),
@@ -56,6 +56,16 @@ module Labkit
56
56
  raise ArgumentError, "ban_for must be a Numeric of at least 1 second or a callable, got #{value.inspect}"
57
57
  end
58
58
 
59
+ # A static limit under 1 blocks every request, and a period under a second
60
+ # reaches EXPIRE as 0, deleting the counter on every write. A :skip rule
61
+ # counts nothing, and a callable may still resolve to 0 to mean "deny all".
62
+ def self.normalize_numeric(field, value, action_sym)
63
+ return value if action_sym == :skip || value.respond_to?(:call)
64
+ return value if value.is_a?(Numeric) && value >= 1
65
+
66
+ raise ArgumentError, "#{field} must be a Numeric of at least 1 or a callable, got #{value.inspect}"
67
+ end
68
+
59
69
  def self.normalize_count_distinct(value, characteristics_arr)
60
70
  sym =
61
71
  case value
@@ -94,8 +104,8 @@ module Labkit
94
104
  super(
95
105
  name: name_str.freeze,
96
106
  match: match.transform_keys(&:to_sym).transform_values { |v| Matcher.build(v) }.freeze,
97
- limit: limit,
98
- period: period,
107
+ limit: self.class.normalize_numeric(:limit, limit, action_sym),
108
+ period: self.class.normalize_numeric(:period, period, action_sym),
99
109
  action: action_sym,
100
110
  characteristics: characteristics_arr,
101
111
  count_distinct: count_distinct_sym,
@@ -173,7 +173,7 @@ RSpec::Matchers.define :complete_user_experience do |user_experience_id, error:
173
173
  "Failed to complete user experience '#{user_experience_id}':\n" \
174
174
  "expected checkpoint='end' counter to increase by 1, but increased by #{@checkpoint_change}\n" \
175
175
  "expected total='error: #{error}' counter to increase by 1, but increased by #{@total_change}\n" \
176
- "expected apdex='success: #{success}' counter to increase by 1, but increased by #{@apdex_change}"
176
+ "expected apdex='success: #{success}' counter to increase by #{error ? 0 : 1}, but increased by #{@apdex_change}"
177
177
  end
178
178
 
179
179
  match_when_negated do |actual|
@@ -192,7 +192,7 @@ RSpec::Matchers.define :complete_user_experience do |user_experience_id, error:
192
192
  @total_change = total_after - total_before
193
193
  @apdex_change = apdex_after - apdex_before
194
194
 
195
- @checkpoint_change.zero? && @total_change.zero? && @apdex_change == (error ? 1 : 0)
195
+ @checkpoint_change.zero? && @total_change.zero? && @apdex_change.zero?
196
196
  end
197
197
 
198
198
  failure_message_when_negated do
data/performance.yml ADDED
@@ -0,0 +1,70 @@
1
+ # Performance contract for labkit-ruby
2
+ # https://handbook.gitlab.com/handbook/engineering/testing/performance-contracts/
3
+ #
4
+ # This file is the single entry point for performance contract tooling.
5
+ # Customize the sections relevant to your service and remove the rest.
6
+ # Schema reference: https://handbook.gitlab.com/handbook/engineering/testing/performance-contracts/#schema-definition
7
+
8
+ version: "1.0"
9
+ service:
10
+ name: "labkit-ruby"
11
+ description: "Performance contract for labkit-ruby"
12
+
13
+ # ---------------------------------------------------------------------------
14
+ # Frontend / UI contracts (SiteSpeed)
15
+ # Uncomment and configure if this service has a frontend component.
16
+ # Budget files live in the sitespeed-measurement-setup submodule.
17
+ # ---------------------------------------------------------------------------
18
+ # frontend:
19
+ # enabled: true
20
+ # budgets:
21
+ # production: testrunner/sitespeed-measurement-setup/performance/budgets/environments/production.json
22
+ # staging: testrunner/sitespeed-measurement-setup/performance/budgets/environments/staging.json
23
+ # mr: testrunner/sitespeed-measurement-setup/performance/budgets/environments/mr.json
24
+ # teams:
25
+ # labkit-ruby:
26
+ # url_dir: testrunner/sitespeed-measurement-setup/gitlab/desktop/urls
27
+ # budget: testrunner/sitespeed-measurement-setup/performance/budgets/teams/labkit-ruby.json
28
+ # default_budget: mr
29
+
30
+ # ---------------------------------------------------------------------------
31
+ # Backend / Service contracts (k6 / CPT)
32
+ # Define endpoint categories with latency and error-rate targets.
33
+ # Choose a tier as a starting point, then tune from baseline data.
34
+ #
35
+ # Tier 1 (fast reads): p95=100ms, p99=250ms, error_rate=0.001
36
+ # Tier 2 (std reads): p95=500ms, p99=1000ms, error_rate=0.005
37
+ # Tier 3 (writes): p95=1500ms, p99=3000ms, error_rate=0.01
38
+ # Tier 4 (git ops): p95=5000ms, p99=10000ms,error_rate=0.001
39
+ # ---------------------------------------------------------------------------
40
+ # endpoints:
41
+ # fast_reads:
42
+ # description: >
43
+ # Single item lookup by ID. Simulates one indexed DB read.
44
+ # routes:
45
+ # - "GET /api/v1/items/{id}"
46
+ # metrics:
47
+ # latency_p95_ms: 100
48
+ # latency_p99_ms: 250
49
+ # error_rate_threshold: 0.001
50
+
51
+ # ---------------------------------------------------------------------------
52
+ # Resource budgets (informational; enforcement planned for a future iteration)
53
+ # ---------------------------------------------------------------------------
54
+ # resources:
55
+ # memory_limit_mb: 256
56
+ # cpu_limit_cores: 0.5
57
+ # connection_pool_max: 10
58
+
59
+ # ---------------------------------------------------------------------------
60
+ # SLI mapping -- links contract endpoints to Prometheus metrics emitted by
61
+ # LabKit v2. Fill in once your service is instrumented.
62
+ # ---------------------------------------------------------------------------
63
+ # sli_mapping:
64
+ # metrics_namespace: gitlab
65
+ # component: labkit-ruby
66
+ # fast_reads:
67
+ # requests_total_metric: gitlab_http_requests_total
68
+ # duration_metric: gitlab_http_request_duration_seconds
69
+ # endpoint_id_label: "GET /api/v1/items/{id}"
70
+ # feature_category_label: labkit_ruby
@@ -3,6 +3,7 @@
3
3
  # Consider contributing upstream when updating this file
4
4
 
5
5
  set -euo pipefail
6
+ IFS=$'\n\t'
6
7
 
7
8
  # ---------------------------------------------------------
8
9
  # This script will prepare your development environment
@@ -21,6 +22,28 @@ warn() {
21
22
  echo >&2 -e "Recommended reading: https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/docs/developer-setup.md"
22
23
  }
23
24
 
25
+ # `mise plugins update` contacts GitHub for every registered plugin: slow, and
26
+ # it adds up when many vendored copies of this script run across many projects
27
+ # on the same machine. Throttle it to once a day using a stamp file in the
28
+ # user's cache directory, deliberately outside the project so that the throttle
29
+ # is shared by every project that vendors this script.
30
+ mise_plugins_update() {
31
+ local stamp_dir="${XDG_CACHE_HOME:-${HOME:-}/.cache}/common-template-copier"
32
+ local stamp_file="${stamp_dir}/mise-plugins-update"
33
+
34
+ # `find -mtime -1` rather than `stat`, which is spelled differently on
35
+ # GNU/BSD. It prints nothing when the stamp is missing or over a day old.
36
+ if [[ -z ${FORCE_MISE_PLUGINS_UPDATE-} ]] && [[ -n $(find "$stamp_file" -mtime -1 2>/dev/null) ]]; then
37
+ echo >&2 "skipping 'mise plugins update' (ran in the last 24h; set FORCE_MISE_PLUGINS_UPDATE=1 to force)"
38
+ return 0
39
+ fi
40
+
41
+ mise plugins update -q
42
+
43
+ # Best effort: a machine without a writable cache dir just updates every time.
44
+ mkdir -p "$stamp_dir" && touch "$stamp_file" || true
45
+ }
46
+
24
47
  if command -v mise >/dev/null; then
25
48
  echo >&2 -e "mise installed..."
26
49
  elif command -v rtx >/dev/null; then
@@ -53,8 +76,8 @@ fi
53
76
 
54
77
  # install mise/asdf dependencies
55
78
  echo "installing required plugins with mise install.."
56
- mise plugins update -q
57
79
  mise trust --yes
80
+ mise_plugins_update
58
81
  mise install
59
82
 
60
83
  # set PROMPT_COMMAND to empty value for mise if unset
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: 5.1.2
4
+ version: 5.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Newdigate
@@ -277,6 +277,20 @@ dependencies:
277
277
  - - "<"
278
278
  - !ruby/object:Gem::Version
279
279
  version: 6.0.0
280
+ - !ruby/object:Gem::Dependency
281
+ name: thrift
282
+ requirement: !ruby/object:Gem::Requirement
283
+ requirements:
284
+ - - "<"
285
+ - !ruby/object:Gem::Version
286
+ version: '0.25'
287
+ type: :runtime
288
+ prerelease: false
289
+ version_requirements: !ruby/object:Gem::Requirement
290
+ requirements:
291
+ - - "<"
292
+ - !ruby/object:Gem::Version
293
+ version: '0.25'
280
294
  - !ruby/object:Gem::Dependency
281
295
  name: excon
282
296
  requirement: !ruby/object:Gem::Requirement
@@ -548,9 +562,10 @@ executables:
548
562
  extensions: []
549
563
  extra_rdoc_files: []
550
564
  files:
565
+ - ".claude/hooks/precommit-validate.sh"
566
+ - ".claude/settings.json"
551
567
  - ".copier-answers.yml"
552
568
  - ".editorconfig"
553
- - ".env.example.sh"
554
569
  - ".gitignore"
555
570
  - ".gitlab-ci-asdf-versions.yml"
556
571
  - ".gitlab-ci-other-versions.yml"
@@ -560,6 +575,7 @@ files:
560
575
  - ".gitlab/merge_request_templates/default.md"
561
576
  - ".gitleaks.toml"
562
577
  - ".mise.toml"
578
+ - ".opencode/plugins/precommit-validate.ts"
563
579
  - ".pre-commit-config.yaml"
564
580
  - ".releaserc.json"
565
581
  - ".rspec"
@@ -568,6 +584,8 @@ files:
568
584
  - ".rufo"
569
585
  - ".tool-versions"
570
586
  - ".yamllint.yaml"
587
+ - AGENTS.md
588
+ - CLAUDE.md
571
589
  - CODEOWNERS
572
590
  - CONTRIBUTING.md
573
591
  - Dangerfile
@@ -697,6 +715,7 @@ files:
697
715
  - lib/labkit/user_experience_sli/experience.rb
698
716
  - lib/labkit/user_experience_sli/null.rb
699
717
  - lib/labkit/user_experience_sli/registry.rb
718
+ - performance.yml
700
719
  - renovate.json
701
720
  - scripts/prepare-dev-env.sh
702
721
  - scripts/update-asdf-version-variables.sh
data/.env.example.sh DELETED
@@ -1,7 +0,0 @@
1
- export CI_PROJECT_ID=10947578
2
- export CI_API_V4_URL="https://gitlab.com/api/v4"
3
- export CI_PROJECT_URL="https://gitlab.com/gitlab-org/ruby/gems/labkit-ruby"
4
- # Don't keep secrets in plaintext files. Use a keyring or 1password to load
5
- # it instead and export it as an env var.
6
- token=$(load-your-token)
7
- export GITLAB_TOKEN=$token