buildkite-test_collector 2.9.0 → 2.11.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.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +35 -3
- data/README.md +18 -37
- data/buildkite-test_collector.gemspec +5 -0
- data/buildkite.yaml +24 -0
- data/cucumber.yml +1 -0
- data/lib/buildkite/test_collector/cucumber_plugin/trace.rb +55 -0
- data/lib/buildkite/test_collector/error.rb +1 -0
- data/lib/buildkite/test_collector/library_hooks/cucumber.rb +75 -0
- data/lib/buildkite/test_collector/library_hooks/rspec.rb +1 -0
- data/lib/buildkite/test_collector/minitest_plugin/trace.rb +11 -27
- data/lib/buildkite/test_collector/minitest_plugin.rb +1 -0
- data/lib/buildkite/test_collector/rspec_plugin/trace.rb +15 -27
- data/lib/buildkite/test_collector/trace.rb +43 -0
- data/lib/buildkite/test_collector/version.rb +1 -1
- data/lib/buildkite/test_collector.rb +9 -2
- metadata +21 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 423b9692a49e1cea2d180d684f9f54c82a6fd84289087efe256cf4a2d1dd5f4b
|
|
4
|
+
data.tar.gz: 7ec78a72fb4506ee301b44f2830adfc22c83eb0508cab3ef7d455ec4a1f3049a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dcf9a81dd2c1b74f8241c22ea94aff3dc75a9c1190afda0b12d4c2ac06bd79b89694fcee5d43a07a051864d404e140cf665064778dbb5d73b389abbba28af1ec
|
|
7
|
+
data.tar.gz: eb43eb66820451723296546c70b3b2fc7b63572aa393ae4ea2380bb8e195e7faa0c6e8b7eff56c04a70223585c55162872a82d647a7a4d74e8cfe7ffa7cad3c6
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v2.11.0
|
|
4
|
+
|
|
5
|
+
* Add `location_prefix` option. Allows a file name prefix to be set which will be prepended to `file_name` and `location` in the test results.
|
|
6
|
+
|
|
7
|
+
**Full Changelog**: https://github.com/buildkite/test-collector-ruby/compare/v2.10.0...v2.11.0
|
|
8
|
+
|
|
9
|
+
## v2.10.0
|
|
10
|
+
|
|
11
|
+
* Add support for Cucumber
|
|
12
|
+
|
|
3
13
|
## v2.9.0
|
|
4
14
|
|
|
5
15
|
* `Buildkite::TestCollector.tag_execution(key, value)` by @pda in https://github.com/buildkite/test-collector-ruby/pull/240
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
buildkite-test_collector (2.
|
|
4
|
+
buildkite-test_collector (2.11.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -22,14 +22,43 @@ GEM
|
|
|
22
22
|
base64 (0.2.0)
|
|
23
23
|
benchmark (0.4.0)
|
|
24
24
|
bigdecimal (3.1.9)
|
|
25
|
+
builder (3.3.0)
|
|
25
26
|
concurrent-ruby (1.3.5)
|
|
26
27
|
connection_pool (2.5.0)
|
|
27
|
-
|
|
28
|
+
cucumber (9.2.1)
|
|
29
|
+
builder (~> 3.2)
|
|
30
|
+
cucumber-ci-environment (> 9, < 11)
|
|
31
|
+
cucumber-core (> 13, < 14)
|
|
32
|
+
cucumber-cucumber-expressions (~> 17.0)
|
|
33
|
+
cucumber-gherkin (> 24, < 28)
|
|
34
|
+
cucumber-html-formatter (> 20.3, < 22)
|
|
35
|
+
cucumber-messages (> 19, < 25)
|
|
36
|
+
diff-lcs (~> 1.5)
|
|
37
|
+
mini_mime (~> 1.1)
|
|
38
|
+
multi_test (~> 1.1)
|
|
39
|
+
sys-uname (~> 1.2)
|
|
40
|
+
cucumber-ci-environment (10.0.1)
|
|
41
|
+
cucumber-core (13.0.3)
|
|
42
|
+
cucumber-gherkin (>= 27, < 28)
|
|
43
|
+
cucumber-messages (>= 20, < 23)
|
|
44
|
+
cucumber-tag-expressions (> 5, < 7)
|
|
45
|
+
cucumber-cucumber-expressions (17.1.0)
|
|
46
|
+
bigdecimal
|
|
47
|
+
cucumber-gherkin (27.0.0)
|
|
48
|
+
cucumber-messages (>= 19.1.4, < 23)
|
|
49
|
+
cucumber-html-formatter (21.9.0)
|
|
50
|
+
cucumber-messages (> 19, < 28)
|
|
51
|
+
cucumber-messages (22.0.0)
|
|
52
|
+
cucumber-tag-expressions (6.1.2)
|
|
53
|
+
diff-lcs (1.6.2)
|
|
28
54
|
drb (2.2.1)
|
|
55
|
+
ffi (1.17.2)
|
|
29
56
|
i18n (1.14.7)
|
|
30
57
|
concurrent-ruby (~> 1.0)
|
|
31
|
-
logger (1.
|
|
58
|
+
logger (1.7.0)
|
|
59
|
+
mini_mime (1.1.5)
|
|
32
60
|
minitest (5.25.4)
|
|
61
|
+
multi_test (1.1.0)
|
|
33
62
|
rake (13.2.1)
|
|
34
63
|
rspec (3.13.0)
|
|
35
64
|
rspec-core (~> 3.13.0)
|
|
@@ -45,6 +74,8 @@ GEM
|
|
|
45
74
|
rspec-support (~> 3.13.0)
|
|
46
75
|
rspec-support (3.13.2)
|
|
47
76
|
securerandom (0.4.1)
|
|
77
|
+
sys-uname (1.3.1)
|
|
78
|
+
ffi (~> 1.1)
|
|
48
79
|
tzinfo (2.0.6)
|
|
49
80
|
concurrent-ruby (~> 1.0)
|
|
50
81
|
uri (1.0.2)
|
|
@@ -55,6 +86,7 @@ PLATFORMS
|
|
|
55
86
|
DEPENDENCIES
|
|
56
87
|
activesupport (>= 4.2)
|
|
57
88
|
buildkite-test_collector!
|
|
89
|
+
cucumber (~> 9.0)
|
|
58
90
|
rake (~> 13.0)
|
|
59
91
|
rspec (~> 3.0)
|
|
60
92
|
rspec-core (~> 3.10)
|
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Versions prior to 2.1.x are unsupported and will not work after mid-2023. Please
|
|
|
5
5
|
|
|
6
6
|
Official [Buildkite Test Engine](https://buildkite.com/platform/test-engine) collectors for Ruby test frameworks ✨
|
|
7
7
|
|
|
8
|
-
⚒ **Supported test frameworks:** RSpec, Minitest, and [more coming soon](https://github.com/buildkite/test-collector-ruby/issues?q=is%3Aissue+is%3Aopen+label%3A%22test+frameworks%22).
|
|
8
|
+
⚒ **Supported test frameworks:** RSpec, Minitest, Cucumber, and [more coming soon](https://github.com/buildkite/test-collector-ruby/issues?q=is%3Aissue+is%3Aopen+label%3A%22test+frameworks%22).
|
|
9
9
|
|
|
10
10
|
📦 **Supported CI systems:** Buildkite, GitHub Actions, CircleCI, Codeship, and others via the `BUILDKITE_ANALYTICS_*` environment variables.
|
|
11
11
|
|
|
@@ -63,47 +63,30 @@ Run your tests locally:
|
|
|
63
63
|
BUILDKITE_ANALYTICS_TOKEN=xyz rake
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Add the `BUILDKITE_ANALYTICS_TOKEN` secret to your CI, push your changes to a branch, and open a pull request 🎉
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
git checkout -b add-buildkite-test-engine
|
|
72
|
-
git commit -am "Add Buildkite Test Engine"
|
|
73
|
-
git push origin add-buildkite-test-engine
|
|
74
|
-
```
|
|
66
|
+
#### Cucumber
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
If your test suites use [VCR](https://github.com/vcr/vcr) to stub network requests, you'll need to modify the config to allow actual network requests to Test Engine.
|
|
68
|
+
Add the following code to your Cucumber setup file:
|
|
78
69
|
|
|
70
|
+
```ruby
|
|
71
|
+
# features/support/env.rb
|
|
72
|
+
require 'buildkite/test_collector'
|
|
73
|
+
Buildkite::TestCollector.configure(hook: :cucumber)
|
|
79
74
|
```
|
|
80
|
-
VCR.configure do |c|
|
|
81
|
-
c.ignore_hosts "analytics-api.buildkite.com"
|
|
82
|
-
end
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## 🗨️ Annotations
|
|
86
75
|
|
|
87
|
-
|
|
76
|
+
Run your tests locally:
|
|
88
77
|
|
|
89
|
-
```
|
|
90
|
-
|
|
78
|
+
```shell
|
|
79
|
+
BUILDKITE_ANALYTICS_TOKEN=xyz cucumber
|
|
91
80
|
```
|
|
92
81
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
## 🏷️ Tagging duplicate test executions with a prefix/suffix
|
|
82
|
+
### Step 3
|
|
96
83
|
|
|
97
|
-
|
|
84
|
+
Add the `BUILDKITE_ANALYTICS_TOKEN` secret to your CI, push your changes to a branch, and open a pull request 🎉
|
|
98
85
|
|
|
99
|
-
```
|
|
100
|
-
BUILDKITE_ANALYTICS_EXECUTION_NAME_PREFIX
|
|
101
|
-
BUILDKITE_ANALYTICS_EXECUTION_NAME_SUFFIX
|
|
102
|
-
```
|
|
103
86
|
|
|
104
|
-
##
|
|
87
|
+
## More information
|
|
105
88
|
|
|
106
|
-
|
|
89
|
+
For more use cases such as custom tags, annotations, and span tracking, please visit our [official Ruby collector documentation](https://buildkite.com/docs/test-engine/ruby-collectors) for details.
|
|
107
90
|
|
|
108
91
|
## ⚒ Developing
|
|
109
92
|
|
|
@@ -130,17 +113,15 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/buildk
|
|
|
130
113
|
## 🚀 Releasing
|
|
131
114
|
|
|
132
115
|
1. Bump the version in `version.rb` and run `bundle` to update the `Gemfile.lock`.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
Once your PR is merged to `main`:
|
|
116
|
+
2. Update the CHANGELOG.md with your new version and a description of your changes.
|
|
117
|
+
3. Once your PR is merged to `main` git tag the merge commit and push:
|
|
136
118
|
|
|
137
|
-
1. Git tag the merge commit and push
|
|
138
119
|
```
|
|
139
120
|
git tag vX.X.X
|
|
140
121
|
git push origin vX.X.X
|
|
141
122
|
```
|
|
142
|
-
|
|
143
|
-
|
|
123
|
+
4. Visit the [release pipeline](https://buildkite.com/buildkite/test-collector-ruby-release) to unblock it and confirm the new version is pushed to rubygems.org
|
|
124
|
+
5. Create a [new release in github](https://github.com/buildkite/test-collector-ruby/releases).
|
|
144
125
|
|
|
145
126
|
## 📜 MIT License
|
|
146
127
|
|
|
@@ -27,4 +27,9 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.add_development_dependency "activesupport", ">= 4.2"
|
|
28
28
|
spec.add_development_dependency "rspec-core", '~> 3.10'
|
|
29
29
|
spec.add_development_dependency "rspec-expectations", '~> 3.10'
|
|
30
|
+
|
|
31
|
+
# When running the legacy CI builds against versions of Ruby pre 2.7 we cannot include cucumber 9 as it's not supported.
|
|
32
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
|
|
33
|
+
spec.add_development_dependency "cucumber", '~> 9.0'
|
|
34
|
+
end
|
|
30
35
|
end
|
data/buildkite.yaml
CHANGED
|
@@ -7,7 +7,20 @@ steps:
|
|
|
7
7
|
- "gem install bundler:2.3.25"
|
|
8
8
|
- "bundle"
|
|
9
9
|
- "bundle exec rake"
|
|
10
|
+
- "bundle exec cucumber"
|
|
10
11
|
plugins:
|
|
12
|
+
- aws-assume-role-with-web-identity#v1.2.0:
|
|
13
|
+
role-arn: "${OIDC_ASSUME_ROLE_ARN:-arn:aws:iam::445615400570:role/pipeline-buildkite-test-collector-ruby-build}"
|
|
14
|
+
session-tags:
|
|
15
|
+
- organization_slug
|
|
16
|
+
- organization_id
|
|
17
|
+
- pipeline_slug
|
|
18
|
+
- build_branch
|
|
19
|
+
|
|
20
|
+
- ecr#v2.9.0:
|
|
21
|
+
login: true
|
|
22
|
+
account_ids: "public.ecr.aws"
|
|
23
|
+
region: "us-east-1"
|
|
11
24
|
- docker#v3.7.0:
|
|
12
25
|
image: "public.ecr.aws/docker/library/ruby:{{matrix}}"
|
|
13
26
|
matrix:
|
|
@@ -27,6 +40,17 @@ steps:
|
|
|
27
40
|
- "bundle"
|
|
28
41
|
- "bundle exec rake"
|
|
29
42
|
plugins:
|
|
43
|
+
- aws-assume-role-with-web-identity#v1.2.0:
|
|
44
|
+
role-arn: "${OIDC_ASSUME_ROLE_ARN:-arn:aws:iam::445615400570:role/pipeline-buildkite-test-collector-ruby-build}"
|
|
45
|
+
session-tags:
|
|
46
|
+
- organization_slug
|
|
47
|
+
- organization_id
|
|
48
|
+
- pipeline_slug
|
|
49
|
+
- build_branch
|
|
50
|
+
- ecr#v2.9.0:
|
|
51
|
+
login: true
|
|
52
|
+
account_ids: "public.ecr.aws"
|
|
53
|
+
region: "us-east-1"
|
|
30
54
|
- docker#v3.7.0:
|
|
31
55
|
# Images for older Ruby versions aren't available on AWS ECR
|
|
32
56
|
# so fall back to Docker Hub
|
data/cucumber.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
default: --publish-quiet
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Buildkite::TestCollector::CucumberPlugin
|
|
4
|
+
class Trace < Buildkite::TestCollector::Trace
|
|
5
|
+
attr_accessor :scenario, :failure_reason, :failure_expanded
|
|
6
|
+
attr_reader :history, :tags, :location_prefix
|
|
7
|
+
|
|
8
|
+
FILE_PATH_REGEX = /^(.*?\.(rb|feature))/
|
|
9
|
+
|
|
10
|
+
def initialize(scenario, history:, failure_reason: nil, failure_expanded: [], tags: nil, location_prefix: nil)
|
|
11
|
+
@scenario = scenario
|
|
12
|
+
@history = history
|
|
13
|
+
@failure_reason = failure_reason
|
|
14
|
+
@failure_expanded = failure_expanded
|
|
15
|
+
@tags = tags
|
|
16
|
+
@location_prefix = location_prefix
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def result
|
|
20
|
+
if scenario.passed?
|
|
21
|
+
'passed'
|
|
22
|
+
elsif scenario.failed?
|
|
23
|
+
'failed'
|
|
24
|
+
else
|
|
25
|
+
'skipped'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def gherkin_parser
|
|
32
|
+
@gherkin_parser ||= Gherkin::Parser.new
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def document
|
|
36
|
+
@document ||= gherkin_parser.parse(File.read(file_name))
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def scope
|
|
40
|
+
document.feature.name
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def name
|
|
44
|
+
scenario.name
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def location
|
|
48
|
+
scenario.location&.to_s
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def file_name
|
|
52
|
+
@file_name ||= location&.to_s[FILE_PATH_REGEX]
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cucumber'
|
|
4
|
+
|
|
5
|
+
require_relative '../cucumber_plugin/trace'
|
|
6
|
+
|
|
7
|
+
# Use Buildkite's uploader for Cucumber as well
|
|
8
|
+
Buildkite::TestCollector.uploader = Buildkite::TestCollector::Uploader
|
|
9
|
+
|
|
10
|
+
# -------------------------------------------------
|
|
11
|
+
# Hooks
|
|
12
|
+
# -------------------------------------------------
|
|
13
|
+
|
|
14
|
+
Before do |scenario|
|
|
15
|
+
tracer = Buildkite::TestCollector::Tracer.new(
|
|
16
|
+
min_duration: Buildkite::TestCollector.trace_min_duration,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
tags = {}
|
|
20
|
+
|
|
21
|
+
# _buildkite prefix reduces chance of collisions in this almost-global (per-fiber) namespace.
|
|
22
|
+
Thread.current[:_buildkite_tracer] = tracer
|
|
23
|
+
Thread.current[:_buildkite_tags] = tags
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
After do |scenario|
|
|
27
|
+
tracer = Thread.current[:_buildkite_tracer]
|
|
28
|
+
tags = Thread.current[:_buildkite_tags]
|
|
29
|
+
|
|
30
|
+
Thread.current[:_buildkite_tracer] = nil
|
|
31
|
+
Thread.current[:_buildkite_tags] = nil
|
|
32
|
+
|
|
33
|
+
if tracer
|
|
34
|
+
tracer.finalize
|
|
35
|
+
|
|
36
|
+
failure_reason = nil
|
|
37
|
+
failure_expanded = []
|
|
38
|
+
|
|
39
|
+
if scenario.failed?
|
|
40
|
+
exception = scenario.exception
|
|
41
|
+
if exception
|
|
42
|
+
failure_reason = exception.message
|
|
43
|
+
failure_expanded << {
|
|
44
|
+
backtrace: exception.backtrace,
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
trace = Buildkite::TestCollector::CucumberPlugin::Trace.new(
|
|
50
|
+
scenario,
|
|
51
|
+
history: tracer.history,
|
|
52
|
+
failure_reason: failure_reason,
|
|
53
|
+
failure_expanded: failure_expanded,
|
|
54
|
+
tags: tags,
|
|
55
|
+
location_prefix: Buildkite::TestCollector.location_prefix,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
Buildkite::TestCollector.uploader.traces[scenario.location.to_s] = trace
|
|
59
|
+
|
|
60
|
+
if Buildkite::TestCollector.session
|
|
61
|
+
Buildkite::TestCollector.session.add_example_to_send_queue(scenario.location.to_s)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
at_exit do
|
|
67
|
+
if Buildkite::TestCollector.session
|
|
68
|
+
Buildkite::TestCollector.session.send_remaining_data
|
|
69
|
+
Buildkite::TestCollector.session.close
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Initialise shared tracing & session behaviour once hooks file is loaded.
|
|
74
|
+
Buildkite::TestCollector.enable_tracing!
|
|
75
|
+
Buildkite::TestCollector.session = Buildkite::TestCollector::Session.new
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Buildkite::TestCollector::MinitestPlugin
|
|
4
|
-
class Trace
|
|
4
|
+
class Trace < Buildkite::TestCollector::Trace
|
|
5
5
|
attr_accessor :example
|
|
6
6
|
attr_writer :failure_reason, :failure_expanded
|
|
7
7
|
attr_reader :history
|
|
8
|
+
attr_reader :location_prefix
|
|
8
9
|
attr_reader :tags
|
|
9
10
|
|
|
10
11
|
RESULT_CODES = {
|
|
@@ -16,10 +17,11 @@ module Buildkite::TestCollector::MinitestPlugin
|
|
|
16
17
|
|
|
17
18
|
FILE_PATH_REGEX = /^(.*?\.(rb|feature))/
|
|
18
19
|
|
|
19
|
-
def initialize(example, history:, tags: nil)
|
|
20
|
+
def initialize(example, history:, tags: nil, trace: nil, location_prefix: nil)
|
|
20
21
|
@example = example
|
|
21
22
|
@history = history
|
|
22
23
|
@tags = tags
|
|
24
|
+
@location_prefix = location_prefix
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def result
|
|
@@ -30,21 +32,15 @@ module Buildkite::TestCollector::MinitestPlugin
|
|
|
30
32
|
@source_location ||= example.method(example.name).source_location
|
|
31
33
|
end
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
location: location,
|
|
38
|
-
file_name: file_name,
|
|
39
|
-
result: result,
|
|
40
|
-
failure_reason: failure_reason,
|
|
41
|
-
failure_expanded: failure_expanded,
|
|
42
|
-
history: history,
|
|
43
|
-
tags: tags,
|
|
44
|
-
).select { |_, value| !value.nil? }
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def scope
|
|
38
|
+
example.class.name
|
|
45
39
|
end
|
|
46
40
|
|
|
47
|
-
|
|
41
|
+
def name
|
|
42
|
+
example.name
|
|
43
|
+
end
|
|
48
44
|
|
|
49
45
|
def location
|
|
50
46
|
if file_name
|
|
@@ -85,17 +81,5 @@ module Buildkite::TestCollector::MinitestPlugin
|
|
|
85
81
|
}
|
|
86
82
|
end
|
|
87
83
|
end
|
|
88
|
-
|
|
89
|
-
def strip_invalid_utf8_chars(object)
|
|
90
|
-
if object.is_a?(Hash)
|
|
91
|
-
Hash[object.map { |key, value| [key, strip_invalid_utf8_chars(value)] }]
|
|
92
|
-
elsif object.is_a?(Array)
|
|
93
|
-
object.map { |value| strip_invalid_utf8_chars(value) }
|
|
94
|
-
elsif object.is_a?(String)
|
|
95
|
-
object.encode('UTF-8', :invalid => :replace, :undef => :replace)
|
|
96
|
-
else
|
|
97
|
-
object
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
84
|
end
|
|
101
85
|
end
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Buildkite::TestCollector::RSpecPlugin
|
|
4
|
-
class Trace
|
|
4
|
+
class Trace < Buildkite::TestCollector::Trace
|
|
5
5
|
attr_accessor :example, :failure_reason, :failure_expanded
|
|
6
6
|
attr_reader :history
|
|
7
7
|
attr_reader :tags
|
|
8
|
+
attr_reader :location_prefix
|
|
8
9
|
|
|
9
10
|
FILE_PATH_REGEX = /^(.*?\.(rb|feature))/
|
|
10
11
|
|
|
11
|
-
def initialize(example, history:, failure_reason: nil, failure_expanded: [], tags: nil)
|
|
12
|
+
def initialize(example, history:, failure_reason: nil, failure_expanded: [], tags: nil, location_prefix: nil)
|
|
12
13
|
@example = example
|
|
13
14
|
@history = history
|
|
14
15
|
@failure_reason = failure_reason
|
|
15
16
|
@failure_expanded = failure_expanded
|
|
16
17
|
@tags = tags
|
|
18
|
+
@location_prefix = location_prefix
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def result
|
|
@@ -24,21 +26,19 @@ module Buildkite::TestCollector::RSpecPlugin
|
|
|
24
26
|
end
|
|
25
27
|
end
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
location: example.location,
|
|
32
|
-
file_name: file_name,
|
|
33
|
-
result: result,
|
|
34
|
-
failure_reason: failure_reason,
|
|
35
|
-
failure_expanded: failure_expanded,
|
|
36
|
-
history: history,
|
|
37
|
-
tags: tags,
|
|
38
|
-
).select { |_, value| !value.nil? }
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def scope
|
|
32
|
+
example.example_group.metadata[:full_description]
|
|
39
33
|
end
|
|
40
34
|
|
|
41
|
-
|
|
35
|
+
def name
|
|
36
|
+
example.description
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def location
|
|
40
|
+
example.location
|
|
41
|
+
end
|
|
42
42
|
|
|
43
43
|
def file_name
|
|
44
44
|
@file_name ||= begin
|
|
@@ -69,17 +69,5 @@ module Buildkite::TestCollector::RSpecPlugin
|
|
|
69
69
|
def shared_example_call_location
|
|
70
70
|
example.metadata[:shared_group_inclusion_backtrace].last.inclusion_location
|
|
71
71
|
end
|
|
72
|
-
|
|
73
|
-
def strip_invalid_utf8_chars(object)
|
|
74
|
-
if object.is_a?(Hash)
|
|
75
|
-
Hash[object.map { |key, value| [key, strip_invalid_utf8_chars(value)] }]
|
|
76
|
-
elsif object.is_a?(Array)
|
|
77
|
-
object.map { |value| strip_invalid_utf8_chars(value) }
|
|
78
|
-
elsif object.is_a?(String)
|
|
79
|
-
object.encode('UTF-8', :invalid => :replace, :undef => :replace)
|
|
80
|
-
else
|
|
81
|
-
object
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
72
|
end
|
|
85
73
|
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Buildkite
|
|
4
|
+
module TestCollector
|
|
5
|
+
class Trace
|
|
6
|
+
def as_hash
|
|
7
|
+
strip_invalid_utf8_chars(
|
|
8
|
+
scope: scope,
|
|
9
|
+
name: name,
|
|
10
|
+
location: prepend_location_prefix(location),
|
|
11
|
+
file_name: prepend_location_prefix(file_name),
|
|
12
|
+
result: result,
|
|
13
|
+
failure_reason: failure_reason,
|
|
14
|
+
failure_expanded: failure_expanded,
|
|
15
|
+
history: history,
|
|
16
|
+
tags: tags,
|
|
17
|
+
).select { |_, value| !value.nil? }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def strip_invalid_utf8_chars(object)
|
|
23
|
+
if object.is_a?(Hash)
|
|
24
|
+
Hash[object.map { |key, value| [key, strip_invalid_utf8_chars(value)] }]
|
|
25
|
+
elsif object.is_a?(Array)
|
|
26
|
+
object.map { |value| strip_invalid_utf8_chars(value) }
|
|
27
|
+
elsif object.is_a?(String)
|
|
28
|
+
object.encode('UTF-8', :invalid => :replace, :undef => :replace)
|
|
29
|
+
else
|
|
30
|
+
object
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def prepend_location_prefix(file_name)
|
|
35
|
+
return file_name unless file_name && location_prefix
|
|
36
|
+
|
|
37
|
+
Pathname.new(location_prefix).join(
|
|
38
|
+
Pathname.new(file_name)
|
|
39
|
+
).to_s
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -20,6 +20,7 @@ require_relative "test_collector/http_client"
|
|
|
20
20
|
require_relative "test_collector/uploader"
|
|
21
21
|
require_relative "test_collector/network"
|
|
22
22
|
require_relative "test_collector/object"
|
|
23
|
+
require_relative "test_collector/trace"
|
|
23
24
|
require_relative "test_collector/tracer"
|
|
24
25
|
require_relative "test_collector/session"
|
|
25
26
|
require_relative "test_collector/uuid"
|
|
@@ -35,6 +36,7 @@ module Buildkite
|
|
|
35
36
|
attr_accessor :session
|
|
36
37
|
attr_accessor :tracing_enabled
|
|
37
38
|
attr_accessor :artifact_path
|
|
39
|
+
attr_accessor :location_prefix
|
|
38
40
|
attr_accessor :env
|
|
39
41
|
attr_accessor :tags
|
|
40
42
|
attr_accessor :batch_size
|
|
@@ -42,11 +44,16 @@ module Buildkite
|
|
|
42
44
|
attr_accessor :span_filters
|
|
43
45
|
end
|
|
44
46
|
|
|
45
|
-
def self.configure(hook:, token: nil, url: nil, tracing_enabled: true, artifact_path: nil, env: {}, tags: {})
|
|
47
|
+
def self.configure(hook:, token: nil, url: nil, tracing_enabled: true, artifact_path: nil, location_prefix: nil, env: {}, tags: {})
|
|
48
|
+
if hook.to_sym == :cucumber && Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7')
|
|
49
|
+
raise UnsupportedFrameworkError.new("Cucumber is only supported in versions of Ruby >= 2.7")
|
|
50
|
+
end
|
|
51
|
+
|
|
46
52
|
self.api_token = (token || ENV["BUILDKITE_ANALYTICS_TOKEN"])&.strip
|
|
47
|
-
self.url = url || DEFAULT_URL
|
|
53
|
+
self.url = url || ENV["BUILDKITE_ANALYTICS_ENDPOINT"] || DEFAULT_URL
|
|
48
54
|
self.tracing_enabled = tracing_enabled
|
|
49
55
|
self.artifact_path = artifact_path
|
|
56
|
+
self.location_prefix = location_prefix || ENV["BUILDKITE_ANALYTICS_LOCATION_PREFIX"]
|
|
50
57
|
self.env = env
|
|
51
58
|
self.tags = tags
|
|
52
59
|
self.batch_size = ENV.fetch("BUILDKITE_ANALYTICS_UPLOAD_BATCH_SIZE") { DEFAULT_UPLOAD_BATCH_SIZE }.to_i
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: buildkite-test_collector
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Buildkite
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -51,6 +51,20 @@ dependencies:
|
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: '3.10'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: cucumber
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '9.0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '9.0'
|
|
54
68
|
email:
|
|
55
69
|
- support+analytics@buildkite.com
|
|
56
70
|
executables: []
|
|
@@ -74,10 +88,13 @@ files:
|
|
|
74
88
|
- bin/setup
|
|
75
89
|
- buildkite-test_collector.gemspec
|
|
76
90
|
- buildkite.yaml
|
|
91
|
+
- cucumber.yml
|
|
77
92
|
- lib/buildkite/test_collector.rb
|
|
78
93
|
- lib/buildkite/test_collector/ci.rb
|
|
94
|
+
- lib/buildkite/test_collector/cucumber_plugin/trace.rb
|
|
79
95
|
- lib/buildkite/test_collector/error.rb
|
|
80
96
|
- lib/buildkite/test_collector/http_client.rb
|
|
97
|
+
- lib/buildkite/test_collector/library_hooks/cucumber.rb
|
|
81
98
|
- lib/buildkite/test_collector/library_hooks/minitest.rb
|
|
82
99
|
- lib/buildkite/test_collector/library_hooks/rspec.rb
|
|
83
100
|
- lib/buildkite/test_collector/minitest_plugin.rb
|
|
@@ -88,6 +105,7 @@ files:
|
|
|
88
105
|
- lib/buildkite/test_collector/rspec_plugin/reporter.rb
|
|
89
106
|
- lib/buildkite/test_collector/rspec_plugin/trace.rb
|
|
90
107
|
- lib/buildkite/test_collector/session.rb
|
|
108
|
+
- lib/buildkite/test_collector/trace.rb
|
|
91
109
|
- lib/buildkite/test_collector/tracer.rb
|
|
92
110
|
- lib/buildkite/test_collector/uploader.rb
|
|
93
111
|
- lib/buildkite/test_collector/uuid.rb
|
|
@@ -113,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
113
131
|
- !ruby/object:Gem::Version
|
|
114
132
|
version: '0'
|
|
115
133
|
requirements: []
|
|
116
|
-
rubygems_version: 3.6.
|
|
134
|
+
rubygems_version: 3.6.9
|
|
117
135
|
specification_version: 4
|
|
118
136
|
summary: Track test executions and report to Buildkite Test Engine
|
|
119
137
|
test_files: []
|