mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-01 21:02:54 +09:00
181 lines
6.2 KiB
YAML
181 lines
6.2 KiB
YAML
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
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: 'PHP Build'
|
|
uses: FOSSBilling/.workflows/.github/actions/php-build@8749327430a3e843ec6c1c997d4568575ab2f364
|
|
with:
|
|
cache-deps: 'true'
|
|
composer-args: '--prefer-dist --optimize-autoloader'
|
|
php-version: 8.1
|
|
|
|
- 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@v4
|
|
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@v4
|
|
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@v4
|
|
with:
|
|
cache: 'npm'
|
|
cache-dependency-path: '**/package-lock.json'
|
|
node-version: 20
|
|
|
|
- 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@v2
|
|
with:
|
|
php-version: '8.3'
|
|
extensions: imagick, gd, intl, xml, dom, curl, iconv, json, opcache, mbstring, bz2, simplexml
|
|
|
|
- name: Setup Apache
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install libapache2-mod-php8.3
|
|
sudo a2enmod php8.3
|
|
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 <<EOF
|
|
<VirtualHost *:80>
|
|
ServerAdmin webmaster@localhost
|
|
ServerName localhost
|
|
DocumentRoot /var/www/localhost
|
|
|
|
<Directory /var/www/localhost>
|
|
Options Indexes FollowSymLinks
|
|
AllowOverride All
|
|
Require all granted
|
|
SetEnv APP_ENV ${APP_ENV}
|
|
</Directory>
|
|
|
|
ErrorLog \${APACHE_LOG_DIR}/error.log
|
|
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
|
</VirtualHost>
|
|
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: Run Cron
|
|
run: php /var/www/localhost/cron.php
|
|
|
|
- name: Run the API test suite
|
|
run: php ./src/vendor/bin/phpunit --configuration phpunit-live.xml
|
|
|
|
- name: Display the FOSSBilling PHP error log
|
|
if: always()
|
|
run: cat /var/www/localhost/data/log/php_error.log
|
|
|
|
- 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
|