-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
ci: cache test images for integration
, VM
and module
tests
#7599
Changes from 4 commits
c75cead
49461b0
208edcd
620ca42
c015645
0609e5d
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -82,6 +82,24 @@ jobs: | |||||||||
with: | ||||||||||
aqua_version: v1.25.0 | ||||||||||
|
||||||||||
- name: Restore test images from cache | ||||||||||
uses: actions/cache@v4 | ||||||||||
id: restore-test-images | ||||||||||
with: | ||||||||||
path: integration/testdata/fixtures/images | ||||||||||
key: cache-test-images-2024-09-10 # trivy-test-images last update date | ||||||||||
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. @knqyf263 I added trivy-test-images (trivy-test-vm-images) last update date to add the ability to control and influence the cache. 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. I want to automatically invalidate the cache when a new image is added to trivy-test-images rather than modifying the key manually. How about something like this?
It doesn't work if the existing images are updated, though. 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. Also, we don't need a step to save cache because it automatically creates a new cache.
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.
Ideally, we should calculate a cache key from each image manifest, but a list of images should be enough at the moment. We can think about it later.
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.
we should definitely do this in the future, because when updating the test image - the digest will remain the same 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.
Exactly. However, since we pin the digest, it is less likely to happen unless we intentionally change the digest. 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: Download test images | ||||||||||
if: steps.restore-test-images.outputs.cache-hit != 'true' | ||||||||||
knqyf263 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
run: mage test:fixtureContainerImages | ||||||||||
|
||||||||||
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. We don't need this step anymore. It is transparently called. Line 277 in bbc8e1d
And it's efficient as it skips images if it exists locally. Lines 30 to 32 in bbc8e1d
Now, we call this check twice, which is just time-consuming (and API-consuming). 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. Right, since the cache will still be saved at the end of the job! Removed |
||||||||||
- name: Save test images into cache | ||||||||||
if: steps.restore-test-images.outputs.cache-hit != 'true' | ||||||||||
uses: actions/cache@v4 | ||||||||||
with: | ||||||||||
path: integration/testdata/fixtures/images | ||||||||||
key: cache-test-images-2024-09-10 # trivy-test-images last update date | ||||||||||
|
||||||||||
- name: Run integration tests | ||||||||||
run: mage test:integration | ||||||||||
|
||||||||||
|
@@ -122,6 +140,24 @@ jobs: | |||||||||
with: | ||||||||||
aqua_version: v1.25.0 | ||||||||||
|
||||||||||
- name: Restore test images from cache | ||||||||||
uses: actions/cache@v4 | ||||||||||
id: restore-test-images | ||||||||||
with: | ||||||||||
path: integration/testdata/fixtures/images | ||||||||||
key: cache-test-images-2024-09-10 # trivy-test-images last update date | ||||||||||
|
||||||||||
- name: Download test images | ||||||||||
if: steps.restore-test-images.outputs.cache-hit != 'true' | ||||||||||
run: mage test:fixtureContainerImages | ||||||||||
|
||||||||||
- name: Save test images into cache | ||||||||||
if: steps.restore-test-images.outputs.cache-hit != 'true' | ||||||||||
uses: actions/cache@v4 | ||||||||||
with: | ||||||||||
path: integration/testdata/fixtures/images | ||||||||||
key: cache-test-images-2024-09-10 # trivy-test-images last update date | ||||||||||
|
||||||||||
- name: Run module integration tests | ||||||||||
shell: bash | ||||||||||
run: | | ||||||||||
|
@@ -142,6 +178,25 @@ jobs: | |||||||||
uses: aquaproj/[email protected] | ||||||||||
with: | ||||||||||
aqua_version: v1.25.0 | ||||||||||
|
||||||||||
- name: Restore test VM images from cache | ||||||||||
uses: actions/cache@v4 | ||||||||||
id: restore-test-vm-images | ||||||||||
with: | ||||||||||
path: integration/testdata/fixtures/vm-images | ||||||||||
key: cache-test-vm-images-2023-06-18 # trivy-test-vm-images last update date | ||||||||||
|
||||||||||
- name: Download test VM images | ||||||||||
if: steps.restore-test-vm-images.outputs.cache-hit != 'true' | ||||||||||
run: mage test:fixtureVMImages | ||||||||||
|
||||||||||
- name: Save test VM images into cache | ||||||||||
if: steps.restore-test-vm-images.outputs.cache-hit != 'true' | ||||||||||
uses: actions/cache@v4 | ||||||||||
with: | ||||||||||
path: integration/testdata/fixtures/vm-images | ||||||||||
key: cache-test-vm-images-2023-06-18 # trivy-test-vm-images last update date | ||||||||||
|
||||||||||
- name: Run vm integration tests | ||||||||||
run: | | ||||||||||
mage test:vm | ||||||||||
|
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.
nit: We no longer need
id
.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.
We want to merge this PR soon. We can delete it later.