diff --git a/.github/workflows/ubuntu-2404-lamp-integration-test.yml b/.github/workflows/ubuntu-2404-lamp-integration-test.yml new file mode 100644 index 0000000..4f7f554 --- /dev/null +++ b/.github/workflows/ubuntu-2404-lamp-integration-test.yml @@ -0,0 +1,241 @@ +name: Ubuntu 24.04 LAMP Integration Test + +on: + workflow_dispatch: + schedule: + - cron: "23 2 * * *" + +jobs: + lamp-integration: + runs-on: ubuntu-24.04 + timeout-minutes: 20 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install PHP 8.4 and prerequisites + run: | + set -ex + + # Add PHP PPA + sudo add-apt-repository ppa:ondrej/php -y + sudo apt update + + # Install PHP 8.4 with required extensions + sudo apt install -y \ + php8.4 \ + php8.4-cli \ + php8.4-fpm \ + php8.4-mysql \ + php8.4-xml \ + php8.4-mbstring \ + php8.4-curl \ + php8.4-gd \ + php8.4-intl \ + php8.4-bcmath \ + php8.4-zip \ + mysql-server \ + apache2 \ + composer + + # Verify installations + php -v + composer --version + apache2 -v + + - name: Configure MySQL database + run: | + set -ex + + # Stop MySQL + sudo systemctl stop mysql + + # Recreate data directory with correct permissions + sudo rm -rf /var/lib/mysql + sudo mkdir -p /var/lib/mysql + sudo chown -R mysql:mysql /var/lib/mysql + sudo chmod 750 /var/lib/mysql + + # Initialize MySQL + sudo mysqld --initialize-insecure --user=mysql --datadir=/var/lib/mysql + + # Start MySQL + sudo systemctl start mysql + sleep 5 + + # Create test database + sudo mysql -u root << 'EOF' + CREATE DATABASE horde_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + CREATE USER 'horde'@'localhost' IDENTIFIED BY 'test123'; + GRANT ALL PRIVILEGES ON horde_test.* TO 'horde'@'localhost'; + FLUSH PRIVILEGES; + EOF + + # Verify + sudo mysql -u root -e "SHOW DATABASES LIKE 'horde_test';" + + - name: Download hordectl + run: | + set -ex + + # Download from org variable + PHAR_URL="${{ vars.HORDECTL_PHAR_URL }}" + + curl -L "$PHAR_URL" -o hordectl.phar + chmod +x hordectl.phar + sudo mv hordectl.phar /usr/local/bin/hordectl + + # Verify installation + hordectl version + + - name: Install bundle to /var/www/horde + run: | + set -ex + + # Copy checked-out bundle to production path + sudo mkdir -p /var/www/horde + sudo cp -r $GITHUB_WORKSPACE/. /var/www/horde/ + + # Install composer dependencies + cd /var/www/horde + sudo composer install --no-dev --no-interaction --prefer-dist + + # Set ownership for Apache + sudo chown -R www-data:www-data /var/www/horde + sudo chmod -R 755 /var/www/horde + + # Ensure var directories are writable + sudo chmod -R 775 /var/www/horde/var + + # Verify installation structure + test -f /var/www/horde/composer.json || exit 1 + test -d /var/www/horde/vendor || exit 1 + test -d /var/www/horde/vendor/horde || exit 1 + test -d /var/www/horde/web || exit 1 + test -f /var/www/horde/web/index.php || exit 1 + + echo "✅ Bundle installation validated" + + - name: Register bundle as hordectl target + run: | + set -ex + + # Add production path as target + sudo hordectl target add ci-test --type=local --path=/var/www/horde + + # Set as current target + sudo hordectl target use ci-test + + # Verify target + sudo hordectl target current + + - name: Configure Apache web server + run: | + set -ex + + # Start PHP-FPM + sudo systemctl start php8.4-fpm + sudo systemctl enable php8.4-fpm + + # Copy vhost config + sudo cp test/fixtures/apache-horde.conf /etc/apache2/sites-available/horde.conf + + # Enable modules + sudo a2enmod rewrite + sudo a2enmod proxy_fcgi + sudo a2enmod setenvif + + # Enable site + sudo a2dissite 000-default + sudo a2ensite horde + + # Restart Apache + sudo systemctl restart apache2 + + # Verify services + sudo systemctl status php8.4-fpm --no-pager + sudo systemctl status apache2 --no-pager + + - name: Activate Horde installation + run: | + set -ex + + sudo hordectl activate + sudo chown -R www-data:www-data /var/www/horde/var + + - name: Configure database connection + run: | + set -ex + + sudo hordectl configure database \ + --type=mysql \ + --host=localhost \ + --port=3306 \ + --username=horde \ + --password=test123 \ + --database=horde_test \ + --charset=utf8mb4 + + - name: Configure session handler + run: | + set -ex + + sudo hordectl configure session --cookie-domain='' --type=builtin + + - name: Configure authentication + run: | + set -ex + + sudo hordectl configure auth --driver=sql --encryption=ssha + + sudo -u www-data /var/www/horde/vendor/bin/horde-db-migrate up + + - name: Configure admin secret for API + run: | + set -ex + + sudo hordectl target update ci-test --endpoint=http://localhost + sudo hordectl secret generate + + - name: Create test user + run: | + set -ex + + sudo hordectl create user --username=administrator --password=admin123 + + - name: Run subsystem tests + run: | + set -ex + + sudo hordectl test db + sudo hordectl test session + sudo hordectl test auth + + - name: Verify web accessibility + run: | + set -ex + + # Test Apache is serving the site + curl -f http://localhost/ || exit 1 + + # Check for Horde in response + curl -s http://localhost/ | grep -i "horde" || echo "⚠️ Horde string not found in response" + + echo "✅ Web server responding" + + - name: Upload logs on failure + if: failure() + run: | + set +e + echo "=== Apache Error Log ===" + sudo cat /var/log/apache2/horde-test-error.log + echo "" + echo "=== Apache Access Log ===" + sudo cat /var/log/apache2/horde-test-access.log + echo "" + echo "=== PHP Error Log ===" + sudo cat /var/log/php8.4-fpm.log || echo "No FPM log" + echo "" + echo "=== Horde Config ===" + sudo cat /var/www/horde/var/config/horde/conf.php || echo "No conf.php" diff --git a/test/fixtures/apache-horde.conf b/test/fixtures/apache-horde.conf new file mode 100644 index 0000000..9c4ee5d --- /dev/null +++ b/test/fixtures/apache-horde.conf @@ -0,0 +1,35 @@ + + ServerName localhost + DocumentRoot /var/www/horde/web + + ErrorLog ${APACHE_LOG_DIR}/horde-test-error.log + CustomLog ${APACHE_LOG_DIR}/horde-test-access.log combined + + + Options -Indexes +FollowSymLinks + AllowOverride None + Require all granted + + # PHP-FPM handler INSIDE the Directory block + + SetHandler "proxy:unix:/run/php/php8.4-fpm.sock|fcgi://localhost" + + + RewriteEngine On + RewriteBase / + + # Pass auth header -- both original and redirect-prefixed + RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + RewriteRule .* - [env=REDIRECT_HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + RewriteRule ^rpc\.php$ horde/rpc.php [QSA,L] + + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^(.*)$ horde/rampage.php [QSA,L] + + + + Require all denied + +