name: Perform Live Tests on: push: pull_request: branches: main env: DB_HOST: 127.0.0.1 DB_NAME: fossbilling DB_USER: root DB_PASS: root DB_PORT: 3306 APP_ENV: test TEST_PASS: 4WGemqiihh8iM3 TEST_EMAIL: email@example.com APP_URL: http://localhost/ TEST_API_KEY: AW6qEQCa7U7FG96J9NFIZXNYMJ79M8LH jobs: fresh-install: runs-on: ubuntu-latest if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.repo.id != github.event.pull_request.head.repo.id) || github.event_name == 'push' }} steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - name: 'PHP Build' uses: FOSSBilling/.workflows/.github/actions/php-build@11c3d3bb2ce6915aa0fc8af3165402a65400b084 with: cache-deps: 'true' composer-args: '--prefer-dist --optimize-autoloader' php-version: 8.3 - name: Make Needed Directories run: | mkdir -p ./src/themes/admin_default/build mkdir -p ./src/themes/huraga/build - name: Cache Built Admin Theme id: cache-admin_default uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5 with: path: ./src/themes/admin_default/build key: admin_default-${{ hashFiles('./package-lock.json', './src/themes/admin_default/assets/fossbilling.js', './src/themes/admin_default/assets/scss/*.scss', './src/themes/admin_default/assets/js/*.js', './src/themes/admin_default/assets/js/ui/*.js') }} - name: Cache Built Huraga Theme id: cache-huraga uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5 with: path: ./src/themes/huraga/build key: huraga-${{ hashFiles('./package-lock.json', './src/themes/huraga/assets/huraga.js', './src/themes/huraga/assets/scss/*.scss') }} - name: 'Install Node.js and Enable Caching' if: steps.cache-admin_default.outputs.cache-hit != 'true' || steps.cache-huraga.outputs.cache-hit != 'true' uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 with: cache: 'npm' cache-dependency-path: '**/package-lock.json' node-version: 24 - name: 'Install Node.js Dependencies' if: steps.cache-admin_default.outputs.cache-hit != 'true' || steps.cache-huraga.outputs.cache-hit != 'true' run: npm ci - name: 'Build Frontend Assets' if: steps.cache-admin_default.outputs.cache-hit != 'true' || steps.cache-huraga.outputs.cache-hit != 'true' run: npm run build - name: 'Download Latest Translations' run: | wget https://github.com/FOSSBilling/locale/releases/download/latest/translations.zip -O translations.zip mkdir -p ./src/locale unzip -o translations.zip -d ./src/locale - name: 'Copy Required Files and Clean-up' run: | cp README.md ./src/ cp LICENSE ./src/ rm translations.zip - name: Start MySQL run: sudo systemctl start mysql.service - name: Setup PHP uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2 with: php-version: '8.4' extensions: imagick, gd, intl, xml, dom, curl, iconv, json, opcache, mbstring, bz2, simplexml, pdo, pdo_mysql - name: Setup Apache run: | sudo apt-get update sudo apt-get install --no-install-recommends \ libapache2-mod-php8.4 php8.4 php8.4-common php8.4-intl \ php8.4-mysql php8.4-xml php8.4-curl php8.4-fpm php8.4-mbstring \ php8.4-opcache php8.4-gd sudo a2enmod php8.4 sudo systemctl start apache2 sudo a2enmod rewrite sudo mkdir /var/www/localhost # sudo unzip "FOSSBilling Preview.zip" -d /var/www/localhost sudo cp -r ./src/* /var/www/localhost # Create a new Apache configuration file sudo tee /etc/apache2/sites-available/localhost.conf > /dev/null < ServerAdmin webmaster@localhost ServerName localhost DocumentRoot /var/www/localhost Options Indexes FollowSymLinks AllowOverride All Require all granted SetEnv APP_ENV ${APP_ENV} ErrorLog \${APACHE_LOG_DIR}/error.log CustomLog \${APACHE_LOG_DIR}/access.log combined EOF # Enable the new configuration and disable the default one sudo a2ensite localhost.conf sudo a2dissite 000-default.conf # Test the Apache configuration sudo apache2ctl configtest # Restart Apache sudo systemctl restart apache2 # Finally, set the permissions sudo chown -R www-data:www-data /var/www/localhost* cd /var/www/localhost sudo find . -type d -exec chmod 755 {} \; sudo find . -type f -exec chmod 644 {} \; - name: Setup MySQL run: | mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASS }} -e "create database ${{ env.DB_NAME }}"; sudo service mysql status - name: Install FOSSBilling run: | curl -H "Content-type: multipart/form-data" \ -F error_reporting=0 \ -F database_hostname="${{ env.DB_HOST }}" \ -F database_port="${{ env.DB_PORT }}" \ -F database_name="${{ env.DB_NAME }}" \ -F database_username="${{ env.DB_USER }}" \ -F database_password="${{ env.DB_PASS }}" \ -F admin_name="test" \ -F admin_email="${{ env.TEST_EMAIL }}" \ -F admin_password="${{ env.TEST_PASS }}" \ -F currency_code="USD" \ -F currency_title="US Dollar" \ -F admin_api_token="${{ env.TEST_API_KEY }}" \ -X POST \ http://localhost/install/install.php?a=install - name: Display the installer error log if it exists run: | LOG_PATH="/var/www/localhost/install/php_error.log" if [ -f "$LOG_PATH" ]; then cat "$LOG_PATH" else echo "The installer error log does not exist." fi - name: Display the admin page run: curl http://localhost/admin - name: Run the API test suite run: php ./src/vendor/bin/phpunit --configuration phpunit-live.xml - name: Display the FOSSBilling PHP error log, if it exists if: always() run: | PHP_ERROR_LOG_PATH="/var/www/localhost/data/log/php_error.log" if [ -f "$PHP_ERROR_LOG_PATH" ]; then cat "$PHP_ERROR_LOG_PATH" else echo "The PHP error log does not exist." fi - name: Display the other FOSSBilling logs if: always() working-directory: /var/www/localhost/data/log/ run: | # Use find again to get a list of files in the current directory files=$(find . -type f ! -name '*.html' ! -name 'php_error.log') # Loop through each file in the current directory and cat its contents for file in $files; do echo "Contents of $file:" cat "$file" echo "--------------------------" done