Skip to content

Update PHP version to 8.0, increment plugin version to 4, and adjust … #7

Update PHP version to 8.0, increment plugin version to 4, and adjust …

Update PHP version to 8.0, increment plugin version to 4, and adjust … #7

Workflow file for this run

name: Tests del Plugin FacturaScripts
on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
jobs:
tests:
name: Tests en ${{ matrix.database }} con PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.0', '8.1']
database: ['mysql', 'postgresql']
env:
NOMBRE_PLUGIN: "Randomizer"
services:
mysql:
image: mariadb:11
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: toor
MARIADB_DATABASE: facturascripts_tests
options: >-
--health-cmd="mariadb-admin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
postgres:
image: postgres:13
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: toor
POSTGRES_DB: facturascripts_tests
options: >-
--health-cmd=pg_isready
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Instalar PHP y extensiones
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: json, fileinfo, simplexml, zip, dom, pdo, pdo_mysql, mysql, mysqli, pgsql, pdo_pgsql, bcmath, gd, curl, soap
tools: composer
coverage: none
- name: Clonar FacturaScripts
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: 'NeoRazorX/facturascripts'
- name: Clonar Plugin ${{ env.NOMBRE_PLUGIN }}
uses: actions/checkout@v4
with:
fetch-depth: 0
path: Plugins/${{ env.NOMBRE_PLUGIN }}
- name: Cache de dependencias de Composer
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
- name: Instalar dependencias de FacturaScripts
run: |
mkdir -p MyFiles
touch MyFiles/plugins.json
composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader
- name: Crear archivo de configuración
run: |
cat > config.php << 'EOF'
<?php
define('FS_COOKIES_EXPIRE', 604800);
define('FS_LANG', 'es_ES');
define('FS_TIMEZONE', 'Europe/Madrid');
define('FS_ROUTE', '');
${{ matrix.database == 'mysql' && format('
define(''FS_DB_TYPE'', ''mysql'');
define(''FS_DB_HOST'', ''127.0.0.1'');
define(''FS_DB_PORT'', ''3306'');
define(''FS_DB_USER'', ''root'');
') || format('
define(''FS_DB_TYPE'', ''postgresql'');
define(''FS_DB_HOST'', ''localhost'');
define(''FS_DB_PORT'', ''5432'');
define(''FS_DB_USER'', ''postgres'');
') }}
define('FS_DB_NAME', 'facturascripts_tests');
define('FS_DB_PASS', 'toor');
define('FS_DB_FOREIGN_KEYS', true);
define('FS_DB_TYPE_CHECK', true);
define('FS_MYSQL_CHARSET', 'utf8');
define('FS_MYSQL_COLLATE', 'utf8_bin');
define('FS_HIDDEN_PLUGINS', '');
define('FS_DEBUG', false);
define('FS_DISABLE_ADD_PLUGINS', false);
define('FS_DISABLE_RM_PLUGINS', false);
define('FS_NF0', 2);
EOF
- name: Copiar archivos de tests del Plugin
run: |
if [ -d "Plugins/${{ env.NOMBRE_PLUGIN }}/Test/main" ]; then
cp -r Plugins/${{ env.NOMBRE_PLUGIN }}/Test/main Test/Plugins
else
echo "No se encontraron tests para el plugin"
exit 1
fi
- name: Instalar dependencias del Plugin ${{ env.NOMBRE_PLUGIN }}
run: |
if [ -f "Plugins/${{ env.NOMBRE_PLUGIN }}/composer.json" ]; then
cd Plugins/${{ env.NOMBRE_PLUGIN }}
composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader
else
echo "El plugin no tiene dependencias de Composer"
fi
- name: Instalar el Plugin ${{ env.NOMBRE_PLUGIN }}
run: php Test/install-plugins.php
- name: Ejecutar tests en ${{ matrix.database }}
run: vendor/bin/phpunit -c phpunit-plugins.xml --verbose
- name: Mostrar logs en caso de fallo
if: failure()
run: |
echo "=== Logs de la base de datos ==="
if [ "${{ matrix.database }}" = "mysql" ]; then
docker logs $(docker ps -q --filter ancestor=mariadb:11) || true
else
docker logs $(docker ps -q --filter ancestor=postgres:13) || true
fi