-
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: split save
and restore
cache actions
#7614
Changes from 2 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 | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,80 @@ | ||||||
name: Cache test images | ||||||
on: | ||||||
workflow_dispatch: | ||||||
|
||||||
env: | ||||||
GO_VERSION: '1.22' | ||||||
jobs: | ||||||
test-images: | ||||||
name: Cache test images | ||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- name: Check out code into the Go module directory | ||||||
uses: actions/checkout@v4.1.6 | ||||||
|
||||||
- name: Set up Go | ||||||
uses: actions/setup-go@v5 | ||||||
with: | ||||||
go-version: ${{ env.GO_VERSION }} | ||||||
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 use
Suggested change
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 also thought about this. |
||||||
|
||||||
- name: Install tools | ||||||
uses: aquaproj/aqua-installer@v3.0.1 | ||||||
with: | ||||||
aqua_version: v1.25.0 | ||||||
|
||||||
- name: Download test images | ||||||
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. Should restore cache before this step. Otherwise, it downloads images every time. 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. Done 91a8016 We use |
||||||
if: github.ref == 'refs/heads/main' | ||||||
run: mage test:fixtureContainerImages | ||||||
|
||||||
- name: Generate image list digest | ||||||
if: github.ref == 'refs/heads/main' | ||||||
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
Suggested change
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. Done |
||||||
id: image-digest | ||||||
run: | | ||||||
IMAGE_LIST=$(skopeo list-tags docker://ghcr.io/aquasecurity/trivy-test-images) | ||||||
DIGEST=$(echo "$IMAGE_LIST" | sha256sum | cut -d' ' -f1) | ||||||
echo "digest=$DIGEST" >> $GITHUB_OUTPUT | ||||||
|
||||||
## We need to save test image cache only for main branch | ||||||
- name: Save test images into cache | ||||||
if: github.ref == 'refs/heads/main' | ||||||
uses: actions/cache/save@v4 | ||||||
with: | ||||||
path: integration/testdata/fixtures/images | ||||||
key: cache-test-images-${{ steps.image-digest.outputs.digest }} | ||||||
|
||||||
test-vm-images: | ||||||
name: Cache test VM images | ||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- name: Check out code into the Go module directory | ||||||
uses: actions/checkout@v4.1.6 | ||||||
|
||||||
- name: Set up Go | ||||||
uses: actions/setup-go@v5 | ||||||
with: | ||||||
go-version: ${{ env.GO_VERSION }} | ||||||
|
||||||
- name: Install tools | ||||||
uses: aquaproj/aqua-installer@v3.0.1 | ||||||
with: | ||||||
aqua_version: v1.25.0 | ||||||
|
||||||
- name: Download test VM images | ||||||
if: github.ref == 'refs/heads/main' | ||||||
run: mage test:fixtureVMImages | ||||||
|
||||||
- name: Generate image list digest | ||||||
if: github.ref == 'refs/heads/main' | ||||||
id: image-digest | ||||||
run: | | ||||||
IMAGE_LIST=$(skopeo list-tags docker://ghcr.io/aquasecurity/trivy-test-vm-images) | ||||||
DIGEST=$(echo "$IMAGE_LIST" | sha256sum | cut -d' ' -f1) | ||||||
echo "digest=$DIGEST" >> $GITHUB_OUTPUT | ||||||
|
||||||
## We need to save test VM image cache only for main branch | ||||||
- name: Save test VM images into cache | ||||||
if: github.ref == 'refs/heads/main' | ||||||
uses: actions/cache/save@v4 | ||||||
with: | ||||||
path: integration/testdata/fixtures/vm-images | ||||||
key: cache-test-vm-images-${{ steps.image-digest.outputs.digest }} |
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.
I'd like to add
schedule
.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.
do this job once a day?
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.
Yes, let's start with daily. Most images are unchanged, and we don't call GHCR API other than listing tags.
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.
Done 91a8016