From 89478eabcc2d1dced299f6e930656638e61a99a2 Mon Sep 17 00:00:00 2001 From: Matthias Bertschy Date: Fri, 12 Dec 2025 14:51:43 +0100 Subject: [PATCH] fix: add k8s Kind cluster creation step and clean up post-e2e script Signed-off-by: Matthias Bertschy --- .github/workflows/02-release.yaml | 5 +++++ .goreleaser.yaml | 2 +- build/goreleaser-post-e2e.sh | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/02-release.yaml b/.github/workflows/02-release.yaml index ab8d607b..4a9541e6 100644 --- a/.github/workflows/02-release.yaml +++ b/.github/workflows/02-release.yaml @@ -83,6 +83,11 @@ jobs: - uses: anchore/sbom-action/download-syft@v0 name: Setup Syft + - name: Create k8s Kind Cluster + uses: helm/kind-action@v1.10.0 + with: + cluster_name: kubescape-e2e + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 3775f664..cfc1c2a2 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -38,7 +38,7 @@ builds: - -X "github.com/kubescape/kubescape/v3/core/cautils.Client={{.Env.CLIENT}}" hooks: post: - - "/bin/sh -lc 'GOARCH={{ .Arch }} sh build/goreleaser-post-e2e.sh'" + - "/bin/sh -lc 'sh build/goreleaser-post-e2e.sh'" - id: downloader dir: downloader binary: downloader diff --git a/build/goreleaser-post-e2e.sh b/build/goreleaser-post-e2e.sh index 35bcbbef..03e1bb16 100644 --- a/build/goreleaser-post-e2e.sh +++ b/build/goreleaser-post-e2e.sh @@ -55,7 +55,7 @@ if ! is_true "${RUN_E2E}"; then exit 0 fi -# Locate the amd64 artifact in dist/. +# Locate the amd64 artifact in dist/. # Goreleaser v2 puts binaries in dist/___/ # Example: dist/cli_linux_amd64_v1/kubescape ART_PATH="" @@ -146,13 +146,13 @@ elif ! kubectl config current-context >/dev/null 2>&1; then log "No active kubernetes context found (kubectl config current-context failed). Skipping system tests." else log "Kubernetes cluster connection verified." - + # Create a temporary directory for system tests SYSTEST_DIR=$(mktemp -d) log "Cloning system-tests into $SYSTEST_DIR" - + if git clone --depth 1 https://github.com/armosec/system-tests.git "$SYSTEST_DIR"; then - + # Save current directory to return later PUSHED_DIR=$(pwd) cd "$SYSTEST_DIR" @@ -163,7 +163,7 @@ else # The script expects to run inside the dir chmod +x ./create_env.sh ./create_env.sh >/dev/null 2>&1 || log "Warning: create_env.sh returned non-zero" - + # Activate the environment if it exists if [ -f "systests_python_env/bin/activate" ]; then # shellcheck disable=SC1091 @@ -195,14 +195,14 @@ scan_custom_framework_scanning_cluster_scope_testing \ scan_custom_framework_scanning_cluster_and_file_scope_testing" FAILURES=0 - + # We use the python executable found earlier or the one from the venv SYSTEST_PYTHON="python3" - + # Run tests for t in $TESTS; do log "Running system test: $t" - + set +e # Note: We must pass the absolute path to kubescape binary $SYSTEST_PYTHON systest-cli.py \ @@ -212,10 +212,10 @@ scan_custom_framework_scanning_cluster_and_file_scope_testing" --duration 3 \ --logger DEBUG \ --kwargs kubescape="$ART_PATH" - + t_rc=$? set -e - + if [ $t_rc -ne 0 ]; then log "Test $t FAILED." FAILURES=$((FAILURES + 1))