fix: Make deployment log artifact names unique #122
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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=StripeBundle&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 StripeBundle (private repo with token) | |
| if docker exec mautic_web ls /var/www/html/docroot/plugins/StripeBundle >/dev/null 2>&1; then | |
| echo "β StripeBundle directory found" | |
| if docker exec mautic_web find /var/www/html/docroot/plugins/StripeBundle -name "*.php" | head -1 | grep -q ".php"; then | |
| echo "β StripeBundle contains PHP files - installation successful" | |
| plugin_success=$((plugin_success + 1)) | |
| else | |
| echo "β οΈ StripeBundle directory exists but no PHP files found" | |
| echo "π Debug: Contents of StripeBundle directory:" | |
| docker exec mautic_web ls -la /var/www/html/docroot/plugins/StripeBundle/ || echo "Failed to list directory contents" | |
| echo "π Debug: Looking for any files in StripeBundle:" | |
| docker exec mautic_web find /var/www/html/docroot/plugins/StripeBundle -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/StripeBundle/ && find /var/www/html/docroot/plugins/StripeBundle -type f | wc -l' || echo "Failed to get directory info" | |
| fi | |
| else | |
| echo "β οΈ StripeBundle 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/StripeBundle/ >/dev/null 2>&1; then | |
| echo "β StripeBundle files are accessible from Mautic container" | |
| plugin_count=$((plugin_count + 1)) | |
| else | |
| echo "βΉοΈ StripeBundle 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 and resize via action re-run | |
| id: upgrade | |
| uses: ./ | |
| with: | |
| vps-name: ${{ steps.test-name.outputs.test-name }} | |
| vps-size: 's-1vcpu-2gb' # Upgrade from 1GB to 2GB | |
| 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 }} | |
| # Upgrade to newer version | |
| mautic-version: '6.0.5-apache' | |
| plugins: | | |
| https://github.com/chimpino/stripe-plugin/archive/refs/heads/6.x.zip?directory=StripeBundle&token=${{ secrets.CHIMPINO_GITHUB_TOKEN }} | |
| - name: Show upgrade and resize results | |
| run: | | |
| echo "π Upgrade and resize completed successfully!" | |
| echo "VPS IP: ${{ steps.upgrade.outputs.vps-ip }}" | |
| echo "Mautic URL: ${{ steps.upgrade.outputs.mautic-url }}" | |
| echo "β Mautic 6.0.5 upgrade + resize to 2GB test passed" | |
| - name: Verify upgrade and resize worked | |
| run: | | |
| echo "π Verifying the upgrade and resize were successful..." | |
| VPS_IP="${{ steps.upgrade.outputs.vps-ip }}" | |
| MAUTIC_URL="${{ steps.upgrade.outputs.mautic-url }}" | |
| # Setup SSH | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| # Download deployment log to check for resize | |
| echo "π₯ Downloading deployment log..." | |
| scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${VPS_IP}:/var/log/setup-dc.log ./upgrade-test.log || echo "Could not download log" | |
| # Check if resize was detected and executed | |
| if [ -f ./upgrade-test.log ]; then | |
| echo "π Checking for droplet resize indicators..." | |
| if grep -q "Droplet size mismatch detected" ./upgrade-test.log; then | |
| echo "β PASS: Droplet size mismatch was detected" | |
| if grep -q "Droplet resized successfully" ./upgrade-test.log; then | |
| echo "β PASS: Droplet resize completed successfully" | |
| else | |
| echo "β FAIL: Droplet resize did not complete" | |
| echo "π Log excerpt:" | |
| grep -A 5 -B 5 "resize" ./upgrade-test.log || echo "No resize info found" | |
| exit 1 | |
| fi | |
| else | |
| echo "β FAIL: No resize detection found in logs" | |
| echo "π Checking deploy.sh log for resize-related messages..." | |
| grep -i "resize\|size\|checking if droplet" ./upgrade-test.log | head -20 || echo "No size-related messages found" | |
| exit 1 | |
| fi | |
| else | |
| echo "β οΈ WARNING: Could not retrieve deployment log" | |
| fi | |
| # Verify Mautic is still working after upgrade and resize | |
| echo "π Testing Mautic accessibility after upgrade and resize..." | |
| 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 | |
| # Verify droplet was actually resized | |
| echo "π Verifying droplet size via doctl..." | |
| doctl auth init --access-token "${{ secrets.DIGITALOCEAN_TOKEN }}" | |
| ACTUAL_SIZE=$(doctl compute droplet get "${{ steps.test-name.outputs.test-name }}" --format Size --no-header) | |
| echo "π Actual droplet size: $ACTUAL_SIZE" | |
| if [ "$ACTUAL_SIZE" = "s-1vcpu-2gb" ]; then | |
| echo "β PASS: Droplet is now 2GB" | |
| else | |
| echo "β FAIL: Droplet is still $ACTUAL_SIZE (expected s-1vcpu-2gb)" | |
| exit 1 | |
| fi | |
| else | |
| echo "β FAIL: Mautic is not accessible after upgrade" | |
| exit 1 | |
| fi | |
| echo "π All version upgrade and resize validation checks passed!" | |
| echo "π Integration test completed successfully:" | |
| echo " β Initial deployment with Mautic 6.0.4 on 1GB droplet" | |
| echo " β Droplet resized from 1GB to 2GB" | |
| echo " β Version upgrade to 6.0.5 without reinstallation" | |
| echo " β Proper maintenance and migration execution" | |
| echo " β Container version verification" | |
| echo " β Droplet size 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 |