From 8ec882ca5f9223272a160e7acde3b59494f78c77 Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Thu, 3 Jul 2025 14:04:10 +0300 Subject: [PATCH] [dx] Refactor collect-images functionality Signed-off-by: Andrei Kvapil --- .github/workflows/pull-requests.yaml | 26 ++++++++++++++------------ hack/collect-images.sh | 8 ++++++++ hack/list-images.sh | 8 -------- packages/core/testing/Makefile | 9 +++++---- 4 files changed, 27 insertions(+), 24 deletions(-) create mode 100755 hack/collect-images.sh delete mode 100755 hack/list-images.sh diff --git a/.github/workflows/pull-requests.yaml b/.github/workflows/pull-requests.yaml index 9057978a..4e989f41 100644 --- a/.github/workflows/pull-requests.yaml +++ b/.github/workflows/pull-requests.yaml @@ -290,8 +290,8 @@ jobs: done echo "✅ The task completed successfully after $attempt attempts" - collect_report: - name: Collect report + collect_debug_information: + name: Collect debug information runs-on: [self-hosted] needs: [test_apps] if: ${{ always() }} @@ -313,10 +313,21 @@ jobs: name: cozyreport path: /tmp/${{ env.SANDBOX_NAME }}/_out/cozyreport.tgz + - name: Collect images list + run: | + cd /tmp/$SANDBOX_NAME + make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME collect-images + + - name: Upload image list + uses: actions/upload-artifact@v4 + with: + name: image-list + path: /tmp/${{ env.SANDBOX_NAME }}/_out/images.txt + cleanup: name: Tear down environment runs-on: [self-hosted] - needs: [collect_report] + needs: [collect_debug_information] if: ${{ always() && needs.test_apps.result == 'success' }} steps: @@ -329,15 +340,6 @@ jobs: - name: Set sandbox ID run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV - - name: List images used - run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME list-images - - - name: Upload image list - uses: actions/upload-artifact@v4 - with: - name: image-list - path: images.txt - - name: Tear down sandbox run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME delete diff --git a/hack/collect-images.sh b/hack/collect-images.sh new file mode 100755 index 00000000..817f1d06 --- /dev/null +++ b/hack/collect-images.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +for node in 11 12 13; do + talosctl -n 192.168.123.${node} -e 192.168.123.${node} images ls >> images.tmp + talosctl -n 192.168.123.${node} -e 192.168.123.${node} images --namespace system ls >> images.tmp +done + +while read _ name sha _ ; do echo $sha $name ; done < images.tmp | sort -u > images.txt diff --git a/hack/list-images.sh b/hack/list-images.sh deleted file mode 100755 index efb772f9..00000000 --- a/hack/list-images.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -for node in 11 12 13; do - talosctl -n 192.168.123.${node} -e 192.168.123.${node} images ls >> /workspace/images.tmp - talosctl -n 192.168.123.${node} -e 192.168.123.${node} images --namespace system ls >> /workspace/images.tmp -done - -while read _ name sha _ ; do echo $sha $name ; done < /workspace/images.tmp | sort -u > /workspace/images.txt diff --git a/packages/core/testing/Makefile b/packages/core/testing/Makefile index ec3b0179..f597d5ce 100755 --- a/packages/core/testing/Makefile +++ b/packages/core/testing/Makefile @@ -55,6 +55,11 @@ collect-report: ## Collect the test report from the sandbox. mkdir -p ../../../_out docker cp "${SANDBOX_NAME}:/workspace/cozyreport.tgz" ../../../_out/cozyreport.tgz +collect-images: ## Collect the list of images used in the sandbox. + docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/collect-images.sh' + mkdir -p ../../../_out + docker cp "${SANDBOX_NAME}":/workspace/images.txt ../../../_out/images.txt + delete: ## Remove sandbox from existing Kubernetes cluster. docker rm -f "${SANDBOX_NAME}" || true @@ -72,7 +77,3 @@ apply: delete "$$(yq .e2e.image values.yaml)" \ --timeout 30m docker cp "${ROOT_DIR}/." "${SANDBOX_NAME}":/workspace - -list-images: - docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/list-images.sh' - docker cp "${SANDBOX_NAME}":/workspace/images.txt ../../../images.txt