Skip to content

Commit 7b9d224

Browse files
committed
Include --additional-build-args in checksum
1 parent e85ca06 commit 7b9d224

File tree

2 files changed

+59
-19
lines changed

2 files changed

+59
-19
lines changed

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN echo 'my expensive build step'
2727
steps:
2828
- command: echo wow
2929
plugins:
30-
- seek-oss/docker-ecr-cache#v2.2.0
30+
- seek-oss/docker-ecr-cache#v2.2.1
3131
- docker#v5.10.0
3232
```
3333
@@ -52,7 +52,7 @@ RUN pnpm install
5252
steps:
5353
- command: pnpm test
5454
plugins:
55-
- seek-oss/docker-ecr-cache#v2.2.0:
55+
- seek-oss/docker-ecr-cache#v2.2.1:
5656
cache-on:
5757
- package.json # avoid cache hits on stale lockfiles
5858
- pnpm-lock.yaml
@@ -67,7 +67,7 @@ The `cache-on` property also supports Bash globbing with `globstar`:
6767
steps:
6868
- command: pnpm test
6969
plugins:
70-
- seek-oss/docker-ecr-cache#v2.2.0:
70+
- seek-oss/docker-ecr-cache#v2.2.1:
7171
cache-on:
7272
- '**/package.json' # monorepo with multiple manifest files
7373
- pnpm-lock.yaml
@@ -84,7 +84,7 @@ A given entry cannot contain both bash globbing and a jq path.
8484
steps:
8585
- command: pnpm test
8686
plugins:
87-
- seek-oss/docker-ecr-cache#v2.2.0:
87+
- seek-oss/docker-ecr-cache#v2.2.1:
8888
cache-on:
8989
- .npmrc
9090
- package.json#.dependencies
@@ -105,7 +105,7 @@ It's possible to specify the Dockerfile to use by:
105105
steps:
106106
- command: echo wow
107107
plugins:
108-
- seek-oss/docker-ecr-cache#v2.2.0:
108+
- seek-oss/docker-ecr-cache#v2.2.1:
109109
dockerfile: my-dockerfile
110110
- docker#v5.10.0
111111
```
@@ -116,7 +116,7 @@ Alternatively, Dockerfile can be embedded inline:
116116
steps:
117117
- command: echo wow
118118
plugins:
119-
- seek-oss/docker-ecr-cache#v2.2.0:
119+
- seek-oss/docker-ecr-cache#v2.2.1:
120120
dockerfile-inline: |
121121
FROM node:20-alpine
122122
WORKDIR /workdir
@@ -145,7 +145,7 @@ steps:
145145
--build-arg BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_TAG
146146
--file Dockerfile.secondary
147147
plugins:
148-
- seek-oss/docker-ecr-cache#v2.2.0
148+
- seek-oss/docker-ecr-cache#v2.2.1
149149
```
150150

151151
Your `Dockerfile.secondary` can then [dynamically use these args](https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact):
@@ -173,7 +173,7 @@ stage to run commands against:
173173
steps:
174174
- command: cargo test
175175
plugins:
176-
- seek-oss/docker-ecr-cache#v2.2.0:
176+
- seek-oss/docker-ecr-cache#v2.2.1:
177177
target: build-deps
178178
- docker#v5.10.0
179179
```
@@ -188,7 +188,7 @@ The `context` property can be used to specify a different path.
188188
steps:
189189
- command: cargo test
190190
plugins:
191-
- seek-oss/docker-ecr-cache#v2.2.0:
191+
- seek-oss/docker-ecr-cache#v2.2.1:
192192
dockerfile: dockerfiles/test/Dockerfile
193193
context: '.'
194194
- docker#v5.10.0
@@ -217,7 +217,7 @@ steps:
217217
env:
218218
ARG_1: wow
219219
plugins:
220-
- seek-oss/docker-ecr-cache#v2.2.0:
220+
- seek-oss/docker-ecr-cache#v2.2.1:
221221
build-args:
222222
- ARG_1
223223
- ARG_2=such
@@ -232,7 +232,7 @@ steps:
232232
env:
233233
ARG_1: wow
234234
plugins:
235-
- seek-oss/docker-ecr-cache#v2.2.0:
235+
- seek-oss/docker-ecr-cache#v2.2.1:
236236
additional-build-args: '--ssh= default=\$SSH_AUTH_SOCK'
237237
- docker#v5.10.0
238238
```
@@ -260,7 +260,7 @@ steps:
260260
env:
261261
SECRET: wow
262262
plugins:
263-
- seek-oss/docker-ecr-cache#v2.2.0:
263+
- seek-oss/docker-ecr-cache#v2.2.1:
264264
secrets:
265265
- SECRET
266266
- docker#v5.10.0
@@ -276,7 +276,7 @@ steps:
276276
plugins:
277277
- seek-oss/private-npm#v1.2.0:
278278
env: SECRET
279-
- seek-oss/docker-ecr-cache#v2.2.0:
279+
- seek-oss/docker-ecr-cache#v2.2.1:
280280
secrets:
281281
- id=npmrc,src=.npmrc
282282
- docker#v5.10.0
@@ -294,7 +294,7 @@ By default images are kept in ECR for up to 30 days. This can be changed by spec
294294
steps:
295295
- command: echo wow
296296
plugins:
297-
- seek-oss/docker-ecr-cache#v2.2.0:
297+
- seek-oss/docker-ecr-cache#v2.2.1:
298298
max-age-days: 7
299299
- docker#v5.10.0
300300
```
@@ -307,7 +307,7 @@ By default, image name and computed tag are exported to the Docker buildkite plu
307307
steps:
308308
- command: echo wow
309309
plugins:
310-
- seek-oss/docker-ecr-cache#v2.2.0:
310+
- seek-oss/docker-ecr-cache#v2.2.1:
311311
export-env-variable: BUILDKITE_PLUGIN_MY_CUSTOM_PLUGIN_CACHE_IMAGE
312312
- my-custom-plugin#v1.0.0:
313313
```
@@ -321,7 +321,7 @@ steps:
321321
- label: Build Cache
322322
command: ':'
323323
plugins:
324-
- seek-oss/docker-ecr-cache#v2.2.0:
324+
- seek-oss/docker-ecr-cache#v2.2.1:
325325
skip-pull-from-cache: true
326326
```
327327

@@ -337,7 +337,7 @@ optionally use a custom repository name:
337337
steps:
338338
- command: echo wow
339339
plugins:
340-
- seek-oss/docker-ecr-cache#v2.2.0:
340+
- seek-oss/docker-ecr-cache#v2.2.1:
341341
ecr-name: my-unique-repository-name
342342
ecr-tags:
343343
Key: Value
@@ -353,7 +353,7 @@ By default, the plugin uses the region specified in the `AWS_DEFAULT_REGION` env
353353
steps:
354354
- command: echo wow
355355
plugins:
356-
- seek-oss/docker-ecr-cache#v2.2.0:
356+
- seek-oss/docker-ecr-cache#v2.2.1:
357357
region: ap-southeast-2
358358
- docker#v5.10.0
359359
```
@@ -395,7 +395,7 @@ Example:
395395
```yaml
396396
- command: echo wow
397397
plugins:
398-
- seek-oss/docker-ecr-cache#v2.2.0:
398+
- seek-oss/docker-ecr-cache#v2.2.1:
399399
registry-provider: gcr
400400
gcp-project: foo-bar-123456
401401
```

tests/stdlib.bats

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pre_command_hook="$PWD/hooks/pre-command"
6363
assert_line "ARCHITECTURE"
6464
assert_line "+ my-architecture"
6565
assert_line "BUILD_ARGS"
66+
refute_line "ADDITIONAL_BUILD_ARGS"
6667
assert_line "CACHE_ON"
6768

6869
unstub uname
@@ -91,6 +92,7 @@ pre_command_hook="$PWD/hooks/pre-command"
9192
assert_line "ARCHITECTURE"
9293
assert_line "+ my-architecture"
9394
assert_line "BUILD_ARGS"
95+
refute_line "ADDITIONAL_BUILD_ARGS"
9496
assert_line "CACHE_ON"
9597

9698
unstub uname
@@ -122,6 +124,7 @@ pre_command_hook="$PWD/hooks/pre-command"
122124
assert_line "+ my-architecture"
123125
assert_line "BUILD_ARGS"
124126
assert_line "+ foo=1"
127+
refute_line "ADDITIONAL_BUILD_ARGS"
125128
assert_line "CACHE_ON"
126129

127130
unstub uname
@@ -155,6 +158,7 @@ pre_command_hook="$PWD/hooks/pre-command"
155158
assert_line "+ my-architecture"
156159
assert_line "BUILD_ARGS"
157160
assert_line "+ foo=1"
161+
refute_line "ADDITIONAL_BUILD_ARGS"
158162
assert_line "CACHE_ON"
159163

160164
unstub uname
@@ -187,6 +191,42 @@ pre_command_hook="$PWD/hooks/pre-command"
187191
assert_line "ARCHITECTURE"
188192
assert_line "+ my-architecture"
189193
assert_line "BUILD_ARGS"
194+
refute_line "ADDITIONAL_BUILD_ARGS"
195+
assert_line "CACHE_ON"
196+
197+
unstub uname
198+
unstub jq
199+
unstub sha1sum
200+
}
201+
202+
@test "Can compute image tag with additional-build-args" {
203+
# this var leaks in via pre-command
204+
target="my-multi-stage-container"
205+
export BUILDKITE_PLUGIN_DOCKER_ADDITIONAL_BUILD_ARGS='--platform=linux/amd64,linux/arm64'
206+
207+
stub uname \
208+
"-m : echo my-architecture" \
209+
"-m : echo my-architecture"
210+
stub jq \
211+
"-r .dependencies test-package.json : echo '{\"test\":\"123\"}'"
212+
stub sha1sum \
213+
"pretend-dockerfile : echo sha1sum(pretend-dockerfile)" \
214+
": echo sha1sum(target: my-multi-stage-container)" \
215+
": echo sha1sum(uname: my-architecture)" \
216+
"--platform=linux/amd64,linux/arm64: echo sha1sum(--platform=linux/amd64,linux/arm64)" \
217+
": echo sha1sum(jq: .dependencies)" \
218+
": echo sha1sum(hashes so far)"
219+
220+
run compute_tag "pretend-dockerfile"
221+
222+
assert_success
223+
assert_line "--- Computing tag"
224+
assert_line "DOCKERFILE"
225+
assert_line "+ pretend-dockerfile:my-multi-stage-container"
226+
assert_line "ARCHITECTURE"
227+
assert_line "+ my-architecture"
228+
assert_line "BUILD_ARGS"
229+
assert_line "ADDITIONAL_BUILD_ARGS"
190230
assert_line "CACHE_ON"
191231

192232
unstub uname

0 commit comments

Comments
 (0)