#!/bin/bash
set -e
echo "π³ Starting Brummer Package Deployment Tests with Podman"
echo "=================================================="
# Change to the project root directory
cd "$(dirname "$0")/.."
# List of test containers to build and run
TESTS=(
"npm-node18:Test NPM package on Node.js 18"
"npm-node20:Test NPM package on Node.js 20"
"ubuntu-npm:Test NPM package on Ubuntu"
"alpine-pnpm:Test PNPM package on Alpine"
"go-install:Test Go install method"
"cross-platform:Test cross-platform binary installation"
)
# Function to run a single test
run_test() {
local test_name="$1"
local description="$2"
local dockerfile="docker-tests/Dockerfile.${test_name}"
echo ""
echo "π§ͺ Running: $description"
echo "βββββββββββββββββββββββββββββββββββββββββββββββ"
# Build the image
echo "π¦ Building container image..."
podman build -f "$dockerfile" -t "brummer-test-${test_name}" .
# Run the test
echo "π Running test container..."
if podman run --rm "brummer-test-${test_name}"; then
echo "β Test passed: $test_name"
else
echo "β Test failed: $test_name"
return 1
fi
}
# Function to cleanup images
cleanup_images() {
echo ""
echo "π§Ή Cleaning up test images..."
for test in "${TESTS[@]}"; do
test_name="${test%%:*}"
podman rmi "brummer-test-${test_name}" 2>/dev/null || true
done
}
# Trap to cleanup on exit
trap cleanup_images EXIT
# Check if podman is available
if ! command -v podman &> /dev/null; then
echo "β Podman is not installed. Please install Podman to run these tests."
echo " On Ubuntu/Debian: sudo apt install podman"
echo " On RHEL/CentOS: sudo dnf install podman"
echo " On macOS: brew install podman"
exit 1
fi
echo "π Found $(echo ${#TESTS[@]}) test scenarios"
echo ""
# Run all tests
failed_tests=()
passed_tests=()
for test in "${TESTS[@]}"; do
test_name="${test%%:*}"
description="${test#*:}"
if run_test "$test_name" "$description"; then
passed_tests+=("$test_name")
else
failed_tests+=("$test_name")
fi
done
# Summary
echo ""
echo "π Test Results Summary"
echo "======================"
echo "β Passed: ${#passed_tests[@]}"
echo "β Failed: ${#failed_tests[@]}"
if [ ${#passed_tests[@]} -gt 0 ]; then
echo ""
echo "Passed tests:"
for test in "${passed_tests[@]}"; do
echo " β $test"
done
fi
if [ ${#failed_tests[@]} -gt 0 ]; then
echo ""
echo "Failed tests:"
for test in "${failed_tests[@]}"; do
echo " β $test"
done
echo ""
echo "β Some tests failed. Check the logs above for details."
exit 1
else
echo ""
echo "π All tests passed! Package deployment is working correctly."
fi