Skip to content

feat: add redaxo/project skeleton #10800

feat: add redaxo/project skeleton

feat: add redaxo/project skeleton #10800

Workflow file for this run

name: Visual Regression Testing
on:
push:
branches: [temp]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
repository_dispatch:
types: [visual-tests-command] # triggered by /visual-tests PR comment
env:
writable: ${{ (github.event_name == 'repository_dispatch' || github.ref == 'refs/heads/temp' || github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') && 1 || 0 }}
COMPOSER_ROOT_VERSION: 6.x-dev
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
visual-tests:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write # for Git to git apply
steps:
- name: Add action run link to trigger comment
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
if: github.event_name == 'repository_dispatch'
with:
token: ${{ secrets.BOT_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: env.writable == 1 && github.event_name != 'repository_dispatch'
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.BOT_TOKEN }}
- name: Checkout fork
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: env.writable == 0
- name: Checkout on chat command
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: github.event_name == 'repository_dispatch'
with:
token: ${{ secrets.BOT_TOKEN }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
- name: Setup nodejs
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 23
cache: npm
cache-dependency-path: .github/workflows/visual-tests.yml
- name: Install npm packages
run: |
npm install playwright pixelmatch pngjs fs mkdirp
npm pkg set type=module
- name: Get installed Playwright version (used in cache key)
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(node -e "process.stdout.write(require('playwright/package.json').version)")" >> $GITHUB_ENV
- name: Cache Playwright browser binaries
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: playwright-${{ env.PLAYWRIGHT_VERSION }}
- name: Install Playwright browsers binaries if cache missed
run: npx playwright install chromium --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Setup PHP
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1
with:
php-version: '8.5'
ini-values: 'error_reporting=E_ALL, display_errors=On, display_startup_errors=On'
extensions: gd, pdo_mysql
coverage: none # disable xdebug, pcov
tools: cs2pr
- name: Composer install
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
- name: Init database
run: |
sudo /etc/init.d/mysql start
mysql -uroot -h127.0.0.1 -proot -e 'create database redaxo6;'
php project/bin/console setup:run -n --lang=de_de --db-host=127.0.0.1 --db-name=redaxo6 --db-password=root --db-createdb=no --db-setup=normal --admin-username=admin --admin-password=adminpassword --error-email=test@redaxo.invalid --ansi -v
php project/bin/console config:set --type boolean debug.enabled true -v
php project/bin/console config:set --type boolean debug.throw_always_exception true -v
php project/bin/console addon:install test -v
- name: Import mock data
run: |
mkdir -p $GITHUB_WORKSPACE/project/var/data/core/backup && cp -r .tools/visual-tests/fixtures/initial-content.sql $GITHUB_WORKSPACE/project/var/data/core/backup/
cp -r .tools/visual-tests/fixtures/media/* $GITHUB_WORKSPACE/project/public/media/
cp -f .tools/visual-tests/fixtures/README.md $GITHUB_WORKSPACE/addons/test/README.de.md
php project/bin/console setup:run -n --lang=de_de --db-password=root --db-setup=import --db-import=initial-content --admin-username=myusername --admin-password=mypassword --ansi -v
- name: Install packages
run: |
php project/bin/console addon:install debug --ansi -v
- name: Start php server
run: |
cat <<EOF > project/public/router.php
<?php
if (preg_match('@redaxo/(?:bin|data|cache|src)@', \$_SERVER['REQUEST_URI'])) http_response_code(403);
else return false;
EOF
PHP_CLI_SERVER_WORKERS=4 php -S localhost:8080 -t project/public/ project/public/router.php &
- name: Take screenshots (differential)
run: |
php project/bin/console config:set setup true -t boolean --ansi -v
php project/bin/console cache:clear --ansi -v
node .tools/visual-tests/visual-record.js setup
php project/bin/console config:set setup false -t boolean --ansi -v
php project/bin/console cache:clear --ansi -v
node .tools/visual-tests/visual-record.js
git add .tools/visual-tests/screenshots/
git diff --cached --exit-code --name-only .tools/visual-tests/screenshots/
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7.1.0
if: failure() && env.writable == 1
with:
commit_message: 'test: update screenshots'
commit_user_name: rex-bot
commit_user_email: rex-bot@users.noreply.github.com
file_pattern: .tools/visual-tests/screenshots/
branch: ${{ github.head_ref }} # repo dispatch needs the target branch
- name: Disable auto-merge
if: failure() && env.writable == 1 && (github.event.pull_request.number || github.event.client_payload.pull_request.number)
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
run: gh pr merge --disable-auto "${{ github.event.pull_request.number || github.event.client_payload.pull_request.number }}"
- name: Remove automerge label
uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 # v1.3.0
if: failure() && env.writable == 1
with:
github_token: ${{ secrets.BOT_TOKEN }}
labels: automerge