Skip to content

Commit e40c36b

Browse files
committed
Partition build jobs
1 parent e68b605 commit e40c36b

File tree

1 file changed

+66
-17
lines changed

1 file changed

+66
-17
lines changed

.gitlab-ci.yml

Lines changed: 66 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,57 @@ 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+
variables:
245+
GRADLE_TARGET: ":baseTest"
246+
CACHE_TYPE: "base"
247+
parallel:
248+
matrix:
249+
- CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
250+
251+
build_tests_profiling:
252+
extends: .build_tests
253+
variables:
254+
GRADLE_TARGET: ":profilingTest"
255+
CACHE_TYPE: "profiling"
256+
parallel:
257+
matrix:
258+
- CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
259+
260+
build_tests_inst:
261+
extends: .build_tests
262+
variables:
263+
GRADLE_TARGET: ":instrumentationTest"
264+
CACHE_TYPE: "inst"
265+
parallel:
266+
matrix:
267+
- CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
268+
269+
build_tests_latestdep:
270+
extends: .build_tests
271+
variables:
272+
GRADLE_TARGET: ":instrumentationLatestDepTest"
273+
CACHE_TYPE: "latestdep"
274+
parallel:
275+
matrix:
276+
- CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
277+
278+
build_tests_smoke:
279+
extends: .build_tests
280+
variables:
281+
GRADLE_TARGET: ":smokeTest"
282+
CACHE_TYPE: "smoke"
283+
parallel:
284+
matrix:
285+
- CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
239286

240287
populate_dep_cache:
241-
extends: build_tests
288+
extends: .build_tests
242289
variables:
243290
BUILD_CACHE_POLICY: pull
244291
DEPENDENCY_CACHE_POLICY: push
@@ -253,16 +300,19 @@ populate_dep_cache:
253300
CACHE_TYPE: "lib"
254301
- GRADLE_TARGET: ":baseTest"
255302
CACHE_TYPE: "base"
303+
CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
256304
- GRADLE_TARGET: ":profilingTest"
257305
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"
306+
CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
307+
- GRADLE_TARGET: ":instrumentationTest"
308+
CACHE_TYPE: "inst"
309+
CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
310+
- GRADLE_TARGET: ":instrumentationLatestDepTest"
311+
CACHE_TYPE: "latestdep"
312+
CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
313+
- GRADLE_TARGET: ":smokeTest"
314+
CACHE_TYPE: "smoke"
315+
CI_SPLIT: ["1/4", "2/4", "3/4", "4/4"]
266316

267317
publish-artifacts-to-s3:
268318
image: registry.ddbuild.io/images/mirror/amazon/aws-cli:2.4.29
@@ -391,7 +441,7 @@ check_debugger:
391441

392442
muzzle:
393443
extends: .gradle_build
394-
needs: [ build_tests ]
444+
needs: [ build_tests_inst ]
395445
stage: tests
396446
parallel: 8
397447
variables:
@@ -416,7 +466,7 @@ muzzle:
416466

417467
muzzle-dep-report:
418468
extends: .gradle_build
419-
needs: [ build_tests ]
469+
needs: [ build_tests_inst ]
420470
stage: tests
421471
variables:
422472
CACHE_TYPE: inst
@@ -451,7 +501,6 @@ muzzle-dep-report:
451501
extends: .gradle_build
452502
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}$testJvm
453503
tags: [ "docker-in-docker:amd64" ] # use docker-in-docker runner for testcontainers
454-
needs: [ build_tests ]
455504
stage: tests
456505
variables:
457506
KUBERNETES_MEMORY_REQUEST: 17Gi

0 commit comments

Comments
 (0)