@@ -10,15 +10,9 @@ setup() {
1010}
1111
1212@test " Pre-command restores cache with basic key" {
13- stub mktemp \
14- " : echo '/tmp/tempfile'"
15-
16- stub mv \
17- " -f /tmp/tempfile v1-cache-key.tar : true"
18-
1913 stub aws \
2014 " s3api head-object --bucket my-bucket --key 'my-org/my-pipeline/v1-cache-key.tar' --profile my-profile : true" \
21- " s3 cp --profile my-profile s3://my-bucket/my-org/my-pipeline/v1-cache-key.tar /tmp/tempfile : echo Copied from S3"
15+ " s3 cp --profile my-profile s3://my-bucket/my-org/my-pipeline/v1-cache-key.tar v1-cache-key.tar : echo Copied from S3"
2216
2317 stub tar \
2418 " -xf v1-cache-key.tar -C . : echo Extracted tar archive"
@@ -45,8 +39,6 @@ setup() {
4539
4640 unstub aws
4741 unstub tar
48- unstub mv
49- unstub mktemp
5042}
5143
5244@test " Pre-command restores S3 backed cache using local file" {
@@ -84,12 +76,8 @@ setup() {
8476
8577@test " Post-command syncs artifacts with a single path" {
8678
87- stub mktemp \
88- " : echo '/tmp/tempfile'"
8979 stub tar \
90- " --ignore-failed-read -cf /tmp/tempfile Pods : echo Created tar archive"
91- stub mv \
92- " -f /tmp/tempfile v1-cache-key.tar : true"
80+ " --ignore-failed-read -cf v1-cache-key.tar Pods : echo Created tar archive"
9381 stub aws \
9482 " s3 cp --profile my-profile v1-cache-key.tar s3://my-bucket/my-org/my-pipeline/v1-cache-key.tar : echo Copied to S3"
9583
@@ -116,24 +104,16 @@ setup() {
116104 unset BUILDKITE_PIPELINE_SLUG
117105 unset BUILDKITE_ORGANIZATION_SLUG
118106
119- unstub mktemp
120107 unstub tar
121- unstub mv
122108 unstub aws
123109}
124110
125111@test " Cache key template evaluation on file" {
126112 CHECKSUM=355831032f586e782b45744f2ed79316cc830244
127113
128- stub mktemp \
129- " : echo '/tmp/tempfile'"
130-
131- stub mv \
132- " -f /tmp/tempfile v1-cache-key-${CHECKSUM} .tar : true"
133-
134114 stub aws \
135115 " s3api head-object --bucket my-bucket --key 'my-org/my-pipeline/v1-cache-key-${CHECKSUM} .tar' --profile my-profile : true" \
136- " s3 cp --profile my-profile s3://my-bucket/my-org/my-pipeline/v1-cache-key-${CHECKSUM} .tar /tmp/tempfile : echo Copied from S3"
116+ " s3 cp --profile my-profile s3://my-bucket/my-org/my-pipeline/v1-cache-key-${CHECKSUM} .tar v1-cache-key- ${CHECKSUM} .tar : echo Copied from S3"
137117
138118 stub tar \
139119 " -xf v1-cache-key-${CHECKSUM} .tar -C . : echo Extracted tar archive"
@@ -157,24 +137,16 @@ setup() {
157137 unset BUILDKITE_PIPELINE_SLUG
158138 unset BUILDKITE_ORGANIZATION_SLUG
159139
160- unstub mktemp
161- unstub mv
162140 unstub aws
163141 unstub tar
164142}
165143
166144@test " Cache key template evaluation on dir" {
167145 CHECKSUM=4cfa4e590847976f26d761074e355e4d95fa8107
168146
169- stub mktemp \
170- " : echo '/tmp/tempfile'"
171-
172- stub mv \
173- " -f /tmp/tempfile v1-cache-key-${CHECKSUM} .tar : true"
174-
175147 stub aws \
176148 " s3api head-object --bucket my-bucket --key 'my-org/my-pipeline/v1-cache-key-${CHECKSUM} .tar' --profile my-profile : true" \
177- " s3 cp --profile my-profile s3://my-bucket/my-org/my-pipeline/v1-cache-key-${CHECKSUM} .tar /tmp/tempfile : echo Copied from S3"
149+ " s3 cp --profile my-profile s3://my-bucket/my-org/my-pipeline/v1-cache-key-${CHECKSUM} .tar v1-cache-key- ${CHECKSUM} .tar : echo Copied from S3"
178150
179151 stub tar \
180152 " -xf v1-cache-key-${CHECKSUM} .tar -C . : echo Extracted tar archive"
@@ -198,24 +170,16 @@ setup() {
198170 unset BUILDKITE_PIPELINE_SLUG
199171 unset BUILDKITE_ORGANIZATION_SLUG
200172
201- unstub mktemp
202- unstub mv
203173 unstub aws
204174 unstub tar
205175}
206176
207177@test " Cache key multi-template evaluation" {
208178 CHECKSUMS=355831032f586e782b45744f2ed79316cc830244-241bc31c8ddc004c48e6d88d7fa51ee981b8ce51
209179
210- stub mktemp \
211- " : echo '/tmp/tempfile'"
212-
213- stub mv \
214- " -f /tmp/tempfile v1-cache-key-${CHECKSUMS} .tar : true"
215-
216180 stub aws \
217181 " s3api head-object --bucket my-bucket --key 'my-org/my-pipeline/v1-cache-key-${CHECKSUMS} .tar' --profile my-profile : true" \
218- " s3 cp --profile my-profile s3://my-bucket/my-org/my-pipeline/v1-cache-key-${CHECKSUMS} .tar /tmp/tempfile : echo Copied from S3"
182+ " s3 cp --profile my-profile s3://my-bucket/my-org/my-pipeline/v1-cache-key-${CHECKSUMS} .tar v1-cache-key- ${CHECKSUMS} .tar : echo Copied from S3"
219183
220184 stub tar \
221185 " -xf v1-cache-key-${CHECKSUMS} .tar -C . : echo Extracted tar archive"
@@ -239,24 +203,16 @@ setup() {
239203 unset BUILDKITE_PIPELINE_SLUG
240204 unset BUILDKITE_ORGANIZATION_SLUG
241205
242- unstub mktemp
243- unstub mv
244206 unstub aws
245207 unstub tar
246208}
247209
248210@test " Cache key template evaluation in middle of key" {
249211 CHECKSUM=355831032f586e782b45744f2ed79316cc830244
250212
251- stub mktemp \
252- " : echo '/tmp/tempfile'"
253-
254- stub mv \
255- " -f /tmp/tempfile v1-cache-${CHECKSUM} -key.tar : true"
256-
257213 stub aws \
258214 " s3api head-object --bucket my-bucket --key 'my-org/my-pipeline/v1-cache-$CHECKSUM -key.tar' --profile my-profile : true" \
259- " s3 cp --profile my-profile s3://my-bucket/my-org/my-pipeline/v1-cache-$CHECKSUM -key.tar /tmp/tempfile : echo Copied from S3"
215+ " s3 cp --profile my-profile s3://my-bucket/my-org/my-pipeline/v1-cache-$CHECKSUM -key.tar v1-cache- $CHECKSUM -key.tar : echo Copied from S3"
260216
261217 stub tar \
262218 " -xf v1-cache-$CHECKSUM -key.tar -C . : echo Extracted tar archive"
@@ -280,8 +236,6 @@ setup() {
280236 unset BUILDKITE_PIPELINE_SLUG
281237 unset BUILDKITE_ORGANIZATION_SLUG
282238
283- unstub mktemp
284- unstub mv
285239 unstub aws
286240 unstub tar
287241}
@@ -310,15 +264,9 @@ setup() {
310264
311265@test " S3 arguments are passed through to copy command" {
312266
313- stub mktemp \
314- " : echo '/tmp/tempfile'"
315-
316- stub mv \
317- " -f /tmp/tempfile v1-cache-key.tar : true"
318-
319267 stub aws \
320268 " s3api head-object --bucket my-bucket --key 'my-org/my-pipeline/v1-cache-key.tar' --profile my-profile : true" \
321- " s3 cp --profile my-profile --acl bucket-owner-full-control s3://my-bucket/my-org/my-pipeline/v1-cache-key.tar /tmp/tempfile : echo Copied from S3"
269+ " s3 cp --profile my-profile --acl bucket-owner-full-control s3://my-bucket/my-org/my-pipeline/v1-cache-key.tar v1-cache-key.tar : echo Copied from S3"
322270
323271 stub tar \
324272 " -xf v1-cache-key.tar -C . : echo Extracted tar archive"
@@ -344,20 +292,15 @@ setup() {
344292 unset BUILDKITE_PIPELINE_SLUG
345293 unset BUILDKITE_ORGANIZATION_SLUG
346294
347- unstub mktemp
348- unstub mv
349295 unstub aws
350296 unstub tar
351297}
352298
353299@test " S3 download errors cause soft failure" {
354300
355- stub mktemp \
356- " : echo '/tmp/tempfile'"
357-
358301 stub aws \
359302 " s3api head-object --bucket my-bucket --key 'my-org/my-pipeline/v1-cache-key.tar' --profile my-profile : true" \
360- " s3 cp --profile my-profile --acl bucket-owner-full-control s3://my-bucket/my-org/my-pipeline/v1-cache-key.tar /tmp/tempfile : false"
303+ " s3 cp --profile my-profile --acl bucket-owner-full-control s3://my-bucket/my-org/my-pipeline/v1-cache-key.tar v1-cache-key.tar : false"
361304
362305 export BUILDKITE_ORGANIZATION_SLUG=" my-org"
363306 export BUILDKITE_PIPELINE_SLUG=" my-pipeline"
@@ -379,6 +322,5 @@ setup() {
379322 unset BUILDKITE_PIPELINE_SLUG
380323 unset BUILDKITE_ORGANIZATION_SLUG
381324
382- unstub mktemp
383325 unstub aws
384- }
326+ }
0 commit comments