Skip to content

More degug logs around plugin unzip #114

More degug logs around plugin unzip

More degug logs around plugin unzip #114

name: Integration Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
test-deployment:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate unique test name
id: test-name
run: |
# Create unique name with GitHub run number
TEST_NAME="mautic-test-${{ github.run_number }}"
echo "test-name=$TEST_NAME" >> $GITHUB_OUTPUT
echo "🏷️ Test VPS name: $TEST_NAME"
- name: Deploy Mautic (Initial Installation)
id: deploy
uses: ./
with:
vps-name: ${{ steps.test-name.outputs.test-name }}
vps-size: 's-1vcpu-1gb'
vps-region: 'nyc1'
email: 'test@mautic-test.local'
mautic-password: ${{ secrets.TEST_MAUTIC_PASSWORD }}
mysql-password: ${{ secrets.TEST_MYSQL_PASSWORD }}
mysql-root-password: ${{ secrets.TEST_MYSQL_ROOT_PASSWORD }}
digitalocean-token: ${{ secrets.DIGITALOCEAN_TOKEN }}
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
# Start with older version for upgrade testing
mautic-version: '6.0.4-apache'
plugins: |
https://github.com/chimpino/stripe-plugin/archive/refs/heads/6.x.zip?directory=StripePlugin&token=${{ secrets.CHIMPINO_GITHUB_TOKEN }}
- name: Show initial deployment results
run: |
echo "πŸŽ‰ Initial deployment completed successfully!"
echo "VPS IP: ${{ steps.deploy.outputs.vps-ip }}"
echo "Mautic URL: ${{ steps.deploy.outputs.mautic-url }}"
echo "βœ… Mautic 6.0.4 installation test passed"
- name: Verify initial deployment is ready
run: |
echo "πŸ” Actively verifying Mautic 6.0.4 is fully ready..."
echo "πŸ› Debug: Checking deployment outputs..."
echo " VPS IP: '${{ steps.deploy.outputs.vps-ip }}'"
echo " Mautic URL: '${{ steps.deploy.outputs.mautic-url }}'"
# Setup SSH for container verification
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
VPS_IP="${{ steps.deploy.outputs.vps-ip }}"
MAUTIC_URL="${{ steps.deploy.outputs.mautic-url }}"
# First verify all containers are running
echo "🐳 Verifying all Docker containers are running correctly..."
CONTAINER_STATUS=$(ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@$VPS_IP "cd /var/www && docker compose ps --format 'table {{.Name}}\t{{.Status}}\t{{.Health}}'")
echo "$CONTAINER_STATUS"
# Check mautic_db
if echo "$CONTAINER_STATUS" | grep -q "mautic_db.*Up.*healthy"; then
echo "βœ… mautic_db container is running and healthy"
else
echo "❌ mautic_db container is not healthy"
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@$VPS_IP "docker logs mautic_db --tail 50"
exit 1
fi
# Check mautic_web
if echo "$CONTAINER_STATUS" | grep -q "mautic_web.*Up.*healthy"; then
echo "βœ… mautic_web container is running and healthy"
else
echo "❌ mautic_web container is not healthy"
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@$VPS_IP "docker logs mautic_web --tail 50"
exit 1
fi
# Check mautic_cron
if echo "$CONTAINER_STATUS" | grep -q "mautic_cron.*Up"; then
echo "βœ… mautic_cron container is running"
else
echo "❌ mautic_cron container is not running"
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@$VPS_IP "docker logs mautic_cron --tail 50"
exit 1
fi
echo "πŸŽ‰ All expected containers are running correctly!"
# Validate URL before proceeding with accessibility tests
if [ -z "$MAUTIC_URL" ]; then
echo "❌ Error: MAUTIC_URL is empty!"
echo "πŸ” Deploy step outputs:"
echo " - vps-ip: '${{ steps.deploy.outputs.vps-ip }}'"
echo " - mautic-url: '${{ steps.deploy.outputs.mautic-url }}'"
echo " - deployment-log: '${{ steps.deploy.outputs.deployment-log }}'"
exit 1
fi
echo "βœ… MAUTIC_URL is set to: $MAUTIC_URL"
# Wait up to 2 minutes for Mautic to be fully ready
timeout=120
counter=0
while [ $counter -lt $timeout ]; do
echo "⏳ Testing Mautic readiness... (${counter}/${timeout}s)"
# Test login page accessibility - accept both 200 and 302 as success
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${MAUTIC_URL}/s/login" 2>/dev/null || echo "000")
echo "πŸ” HTTP response code: $HTTP_CODE"
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then
echo "βœ… Mautic is responding (HTTP $HTTP_CODE)"
# For 302 redirects, this is normal for fresh Mautic installations
if [ "$HTTP_CODE" = "302" ]; then
echo "πŸ“‹ HTTP 302 detected - Mautic is redirecting (normal for fresh installation)"
echo "βœ… Mautic application is ready for setup!"
break
fi
# For 200 responses, verify the page contains expected Mautic content
if curl -s "${MAUTIC_URL}/s/login" | grep -q -i "mautic\|login"; then
echo "βœ… Mautic application is fully ready!"
break
else
echo "⚠️ Page accessible but content not ready yet..."
fi
else
echo "⚠️ Mautic not yet accessible (HTTP $HTTP_CODE)..."
fi
sleep 5
counter=$((counter + 5))
done
if [ $counter -ge $timeout ]; then
echo "❌ Timeout waiting for Mautic to be ready"
echo "πŸ” Final check - attempting to access ${MAUTIC_URL}/s/login"
curl -v "${MAUTIC_URL}/s/login" || echo "Failed to access Mautic"
exit 1
fi
echo "πŸŽ‰ Initial deployment verification completed - ready for upgrade test!"
- name: Verify plugin installation
run: |
echo "πŸ” Verifying plugins were installed correctly..."
VPS_IP="${{ steps.deploy.outputs.vps-ip }}"
if [ -z "$VPS_IP" ]; then
echo "❌ Error: VPS_IP is empty!"
exit 1
fi
# Check if the plugin directories exist and contain expected files
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${VPS_IP} << 'EOF'
echo "πŸ“‚ Checking plugin directory structure..."
plugin_success=0
# Check StripePlugin (private repo with token)
if docker exec mautic_web ls /var/www/html/docroot/plugins/StripePlugin >/dev/null 2>&1; then
echo "βœ… StripePlugin directory found"
if docker exec mautic_web find /var/www/html/docroot/plugins/StripePlugin -name "*.php" | head -1 | grep -q ".php"; then
echo "βœ… StripePlugin contains PHP files - installation successful"
plugin_success=$((plugin_success + 1))
else
echo "⚠️ StripePlugin directory exists but no PHP files found"
echo "πŸ” Debug: Contents of StripePlugin directory:"
docker exec mautic_web ls -la /var/www/html/docroot/plugins/StripePlugin/ || echo "Failed to list directory contents"
echo "πŸ” Debug: Looking for any files in StripePlugin:"
docker exec mautic_web find /var/www/html/docroot/plugins/StripePlugin -type f | head -10 || echo "No files found"
echo "πŸ” Debug: Directory size and file count:"
docker exec mautic_web bash -c 'du -sh /var/www/html/docroot/plugins/StripePlugin/ && find /var/www/html/docroot/plugins/StripePlugin -type f | wc -l' || echo "Failed to get directory info"
fi
else
echo "⚠️ StripePlugin directory not found (check CHIMPINO_GITHUB_TOKEN secret)"
fi
echo "πŸ“‹ Available plugin directories:"
docker exec mautic_web ls -la /var/www/html/docroot/plugins/ || echo "No plugins directory found"
if [ $plugin_success -gt 0 ]; then
echo "βœ… Plugin installation verification completed ($plugin_success plugins successful)"
exit 0
else
echo "❌ No plugins were installed successfully"
exit 1
fi
EOF
echo "πŸŽ‰ Plugin verification completed successfully!"
- name: Test plugin accessibility via Mautic
run: |
echo "πŸ” Testing if Mautic recognizes the installed plugins..."
VPS_IP="${{ steps.deploy.outputs.vps-ip }}"
# Check plugin status through Mautic console (if available)
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${VPS_IP} << 'EOF'
cd /var/www
echo "πŸ”§ Testing Mautic plugin recognition..."
# Check if plugin files are accessible from container
plugin_count=0
if docker exec mautic_web ls /var/www/html/plugins/StripePlugin/ >/dev/null 2>&1; then
echo "βœ… StripePlugin files are accessible from Mautic container"
plugin_count=$((plugin_count + 1))
else
echo "ℹ️ StripePlugin not accessible from container"
fi
if docker exec mautic_web ls /var/www/html/plugins/IntegrationsPlugin/ >/dev/null 2>&1; then
echo "βœ… IntegrationsPlugin files are accessible from Mautic container"
plugin_count=$((plugin_count + 1))
else
echo "ℹ️ IntegrationsPlugin not accessible from container"
fi
echo "πŸ“Š Summary: $plugin_count plugins accessible from container"
# List all available plugins
echo "πŸ“‹ All plugins in container:"
docker exec mautic_web find /var/www/html/docroot/plugins -maxdepth 1 -type d | tail -n +2 | head -10 || echo "No plugins found in container"
EOF
- name: Setup SSH for manual upgrade test
run: |
echo "πŸ” Setting up SSH for manual upgrade testing..."
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Test version upgrade manually
run: |
echo "πŸ”„ Testing Mautic version upgrade from 6.0.4 to 6.0.5..."
VPS_IP="${{ steps.deploy.outputs.vps-ip }}"
if [ -z "$VPS_IP" ]; then
echo "❌ Error: VPS_IP is empty!"
exit 1
fi
echo "πŸ“ Updating Mautic version configuration on VPS: $VPS_IP"
# SSH into VPS and modify the version, then trigger upgrade
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${VPS_IP} << 'EOF'
cd /var/www
echo "πŸ” Current deploy.env contents:"
cat deploy.env
echo ""
echo "πŸ”„ Updating MAUTIC_VERSION to 6.0.5-apache..."
sed -i 's/MAUTIC_VERSION=.*/MAUTIC_VERSION=6.0.5-apache/' deploy.env
echo "βœ… Updated deploy.env contents:"
cat deploy.env
echo ""
echo "πŸš€ Re-running setup script to trigger upgrade detection..."
./setup 2>&1 | tee /var/log/upgrade-test.log
EOF
echo "βœ… Version upgrade test completed"
- name: Verify upgrade worked
run: |
echo "πŸ” Verifying the upgrade was successful..."
VPS_IP="${{ steps.deploy.outputs.vps-ip }}"
MAUTIC_URL="${{ steps.deploy.outputs.mautic-url }}"
# Download upgrade log
scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${VPS_IP}:/var/log/upgrade-test.log ./upgrade-test.log || echo "Could not download upgrade log"
# Check if upgrade was detected
if [ -f ./upgrade-test.log ]; then
echo "πŸ“‹ Checking upgrade log for update indicators..."
if grep -q "Version mismatch:" ./upgrade-test.log; then
echo "βœ… PASS: Version update was detected"
else
echo "❌ FAIL: Version update was not detected"
echo "πŸ“‹ Recent log entries:"
tail -20 ./upgrade-test.log
exit 1
fi
if grep -q "Containers recreated successfully" ./upgrade-test.log; then
echo "βœ… PASS: Containers were updated successfully"
else
echo "❌ FAIL: Container update failed"
echo "πŸ“‹ Checking for alternative success indicators..."
if grep -q "Mautic update completed successfully" ./upgrade-test.log; then
echo "βœ… PASS: Mautic update completed successfully"
else
echo "❌ No success indicators found"
exit 1
fi
fi
fi
# Verify Mautic is still working after upgrade
echo "πŸ” Testing Mautic accessibility after upgrade..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${MAUTIC_URL}/s/login" 2>/dev/null || echo "000")
echo "πŸ“‹ HTTP response code: $HTTP_CODE"
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then
echo "βœ… PASS: Mautic is still accessible after upgrade (HTTP $HTTP_CODE)"
# Check that it's actually the new version by inspecting container
echo "πŸ” Verifying container is running new version..."
CONTAINER_IMAGE=$(ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${VPS_IP} "docker inspect mautic_web --format='{{.Config.Image}}' 2>/dev/null || echo 'unknown'")
echo "πŸ“¦ Container image: $CONTAINER_IMAGE"
if echo "$CONTAINER_IMAGE" | grep -q "6.0.5-apache"; then
echo "βœ… PASS: Container is running Mautic 6.0.5-apache"
else
echo "❌ FAIL: Container is not running expected version"
exit 1
fi
else
echo "❌ FAIL: Mautic is not accessible after upgrade"
exit 1
fi
echo "πŸŽ‰ All version upgrade validation checks passed!"
echo "🏁 Integration test completed successfully:"
echo " βœ… Initial deployment with Mautic 6.0.4"
echo " βœ… Version upgrade to 6.0.5 without reinstallation"
echo " βœ… Proper maintenance and migration execution"
echo " βœ… Container version verification"
- name: Cleanup test droplet
if: always()
run: |
echo "🧹 Cleaning up test droplet..."
TEST_NAME="${{ steps.test-name.outputs.test-name }}"
# Install doctl
doctl auth init --access-token "${{ secrets.DIGITALOCEAN_TOKEN }}"
# Delete the test droplet
if doctl compute droplet list | grep -q "$TEST_NAME"; then
echo "Deleting droplet: $TEST_NAME"
doctl compute droplet delete "$TEST_NAME" --force
echo "βœ… Test droplet deleted"
else
echo "ℹ️ Test droplet not found (may have failed to create)"
fi
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: integration-test-logs-${{ github.run_number }}
path: |
./setup-dc.log
./deploy.env
if-no-files-found: warn
retention-days: 7