Skip to content

Commit de656d2

Browse files
authored
build-sbt directly, and don't restore build-maven where not necessary (apache-spark-on-k8s#340)
1 parent cf31e83 commit de656d2

File tree

1 file changed

+65
-63
lines changed

1 file changed

+65
-63
lines changed

.circleci/config.yml

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ defaults: &defaults
44
docker:
55
- image: palantirtechnologies/circle-spark-base
66
resource_class: xlarge
7-
environment:
7+
environment: &defaults-environment
88
TERM: dumb
9+
BUILD_SBT_CACHE: "/home/circleci/build-sbt-cache"
910

1011

1112
test-defaults: &test-defaults
1213
<<: *defaults
1314
environment:
15+
<<: *defaults-environment
1416
CIRCLE_TEST_REPORTS: /tmp/circle-test-reports
1517
TEST_RESULTS_FILE: /tmp/test-results/results.json
1618

@@ -29,6 +31,35 @@ deployable-branches-and-tags: &deployable-branches-and-tags
2931
only: master
3032

3133

34+
# Step templates
35+
36+
step_templates:
37+
restore-build-binaries-cache: &restore-build-binaries-cache
38+
restore_cache:
39+
key: build-binaries-{{ checksum "build/mvn" }}-{{ checksum "build/sbt" }}
40+
restore-ivy-cache: &restore-ivy-cache
41+
restore_cache:
42+
keys:
43+
- v7-ivy-dependency-cache-{{ .Branch }}-{{ checksum "pom.xml" }}
44+
# if cache for exact version of `pom.xml` is not present then load any most recent one
45+
- v7-ivy-dependency-cache-{{ .Branch }}-
46+
- v7-ivy-dependency-cache-master-{{ checksum "pom.xml" }}
47+
- v7-ivy-dependency-cache-master-
48+
restore-home-sbt-cache: &restore-home-sbt-cache
49+
restore_cache:
50+
keys:
51+
- v2-home-sbt-{{ checksum "build/sbt" }}-{{ checksum "project/target/streams/$global/update/$global/streams/update_cache_2.10/inputs" }}
52+
restore-build-sbt-cache: &restore-build-sbt-cache
53+
restore_cache:
54+
key: v1-build-sbt-{{ .Branch }}-{{ .Revision }}
55+
link-in-build-sbt-cache: &link-in-build-sbt-cache
56+
run:
57+
name: Hard link cache contents into current build directory
58+
command: |
59+
if [[ -d "$BUILD_SBT_CACHE" ]]; then
60+
rsync --info=stats2,misc1,flist0 -a --link-dest="$BUILD_SBT_CACHE" "$BUILD_SBT_CACHE/" .
61+
fi
62+
3263
jobs:
3364
build-maven:
3465
<<: *defaults
@@ -80,14 +111,11 @@ jobs:
80111
resource_class: small
81112
steps:
82113
- checkout
83-
- restore_cache:
84-
key: build-maven-{{ .Branch }}-{{ .BuildNum }}
85114
# Need maven dependency cache, otherwise checkstyle tests fail as such:
86115
# Failed to execute goal on project spark-assembly_2.11: Could not resolve dependencies for project org.apache.spark:spark-assembly_2.11:pom:2.4.0-SNAPSHOT
87116
- restore_cache:
88117
key: maven-dependency-cache-{{ checksum "pom.xml" }}
89-
- restore_cache:
90-
key: build-binaries-{{ checksum "build/mvn" }}-{{ checksum "build/sbt" }}
118+
- *restore-build-binaries-cache
91119
- run: dev/run-style-tests.py | tee /tmp/run-style-tests.log
92120
- store_artifacts:
93121
path: /tmp/run-style-tests.log
@@ -103,8 +131,7 @@ jobs:
103131
key: build-maven-{{ .Branch }}-{{ .BuildNum }}
104132
- restore_cache:
105133
key: maven-dependency-cache-{{ checksum "pom.xml" }}
106-
- restore_cache:
107-
key: build-binaries-{{ checksum "build/mvn" }}-{{ checksum "build/sbt" }}
134+
- *restore-build-binaries-cache
108135
- run: |
109136
dev/run-build-tests.py | tee /tmp/run-build-tests.log
110137
- store_artifacts:
@@ -113,13 +140,11 @@ jobs:
113140

114141
build-sbt:
115142
<<: *defaults
116-
environment:
117-
BUILD_SBT_CACHE: "/home/circleci/build-sbt-cache"
118143
steps:
119144
# Saves us from recompiling every time...
120145
- restore_cache:
121146
keys:
122-
- v1-build-sbt-{{ .Branch }}-{{ .BuildNum }}
147+
- v1-build-sbt-{{ .Branch }}-{{ .Revision }}
123148
- v1-build-sbt-{{ .Branch }}-
124149
- v1-build-sbt-master-
125150
- checkout
@@ -129,19 +154,9 @@ jobs:
129154
if [[ -d "$BUILD_SBT_CACHE" ]]; then
130155
rsync --info=stats2,misc1,flist0 -a --link-dest="$BUILD_SBT_CACHE" "$BUILD_SBT_CACHE/" .
131156
fi
132-
- restore_cache:
133-
keys:
134-
- v5-ivy-dependency-cache-{{ checksum "pom.xml" }}
135-
# if cache for exact version of `pom.xml` is not present then load any most recent one
136-
- v5-ivy-dependency-cache-
137-
- restore_cache:
138-
key: maven-dependency-cache-{{ checksum "pom.xml" }}
139-
- restore_cache:
140-
keys:
141-
- v2-home-sbt-{{ checksum "build/sbt" }}-{{ checksum "project/target/streams/$global/update/$global/streams/update_cache_2.10/inputs" }}
142-
# Given the build-sbt cache, this is superfluous, but leave it in in case we will want to remove the former
143-
- restore_cache:
144-
key: build-binaries-{{ checksum "build/mvn" }}-{{ checksum "build/sbt" }}
157+
- *restore-ivy-cache
158+
- *restore-home-sbt-cache
159+
- *restore-build-binaries-cache
145160
- run:
146161
name: Download all external dependencies for the test configuration (which extends compile) and ensure we update first
147162
command: dev/sbt test:externalDependencyClasspath oldDeps/test:externalDependencyClasspath
@@ -150,7 +165,7 @@ jobs:
150165
- store_artifacts:
151166
path: /tmp/heap.bin
152167
- save_cache:
153-
key: v5-ivy-dependency-cache-{{ checksum "pom.xml" }}
168+
key: v7-ivy-dependency-cache-{{ .Branch }}-{{ checksum "pom.xml" }}
154169
paths:
155170
- "~/.ivy2"
156171
- store_artifacts:
@@ -167,22 +182,16 @@ jobs:
167182
--exclude '***/*.jar' --include 'target/***'
168183
--include '**/' --exclude '*' . "$BUILD_SBT_CACHE/"
169184
- save_cache:
170-
key: v1-build-sbt-{{ .Branch }}-{{ .BuildNum }}
185+
key: v1-build-sbt-{{ .Branch }}-{{ .Revision }}
171186
paths:
172187
- "~/build-sbt-cache"
173-
# Also save all the target directories to the workspace - need assembly jars for spark submitting
188+
# Also save all the assembly jars directories to the workspace - need them for spark submitting
174189
- persist_to_workspace:
175190
root: .
176191
paths:
177-
- "target"
178-
- "*/target"
179-
- "common/*/target"
180-
- "dists/*/target"
181-
- "external/*/target"
182-
- "resource-managers/*/target"
183-
- "resource-managers/*/*/target"
184-
- "sql/*/target"
185-
- "project/project/target"
192+
- 'assembly/target/scala-*/jars'
193+
- 'examples/target/scala-*/jars'
194+
- 'external/*/target/scala-*/*.jar'
186195

187196
run-backcompat-tests:
188197
# depends on build-sbt
@@ -191,16 +200,9 @@ jobs:
191200
- checkout
192201
- attach_workspace:
193202
at: .
194-
- restore_cache:
195-
key: v5-ivy-dependency-cache-{{ checksum "pom.xml" }}
196-
# TODO(dsanduleac): do we need the maven cache?
197-
- restore_cache:
198-
key: maven-dependency-cache-{{ checksum "pom.xml" }}
199-
- restore_cache:
200-
key: build-binaries-{{ checksum "build/mvn" }}-{{ checksum "build/sbt" }}
201-
- restore_cache:
202-
keys:
203-
- v2-home-sbt-{{ checksum "build/sbt" }}-{{ checksum "project/target/streams/$global/update/$global/streams/update_cache_2.10/inputs" }}
203+
- *restore-ivy-cache
204+
- *restore-build-binaries-cache
205+
- *restore-home-sbt-cache
204206
- run: |
205207
dev/run-backcompat-tests.py | tee /tmp/run-backcompat-tests.log
206208
- store_artifacts:
@@ -209,13 +211,19 @@ jobs:
209211

210212

211213
run-python-tests:
212-
# depends on build-sbt, so we're restoring the build-sbt cache
214+
# depends on build-sbt, but we only need the assembly jars
213215
<<: *defaults
214216
docker:
215217
- image: palantirtechnologies/circle-spark-python
216218
parallelism: 2
217219
steps:
218220
- checkout
221+
# These two steps restore all the target directories except jars
222+
# Necessary because of SPARK_PREPEND_CLASSES being used in python tests, and some python tests
223+
# accessing classes from the core/test configuration.
224+
- *restore-build-sbt-cache
225+
- *link-in-build-sbt-cache
226+
# ---
219227
# Python tests need assembly files build by the `build-sbt` job
220228
# e.g. external/kafka-0-8-assembly/target/scala-2.11/spark-streaming-kafka-0-8-assembly-2.4.0-SNAPSHOT.jar
221229
- attach_workspace:
@@ -228,7 +236,7 @@ jobs:
228236

229237

230238
run-r-tests:
231-
# depends on build-sbt, so we're restoring the build-sbt cache
239+
# depends on build-sbt, but we only need the assembly jars
232240
<<: *defaults
233241
docker:
234242
- image: palantirtechnologies/circle-spark-r
@@ -257,15 +265,13 @@ jobs:
257265
- checkout
258266
- attach_workspace:
259267
at: .
260-
- restore_cache:
261-
key: maven-dependency-cache-{{ checksum "pom.xml" }}
262-
- restore_cache:
263-
key: v5-ivy-dependency-cache-{{ checksum "pom.xml" }}
264-
- restore_cache:
265-
key: build-binaries-{{ checksum "build/mvn" }}-{{ checksum "build/sbt" }}
266-
- restore_cache:
267-
keys:
268-
- v2-home-sbt-{{ checksum "build/sbt" }}-{{ checksum "project/target/streams/$global/update/$global/streams/update_cache_2.10/inputs" }}
268+
# These two steps restore all the target directories except jars
269+
- *restore-build-sbt-cache
270+
- *link-in-build-sbt-cache
271+
# ---
272+
- *restore-ivy-cache
273+
- *restore-build-binaries-cache
274+
- *restore-home-sbt-cache
269275
- restore_cache:
270276
keys:
271277
- v1-test-results-{{ .Branch }}-{{ .BuildNum }}
@@ -346,8 +352,7 @@ jobs:
346352
- checkout
347353
- restore_cache:
348354
key: maven-dependency-cache-{{ checksum "pom.xml" }}
349-
- restore_cache:
350-
key: build-binaries-{{ checksum "build/mvn" }}-{{ checksum "build/sbt" }}
355+
- *restore-build-binaries-cache
351356
- run:
352357
command: dev/set_version_and_package.sh
353358
# This is potentially costly but we can't use the workspace as it would conflict with
@@ -371,8 +376,7 @@ jobs:
371376
key: v1-maven-build-with-version-{{ .Branch }}-{{ .Revision }}
372377
- restore_cache:
373378
key: v1-maven-dependency-cache-versioned-{{ checksum "pom.xml" }}
374-
- restore_cache:
375-
key: build-binaries-{{ checksum "build/mvn" }}-{{ checksum "build/sbt" }}
379+
- *restore-build-binaries-cache
376380

377381
- run: echo "user=$BINTRAY_USERNAME" > .credentials
378382
- run: echo "password=$BINTRAY_PASSWORD" >> .credentials
@@ -402,8 +406,6 @@ workflows:
402406
- build-maven
403407
<<: *all-branches-and-tags
404408
- build-sbt:
405-
requires:
406-
- build-maven
407409
<<: *all-branches-and-tags
408410
- run-backcompat-tests:
409411
requires:
@@ -424,7 +426,7 @@ workflows:
424426
- build-maven-versioned:
425427
requires:
426428
- build-maven
427-
<<: *deployable-branches-and-tags
429+
<<: *all-branches-and-tags
428430
- deploy:
429431
requires:
430432
- build-maven

0 commit comments

Comments
 (0)