-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: filter out anonymous images #789
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ build | |
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
node_modules/ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,12 @@ Cache Docker Images Whether Built or Pulled | |
- [Usage](#usage) | ||
- [Inputs](#inputs) | ||
- [Required](#required) | ||
- [`key`](#key) | ||
- [Optional](#optional) | ||
- [`read-only`](#read-only) | ||
Comment on lines
+30
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem related to this pull request. I'm guessing this change was made by our tooling? |
||
- [Outputs](#outputs) | ||
- [`cache-hit`](#cache-hit) | ||
- [Anonymous image names](#anonymous-image-names) | ||
- [Supported Runners](#supported-runners) | ||
- [Permissions](#permissions) | ||
- [Changelog](#changelog) | ||
|
@@ -94,6 +97,30 @@ True on cache hit (even if the subsequent | |
failed) and false on cache miss. See also | ||
[skipping steps based on cache-hit](https://github.com/marketplace/actions/cache#Skipping-steps-based-on-cache-hit). | ||
|
||
## Anonymous image names | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Anonymous image names" --> "Anonymous Images" (since they could either have anonymous names or tags or both) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section is only relevant to a small minority of users, so let's move it below the Permissions section. |
||
|
||
Anonymous images (eg. `<none>:<none>`) will be skipped during caching | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: "eg." --> "e.g.," |
||
via `docker save`, as we use the `{{ .Repository }}:{{ .Tag }}` format | ||
to reference which images to save. | ||
|
||
`docker save {{ .ID }}` would allow us to cache/load such anonymous images. | ||
However, the docker client loses reference to the original | ||
`{{ .Repository }}:{{ .Tag }}` value upon `docker load` for previously | ||
named images, resulting in: | ||
|
||
```sh | ||
my-image:tag | ||
``` | ||
|
||
to become | ||
|
||
```sh | ||
<none>:<none> | ||
``` | ||
|
||
Comment on lines
+106
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is great context for the commit message, but I doubt the typical developer cares to know our rationale, and I am sensitive to how quickly people stop reading once they feel the docs are no longer relevant. |
||
Be sure to name + tag those images you wish to be handled by the caching | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "name + tag" --> "name and tag" in case the plus sign might momentarily throw off some non-native speakers |
||
and loading operations in this action. | ||
Comment on lines
+121
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "handled by the caching and loading operations in this action" --> "cached" for brevity
Comment on lines
+121
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be combined with the first paragraph. |
||
|
||
## Supported Runners | ||
|
||
- Tested on `ubuntu-22.04` and `windows-2022` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,7 +256,10 @@ describe("Docker images", (): void => { | |
assertSaveCacheHit(key); | ||
} else if (readOnly) { | ||
assertSaveReadOnly(key); | ||
} else if (newImages.length === 0) { | ||
} else if ( | ||
newImages.length === 0 || | ||
newImages.every((img) => img == "<none>:<none>") | ||
Comment on lines
+260
to
+261
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be simplified/corrected to: |
||
) { | ||
assertNoNewImagesToSave(); | ||
} else { | ||
assertSaveCacheMiss(key, newImages); | ||
|
@@ -268,6 +271,7 @@ describe("Docker images", (): void => { | |
["my-key", false, false, [["preexisting-image"], []]], | ||
["my-key", false, true, [["preexisting-image"], ["new-image"]]], | ||
["my-key", true, false, [["preexisting-image"], ["new-image"]]], | ||
["my-key", false, false, [["preexisting-image"], ["<none>:<none>"]]], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Astutely observed that this change was needed! We should probably also bias the |
||
], | ||
}, | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,8 @@ const saveDockerImages = async (): Promise<void> => { | |
const images = await execBashCommand(LIST_COMMAND); | ||
const imagesList = images.split("\n"); | ||
const newImages = imagesList.filter( | ||
(image: string): boolean => !preexistingImages.includes(image), | ||
(image: string): boolean => | ||
!preexistingImages.includes(image) && image !== "<none>:<none>", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The failure also occurs when only the tag is |
||
); | ||
if (newImages.length === 0) { | ||
info("No Docker images to save"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on the rationale for this change?