27
27
name : batch
28
28
outputs :
29
29
batches : " ${{ steps.set-batches.outputs.batches }}"
30
+ misc : " ${{ steps.set-batches.outputs.misc }}"
30
31
cache-key : " ${{ steps.restore-cache.outputs.cache-primary-key }}"
31
32
lockfile : " ${{ steps.lockfile.outputs.lockfile }}"
32
33
container :
@@ -60,18 +61,47 @@ jobs:
60
61
- id : set-batches
61
62
name : Distribute tasks into batches
62
63
run : |
63
- batches_json=$(bundle exec rake github:generate_batches)
64
- echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
65
- echo "batches=$batches_json" >> $GITHUB_OUTPUT
64
+ data=$(bundle exec rake github:generate_batches)
65
+ echo "$data" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
66
+
67
+ # Extract each key and set it as a separate output
68
+ batches_data=$(echo "$data" | ruby -rjson -e 'puts JSON.parse(STDIN.read)["batches"].to_json')
69
+ misc_data=$(echo "$data" | ruby -rjson -e 'puts JSON.parse(STDIN.read)["misc"].to_json')
70
+
71
+ echo "batches=$batches_data" >> $GITHUB_OUTPUT
72
+ echo "misc=$misc_data" >> $GITHUB_OUTPUT
66
73
- name : Generate batch summary
67
74
run : bundle exec rake github:generate_batch_summary
68
75
env :
69
76
batches_json : " ${{ steps.set-batches.outputs.batches }}"
70
- build-test :
77
+
78
+ # `Initialize containers` step becomes quite heavily when many services are used.
79
+ #
80
+ # The job can failed with timeout because it takes a long time pulling the image or waiting for the service to be ready).
81
+ #
82
+ # `build-test-standard` job is used to run most of our tasks and configured with the following services:
83
+ # - mysql
84
+ # - postgres
85
+ # - redis
86
+ #
87
+ # `build-test-misc` job is extracted to run specific tasks that requires the following services:
88
+ # - elasticsearch
89
+ # - memcached
90
+ # - mongodb
91
+ # - opensearch
92
+ # - presto
93
+ #
94
+ # Benefit of this optimization:
95
+ # - Unnecessary services are not started
96
+ # - Reduce the overhead for pulling images
97
+ # - Improve reliability for starting dependent services
98
+ #
99
+ # In the future, we could consider to extract jobs to run database dependent tasks to optimize the workflow.
100
+ build-test-standard :
71
101
needs :
72
102
- batch
73
103
runs-on : ubuntu-24.04
74
- name : build & test [${{ matrix.batch }}]
104
+ name : build & test (standard) [${{ matrix.batch }}]
75
105
timeout-minutes : 30
76
106
env :
77
107
BATCHED_TASKS : " ${{ toJSON(matrix.tasks) }}"
@@ -86,13 +116,7 @@ jobs:
86
116
DD_REMOTE_CONFIGURATION_ENABLED : ' false'
87
117
TEST_POSTGRES_HOST : postgres
88
118
TEST_REDIS_HOST : redis
89
- TEST_ELASTICSEARCH_HOST : elasticsearch
90
- TEST_MEMCACHED_HOST : memcached
91
- TEST_MONGODB_HOST : mongodb
92
119
TEST_MYSQL_HOST : mysql
93
- TEST_OPENSEARCH_HOST : opensearch
94
- TEST_OPENSEARCH_PORT : ' 9200'
95
- TEST_PRESTO_HOST : presto
96
120
DD_AGENT_HOST : agent
97
121
DD_TRACE_AGENT_PORT : ' 9126'
98
122
DATADOG_GEM_CI : ' true'
@@ -108,6 +132,12 @@ jobs:
108
132
DD_POOL_TRACE_CHECK_FAILURES : ' true'
109
133
DD_DISABLE_ERROR_RESPONSES : ' true'
110
134
ENABLED_CHECKS : trace_content_length,trace_stall,meta_tracer_version_header,trace_count_header,trace_peer_service,trace_dd_service
135
+ mysql :
136
+ image : ghcr.io/datadog/images-rb/services/mysql:8.0
137
+ env :
138
+ MYSQL_ROOT_PASSWORD : root
139
+ MYSQL_PASSWORD : mysql
140
+ MYSQL_USER : mysql
111
141
postgres :
112
142
image : ghcr.io/datadog/images-rb/services/postgres:9.6
113
143
env :
@@ -116,6 +146,57 @@ jobs:
116
146
POSTGRES_DB : postgres
117
147
redis :
118
148
image : ghcr.io/datadog/images-rb/services/redis:6.2
149
+ steps :
150
+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
151
+ - name : Restore bundle cache
152
+ uses : ./.github/actions/bundle-restore
153
+ with :
154
+ lockfile-name : ${{ needs.batch.outputs.lockfile }}
155
+ cache-key : ${{ needs.batch.outputs.cache-key }}
156
+ - name : Build & Test
157
+ uses : ./.github/actions/build-test
158
+ with :
159
+ alias : ${{ inputs.alias }}
160
+ container-id : " standard-${{ matrix.batch }}"
161
+
162
+ build-test-misc :
163
+ needs :
164
+ - batch
165
+ runs-on : ubuntu-24.04
166
+ name : build & test (misc) [${{ matrix.batch }}]
167
+ timeout-minutes : 30
168
+ env :
169
+ BATCHED_TASKS : " ${{ toJSON(matrix.tasks) }}"
170
+ strategy :
171
+ fail-fast : false
172
+ matrix :
173
+ include : " ${{ fromJson(needs.batch.outputs.misc).include }}"
174
+ container :
175
+ image : ghcr.io/datadog/images-rb/engines/${{ inputs.engine }}:${{ inputs.version }}
176
+ env :
177
+ DD_INSTRUMENTATION_TELEMETRY_ENABLED : ' false'
178
+ DD_REMOTE_CONFIGURATION_ENABLED : ' false'
179
+ TEST_ELASTICSEARCH_HOST : elasticsearch
180
+ TEST_MEMCACHED_HOST : memcached
181
+ TEST_MONGODB_HOST : mongodb
182
+ TEST_OPENSEARCH_HOST : opensearch
183
+ TEST_OPENSEARCH_PORT : ' 9200'
184
+ TEST_PRESTO_HOST : presto
185
+ DD_AGENT_HOST : agent
186
+ DD_TRACE_AGENT_PORT : ' 9126'
187
+ DATADOG_GEM_CI : ' true'
188
+ TEST_DATADOG_INTEGRATION : ' 1'
189
+ JRUBY_OPTS : " --dev" # Faster JVM startup: https://github.com/jruby/jruby/wiki/Improving-startup-time#use-the---dev-flag
190
+ services :
191
+ agent :
192
+ image : ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.18.0
193
+ env :
194
+ LOG_LEVEL : DEBUG
195
+ TRACE_LANGUAGE : ruby
196
+ PORT : ' 9126'
197
+ DD_POOL_TRACE_CHECK_FAILURES : ' true'
198
+ DD_DISABLE_ERROR_RESPONSES : ' true'
199
+ ENABLED_CHECKS : trace_content_length,trace_stall,meta_tracer_version_header,trace_count_header,trace_peer_service,trace_dd_service
119
200
elasticsearch :
120
201
image : ghcr.io/datadog/images-rb/services/elasticsearch:8.1.3
121
202
env :
@@ -138,54 +219,15 @@ jobs:
138
219
cluster.routing.allocation.disk.threshold_enabled : ' false'
139
220
presto :
140
221
image : ghcr.io/datadog/images-rb/services/starburstdata/presto:332-e.9
141
- mysql :
142
- image : ghcr.io/datadog/images-rb/services/mysql:8.0
143
- env :
144
- MYSQL_ROOT_PASSWORD : root
145
- MYSQL_PASSWORD : mysql
146
- MYSQL_USER : mysql
147
222
steps :
148
223
- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
149
- - name : Configure Git
150
- run : git config --global --add safe.directory "$GITHUB_WORKSPACE"
151
- - name : Download lockfile
152
- uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
224
+ - name : Restore bundle cache
225
+ uses : ./.github/actions/bundle-restore
153
226
with :
154
- name : lockfile-${{ inputs.alias }}-${{ github.run_id }}
155
- - name : Restore cache
156
- uses : actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
157
- id : restore-cache
158
- with :
159
- key : " ${{ needs.batch.outputs.cache-key }}"
160
- path : " /usr/local/bundle"
161
- - run : bundle check || bundle install
162
- - run : bundle exec rake github:run_batch_build
163
- - name : Configure RSpec
164
- run : ln -s .rspec-local.example .rspec-local
165
- - run : bundle exec rake github:run_batch_tests
166
- env :
167
- COVERAGE_DIR : coverage/versions/${{ inputs.alias }}/${{ matrix.batch }}
168
- - name : Debug with SSH connection
169
- if : ${{ failure() && runner.debug == '1' }}
170
- uses : mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48 # v3.19.0
171
- with :
172
- limit-access-to-actor : true
173
- # This mode will wait at the end of the job for a user to connect and then to terminate the tmate session.
174
- # If no user has connected within 10 minutes after the post-job step started,
175
- # it will terminate the tmate session and quit gracefully.
176
- detached : true
177
- - name : Validate test agent data
178
- if : ${{ !cancelled() }}
179
- run : ruby .github/scripts/test_agent_check.rb
180
- - name : Upload junit reports
181
- if : ${{ !cancelled() }}
182
- uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
183
- with :
184
- name : junit-${{ inputs.alias }}-${{ matrix.batch }}-${{ github.run_id }}
185
- path : tmp/rspec/*.xml
186
- - name : Upload coverage data
187
- uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
227
+ lockfile-name : ${{ needs.batch.outputs.lockfile }}
228
+ cache-key : ${{ needs.batch.outputs.cache-key }}
229
+ - name : Build & Test
230
+ uses : ./.github/actions/build-test
188
231
with :
189
- name : coverage-${{ inputs.alias }}-${{ matrix.batch }}-${{ github.run_id }}
190
- path : coverage
191
- include-hidden-files : true # Coverage data generated by SimpleCov are hidden
232
+ alias : ${{ inputs.alias }}
233
+ container-id : " misc-${{ matrix.batch }}"
0 commit comments