Skip to content

Commit

Permalink
test: use image list digest for image cache
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Sep 26, 2024
1 parent e312370 commit b5b810e
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,26 @@ jobs:
with:
aqua_version: v1.25.0

- name: Generate image list digest
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
- 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
key: cache-test-images-${{ steps.image-digest.outputs.digest }}
restore-keys:
cache-test-images-

- 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 integration tests
run: mage test:integration

Expand Down Expand Up @@ -142,24 +144,26 @@ jobs:
with:
aqua_version: v1.25.0

- name: Generate image list digest
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
- 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
key: cache-test-images-${{ steps.image-digest.outputs.digest }}
restore-keys:
cache-test-images-

- 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: |
Expand All @@ -181,24 +185,26 @@ jobs:
with:
aqua_version: v1.25.0

- name: Restore test VM images from cache
- name: Generate image list digest
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
- name: Restore test images from cache
uses: actions/cache@v4
id: restore-test-vm-images
id: restore-test-images
with:
path: integration/testdata/fixtures/vm-images
key: cache-test-vm-images-2023-06-18 # trivy-test-vm-images last update date
key: cache-test-images-${{ steps.image-digest.outputs.digest }}
restore-keys:
cache-test-images-

- name: Download test VM images
if: steps.restore-test-vm-images.outputs.cache-hit != 'true'
if: steps.restore-test-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
Expand Down

0 comments on commit b5b810e

Please sign in to comment.