datadog-ci 1.20.2 → 1.21.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d52c09221c7fbde835ed3db436baf1ffe998903eaff32f3ea9c6c463d4d67e6
4
- data.tar.gz: f1445fdbb0e305050d3340e099113b12077a3b9323029fc7b5c524b936eb478b
3
+ metadata.gz: e7fac7df8bd20e5c52ea01bfe200854a7d2ad85454b60b9bad429d43527074b1
4
+ data.tar.gz: 6763a5ac2a1f6c5dafbec6a1f3ed95f3eccfbd8e66b009b115dcae82ff6b62c8
5
5
  SHA512:
6
- metadata.gz: 06f3c204a01fbb5c73560cd9eca6af94d8b01a9142fa464ca3d65f77c6a1ec375ddc0ec3045d510dae0b7afa0b59f842c5548d62265036e574f540d74c676bcf
7
- data.tar.gz: '08eaeb1b1f58ac8f27d93f83ec011c87d5d706498cd546b27335448ef9dcba2c2ed51fbc72c73799ae114ff5545cae487c3db760961f1f1051a838b60da75383'
6
+ metadata.gz: e1fefe3b31fff717f7df05fe2399459b2db086380c78cc7f27d7211cc082b804723d83cc0617c00c8851b8389205aa511d07ba09d67871de2bb1d38b67498b38
7
+ data.tar.gz: 8eac96f33d23410db16c0199aa0b4bd28237b6f1e9eac087dde993db4a14c309017fe92592071e5c67718f7c2a7b2ce7e773b39cd7a643860a4898135381cb3f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.21.0] - 2025-07-14
4
+
5
+ ### Added
6
+
7
+ * Support automated flaky test fixing flow for Github Action jobs with pull_request trigger ([#370][])
8
+
3
9
  ## [1.20.2] - 2025-07-04
4
10
 
5
11
  ### Fixed
@@ -486,7 +492,8 @@ Currently test suite level visibility is not used by our instrumentation: it wil
486
492
 
487
493
  - Ruby versions < 2.7 no longer supported ([#8][])
488
494
 
489
- [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.20.2...main
495
+ [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.21.0...main
496
+ [1.21.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.20.2...v1.21.0
490
497
  [1.20.2]: https://github.com/DataDog/datadog-ci-rb/compare/v1.20.1...v1.20.2
491
498
  [1.20.1]: https://github.com/DataDog/datadog-ci-rb/compare/v1.20.0...v1.20.1
492
499
  [1.20.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.19.0...v1.20.0
@@ -690,4 +697,5 @@ Currently test suite level visibility is not used by our instrumentation: it wil
690
697
  [#349]: https://github.com/DataDog/datadog-ci-rb/issues/349
691
698
  [#355]: https://github.com/DataDog/datadog-ci-rb/issues/355
692
699
  [#359]: https://github.com/DataDog/datadog-ci-rb/issues/359
693
- [#366]: https://github.com/DataDog/datadog-ci-rb/issues/366
700
+ [#366]: https://github.com/DataDog/datadog-ci-rb/issues/366
701
+ [#370]: https://github.com/DataDog/datadog-ci-rb/issues/370
@@ -36,22 +36,31 @@ module Datadog
36
36
  Environment::TAG_NODE_NAME => @provider.node_name,
37
37
  Environment::TAG_CI_ENV_VARS => @provider.ci_env_vars,
38
38
 
39
- Git::TAG_BRANCH => @provider.git_branch,
40
39
  Git::TAG_REPOSITORY_URL => @provider.git_repository_url,
40
+ Git::TAG_BRANCH => @provider.git_branch,
41
41
  Git::TAG_TAG => @provider.git_tag,
42
+
43
+ Git::TAG_COMMIT_SHA => @provider.git_commit_sha,
44
+ Git::TAG_COMMIT_MESSAGE => @provider.git_commit_message,
42
45
  Git::TAG_COMMIT_AUTHOR_DATE => @provider.git_commit_author_date,
43
46
  Git::TAG_COMMIT_AUTHOR_EMAIL => @provider.git_commit_author_email,
44
47
  Git::TAG_COMMIT_AUTHOR_NAME => @provider.git_commit_author_name,
45
48
  Git::TAG_COMMIT_COMMITTER_DATE => @provider.git_commit_committer_date,
46
49
  Git::TAG_COMMIT_COMMITTER_EMAIL => @provider.git_commit_committer_email,
47
50
  Git::TAG_COMMIT_COMMITTER_NAME => @provider.git_commit_committer_name,
48
- Git::TAG_COMMIT_MESSAGE => @provider.git_commit_message,
49
- Git::TAG_COMMIT_SHA => @provider.git_commit_sha,
51
+
50
52
  Git::TAG_PULL_REQUEST_BASE_BRANCH => @provider.git_pull_request_base_branch,
51
53
  Git::TAG_PULL_REQUEST_BASE_BRANCH_SHA => @provider.git_pull_request_base_branch_sha,
52
- Git::TAG_COMMIT_HEAD_SHA => @provider.git_commit_head_sha,
54
+ Environment::TAG_PR_NUMBER => @provider.pr_number,
53
55
 
54
- Environment::TAG_PR_NUMBER => @provider.pr_number
56
+ Git::TAG_COMMIT_HEAD_SHA => @provider.git_commit_head_sha,
57
+ Git::TAG_COMMIT_HEAD_MESSAGE => @provider.git_commit_head_message,
58
+ Git::TAG_COMMIT_HEAD_AUTHOR_DATE => @provider.git_commit_head_author_date,
59
+ Git::TAG_COMMIT_HEAD_AUTHOR_EMAIL => @provider.git_commit_head_author_email,
60
+ Git::TAG_COMMIT_HEAD_AUTHOR_NAME => @provider.git_commit_head_author_name,
61
+ Git::TAG_COMMIT_HEAD_COMMITTER_DATE => @provider.git_commit_head_committer_date,
62
+ Git::TAG_COMMIT_HEAD_COMMITTER_EMAIL => @provider.git_commit_head_committer_email,
63
+ Git::TAG_COMMIT_HEAD_COMMITTER_NAME => @provider.git_commit_head_committer_name
55
64
  }
56
65
 
57
66
  # Normalize Git references and filter sensitive data
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../../../git/local_repository"
4
+
3
5
  module Datadog
4
6
  module CI
5
7
  module Ext
@@ -105,6 +107,27 @@ module Datadog
105
107
  def git_commit_head_sha
106
108
  end
107
109
 
110
+ def git_commit_head_message
111
+ end
112
+
113
+ def git_commit_head_author_date
114
+ end
115
+
116
+ def git_commit_head_author_email
117
+ end
118
+
119
+ def git_commit_head_author_name
120
+ end
121
+
122
+ def git_commit_head_committer_date
123
+ end
124
+
125
+ def git_commit_head_committer_email
126
+ end
127
+
128
+ def git_commit_head_committer_name
129
+ end
130
+
108
131
  def pr_number
109
132
  end
110
133
 
@@ -31,27 +31,57 @@ module Datadog
31
31
  end
32
32
 
33
33
  def git_commit_author_name
34
- author.name
34
+ author&.name
35
35
  end
36
36
 
37
37
  def git_commit_author_email
38
- author.email
38
+ author&.email
39
39
  end
40
40
 
41
41
  def git_commit_author_date
42
- author.date
42
+ author&.date
43
43
  end
44
44
 
45
45
  def git_commit_committer_name
46
- committer.name
46
+ committer&.name
47
47
  end
48
48
 
49
49
  def git_commit_committer_email
50
- committer.email
50
+ committer&.email
51
51
  end
52
52
 
53
53
  def git_commit_committer_date
54
- committer.date
54
+ committer&.date
55
+ end
56
+
57
+ def git_commit_head_message
58
+ return nil if head_commit_sha_from_env.nil?
59
+
60
+ CI::Git::LocalRepository.git_commit_message(head_commit_sha_from_env)
61
+ end
62
+
63
+ def git_commit_head_author_date
64
+ head_author&.date
65
+ end
66
+
67
+ def git_commit_head_author_email
68
+ head_author&.email
69
+ end
70
+
71
+ def git_commit_head_author_name
72
+ head_author&.name
73
+ end
74
+
75
+ def git_commit_head_committer_date
76
+ head_committer&.date
77
+ end
78
+
79
+ def git_commit_head_committer_email
80
+ head_committer&.email
81
+ end
82
+
83
+ def git_commit_head_committer_name
84
+ head_committer&.name
55
85
  end
56
86
 
57
87
  def workspace_path
@@ -74,8 +104,30 @@ module Datadog
74
104
  @committer
75
105
  end
76
106
 
107
+ def head_author
108
+ return @head_author if defined?(@head_author)
109
+
110
+ set_git_commit_users
111
+ @head_author
112
+ end
113
+
114
+ def head_committer
115
+ return @head_committer if defined?(@head_committer)
116
+
117
+ set_git_commit_users
118
+ @head_committer
119
+ end
120
+
77
121
  def set_git_commit_users
78
122
  @author, @committer = CI::Git::LocalRepository.git_commit_users
123
+
124
+ return if head_commit_sha_from_env.nil?
125
+
126
+ @head_author, @head_committer = CI::Git::LocalRepository.git_commit_users(head_commit_sha_from_env)
127
+ end
128
+
129
+ def head_commit_sha_from_env
130
+ @head_commit_sha_from_env ||= env[Ext::Environment::ENV_SPECIAL_KEY_FOR_GIT_COMMIT_HEAD_SHA]
79
131
  end
80
132
  end
81
133
  end
@@ -47,6 +47,8 @@ module Datadog
47
47
 
48
48
  POSSIBLE_BUNDLE_LOCATIONS = %w[vendor/bundle .bundle].freeze
49
49
 
50
+ ENV_SPECIAL_KEY_FOR_GIT_COMMIT_HEAD_SHA = "_dd.ci.environment.git_commit_head_sha"
51
+
50
52
  module_function
51
53
 
52
54
  def tags(env)
@@ -57,6 +59,22 @@ module Datadog
57
59
  user_provided_tags = Environment::Extractor.new(env, provider_klass: Providers::UserDefinedTags).tags
58
60
  tags.merge!(user_provided_tags)
59
61
 
62
+ # NOTE: we need to provide head commit sha as part of the environment if it was discovered from provider.
63
+ #
64
+ # This info will be later used by LocalGit provider to extract commit message and user info for head commit.
65
+ # It is useful for CI providers that run jobs on artificial merge commits instead of a head commit of a
66
+ # feature branch.
67
+ #
68
+ # NOTE 2: when we discover that head commit sha exists it means that we are running on an artificial merge
69
+ # commit created by CI provider. Most likely we also operate on a shallow clone of a repo - in this case
70
+ # we need to unshallow at least the parent of the current merge commit to be able to extract information
71
+ # from the real original commit.
72
+ if tags[Git::TAG_COMMIT_HEAD_SHA]
73
+ CI::Git::LocalRepository.git_unshallow(parent_only: true) if CI::Git::LocalRepository.git_shallow_clone?
74
+
75
+ env[ENV_SPECIAL_KEY_FOR_GIT_COMMIT_HEAD_SHA] = tags[Git::TAG_COMMIT_HEAD_SHA]
76
+ end
77
+
60
78
  # Fill out tags from local git as fallback
61
79
  local_git_tags = Environment::Extractor.new(env, provider_klass: Providers::LocalGit).tags
62
80
  local_git_tags.each do |key, value|
@@ -21,10 +21,18 @@ module Datadog
21
21
  TAG_COMMIT_SHA = "git.commit.sha"
22
22
 
23
23
  # additional tags that we use for github actions jobs with "pull_request" target
24
- TAG_COMMIT_HEAD_SHA = "git.commit.head_sha"
25
24
  TAG_PULL_REQUEST_BASE_BRANCH = "git.pull_request.base_branch"
26
25
  TAG_PULL_REQUEST_BASE_BRANCH_SHA = "git.pull_request.base_branch_sha"
27
26
 
27
+ TAG_COMMIT_HEAD_SHA = "git.commit.head.sha"
28
+ TAG_COMMIT_HEAD_MESSAGE = "git.commit.head.message"
29
+ TAG_COMMIT_HEAD_AUTHOR_DATE = "git.commit.head.author.date"
30
+ TAG_COMMIT_HEAD_AUTHOR_EMAIL = "git.commit.head.author.email"
31
+ TAG_COMMIT_HEAD_AUTHOR_NAME = "git.commit.head.author.name"
32
+ TAG_COMMIT_HEAD_COMMITTER_DATE = "git.commit.head.committer.date"
33
+ TAG_COMMIT_HEAD_COMMITTER_EMAIL = "git.commit.head.committer.email"
34
+ TAG_COMMIT_HEAD_COMMITTER_NAME = "git.commit.head.committer.name"
35
+
28
36
  ENV_REPOSITORY_URL = "DD_GIT_REPOSITORY_URL"
29
37
  ENV_COMMIT_SHA = "DD_GIT_COMMIT_SHA"
30
38
  ENV_BRANCH = "DD_GIT_BRANCH"
@@ -95,7 +95,7 @@ module Datadog
95
95
  AUTO_TEST_RETRIES_VERSION = "1"
96
96
  TEST_MANAGEMENT_QUARANTINE_VERSION = "1"
97
97
  TEST_MANAGEMENT_DISABLE_VERSION = "1"
98
- TEST_MANAGEMENT_ATTEMPT_TO_FIX_VERSION = "4"
98
+ TEST_MANAGEMENT_ATTEMPT_TO_FIX_VERSION = "5"
99
99
  end
100
100
 
101
101
  # Map of capabilities to their versions
@@ -3,8 +3,6 @@
3
3
  require_relative "base"
4
4
  require_relative "branch_metric"
5
5
 
6
- require_relative "../local_repository"
7
-
8
6
  module Datadog
9
7
  module CI
10
8
  module Git
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "base"
4
- require_relative "../local_repository"
5
4
 
6
5
  module Datadog
7
6
  module CI
@@ -143,16 +143,16 @@ module Datadog
143
143
  nil
144
144
  end
145
145
 
146
- def self.git_commit_message
147
- CLI.exec_git_command(["log", "-n", "1", "--format=%B"])
146
+ def self.git_commit_message(commit_sha = nil)
147
+ CLI.exec_git_command(["log", "-n", "1", "--format=%B", commit_sha].compact)
148
148
  rescue => e
149
149
  log_failure(e, "git commit message")
150
150
  nil
151
151
  end
152
152
 
153
- def self.git_commit_users
153
+ def self.git_commit_users(commit_sha = nil)
154
154
  # Get committer and author information in one command.
155
- output = CLI.exec_git_command(["show", "-s", "--format=%an\t%ae\t%at\t%cn\t%ce\t%ct"])
155
+ output = CLI.exec_git_command(["show", "-s", "--format=%an\t%ae\t%at\t%cn\t%ce\t%ct", commit_sha].compact)
156
156
  unless output
157
157
  Datadog.logger.debug(
158
158
  "Unable to read git commit users: git command output is nil"
@@ -268,7 +268,7 @@ module Datadog
268
268
  false
269
269
  end
270
270
 
271
- def self.git_unshallow
271
+ def self.git_unshallow(parent_only: false)
272
272
  Telemetry.git_command(Ext::Telemetry::Command::UNSHALLOW)
273
273
  # @type var res: String?
274
274
  res = nil
@@ -289,10 +289,11 @@ module Datadog
289
289
 
290
290
  res =
291
291
  begin
292
+ unshallowing_depth = parent_only ? "--deepen=1" : "--shallow-since=\"1 month ago\""
292
293
  # @type var cmd: Array[String]
293
294
  cmd = [
294
295
  "fetch",
295
- "--shallow-since=\"1 month ago\"",
296
+ unshallowing_depth,
296
297
  "--update-shallow",
297
298
  "--filter=blob:none",
298
299
  "--recurse-submodules=no",
@@ -165,6 +165,30 @@ module Datadog
165
165
  tracer_span.get_tag(Ext::Git::TAG_COMMIT_SHA)
166
166
  end
167
167
 
168
+ # Returns the git commit message extracted from the environment.
169
+ # @return [String] the commit message.
170
+ def git_commit_message
171
+ get_tag(Ext::Git::TAG_COMMIT_MESSAGE)
172
+ end
173
+
174
+ # Returns the original last git commit SHA extracted from the environment.
175
+ # Original here means that it is the last commit that was pushed by the user,
176
+ # not the artifical merge commit created by CI provider
177
+ #
178
+ # @return [String] the commit SHA of the last commit.
179
+ def original_git_commit_sha
180
+ get_tag(Ext::Git::TAG_COMMIT_HEAD_SHA) || git_commit_sha
181
+ end
182
+
183
+ # Returns the original last git commit message extracted from the environment.
184
+ # Original here means that it is the last commit that was pushed by the user,
185
+ # not the artifical merge commit created by CI provider
186
+ #
187
+ # @return [String] the commit message of the last commit.
188
+ def original_git_commit_message
189
+ get_tag(Ext::Git::TAG_COMMIT_HEAD_MESSAGE) || git_commit_message
190
+ end
191
+
168
192
  # Returns the git branch name extracted from the environment.
169
193
  # @return [String] the branch.
170
194
  def git_branch
@@ -118,8 +118,8 @@ module Datadog
118
118
  "type" => Ext::Transport::DD_API_TEST_MANAGEMENT_TESTS_TYPE,
119
119
  "attributes" => {
120
120
  "repository_url" => test_session.git_repository_url,
121
- "commit_message" => test_session.git_commit_message,
122
- "sha" => test_session.git_commit_sha
121
+ "commit_message" => test_session.original_git_commit_message,
122
+ "sha" => test_session.original_git_commit_sha
123
123
  }
124
124
  }
125
125
  }.to_json
@@ -46,12 +46,6 @@ module Datadog
46
46
  get_tag(Ext::Environment::TAG_JOB_NAME)
47
47
  end
48
48
 
49
- # Returns the git commit message extracted from the environment.
50
- # @return [String] the commit message.
51
- def git_commit_message
52
- get_tag(Ext::Git::TAG_COMMIT_MESSAGE)
53
- end
54
-
55
49
  def skipping_tests?
56
50
  get_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_ENABLED) == "true"
57
51
  end
@@ -4,8 +4,8 @@ module Datadog
4
4
  module CI
5
5
  module VERSION
6
6
  MAJOR = 1
7
- MINOR = 20
8
- PATCH = 2
7
+ MINOR = 21
8
+ PATCH = 0
9
9
  PRE = nil
10
10
  BUILD = nil
11
11
  # PRE and BUILD above are modified for dev gems during gem build GHA workflow
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datadog-ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.2
4
+ version: 1.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.