rspec_trunk_flaky_tests 0.17.0.pre.beta.4-aarch64-linux-gnu → 1.0.0.pre.beta.2-aarch64-linux-gnu

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: a7107ccfbea8d29269227c02ccc55a941bc3a54947573f6f1b22417c71443d0c
4
- data.tar.gz: 4fc78b6c2385b0f1316b94ffee8a6836ac72432b9f882ea9a66a0a22e8822b91
3
+ metadata.gz: 6de4741df2ef718809191e9e1512d4e9bd8fa4615f2ed28ad6bc464f8a076732
4
+ data.tar.gz: 5b308df631c76f7640a1d18cc0b7685cbc69c5624009d88cd83837ce0e6e1f6f
5
5
  SHA512:
6
- metadata.gz: 8426f4e14aade081c04eb4c3635a53cb7b744ca87b78682b415cc1e7bb5a2b992105802a207c3bfb661c71b92d5522d736e8cb669e1bb706ba24758c83664623
7
- data.tar.gz: 4bc2bf9c0d13fa502437326fb909ea0a6f2e32f507830d002cfdb9263cafe0f349e0452bfbbc89010be5840ca59be76c062316db813f3980efeedee3ea36a3e8
6
+ metadata.gz: 92ef6284ef51b4dab93b64924025848190203913799c5ab6c3e2082342815a342c1ad910fc660edbaca574c8167cc4273c5862d14c1ac67f92a42af3aac871a6
7
+ data.tar.gz: 1afb4a17fe88f9a3d64d44f91bee926891e997cb7b7eda2c6dcbde14e8ae933e29d5b7b6d752cba56d6f9d97f549aca8abfc1d576ca1dbfc62c9c749f0b9a7e6
@@ -7,7 +7,9 @@
7
7
  #
8
8
  # Required environment variables:
9
9
  # TRUNK_ORG_URL_SLUG - Your organization's URL slug
10
- # TRUNK_API_TOKEN - Your API token for authentication
10
+ # TRUNK_API_TOKEN - A Trunk v2 API key (trunk_v2_...) with the Upload test results permission,
11
+ # or a Trunk JWT that outlasts the run; the organization token is refused
12
+ # TRUNK_TEST_COLLECTION_ID - The ID of the test collection to upload to
11
13
  #
12
14
  # Optional environment variables for repository metadata:
13
15
  # TRUNK_REPO_ROOT - Path to repository root
@@ -20,7 +22,6 @@
20
22
  #
21
23
  # Optional environment variables for configuration:
22
24
  # TRUNK_CODEOWNERS_PATH - Path to CODEOWNERS file
23
- # TRUNK_TEST_COLLECTION_ID - Optional 8 character alphanumeric ID for a test collection
24
25
  # TRUNK_VARIANT - Variant name for test results (e.g., 'linux', 'pr-123')
25
26
  # TRUNK_DISABLE_QUARANTINING - Set to 'true' to disable quarantining
26
27
  # TRUNK_ALLOW_EMPTY_TEST_RESULTS - Set to 'true' to allow empty results
@@ -55,6 +56,9 @@ module RSpec
55
56
  MODULE_TO_S = Module.instance_method(:to_s)
56
57
  MEMORY_ADDRESS = /:0x\h+>/
57
58
 
59
+ # Raised when Trunk is configured to upload but can't: see .check_configuration!.
60
+ class ConfigurationError < StandardError; end
61
+
58
62
  # Knapsack example detector instantiates all test cases in order to determine how to shard them
59
63
  # These instantiations should not generate test bundles, so we
60
64
  # disable the gem when running under knapsack_pro:rspec_test_example_detector
@@ -81,6 +85,7 @@ module RSpec
81
85
  def setup
82
86
  return if current_run || disabled?
83
87
 
88
+ check_configuration!
84
89
  run = @current_run = Run.new
85
90
  RSpec::Core::Example.prepend(ExampleExtension)
86
91
  RSpec::Core::ExampleGroup.singleton_class.prepend(ExampleGroupExtension)
@@ -104,9 +109,28 @@ module RSpec
104
109
  config.reporter.register_listener AnalyticsListener.new(run), :example_finished, :close
105
110
  end
106
111
 
112
+ # An empty token counts as none: it is what a fork pull request's missing secret turns into.
107
113
  def disabled?
108
114
  knapsack_detector_mode? || ENV['DISABLE_RSPEC_TRUNK_FLAKY_TESTS'] == 'true' ||
109
- ENV['TRUNK_ORG_URL_SLUG'].nil? || ENV['TRUNK_API_TOKEN'].nil?
115
+ ENV['TRUNK_ORG_URL_SLUG'].nil? || ENV.fetch('TRUNK_API_TOKEN', '').strip.empty?
116
+ end
117
+
118
+ # A run with a token and a slug means to upload, so one that can't is an error rather than a
119
+ # warning: a warning leaves the build green while uploads and quarantining stop, which is how
120
+ # a dependency bot's upgrade to 1.0.0 would merge unnoticed. Raised while spec_helper loads,
121
+ # so RSpec runs no examples and exits non-zero, as the CLI's `test` command does.
122
+ def check_configuration!
123
+ if ENV.fetch('TRUNK_TEST_COLLECTION_ID', '').strip.empty?
124
+ configuration_error!('this run names no test collection. Set TRUNK_TEST_COLLECTION_ID to upload its ' \
125
+ "test results; the ID is on the collection's page in Trunk.")
126
+ end
127
+ refusal = RSpec::Trunk.token_refusal(ENV.fetch('TRUNK_API_TOKEN'))
128
+ configuration_error!(refusal) if refusal
129
+ end
130
+
131
+ def configuration_error!(reason)
132
+ raise ConfigurationError, "Trunk Flaky Tests: #{reason} To run without Trunk, set " \
133
+ 'DISABLE_RSPEC_TRUNK_FLAKY_TESTS=true.'
110
134
  end
111
135
 
112
136
  def knapsack_detector_mode?
@@ -334,13 +358,15 @@ module RSpec
334
358
  if result.quarantine_lookup_failed
335
359
  unless lookup_failed?
336
360
  puts Colors.yellow('Failed to check quarantining status, no failures will be quarantined')
361
+ reason = report.quarantine_lookup_error
362
+ puts Colors.yellow(" Reason: #{reason}") if reason
337
363
  @lookup_failed = true
338
364
  end
339
365
  abort_run(example, exception) if Trunk.quarantine_query_failure_exit?
340
366
  false
341
367
  elsif result.quarantining_disabled_for_repo
342
368
  unless quarantining_disabled?
343
- puts Colors.yellow('Quarantining is disabled for this repo, no failures will be quarantined')
369
+ puts Colors.yellow('Quarantining is disabled for this test collection, no failures will be quarantined')
344
370
  @quarantining_disabled = true
345
371
  end
346
372
  false
@@ -534,7 +560,8 @@ module RSpec
534
560
  puts Colors.yellow('Note: TRUNK_DISABLE_QUARANTINING is set. Test failures were not quarantined.')
535
561
  end
536
562
  if @run.quarantining_disabled?
537
- puts Colors.yellow('Note: Quarantining is disabled for this repo. Test failures were not quarantined.')
563
+ puts Colors.yellow('Note: Quarantining is disabled for this test collection. ' \
564
+ 'Test failures were not quarantined.')
538
565
  end
539
566
  if @run.lookup_failed?
540
567
  puts Colors.yellow('Note: Failed to check quarantining status. Test failures were not quarantined.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_trunk_flaky_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0.pre.beta.4
4
+ version: 1.0.0.pre.beta.2
5
5
  platform: aarch64-linux-gnu
6
6
  authors:
7
7
  - Trunk Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-10 00:00:00.000000000 Z
11
+ date: 2026-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core