Skip to content

Commit a480cd4

Browse files
committed
Partition build jobs
1 parent e68b605 commit a480cd4

File tree

1 file changed

+71
-17
lines changed

1 file changed

+71
-17
lines changed

.gitlab-ci.yml

Lines changed: 71 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,25 @@ default:
143143
CACHE_TYPE: lib #default
144144
RUNTIME_AVAILABLE_PROCESSORS_OVERRIDE: 4 # Runtime.getRuntime().availableProcessors() returns incorrect or very high values in Kubernetes
145145
cache:
146-
- key: '$CI_SERVER_VERSION-$CACHE_TYPE' # Dependencies cache. Reset the cache every time gitlab is upgraded. ~Every couple months
146+
- key: '$CI_SERVER_VERSION-$CACHE_TYPE-$NORMALIZED_NODE_TOTAL-$NORMALIZED_NODE_INDEX' # Dependencies cache. Reset the cache every time gitlab is upgraded. ~Every couple months
147147
paths:
148148
# Cached dependencies and wrappers for gradle
149149
- .gradle/wrapper
150150
- .gradle/caches
151151
- .gradle/notifications
152152
policy: $DEPENDENCY_CACHE_POLICY
153153
fallback_keys: # Use fallback keys because all cache types are not populated. See note under: populate_dep_cache
154+
#- '$CI_SERVER_VERSION-$CACHE_TYPE'
154155
- '$CI_SERVER_VERSION-base'
155156
- '$CI_SERVER_VERSION-lib'
156-
- key: $CI_PIPELINE_ID-$CACHE_TYPE # Incremental build cache. Shared by all jobs in the pipeline of the same type
157+
- key: $CI_PIPELINE_ID-$CACHE_TYPE-$NORMALIZED_NODE_TOTAL-$NORMALIZED_NODE_INDEX # Incremental build cache. Shared by all jobs in the pipeline of the same type
157158
paths:
158159
- .gradle/caches/$GRADLE_VERSION
159160
- .gradle/$GRADLE_VERSION/executionHistory
160161
- workspace
161162
policy: $BUILD_CACHE_POLICY
163+
#fallback_keys:
164+
# - '$CI_PIPELINE_ID-$CACHE_TYPE'
162165
before_script:
163166
- source .gitlab/gitlab-utils.sh
164167
- mkdir -p .gradle
@@ -210,7 +213,7 @@ build:
210213
reports:
211214
dotenv: build.env
212215

213-
build_tests:
216+
.build_tests:
214217
extends: .gradle_build
215218
variables:
216219
BUILD_CACHE_POLICY: push
@@ -232,13 +235,62 @@ build_tests:
232235
- GRADLE_TARGET: ":smokeTest"
233236
CACHE_TYPE: "smoke"
234237
MAVEN_OPTS: "-Xms64M -Xmx512M -Dorg.slf4j.simpleLogger.defaultLogLevel=debug" # FIXME: Build :smokeTest build fails unless mvn debug logging is on
235-
236238
script:
237239
- *gitlab_base_ref_params
238-
- ./gradlew clean $GRADLE_TARGET $GRADLE_PARAMS -PskipTests $GRADLE_ARGS
240+
- ./gradlew clean $GRADLE_TARGET $GRADLE_PARAMS -PskipTests -PtaskPartitionCount=$NORMALIZED_NODE_TOTAL -PtaskPartition=$NORMALIZED_NODE_INDEX $GRADLE_ARGS
241+
242+
build_tests_base:
243+
extends: .build_tests
244+
needs: [ build_tests_base ]
245+
variables:
246+
GRADLE_TARGET: ":baseTest"
247+
CACHE_TYPE: "base"
248+
parallel:
249+
matrix:
250+
- CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
251+
252+
build_tests_profiling:
253+
extends: .build_tests
254+
needs: [ build_tests_profiling ]
255+
variables:
256+
GRADLE_TARGET: ":profilingTest"
257+
CACHE_TYPE: "profiling"
258+
parallel:
259+
matrix:
260+
- CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
261+
262+
build_tests_inst:
263+
extends: .build_tests
264+
needs: [ build_tests_inst ]
265+
variables:
266+
GRADLE_TARGET: ":instrumentationTest"
267+
CACHE_TYPE: "inst"
268+
parallel:
269+
matrix:
270+
- CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
271+
272+
build_tests_latestdep:
273+
extends: .build_tests
274+
needs: [ build_tests_latestdep ]
275+
variables:
276+
GRADLE_TARGET: ":instrumentationLatestDepTest"
277+
CACHE_TYPE: "latestdep"
278+
parallel:
279+
matrix:
280+
- CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
281+
282+
build_tests_smoke:
283+
extends: .build_tests
284+
needs: [ build_tests_smoke ]
285+
variables:
286+
GRADLE_TARGET: ":smokeTest"
287+
CACHE_TYPE: "smoke"
288+
parallel:
289+
matrix:
290+
- CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
239291

240292
populate_dep_cache:
241-
extends: build_tests
293+
extends: .build_tests
242294
variables:
243295
BUILD_CACHE_POLICY: pull
244296
DEPENDENCY_CACHE_POLICY: push
@@ -253,16 +305,19 @@ populate_dep_cache:
253305
CACHE_TYPE: "lib"
254306
- GRADLE_TARGET: ":baseTest"
255307
CACHE_TYPE: "base"
308+
CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
256309
- GRADLE_TARGET: ":profilingTest"
257310
CACHE_TYPE: "profiling"
258-
# FIXME: Gitlab doesn't support s3 based caches >5GB. Fixed in Gitlab 17.5
259-
# See: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/26921#note_2132307223
260-
# - GRADLE_TARGET: ":instrumentationTest"
261-
# CACHE_TYPE: "inst"
262-
# - GRADLE_TARGET: ":instrumentationLatestDepTest"
263-
# CACHE_TYPE: "latestdep"
264-
# - GRADLE_TARGET: ":smokeTest"
265-
# CACHE_TYPE: "smoke"
311+
CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
312+
- GRADLE_TARGET: ":instrumentationTest"
313+
CACHE_TYPE: "inst"
314+
CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
315+
- GRADLE_TARGET: ":instrumentationLatestDepTest"
316+
CACHE_TYPE: "latestdep"
317+
CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
318+
- GRADLE_TARGET: ":smokeTest"
319+
CACHE_TYPE: "smoke"
320+
CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
266321

267322
publish-artifacts-to-s3:
268323
image: registry.ddbuild.io/images/mirror/amazon/aws-cli:2.4.29
@@ -391,7 +446,7 @@ check_debugger:
391446

392447
muzzle:
393448
extends: .gradle_build
394-
needs: [ build_tests ]
449+
needs: [ build_tests_inst ]
395450
stage: tests
396451
parallel: 8
397452
variables:
@@ -416,7 +471,7 @@ muzzle:
416471

417472
muzzle-dep-report:
418473
extends: .gradle_build
419-
needs: [ build_tests ]
474+
needs: [ build_tests_inst ]
420475
stage: tests
421476
variables:
422477
CACHE_TYPE: inst
@@ -451,7 +506,6 @@ muzzle-dep-report:
451506
extends: .gradle_build
452507
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}$testJvm
453508
tags: [ "docker-in-docker:amd64" ] # use docker-in-docker runner for testcontainers
454-
needs: [ build_tests ]
455509
stage: tests
456510
variables:
457511
KUBERNETES_MEMORY_REQUEST: 17Gi

0 commit comments

Comments
 (0)