Skip to content

Commit 4096cbb

Browse files
committed
Merge branch 'di-strip-path' into di-demo
* di-strip-path: (52 commits) types standard integration test quick fix doc for what to do Bump ruby/setup-ruby in the gh-actions-packages group (#4343) ci: pin all GitHub Actions by SHA and update via dependabot (#4341) Bundle install Pin system test sha Update lockfiles for release 2.10.0 Bump version 2.9.0 to 2.10.0 Add 2.10.0 to CHANGELOG.md Remove magic nix cache action (#4339) Test creating supported versions (#4236) Update supported versions workflow (#4326) Enable on pull request Provide batch summary Fix batches Purge cache after merge Implement cache ...
2 parents d25a59a + f5eaac9 commit 4096cbb

File tree

605 files changed

+3040
-1086
lines changed

Some content is hidden

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

605 files changed

+3040
-1086
lines changed

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "monthly"
12+
groups:
13+
gh-actions-packages:
14+
patterns:
15+
- "*"

.github/scripts/generate_table_versions.rb

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/scripts/find_gem_version_bounds.rb renamed to .github/scripts/update_supported_versions.rb

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ class GemfileProcessor
1414
EXCLUDED_INTEGRATIONS = ["configuration", "propagation", "utils"].freeze
1515

1616
def initialize(directory: 'gemfiles/', contrib_dir: 'lib/datadog/tracing/contrib/')
17+
unless Dir.exist?(directory)
18+
warn("Directory #{directory} does not exist")
19+
end
20+
21+
unless Dir.exist?(contrib_dir)
22+
warn("Directory #{contrib_dir} does not exist")
23+
end
1724
@directory = directory
1825
@contrib_dir = contrib_dir
1926
@min_gems = { 'ruby' => {}, 'jruby' => {} }
@@ -25,7 +32,7 @@ def process
2532
parse_gemfiles
2633
process_integrations
2734
include_hardcoded_versions
28-
write_output
35+
write_markdown_output
2936
end
3037

3138
private
@@ -106,18 +113,18 @@ def process_integrations
106113
def include_hardcoded_versions
107114
# `httpx` is maintained externally
108115
@integration_json_mapping['httpx'] = [
109-
'0.11', # Min version Ruby
110-
'infinity', # Max version Ruby
111-
'0.11', # Min version JRuby
112-
'infinity' # Max version JRuby
116+
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Min version Ruby
117+
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Max version Ruby
118+
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Min version JRuby
119+
'[3rd-party support](https://honeyryderchuck.gitlab.io/httpx/)', # Max version JRuby
113120
]
114121

115122
# `makara` is part of `activerecord`
116123
@integration_json_mapping['makara'] = [
117-
'0.3.5', # Min version Ruby
118-
'infinity', # Max version Ruby
119-
'0.3.5', # Min version JRuby
120-
'infinity' # Max version JRuby
124+
'0.5.1', # Min version Ruby
125+
'0.5.1', # Max version Ruby
126+
'0.5.1', # Min version JRuby
127+
'0.5.1' # Max version JRuby
121128
]
122129
end
123130

@@ -131,10 +138,60 @@ def resolve_integration_name(integration)
131138
integration
132139
end
133140

134-
def write_output
135-
@integration_json_mapping = @integration_json_mapping.sort.to_h
136-
File.write("gem_output.json", JSON.pretty_generate(@integration_json_mapping))
141+
def write_markdown_output
142+
output_file = 'docs/integration_versions.md'
143+
comment = <<~COMMENT
144+
<!--
145+
# Please do NOT manually edit this file.
146+
# This file is generated by `bundle exec ruby .github/scripts/update_supported_versions.rb`
147+
148+
### Supported Versions Table ###
149+
150+
This markdown file is generated from the minimum and maximum versions of the integrations we support, as tested in our `gemfile.lock` lockfiles.
151+
For a list of available integrations, and their supported version ranges, refer to the following:
152+
-->
153+
COMMENT
154+
column_widths = {
155+
integration: 24,
156+
ruby_min: 19,
157+
ruby_max: 19,
158+
jruby_min: 19,
159+
jruby_max: 19
160+
}
161+
columns = {
162+
integration: "Integration",
163+
ruby_min: "Ruby Min",
164+
ruby_max: "Ruby Max",
165+
jruby_min: "JRuby Min",
166+
jruby_max: "JRuby Max"
167+
}
168+
169+
adjusted_widths = columns.transform_values.with_index do |title, index|
170+
[title.length, column_widths.values[index]].max
171+
end
172+
173+
header = "| " + columns.map { |key, title| title.ljust(adjusted_widths[key]) }.join(" | ") + " |"
174+
separator = "|-" + adjusted_widths.map { |_, width| "-" * width }.join("-|-") + "-|"
175+
rows = @integration_json_mapping
176+
.sort_by { |name, _versions| name.downcase }
177+
.map do |name, versions|
178+
integration_name = name.ljust(column_widths[:integration])
179+
ruby_min = (versions[0] || "None").ljust(column_widths[:ruby_min])
180+
ruby_max = (versions[1] == 'infinity' ? 'latest' : versions[1] || 'None').ljust(column_widths[:ruby_max])
181+
jruby_min = (versions[2] || "None").ljust(column_widths[:jruby_min])
182+
jruby_max = (versions[3] == 'infinity' ? 'latest' : versions[3] || 'None').ljust(column_widths[:jruby_max])
183+
184+
"| #{integration_name} | #{ruby_min} | #{ruby_max} | #{jruby_min} | #{jruby_max} |"
185+
end
186+
187+
File.open(output_file, 'w') do |file|
188+
file.puts comment
189+
file.puts header
190+
file.puts separator
191+
rows.each { |row| file.puts row }
192+
end
137193
end
138194
end
139195

196+
140197
GemfileProcessor.new.process

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- name: Checkout code
1616
# Checks out the branch that the pull request is merged into
17-
uses: actions/checkout@v4
17+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1818
with:
1919
ref: ${{ github.event.pull_request.base.ref }}
2020

@@ -26,7 +26,7 @@ jobs:
2626
2727
- name: Get project milestones
2828
id: milestones
29-
uses: actions/github-script@v7
29+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
3030
with:
3131
github-token: ${{secrets.GITHUB_TOKEN}}
3232
script: |
@@ -39,7 +39,7 @@ jobs:
3939
4040
- name: Update Pull Request
4141
# Update the merged pull request with the milestone starts with the major version
42-
uses: actions/github-script@v7
42+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
4343
with:
4444
github-token: ${{secrets.GITHUB_TOKEN}}
4545
script: |

.github/workflows/build-gem.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
name: Build gem (${{ matrix.type }})
2828
steps:
2929
- name: Checkout
30-
uses: actions/checkout@v4
31-
- uses: ruby/setup-ruby@v1
30+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
31+
- uses: ruby/setup-ruby@8388f20e6a9c43cd241131b678469a9f89579f37 # v1.216.0
3232
with:
3333
ruby-version: '3.2'
3434
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
@@ -60,7 +60,7 @@ jobs:
6060
run: |
6161
find pkg
6262
- name: Upload artifact
63-
uses: actions/upload-artifact@v4
63+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
6464
with:
6565
name: 'datadog-gem-${{ matrix.type }}-gha${{ github.run_id }}-g${{ github.sha }}'
6666
path: 'pkg/*.gem'
@@ -77,14 +77,14 @@ jobs:
7777
- build
7878
steps:
7979
- name: Download artifact
80-
uses: actions/download-artifact@v4
80+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
8181
with:
8282
name: 'datadog-gem-${{ matrix.type }}-gha${{ github.run_id }}-g${{ github.sha }}'
8383
path: 'pkg'
8484
- name: List gem
8585
run: |
8686
find pkg
87-
- uses: ruby/setup-ruby@v1
87+
- uses: ruby/setup-ruby@8388f20e6a9c43cd241131b678469a9f89579f37 # v1.216.0
8888
with:
8989
ruby-version: '3.2'
9090
- name: Install gem
@@ -103,7 +103,7 @@ jobs:
103103
if: ${{ inputs.push }}
104104
steps:
105105
- name: Download artifact
106-
uses: actions/download-artifact@v4
106+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
107107
with:
108108
name: 'datadog-gem-${{ matrix.type }}-gha${{ github.run_id }}-g${{ github.sha }}'
109109
path: 'pkg'
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Reference:
2+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
3+
4+
name: Cleanup caches by a branch
5+
on:
6+
pull_request:
7+
types:
8+
- closed
9+
10+
jobs:
11+
cleanup:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Cleanup
15+
run: |
16+
echo "Fetching list of cache key"
17+
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
18+
19+
## Setting this to not fail the workflow while deleting cache keys.
20+
set +e
21+
echo "Deleting caches..."
22+
for cacheKey in $cacheKeysForPR
23+
do
24+
gh cache delete $cacheKey
25+
done
26+
echo "Done"
27+
env:
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
GH_REPO: ${{ github.repository }}
30+
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge

.github/workflows/check.yml

Lines changed: 101 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,57 @@
1-
name: Check
1+
name: Static Analysis
22
on:
33
push:
44

5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
59
jobs:
6-
lint:
7-
runs-on: ubuntu-22.04
8-
container:
9-
image: ghcr.io/datadog/images-rb/engines/ruby:3.2
10+
build:
11+
name: build
12+
runs-on: ubuntu-24.04
13+
container: ghcr.io/datadog/images-rb/engines/ruby:3.3
14+
steps:
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
- run: bundle lock
17+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
18+
id: lockfile
19+
with:
20+
name: 'check-lockfile-${{ github.sha }}-${{ github.run_id }}'
21+
path: '*.lock'
22+
if-no-files-found: error
23+
24+
rubocop:
25+
name: rubocop/lint
26+
runs-on: ubuntu-24.04
27+
needs: ['build']
28+
container: ghcr.io/datadog/images-rb/engines/ruby:3.3
1029
steps:
11-
- uses: actions/checkout@v4
30+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
31+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
32+
- run: bundle install
33+
- run: bundle exec rake rubocop
34+
35+
standard:
36+
name: standard/lint
37+
runs-on: ubuntu-24.04
38+
needs: ['build']
39+
container: ghcr.io/datadog/images-rb/engines/ruby:3.3
40+
steps:
41+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
42+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
1243
- name: Install dependencies
1344
run: bundle install
14-
- run: bundle exec rake rubocop standard
45+
- run: bundle exec rake standard
1546

16-
check:
17-
name: Check types
18-
runs-on: ubuntu-22.04
19-
container:
20-
image: ghcr.io/datadog/images-rb/engines/ruby:3.2
47+
steep:
48+
name: steep/typecheck
49+
runs-on: ubuntu-24.04
50+
needs: ['build']
51+
container: ghcr.io/datadog/images-rb/engines/ruby:3.3
2152
steps:
22-
- uses: actions/checkout@v4
53+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
54+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
2355
- name: Install dependencies
2456
run: bundle install
2557
- name: Check for stale signature files
@@ -30,3 +62,59 @@ jobs:
3062
run: bundle exec rake steep:check
3163
- name: Record stats
3264
run: bundle exec rake steep:stats[md] >> $GITHUB_STEP_SUMMARY
65+
66+
# Dogfooding Datadog SBOM Analysis
67+
dd-software-composition-analysis:
68+
name: dd/sca
69+
runs-on: ubuntu-24.04
70+
needs: ['build']
71+
container: ghcr.io/datadog/images-rb/engines/ruby:3.3
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
75+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 # requires the lockfile
76+
- uses: DataDog/datadog-sca-github-action@main
77+
with:
78+
dd_api_key: ${{ secrets.DD_API_KEY }}
79+
dd_app_key: ${{ secrets.DD_APP_KEY }}
80+
dd_site: datadoghq.com
81+
82+
# Dogfooding Datadog Static Analysis
83+
dd-static-analysis:
84+
name: dd/static-analysis
85+
runs-on: ubuntu-24.04
86+
steps:
87+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
88+
- uses: DataDog/datadog-static-analyzer-github-action@v1
89+
with:
90+
dd_api_key: ${{ secrets.DD_API_KEY }}
91+
dd_app_key: ${{ secrets.DD_APP_KEY }}
92+
dd_site: datadoghq.com
93+
cpu_count: 2
94+
95+
semgrep:
96+
name: semgrep/ci
97+
runs-on: ubuntu-24.04
98+
container: semgrep/semgrep # PENDING: Possible to be rate limited.
99+
steps:
100+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
101+
- run: |
102+
semgrep ci \
103+
--include=bin/* \
104+
--include=ext/* \
105+
--include=lib/* \
106+
--exclude-rule=ruby.lang.security.model-attributes-attr-accessible.model-attributes-attr-accessible
107+
env:
108+
SEMGREP_RULES: p/default
109+
110+
static-analysis:
111+
needs:
112+
- 'steep'
113+
- 'rubocop'
114+
- 'standard'
115+
- 'semgrep'
116+
- 'dd-software-composition-analysis'
117+
- 'dd-static-analysis'
118+
runs-on: ubuntu-24.04
119+
steps:
120+
- run: echo "Done"

0 commit comments

Comments
 (0)