buildkite-test_collector 2.17.0 → 2.17.1

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: f40dec372895345d99af434be7e214f1cc9009643a904b20f78d7bb158be935d
4
- data.tar.gz: ac03c35d84ba8bb8c80fa850284f3a29387861872503d1bc9419de85d7b74f6a
3
+ metadata.gz: 29e5f8120de5f3642d9b15eb0d6010609e349846b3ad88e1faa9c6cf49d7c855
4
+ data.tar.gz: 2f43d314048fb3cda0417dad38fa19ba7a790dbc772d9432c088a12d5a639d0d
5
5
  SHA512:
6
- metadata.gz: c2a1da6bb295a35862e55e31c99551484d21adedf5e9cc4b71e2387a6480097640314b746c7927b86847737435ba0e7a5e2153640627716489c8e50707b72b27
7
- data.tar.gz: 57646e4a9e9f13045e257a838f450f43331c24c9f6f6161168bfa36687bff5586cef1abff0525232df99006fbfeebf5167bfcf18882ab806b35d571d3feecc96
6
+ metadata.gz: caf2485a0c8c684540a6fe8d0a319ee3f9e3f5ce863ccd9eb8b9efb9ba7f2afdd818fcbffed602cf56031e3baa5497cf04fc877946b15655092c00d8eb1249f3
7
+ data.tar.gz: 0264b27f43d06c91112de1445a1aa544d574feb99a8d7346ffe7fc2ca6293e2da8f56551ddbf2b7d999944d63b1989b897ad47d4b1a3cdd2bf2347099e8aa8ad
@@ -14,9 +14,9 @@
14
14
  # every rehearsal, so rehearsals exercise the release code. It never sees
15
15
  # RELEASE_PUBLISH (set only on the publish step below), so it stops
16
16
  # before `gem push` even on tag builds.
17
- # - The publish steps mint a push token via the rubygems.org OIDC API key
18
- # role, whose access policy trusts this pipeline (see the credential
19
- # cut-over section of ctg docs/publishing.md).
17
+ # - The publish step mints a push token inside the patched container via
18
+ # the rubygems.org OIDC API key role. Its access policy trusts this pipeline
19
+ # (see the credential cut-over section of ctg docs/publishing.md).
20
20
  # - The publish step exists only on an exact test-collector-ruby/vX.Y.Z
21
21
  # tag, behind a block step; it sets RELEASE_PUBLISH=true in its own
22
22
  # environment, and the release script independently re-checks the tag
@@ -32,6 +32,7 @@ steps:
32
32
  plugins:
33
33
  - docker#v5.12.0:
34
34
  image: "ruby:3.4"
35
+ user: "root" # release script upgrades CA trust before contacting RubyGems
35
36
  environment:
36
37
  - BUILDKITE_TAG
37
38
 
@@ -48,13 +49,14 @@ steps:
48
49
  # Step-local publish signal: distinguishes this credentialed step from
49
50
  # the rehearsal build step, which runs the same script.
50
51
  RELEASE_PUBLISH: "true"
52
+ RUBYGEMS_OIDC_ROLE: "rg_oidc_akr_fy1x4px4yjwd1rdhkkda"
51
53
  command: test-collector-ruby/.buildkite/steps/release
52
54
  plugins:
53
- - rubygems-oidc#v0.2.0:
54
- role: "rg_oidc_akr_fy1x4px4yjwd1rdhkkda"
55
55
  - docker#v5.12.0:
56
56
  image: "ruby:3.4"
57
+ user: "root"
58
+ mount-buildkite-agent: true
57
59
  environment:
58
- - GEM_HOST_API_KEY
60
+ - RUBYGEMS_OIDC_ROLE
59
61
  - BUILDKITE_TAG
60
62
  - RELEASE_PUBLISH
@@ -12,6 +12,8 @@
12
12
 
13
13
  set -euo pipefail
14
14
 
15
+ bash "$(dirname "$0")/../../../.buildkite/steps/update-ca-certificates"
16
+
15
17
  cd "$(dirname "$0")/../.." # this project's root, wherever the checkout cwd is
16
18
 
17
19
  PROJECT="test-collector-ruby"
@@ -67,8 +69,21 @@ if [ "${ALREADY_PUBLISHED}" = "true" ]; then
67
69
  echo "version ${VERSION} already published; refusing" >&2
68
70
  exit 1
69
71
  fi
70
- if [ -z "${GEM_HOST_API_KEY:-}" ]; then
71
- echo "GEM_HOST_API_KEY not set (rubygems-oidc plugin missing or failed)" >&2
72
- exit 1
73
- fi
72
+
73
+ # The OIDC plugin's environment hook ran on the agent before Docker, outside
74
+ # this trust update. Exchange the same short-lived JWT inside the container.
75
+ echo "--- Obtaining RubyGems push key (OIDC)"
76
+ GEM_HOST_API_KEY="$(
77
+ buildkite-agent oidc request-token --audience rubygems.org --lifetime 60 |
78
+ ruby -rnet/http -rjson -e '
79
+ role = ARGV.fetch(0)
80
+ uri = URI("https://rubygems.org/api/v1/oidc/api_key_roles/#{role}/assume_role")
81
+ response = Net::HTTP.post(uri, JSON.generate(jwt: STDIN.read.strip), "Content-Type" => "application/json")
82
+ abort "RubyGems OIDC exchange failed (HTTP #{response.code})" unless response.is_a?(Net::HTTPSuccess)
83
+ key = JSON.parse(response.body).fetch("rubygems_api_key")
84
+ abort "RubyGems OIDC exchange returned an empty key" if key.to_s.empty?
85
+ print key
86
+ ' "${RUBYGEMS_OIDC_ROLE:?RUBYGEMS_OIDC_ROLE must be set for publishing}"
87
+ )"
88
+ export GEM_HOST_API_KEY
74
89
  gem push "${GEM_FILENAME}"
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## v2.17.1
6
+
7
+ * Failed tests with no instrumented work no longer send OpenTelemetry phase
8
+ spans (`test.setup`, `test.body`, and `test.teardown`) to Buildkite, reducing
9
+ billable child span ingest for uninstrumented suites. Test spans still carry
10
+ the failure status and exception events. The trace identifies the failing
11
+ phase only when it grouped a tracked child span.
12
+
5
13
  ## v2.17.0
6
14
 
7
15
  * Export an OpenTelemetry `test.execution` span for examples that RSpec fails
data/README.md CHANGED
@@ -90,8 +90,12 @@ trace is rooted in a `test.execution` span carrying the test's name, location,
90
90
  result, and failure detail. Phase spans underneath it, `test.setup`,
91
91
  `test.body`, and `test.teardown`, group the instrumented child spans by whether
92
92
  they ran in before hooks, the example itself, or after hooks, and each records
93
- the failure raised in its phase. A phase with no spans and no failure is not
94
- exported.
93
+ the failure raised in its phase. Only phases that grouped at least one tracked
94
+ child span are sent to Buildkite, even if the child is later filtered out.
95
+ An uninstrumented suite sends no child spans, even when tests fail: the test
96
+ span still carries the failure. The trace identifies which phase failed only
97
+ when that phase grouped a child span. A suite-owned provider's own exporters
98
+ still receive every phase.
95
99
 
96
100
  This feature is still under development and may change. OpenTelemetry is off by
97
101
  default. Enable it when you configure the collector:
@@ -49,15 +49,18 @@ test.execution "Buildkite::Pipeline creates a build" 12.4ms
49
49
  `test.setup` covers `before(:each)` hooks and `let!`, `test.body` the example
50
50
  block, and `test.teardown` `after(:each)` hooks and mock verification. A phase
51
51
  whose failure fails the example gets an error status and an `exception` event
52
- per failure, so a trace shows which phase failed even before you read the
53
- test's own error. A before hook that raises leaves no `test.body` span, because
54
- RSpec never runs the example. `around` hooks wrap all three phases, so spans
55
- they open stay direct children of the test span, alongside the phases.
56
-
57
- A phase is exported only when it grouped at least one span or failed; a phase
58
- with nothing in it says nothing the test span does not. An example with no
59
- instrumented work therefore adds no child spans at all, and `otel_span_filter`
60
- never sees phase spans.
52
+ per failure. The trace identifies which phase failed only when that phase
53
+ grouped a child span and is exported. A before hook that raises leaves no
54
+ `test.body` span, because RSpec never runs the example. `around` hooks wrap all
55
+ three phases, so spans they open stay direct children of the test span,
56
+ alongside the phases.
57
+
58
+ A phase is sent to Buildkite only when it grouped at least one tracked child
59
+ span, even if the child is later dropped by `otel_span_filter`. An example
60
+ with no instrumented work therefore adds no child spans at all, even when it
61
+ fails: the test span still carries the error status and exception events.
62
+ The filter never sees phase spans. A suite-owned provider's own exporters
63
+ still receive every phase, empty or not.
61
64
 
62
65
  One example is one trace. Child spans share the root's trace ID, and the root is
63
66
  never nested under anything else, so a trace always belongs to exactly one test.
@@ -211,9 +214,9 @@ configure instrumentation there as you normally would. This is also the way to
211
214
  keep a bundle full of instrumentation gems (such as
212
215
  `opentelemetry-instrumentation-all`, loaded for production) unpatched under
213
216
  test: configure the SDK yourself, before the suite starts, without `use` or
214
- `use_all`, and the collector forwards only `test.execution` spans, the phase
215
- spans, and any spans your suite creates by hand. Set `OTEL_TRACES_EXPORTER=none`
216
- as well, or the SDK adds its own default OTLP exporter aimed at
217
+ `use_all`, and the collector forwards only `test.execution` spans, any spans
218
+ your suite creates by hand, and the phases that grouped those spans. Set
219
+ `OTEL_TRACES_EXPORTER=none` as well, or the SDK adds its own default OTLP exporter aimed at
217
220
  `localhost:4318`:
218
221
 
219
222
  ```ruby
@@ -80,14 +80,13 @@ module Buildkite
80
80
 
81
81
  private
82
82
 
83
- # Called under @mutex. A phase span that grouped nothing and did not
84
- # fail says nothing the test span does not, so an uninstrumented
85
- # suite exports no child spans at all.
83
+ # Called under @mutex. Failures already ride on the test span, so an
84
+ # uninstrumented suite exports no child spans, even when tests fail.
86
85
  def accept(span)
87
86
  return false unless @spans.delete(span)
88
87
  return true unless phase_span?(span)
89
88
 
90
- @populated_phases.delete(span) || span.status.code != OpenTelemetry::Trace::Status::UNSET
89
+ @populated_phases.delete(span)
91
90
  end
92
91
 
93
92
  # Only called with tracked spans, which have a name.
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Buildkite
4
4
  module TestCollector
5
- VERSION = "2.17.0"
5
+ VERSION = "2.17.1"
6
6
  NAME = "buildkite-test_collector"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildkite-test_collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.17.0
4
+ version: 2.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Buildkite