rspec-buildkite-analytics 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b1c6bc2713e36242b9d710e348574bd05b8cda4e4d3961742a781256595114f
4
- data.tar.gz: f221e0f6486ceeb41547a344ec72b47c1385d1ec41689d61aa4e9d9653fa51e3
3
+ metadata.gz: a29588419eb727d74849c54b0d38f5b90974c3f58f083e48958a17288a1dc1fe
4
+ data.tar.gz: 1fd5fd323f7737c247b61bcd87ea9778e3f020601514eb52777c0ba5871c24aa
5
5
  SHA512:
6
- metadata.gz: a2fd21327c874a8efac7822e995ce9b487029462905ea24ea45aa7e34b89ff2fdf90aec46e1a048fed546ea78192471ce05018546845434821c952f76be36951
7
- data.tar.gz: 29ca02ed84c008bf2adad2ee75d2d02562d398ef976bf5f00b0c4f30ca3ddb3a4475c7ba1e5d6eb1a7d3de0f6628421dc1b7b83bc902506440d417da4b7a8078
6
+ metadata.gz: 45624d6a321c8ff16008e259b4a3eb3f118449d36947f1cb0efb86c7e988ee3e904a2665be517b4be2cd8075d4c1352d8356df88ac43c615664ec28383ced50f
7
+ data.tar.gz: fdb57102cd80974a01e939e8ab8bc8ae3ce22f39ff5a6862cc7cdc9d5250672a93ff966dfa391e47e80cdfaf70354082f0afd9ca1f6d4e1104edb53dbc11d977
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # CHANGELOG
2
+
3
+ ## v0.8.0
4
+
5
+ - Support multiple CI platforms and generic env #80 — @blaknite
6
+ - Replace invalid UTF-8 characters in test names #85 — @mariovisic
7
+ - Relax Active Support constraint #87 — @ags
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-buildkite-analytics (0.7.0)
5
- activesupport (>= 5.2, <= 7.0)
4
+ rspec-buildkite-analytics (0.8.0)
5
+ activesupport (>= 5.2, < 8)
6
6
  rspec-core (~> 3.10)
7
7
  rspec-expectations (~> 3.10)
8
8
  websocket (~> 1.2)
@@ -10,14 +10,14 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (7.0.0)
13
+ activesupport (7.0.2.3)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
17
17
  tzinfo (~> 2.0)
18
- concurrent-ruby (1.1.9)
18
+ concurrent-ruby (1.1.10)
19
19
  diff-lcs (1.4.4)
20
- i18n (1.9.1)
20
+ i18n (1.10.0)
21
21
  concurrent-ruby (~> 1.0)
22
22
  minitest (5.15.0)
23
23
  rake (13.0.6)
@@ -2,30 +2,85 @@
2
2
 
3
3
  require "securerandom"
4
4
 
5
- module RSpec::Buildkite::Analytics::CI
5
+ class RSpec::Buildkite::Analytics::CI
6
6
  def self.env
7
- if ENV["BUILDKITE_BUILD_ID"]
8
- {
9
- "CI" => "buildkite",
10
- "key" => ENV["BUILDKITE_BUILD_ID"],
11
- "url" => ENV["BUILDKITE_BUILD_URL"],
12
- "branch" => ENV["BUILDKITE_BRANCH"],
13
- "commit_sha" => ENV["BUILDKITE_COMMIT"],
14
- "number" => ENV["BUILDKITE_BUILD_NUMBER"],
15
- "job_id" => ENV["BUILDKITE_JOB_ID"],
16
- "message" => ENV["BUILDKITE_MESSAGE"],
17
- "debug" => ENV["BUILDKITE_ANALYTICS_DEBUG_ENABLED"],
18
- "version" => RSpec::Buildkite::Analytics::VERSION,
19
- "collector" => RSpec::Buildkite::Analytics::NAME
20
- }
21
- else
22
- {
23
- "CI" => nil,
24
- "key" => SecureRandom.uuid,
25
- "debug" => ENV["BUILDKITE_ANALYTICS_DEBUG_ENABLED"],
26
- "version" => RSpec::Buildkite::Analytics::VERSION,
27
- "collector" => RSpec::Buildkite::Analytics::NAME
28
- }
29
- end
7
+ new.env
8
+ end
9
+
10
+ # The analytics env are more specific than the automatic ci platform env.
11
+ # If they've been specified we'll assume the user wants to use that value instead.
12
+ def env
13
+ ci_env.merge(analytics_env)
14
+ end
15
+
16
+ private
17
+
18
+ def ci_env
19
+ return buildkite if ENV["BUILDKITE_BUILD_ID"]
20
+ return github_actions if ENV["GITHUB_RUN_NUMBER"]
21
+ return circleci if ENV["CIRCLE_BUILD_NUM"]
22
+ return generic if ENV["CI"]
23
+
24
+ {
25
+ "CI" => nil,
26
+ "key" => SecureRandom.uuid,
27
+ }
28
+ end
29
+
30
+ def analytics_env
31
+ {
32
+ "key" => ENV["BUILDKITE_ANALYTICS_KEY"],
33
+ "url" => ENV["BUILDKITE_ANALYTICS_URL"],
34
+ "branch" => ENV["BUILDKITE_ANALYTICS_BRANCH"],
35
+ "commit_sha" => ENV["BUILDKITE_ANALYTICS_SHA"],
36
+ "number" => ENV["BUILDKITE_ANALYTICS_NUMBER"],
37
+ "job_id" => ENV["BUILDKITE_ANALYTICS_JOB_ID"],
38
+ "message" => ENV["BUILDKITE_ANANLYTICS_MESSAGE"],
39
+ "debug" => ENV["BUILDKITE_ANALYTICS_DEBUG_ENABLED"],
40
+ "version" => RSpec::Buildkite::Analytics::VERSION,
41
+ "collector" => RSpec::Buildkite::Analytics::NAME,
42
+ }.compact
43
+ end
44
+
45
+ def generic
46
+ {
47
+ "CI" => "generic",
48
+ "key" => SecureRandom.uuid,
49
+ }
50
+ end
51
+
52
+ def buildkite
53
+ {
54
+ "CI" => "buildkite",
55
+ "key" => ENV["BUILDKITE_BUILD_ID"],
56
+ "url" => ENV["BUILDKITE_BUILD_URL"],
57
+ "branch" => ENV["BUILDKITE_BRANCH"],
58
+ "commit_sha" => ENV["BUILDKITE_COMMIT"],
59
+ "number" => ENV["BUILDKITE_BUILD_NUMBER"],
60
+ "job_id" => ENV["BUILDKITE_JOB_ID"],
61
+ "message" => ENV["BUILDKITE_MESSAGE"],
62
+ }
63
+ end
64
+
65
+ def github_actions
66
+ {
67
+ "CI" => "github_actions",
68
+ "key" => "#{ENV["GITHUB_ACTION"]}-#{ENV["GITHUB_RUN_NUMBER"]}-#{ENV["GITHUB_RUN_ATTEMPT"]}",
69
+ "url" => File.join("https://github.com", ENV["GITHUB_REPOSITORY"], "actions/runs", ENV["GITHUB_RUN_ID"]),
70
+ "branch" => ENV["GITHUB_REF"],
71
+ "commit_sha" => ENV["GITHUB_SHA"],
72
+ "number" => ENV["GITHUB_RUN_NUMBER"],
73
+ }
74
+ end
75
+
76
+ def circleci
77
+ {
78
+ "CI" => "circleci",
79
+ "key" => "#{ENV["CIRCLE_WORKFLOW_ID"]}-#{ENV["CIRCLE_BUILD_NUM"]}",
80
+ "url" => ENV["CIRCLE_BUILD_URL"],
81
+ "branch" => ENV["CIRCLE_BRANCH"],
82
+ "commit_sha" => ENV["CIRCLE_SHA1"],
83
+ "number" => ENV["CIRCLE_BUILD_NUM"],
84
+ }
30
85
  end
31
86
  end
@@ -42,7 +42,7 @@ module RSpec::Buildkite::Analytics
42
42
  end
43
43
 
44
44
  def as_hash
45
- {
45
+ strip_invalid_utf8_chars(
46
46
  id: @id,
47
47
  scope: example.example_group.metadata[:full_description],
48
48
  name: example.description,
@@ -53,14 +53,14 @@ module RSpec::Buildkite::Analytics
53
53
  failure_reason: failure_reason,
54
54
  failure_expanded: failure_expanded,
55
55
  history: history,
56
- }.with_indifferent_access.compact
56
+ ).with_indifferent_access.compact
57
57
  end
58
58
 
59
59
  private
60
60
 
61
61
  def generate_file_name(example)
62
62
  file_path_regex = /^(.*?\.(rb|feature))/
63
- identifier_file_name = example.id[file_path_regex]
63
+ identifier_file_name = strip_invalid_utf8_chars(example.id)[file_path_regex]
64
64
  location_file_name = example.location[file_path_regex]
65
65
 
66
66
  if identifier_file_name != location_file_name
@@ -78,6 +78,18 @@ module RSpec::Buildkite::Analytics
78
78
  identifier_file_name
79
79
  end
80
80
  end
81
+
82
+ def strip_invalid_utf8_chars(object)
83
+ if object.is_a?(Hash)
84
+ Hash[object.map { |key, value| [key, strip_invalid_utf8_chars(value)] }]
85
+ elsif object.is_a?(Array)
86
+ object.map { |value| strip_invalid_utf8_chars(value) }
87
+ elsif object.is_a?(String)
88
+ object.encode('UTF-8', :invalid => :replace, :undef => :replace)
89
+ else
90
+ object
91
+ end
92
+ end
81
93
  end
82
94
 
83
95
  def self.traces
@@ -3,7 +3,7 @@
3
3
  module RSpec
4
4
  module Buildkite
5
5
  module Analytics
6
- VERSION = "0.7.0"
6
+ VERSION = "0.8.0"
7
7
  NAME = "rspec-buildkite"
8
8
  end
9
9
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
26
26
 
27
- spec.add_dependency "activesupport", ">= 5.2", "<= 7.0"
27
+ spec.add_dependency "activesupport", ">= 5.2", "< 8"
28
28
  spec.add_dependency "rspec-core", '~> 3.10'
29
29
  spec.add_dependency "rspec-expectations", '~> 3.10'
30
30
  spec.add_dependency "websocket", '~> 1.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-buildkite-analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Buildkite
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-08 00:00:00.000000000 Z
11
+ date: 2022-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -17,9 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '5.2'
20
- - - "<="
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7.0'
22
+ version: '8'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +27,9 @@ dependencies:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '5.2'
30
- - - "<="
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7.0'
32
+ version: '8'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec-core
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -72,7 +72,7 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '1.2'
75
- description:
75
+ description:
76
76
  email:
77
77
  - hello@buildkite.com
78
78
  executables: []
@@ -81,6 +81,7 @@ extra_rdoc_files: []
81
81
  files:
82
82
  - ".gitignore"
83
83
  - ".rspec"
84
+ - CHANGELOG.md
84
85
  - Gemfile
85
86
  - Gemfile.lock
86
87
  - LICENSE.txt
@@ -106,7 +107,7 @@ licenses:
106
107
  metadata:
107
108
  homepage_uri: https://github.com/buildkite/rspec-buildkite-analytics
108
109
  source_code_uri: https://github.com/buildkite/rspec-buildkite-analytics
109
- post_install_message:
110
+ post_install_message:
110
111
  rdoc_options: []
111
112
  require_paths:
112
113
  - lib
@@ -121,8 +122,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
122
  - !ruby/object:Gem::Version
122
123
  version: '0'
123
124
  requirements: []
124
- rubygems_version: 3.1.4
125
- signing_key:
125
+ rubygems_version: 3.3.3
126
+ signing_key:
126
127
  specification_version: 4
127
128
  summary: Track execution of specs and report to Buildkite Analytics
128
129
  test_files: []