fix tag #39353
Workflow file for this run
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: Unit | |
| on: | |
| pull_request: | |
| push: | |
| schedule: | |
| - cron: '0 0/2 * * *' | |
| jobs: | |
| behat-test: | |
| name: Behat | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/mvorisek/image-php:${{ matrix.php }}-selenium | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # Selenium with PHP 7.4 and 8.0 was failing too often on initial/create session request, probably because of older (Alpine 3.16) base image | |
| php: ['8.1', '8.2', '8.3'] | |
| type: ['Chrome', 'Chrome Lowest'] | |
| include: | |
| - php: 'latest' | |
| type: 'Firefox' | |
| env: | |
| LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == '8.3' && matrix.type == 'Chrome' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}" | |
| services: | |
| mysql: | |
| image: mysql | |
| options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=atk4_pass_root -e MYSQL_USER=atk4_test_user -e MYSQL_PASSWORD=atk4_pass -e MYSQL_DATABASE=atk4_test | |
| mariadb: | |
| image: mariadb | |
| options: --health-cmd="mariadb-admin ping" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=atk4_pass_root -e MYSQL_USER=atk4_test_user -e MYSQL_PASSWORD=atk4_pass -e MYSQL_DATABASE=atk4_test | |
| postgres: | |
| image: postgres:alpine | |
| env: | |
| POSTGRES_USER: atk4_test_user | |
| POSTGRES_PASSWORD: atk4_pass | |
| POSTGRES_DB: atk4_test | |
| options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| mssql: | |
| image: mcr.microsoft.com/mssql/server:2022-latest | |
| env: | |
| ACCEPT_EULA: Y | |
| SA_PASSWORD: atk4_pass | |
| oracle: | |
| image: gvenzl/oracle-xe:18-slim-faststart | |
| env: | |
| ORACLE_PASSWORD: atk4_pass | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Configure PHP | |
| run: | | |
| if [ -n "$LOG_COVERAGE" ]; then echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; else rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; fi | |
| php --version | |
| - name: Setup cache 1/2 | |
| id: composer-cache | |
| run: | | |
| echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Setup cache 2/2 | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-behat-${{ matrix.php }}-${{ matrix.type }}-${{ hashFiles('composer.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-composer- | |
| - name: Install JS dependencies (only for coverage or Chrome Slow) | |
| if: env.LOG_COVERAGE || matrix.type == 'Chrome Slow' | |
| run: | | |
| if [ -n "$LOG_COVERAGE" ]; then | |
| (cd js && npm install --package-lock-only --save-dev babel-plugin-istanbul nyc && npm ci --loglevel=error) | |
| else | |
| mv public public.orig | |
| mkdir public public/css public/external | |
| cp public.orig/.gitattributes public | |
| cp public.orig/.gitignore public | |
| cp public.orig/logo.png public | |
| cp public.orig/css/agileui.less public/css | |
| cp public.orig/external/.gitignore public/external | |
| cp public.orig/external/package.json public/external | |
| cp public.orig/external/package-lock.json public/external | |
| cp public.orig/external/postinstall.js public/external | |
| npm install --loglevel=error -g pug-cli less less-plugin-clean-css uglify-js | |
| (cd js && npm ci --loglevel=error) | |
| (cd public/external && npm ci --loglevel=error && git clean -dxfq .) | |
| fi | |
| - name: Lint JS files (only for Chrome Slow) | |
| if: matrix.type == 'Chrome Slow' | |
| run: | | |
| cp public/external/postinstall.js js | |
| (cd js && npm run lint) | |
| - name: Compile HTML files (only for Chrome Slow) | |
| if: matrix.type == 'Chrome Slow' | |
| run: | | |
| cp -r template template.orig | |
| find template -not -type d -not -name '*.pug' -delete | |
| (cd template && pug --doctype html --pretty --silent .) | |
| - name: Compile CSS files (only for Chrome Slow) | |
| if: matrix.type == 'Chrome Slow' | |
| run: | | |
| lessc public/css/agileui.less public/css/agileui.min.css --clean-css="--s1 --advanced" --source-map | |
| - name: Compile JS files (only for coverage or Chrome Slow) | |
| if: env.LOG_COVERAGE || matrix.type == 'Chrome Slow' | |
| run: | | |
| if [ -n "$LOG_COVERAGE" ]; then | |
| rm -r public/js | |
| (cd js && ISTANBUL_COVERAGE=1 npm run build) | |
| else | |
| (cd js && npm run build) | |
| fi | |
| - name: Diff compiled files (only for Chrome Slow) | |
| if: matrix.type == 'Chrome Slow' | |
| run: | | |
| diff -ru public.orig public | |
| diff -ru template.orig template | |
| rm -r public.orig template.orig | |
| - name: Install PHP dependencies | |
| run: | | |
| composer remove --no-interaction --no-update phpunit/phpunit ergebnis/phpunit-slow-test-detector --dev | |
| composer remove --no-interaction --no-update friendsofphp/php-cs-fixer ergebnis/composer-normalize --dev | |
| composer remove --no-interaction --no-update phpstan/\* --dev | |
| if [ -n "$LOG_COVERAGE" ]; then composer require --no-interaction --no-install phpunit/phpcov; fi | |
| composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader | |
| if [ "${{ matrix.type }}" = "Chrome Lowest" ]; then composer update --ansi --prefer-dist --prefer-lowest --prefer-stable --no-interaction --no-progress --optimize-autoloader; fi | |
| - name: Init | |
| run: | | |
| php -r '(new PDO("mysql:host=mysql", "root", "atk4_pass_root"))->exec("ALTER USER '"'"'atk4_test_user'"'"'@'"'"'%'"'"' WITH MAX_USER_CONNECTIONS 5");' | |
| php -r '(new PDO("mysql:host=mariadb", "root", "atk4_pass_root"))->exec("ALTER USER '"'"'atk4_test_user'"'"'@'"'"'%'"'"' WITH MAX_USER_CONNECTIONS 5");' | |
| php -r '(new PDO("pgsql:host=postgres;dbname=atk4_test", "atk4_test_user", "atk4_pass"))->exec("ALTER ROLE atk4_test_user CONNECTION LIMIT 1");' | |
| /usr/lib/oracle/setup.sh | |
| if [ -n "$LOG_COVERAGE" ]; then mkdir coverage coverage/js; fi | |
| ci_wait_until () { timeout 30 sh -c "until { $1 2> /dev/null; }; do sleep 0.02; done" || timeout 15 sh -c "$1" || { echo "health timeout: $1"; exit 1; }; } | |
| php -d opcache.enable_cli=1 -S 127.0.0.1:8888 > /dev/null 2>&1 & | |
| ci_wait_until 'nc -w 1 127.0.0.1 8888' | |
| if [ -f /etc/alpine-release ]; then addgroup browser && adduser browser -G browser -D -s /bin/sh; else adduser browser --gecos "" --disabled-login -shell /bin/sh > /dev/null; fi | |
| { Xvfb -ac :99 -screen 0 1920x1200x24 2> /dev/null & } && export DISPLAY=:99 | |
| ci_wait_until '[ -e /tmp/.X11-unix/X99 ]' | |
| su browser -c 'java -Dwebdriver.chrome.whitelistedIps=127.0.0.1 -jar /opt/selenium-server-standalone.jar -role standalone -host 127.0.0.1 -port 4444 -sessionTimeout 15 -browserTimeout 12 > /dev/null 2>&1 &' | |
| ci_wait_until 'nc -w 1 127.0.0.1 4444' | |
| if [ "${{ matrix.type }}" = "Firefox" ] || [ "${{ matrix.type }}" = "Firefox Slow" ]; then sed -i "s~chrome~firefox~" behat.yml.dist; fi | |
| if [ "${{ matrix.type }}" = "Chrome Slow" ] || [ "${{ matrix.type }}" = "Firefox Slow" ]; then echo 'usleep(500_000);' >> demos/init-app.php; fi | |
| - name: "Run tests: MSSQL (only for cron)" | |
| if: (success() || failure()) | |
| env: | |
| DB_DSN: "sqlsrv:host=mssql;dbname=master;driverOptions[TrustServerCertificate]=1" | |
| DB_USER: sa | |
| DB_PASSWORD: atk4_pass | |
| run: | | |
| sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php | |
| php demos/_demo-data/create-db.php | |
| vendor/bin/behat --strict -vv --config behat.yml.dist |