Update test.sh
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 7s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 7s
This commit is contained in:
69
test.sh
69
test.sh
@@ -22,6 +22,15 @@ function warning() {
|
|||||||
echo -e "\033[33m⚠ $1\033[0m"
|
echo -e "\033[33m⚠ $1\033[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if ds command is available
|
||||||
|
DS_AVAILABLE=false
|
||||||
|
if command -v ds >/dev/null 2>&1; then
|
||||||
|
DS_AVAILABLE=true
|
||||||
|
info "Using dropshell validate for template validation"
|
||||||
|
else
|
||||||
|
warning "ds command not found - using basic validation only"
|
||||||
|
fi
|
||||||
|
|
||||||
# Get list of template directories (exclude hidden directories)
|
# Get list of template directories (exclude hidden directories)
|
||||||
TEMPLATES=$(find . -maxdepth 1 -type d ! -name ".*" ! -name "." | sed 's|^\./||' | grep -v ".gitea")
|
TEMPLATES=$(find . -maxdepth 1 -type d ! -name ".*" ! -name "." | sed 's|^\./||' | grep -v ".gitea")
|
||||||
|
|
||||||
@@ -34,7 +43,7 @@ info "Found templates to test: $(echo $TEMPLATES | tr '\n' ' ')"
|
|||||||
FAILED_TESTS=""
|
FAILED_TESTS=""
|
||||||
SKIPPED_TESTS=""
|
SKIPPED_TESTS=""
|
||||||
|
|
||||||
# Run basic validation tests for each template
|
# Run validation tests for each template
|
||||||
for TEMPLATE in $TEMPLATES; do
|
for TEMPLATE in $TEMPLATES; do
|
||||||
echo ""
|
echo ""
|
||||||
info "Testing template: $TEMPLATE"
|
info "Testing template: $TEMPLATE"
|
||||||
@@ -46,8 +55,27 @@ for TEMPLATE in $TEMPLATES; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make scripts executable if needed
|
||||||
|
for SCRIPT in $TEMPLATE/*.sh; do
|
||||||
|
if [ -f "$SCRIPT" ] && [ ! -x "$SCRIPT" ]; then
|
||||||
|
chmod +x "$SCRIPT"
|
||||||
|
info "Made $SCRIPT executable"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$DS_AVAILABLE" = true ]; then
|
||||||
|
# Use dropshell's validate command
|
||||||
|
if ds validate "$TEMPLATE" 2>&1; then
|
||||||
|
success "Template $TEMPLATE passed validation"
|
||||||
|
else
|
||||||
|
echo " ERROR: Template $TEMPLATE failed ds validate"
|
||||||
|
FAILED_TESTS="$FAILED_TESTS $TEMPLATE"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Fallback: basic validation when ds is not available
|
||||||
|
|
||||||
# Check for required scripts
|
# Check for required scripts
|
||||||
REQUIRED_SCRIPTS="install.sh uninstall.sh start.sh stop.sh status.sh"
|
REQUIRED_SCRIPTS="install.sh uninstall.sh status.sh"
|
||||||
MISSING_SCRIPTS=""
|
MISSING_SCRIPTS=""
|
||||||
|
|
||||||
for SCRIPT in $REQUIRED_SCRIPTS; do
|
for SCRIPT in $REQUIRED_SCRIPTS; do
|
||||||
@@ -62,35 +90,19 @@ for TEMPLATE in $TEMPLATES; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success "All required scripts present"
|
# Check for config directory and service.env
|
||||||
|
|
||||||
# Check if scripts are executable
|
|
||||||
NON_EXECUTABLE=""
|
|
||||||
for SCRIPT in $TEMPLATE/*.sh; do
|
|
||||||
if [ -f "$SCRIPT" ] && [ ! -x "$SCRIPT" ]; then
|
|
||||||
chmod +x "$SCRIPT"
|
|
||||||
info "Made $SCRIPT executable"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Check for config directory
|
|
||||||
if [ ! -d "$TEMPLATE/config" ]; then
|
if [ ! -d "$TEMPLATE/config" ]; then
|
||||||
echo " ERROR: Missing config directory"
|
echo " ERROR: Missing config directory"
|
||||||
FAILED_TESTS="$FAILED_TESTS $TEMPLATE"
|
FAILED_TESTS="$FAILED_TESTS $TEMPLATE"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success "Config directory exists"
|
|
||||||
|
|
||||||
# Check for service.env file
|
|
||||||
if [ ! -f "$TEMPLATE/config/service.env" ]; then
|
if [ ! -f "$TEMPLATE/config/service.env" ]; then
|
||||||
echo " ERROR: Missing config/service.env file"
|
echo " ERROR: Missing config/service.env file"
|
||||||
FAILED_TESTS="$FAILED_TESTS $TEMPLATE"
|
FAILED_TESTS="$FAILED_TESTS $TEMPLATE"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success "service.env file exists"
|
|
||||||
|
|
||||||
# Validate shell scripts for basic syntax errors
|
# Validate shell scripts for basic syntax errors
|
||||||
SYNTAX_ERRORS=""
|
SYNTAX_ERRORS=""
|
||||||
for SCRIPT in $TEMPLATE/*.sh; do
|
for SCRIPT in $TEMPLATE/*.sh; do
|
||||||
@@ -108,23 +120,8 @@ for TEMPLATE in $TEMPLATES; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success "All scripts pass syntax check"
|
success "Template $TEMPLATE passed basic validation"
|
||||||
|
|
||||||
# If we have the ds command available and we're in CI, we could run full tests
|
|
||||||
# For now, we'll skip integration tests in CI to avoid dependencies
|
|
||||||
if [ -n "$CI" ]; then
|
|
||||||
info "Skipping integration tests in CI environment"
|
|
||||||
else
|
|
||||||
if which ds >/dev/null 2>&1; then
|
|
||||||
info "ds command found, could run integration tests (skipping for safety)"
|
|
||||||
# Uncomment to enable integration tests:
|
|
||||||
# ./test_template.sh "$TEMPLATE" || FAILED_TESTS="$FAILED_TESTS $TEMPLATE"
|
|
||||||
else
|
|
||||||
info "ds command not found, skipping integration tests"
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
success "Template $TEMPLATE passed all tests"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
@@ -140,6 +137,6 @@ if [ -n "$FAILED_TESTS" ]; then
|
|||||||
echo -e "\033[31m✗ Failed templates:$FAILED_TESTS\033[0m"
|
echo -e "\033[31m✗ Failed templates:$FAILED_TESTS\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo -e "\033[32m✓ All templates passed validation tests!\033[0m"
|
echo -e "\033[32m✓ All templates passed validation!\033[0m"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user