mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
fix: add k8s Kind cluster creation step and clean up post-e2e script
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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/<id>_<os>_<arch>_<version>/<binary>
|
||||
# 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))
|
||||
|
||||
Reference in New Issue
Block a user