Skip to content

Commit eac5c45

Browse files
committed
Merge branch 'master' into community/pr-4916
2 parents 7acecb3 + c5e3981 commit eac5c45

File tree

1,367 files changed

+39845
-8764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,367 files changed

+39845
-8764
lines changed

.github/actions/bundle-cache/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ runs:
1717
shell: bash
1818
run: |
1919
engine=$(ruby -e "puts RUBY_ENGINE")
20-
alias=$(ruby -e "puts RUBY_ENGINE_VERSION.split('.').take(2).join")
20+
alias=$(ruby -e "puts RUBY_ENGINE_VERSION")
2121
2222
echo "ruby-alias=$engine-$alias" >> "$GITHUB_OUTPUT"
2323
- name: Generate lockfile

.github/scripts/typing_stats.rb

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'steep'
4+
require 'parser/ruby25'
5+
require 'json'
6+
7+
METHOD_AND_PARAM_NAME = /(?:\w*|`[^`]+`)/
8+
PARAMETER = /(?:\*{1,2})?\s*(?:\??\s*untyped\s*\??\s*|\??#{METHOD_AND_PARAM_NAME}:\s*untyped\s*\??)\s*#{METHOD_AND_PARAM_NAME}/
9+
PARAMETERS = /\(\s*(?:\?|(?:(?:#{PARAMETER})\s*(?:,\s*(?:#{PARAMETER})\s*)*)?)\s*\)/
10+
PROTOTYPE_INITIALIZE = /\s*(?:public|private)?\s*def\s+initialize:\s*#{PARAMETERS}(?:\s*\??\{\s*#{PARAMETERS}\s*->\s*untyped\s*\})?\s*->\s*void/
11+
PROTOTYPE_METHOD = /\s*(?:public|private)?\s*def\s+(?:self\??\.)?(?:[^\s]+):\s*#{PARAMETERS}(?:\s*\??\{\s*#{PARAMETERS}\s*->\s*untyped\s*\})?\s*->\s*untyped/
12+
13+
# TODO: Find untyped/partially typed attributes, instance variables, class variables, constants
14+
15+
steepfile_path = Pathname(ENV['STEEPFILE_PATH'])
16+
project = Steep::Project.new(steepfile_path: steepfile_path).tap do |project|
17+
Steep::Project::DSL.parse(project, steepfile_path.read, filename: steepfile_path.to_s)
18+
end
19+
datadog_target = project.targets&.find { |target| target.name == :datadog }
20+
loader = ::Steep::Services::FileLoader.new(base_dir: project.base_dir)
21+
22+
ignored_paths = datadog_target&.source_pattern&.ignores
23+
24+
# List signature files that are not related to ignored files
25+
signature_paths_with_ignored_files = loader.each_path_in_patterns(datadog_target.signature_pattern)
26+
signature_paths = signature_paths_with_ignored_files.reject do |sig_path|
27+
# replace sig/ with lib/ and .rbs with .rb
28+
corresponding_lib_file = sig_path.to_s.sub(/^sig/, 'lib').sub(/\.rbs$/, '.rb')
29+
ignored_paths.any? do |ignored|
30+
if ignored.end_with?('/')
31+
# Directory ignore - check if signature file is inside this directory
32+
corresponding_lib_file.start_with?(ignored)
33+
else
34+
# File ignore - check if signature file matches exactly
35+
corresponding_lib_file == ignored
36+
end
37+
end
38+
end
39+
40+
# Ignored files stats
41+
ignored_files_size = ignored_paths.inject(0) do |result, path|
42+
if path.end_with?('/')
43+
result + Dir.glob(path + '**/*.rb').size
44+
else
45+
result + 1
46+
end
47+
end
48+
total_files_size = Dir.glob("#{project.base_dir}/lib/**/*.rb").size
49+
50+
# steep:ignore comments stats
51+
ignore_comments = loader.each_path_in_patterns(datadog_target.source_pattern).each_with_object([]) do |path, result|
52+
buffer = ::Parser::Source::Buffer.new(path.to_s, 1, source: path.read)
53+
_, comments = ::Parser::Ruby25.new.parse_with_comments(buffer)
54+
rbs_buffer = ::RBS::Buffer.new(name: path, content: path.read)
55+
comments.each do |comment|
56+
ignore = ::Steep::AST::Ignore.parse(comment, rbs_buffer)
57+
next if ignore.nil? || ignore.is_a?(::Steep::AST::Ignore::IgnoreEnd)
58+
59+
result << {
60+
path: path.to_s,
61+
line: ignore.line
62+
}
63+
end
64+
end
65+
66+
# sig files stats
67+
untyped_methods = []
68+
partially_typed_methods = []
69+
typed_methods_size = 0
70+
71+
untyped_others = []
72+
partially_typed_others = []
73+
typed_others_size = 0
74+
signature_paths.each do |sig_path|
75+
sig_file_content = sig_path.read
76+
# for each line in the file, check if it matches the regex
77+
sig_file_content.each_line.with_index(1) do |line, index|
78+
next if line.strip.empty? || line.strip.start_with?("#") || line.strip.end_with?("# untyped:accept")
79+
80+
case line
81+
# Methods
82+
when PROTOTYPE_INITIALIZE
83+
untyped_methods << {path: sig_path.to_s, line: index, line_content: line.strip}
84+
when PROTOTYPE_METHOD
85+
untyped_methods << {path: sig_path.to_s, line: index, line_content: line.strip}
86+
when /^\s*(?:public|private)?\s*def\s.*untyped/ # Any line containing untyped
87+
partially_typed_methods << {path: sig_path.to_s, line: index, line_content: line.strip}
88+
when /^\s*(?:public|private)?\s*def\s.*/ # Any line containing a method definition not matched by the other regexes
89+
typed_methods_size += 1
90+
# Attributes
91+
when /^\s*(?:public|private)?\s*attr_(?:reader|writer|accessor)\s.*:\s*untyped/
92+
untyped_others << {path: sig_path.to_s, line: index, line_content: line.strip}
93+
when /^\s*(?:public|private)?\s*attr_(?:reader|writer|accessor)\s.*untyped/
94+
partially_typed_others << {path: sig_path.to_s, line: index, line_content: line.strip}
95+
when /^\s*(?:public|private)?\s*attr_(?:reader|writer|accessor)\s.*/
96+
typed_others_size += 1
97+
# Constants
98+
when /[A-Z]\w*\s*:\s*untyped/ # We don't match beginning of string as constant can have a namespace prefix
99+
untyped_others << {path: sig_path.to_s, line: index, line_content: line.strip}
100+
when /[A-Z]\w*\s*:[^:].*untyped/
101+
partially_typed_others << {path: sig_path.to_s, line: index, line_content: line.strip}
102+
when /[A-Z]\w*\s*:[^:]/
103+
typed_others_size += 1
104+
# Globals
105+
when /^\s*\$[a-zA-Z]\w+\s*:\s*untyped/
106+
untyped_others << {path: sig_path.to_s, line: index, line_content: line.strip}
107+
when /^\s*\$[a-zA-Z]\w+\s*:.*untyped/
108+
partially_typed_others << {path: sig_path.to_s, line: index, line_content: line.strip}
109+
when /^\s*\$[a-zA-Z]\w+\s*:/
110+
typed_others_size += 1
111+
# Class and instance variables
112+
when /^\s*@?@\w+\s*:\s*untyped/
113+
untyped_others << {path: sig_path.to_s, line: index, line_content: line.strip}
114+
when /^\s*@?@\w+\s*:.*untyped/
115+
partially_typed_others << {path: sig_path.to_s, line: index, line_content: line.strip}
116+
when /^\s*@?@\w+\s*:/
117+
typed_others_size += 1
118+
end
119+
end
120+
end
121+
122+
resulting_stats = {
123+
total_files_size: total_files_size,
124+
ignored_files: {
125+
size: ignored_files_size, # Required as we don't list all ignored files, but only their paths
126+
paths: ignored_paths
127+
},
128+
129+
steep_ignore_comments: ignore_comments,
130+
131+
untyped_methods: untyped_methods,
132+
partially_typed_methods: partially_typed_methods,
133+
typed_methods_size: typed_methods_size, # Location not needed for already typed methods
134+
135+
untyped_others: untyped_others,
136+
partially_typed_others: partially_typed_others,
137+
typed_others_size: typed_others_size # Location not needed for already typed attributes, constants, globals, instance variables
138+
}
139+
140+
puts resulting_stats.to_json

.github/workflows/_unit_test.yml

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Unit Test Template
1+
name: Unit Tests (Ruby version specific)
22

33
on: # yamllint disable-line rule:truthy
44
workflow_call:
@@ -13,6 +13,9 @@ on: # yamllint disable-line rule:truthy
1313
alias:
1414
required: true
1515
type: string
16+
seed:
17+
required: false
18+
type: number
1619
outputs:
1720
lockfile:
1821
description: "The lockfile artifact"
@@ -21,19 +24,41 @@ on: # yamllint disable-line rule:truthy
2124
description: "The cache key for bundle"
2225
value: ${{ jobs.batch.outputs.cache-key }}
2326

27+
workflow_dispatch:
28+
inputs:
29+
engine:
30+
description: "`ruby` or `jruby`"
31+
required: true
32+
type: string
33+
version:
34+
description: "The version of the engine (2.x or 3.x for Ruby, 9.x or 10.x for JRuby)"
35+
required: true
36+
type: string
37+
alias:
38+
description: "The alias of the engine (e.g. `ruby-34` for Ruby 3.4)"
39+
required: true
40+
type: string
41+
seed:
42+
description: "The seed to reproduce a CI run"
43+
required: false
44+
type: number
45+
46+
permissions: {}
47+
2448
jobs:
2549
batch:
2650
runs-on: ubuntu-24.04
2751
name: batch
2852
outputs:
53+
seed: "${{ steps.set-batches.outputs.seed }}"
2954
batches: "${{ steps.set-batches.outputs.batches }}"
3055
misc: "${{ steps.set-batches.outputs.misc }}"
3156
cache-key: "${{ steps.bundle-cache.outputs.cache-key }}"
3257
lockfile: "${{ steps.bundle-cache.outputs.lockfile }}"
3358
container:
34-
image: ghcr.io/datadog/images-rb/engines/${{ inputs.engine }}:${{ inputs.version }}
59+
image: ghcr.io/datadog/images-rb/engines/${{ inputs.engine }}:${{ inputs.version }}-gnu-gcc
3560
steps:
36-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
61+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3762
with:
3863
persist-credentials: false
3964

@@ -43,20 +68,23 @@ jobs:
4368

4469
- id: set-batches
4570
name: Distribute tasks into batches
71+
env:
72+
CI_TEST_SEED: "${{ inputs.seed || '' }}"
4673
run: |
4774
data=$(bundle exec rake github:generate_batches)
4875
echo "$data" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
4976
5077
# Extract each key and set it as a separate output
78+
seed_data=$(echo "$data" | ruby -rjson -e 'puts JSON.parse(STDIN.read)["seed"]')
5179
batches_data=$(echo "$data" | ruby -rjson -e 'puts JSON.parse(STDIN.read)["batches"].to_json')
5280
misc_data=$(echo "$data" | ruby -rjson -e 'puts JSON.parse(STDIN.read)["misc"].to_json')
5381
54-
echo "batches=$batches_data" >> "$GITHUB_OUTPUT"
55-
echo "misc=$misc_data" >> "$GITHUB_OUTPUT"
82+
{ echo "seed=$seed_data"; echo "batches=$batches_data"; echo "misc=$misc_data"; } >> "$GITHUB_OUTPUT"
5683
- name: Generate batch summary
57-
run: bundle exec rake github:generate_batch_summary
5884
env:
5985
batches_json: "${{ steps.set-batches.outputs.batches }}"
86+
CI_TEST_SEED: "${{ steps.set-batches.outputs.seed }}"
87+
run: bundle exec rake github:generate_batch_summary
6088

6189
# `Initialize containers` step becomes quite heavily when many services are used.
6290
#
@@ -88,12 +116,13 @@ jobs:
88116
timeout-minutes: 30
89117
env:
90118
BATCHED_TASKS: "${{ toJSON(matrix.tasks) }}"
119+
CI_TEST_SEED: "${{ needs.batch.outputs.seed }}"
91120
strategy:
92121
fail-fast: false
93122
matrix:
94123
include: "${{ fromJson(needs.batch.outputs.batches).include }}"
95124
container:
96-
image: ghcr.io/datadog/images-rb/engines/${{ inputs.engine }}:${{ inputs.version }}
125+
image: ghcr.io/datadog/images-rb/engines/${{ inputs.engine }}:${{ inputs.version }}-gnu-gcc
97126
env:
98127
DD_INSTRUMENTATION_TELEMETRY_ENABLED: 'false'
99128
DD_REMOTE_CONFIGURATION_ENABLED: 'false'
@@ -130,7 +159,7 @@ jobs:
130159
redis:
131160
image: ghcr.io/datadog/images-rb/services/redis:6.2
132161
steps:
133-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
162+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
134163
with:
135164
persist-credentials: false
136165
- name: Restore bundle cache
@@ -152,12 +181,13 @@ jobs:
152181
timeout-minutes: 30
153182
env:
154183
BATCHED_TASKS: "${{ toJSON(matrix.tasks) }}"
184+
CI_TEST_SEED: "${{ needs.batch.outputs.seed }}"
155185
strategy:
156186
fail-fast: false
157187
matrix:
158188
include: "${{ fromJson(needs.batch.outputs.misc).include }}"
159189
container:
160-
image: ghcr.io/datadog/images-rb/engines/${{ inputs.engine }}:${{ inputs.version }}
190+
image: ghcr.io/datadog/images-rb/engines/${{ inputs.engine }}:${{ inputs.version }}-gnu-gcc
161191
env:
162192
DD_INSTRUMENTATION_TELEMETRY_ENABLED: 'false'
163193
DD_REMOTE_CONFIGURATION_ENABLED: 'false'
@@ -207,7 +237,7 @@ jobs:
207237
presto:
208238
image: ghcr.io/datadog/images-rb/services/starburstdata/presto:332-e.9
209239
steps:
210-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
240+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
211241
with:
212242
persist-credentials: false
213243
- name: Restore bundle cache

.github/workflows/add-milestone-to-pull-requests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- name: Checkout code
1717
# Checks out the branch that the pull request is merged into
18-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1919
with:
2020
persist-credentials: false
2121
ref: ${{ github.event.pull_request.base.ref }}
@@ -29,7 +29,7 @@ jobs:
2929
3030
- name: Get project milestones
3131
id: milestones
32-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
32+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
3333
with:
3434
github-token: ${{secrets.GITHUB_TOKEN}}
3535
script: |
@@ -42,7 +42,7 @@ jobs:
4242
4343
- name: Update Pull Request
4444
# Update the merged pull request with the milestone starts with the major version
45-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
45+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
4646
with:
4747
github-token: ${{secrets.GITHUB_TOKEN}}
4848
script: |

.github/workflows/all-green.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
timeout-minutes: 60
2020
steps:
2121
- name: Run Ensure CI Success
22-
uses: DataDog/ensure-ci-success@4a4b720e881d965254a9de2a4f14d1ec0c3d0d7c # v2.2.0
22+
uses: DataDog/ensure-ci-success@b0d931ac77c810490e61964c321103040eef888e # v2.3.0
2323
with:
2424
# How long to wait before we start checking the job status
2525
# GitHub's API has a limit, so this helps avoid making too many calls

.github/workflows/build-gem.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ jobs:
3333
name: Build gem (${{ matrix.type }})
3434
steps:
3535
- name: Checkout
36-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
36+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3737
with:
3838
persist-credentials: false
39-
- uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 # v1.245.0
39+
- uses: ruby/setup-ruby@0481980f17b760ef6bca5e8c55809102a0af1e5a # v1.263.0
4040
with:
4141
ruby-version: '3.2'
4242
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
@@ -80,14 +80,14 @@ jobs:
8080
- build
8181
steps:
8282
- name: Download artifact
83-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
83+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
8484
with:
8585
name: 'datadog-gem-${{ matrix.type }}-gha${{ github.run_id }}-g${{ github.sha }}'
8686
path: 'pkg'
8787
- name: List gem
8888
run: |
8989
find pkg
90-
- uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 # v1.245.0
90+
- uses: ruby/setup-ruby@0481980f17b760ef6bca5e8c55809102a0af1e5a # v1.263.0
9191
with:
9292
ruby-version: '3.2'
9393
- name: Install gem
@@ -106,7 +106,7 @@ jobs:
106106
if: ${{ inputs.push }}
107107
steps:
108108
- name: Download artifact
109-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
109+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
110110
with:
111111
name: 'datadog-gem-${{ matrix.type }}-gha${{ github.run_id }}-g${{ github.sha }}'
112112
path: 'pkg'

.github/workflows/bump-gem-version.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ jobs:
3232
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3333
NEXT_VERSION: ${{ inputs.version }}
3434
steps:
35-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3636
with:
3737
persist-credentials: true
3838
token: ${{ secrets.GITHUB_TOKEN }}
3939
fetch-depth: 0
4040

4141
- name: Set up Ruby
42-
uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 # v1.245.0
42+
uses: ruby/setup-ruby@0481980f17b760ef6bca5e8c55809102a0af1e5a # v1.263.0
4343
with:
4444
ruby-version: "3.3.7"
4545

@@ -52,7 +52,7 @@ jobs:
5252
5353
- name: Generate GitHub App Token
5454
id: generate-token
55-
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
55+
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
5656
with:
5757
app-id: ${{ secrets.APP_ID }}
5858
private-key: ${{ secrets.APP_PRIVATE_KEY }}

0 commit comments

Comments
 (0)