fix(rest-api): add missing REST API endpoints for E2E tests #33
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: CI | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| name: Tests (PHP ${{ matrix.php-version }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php-version: [ "8.3", "8.4" ] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| coverage: pcov | |
| tools: composer:v2 | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: vendor | |
| key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-php-${{ matrix.php-version }}-composer- | |
| - name: Install dependencies | |
| run: composer install --no-interaction --no-progress --prefer-dist | |
| - name: Validate composer.json | |
| run: composer validate --no-check-all --no-check-lock | |
| - name: Run Unit tests | |
| run: ./vendor/bin/pest tests/Unit | |
| e2e: | |
| name: E2E Tests (WordPress ${{ matrix.wordpress-version }}) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 # Жёсткий таймаут — не более 10 минут | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php-version: [ "8.3" ] | |
| wordpress-version: [ "latest", "6.7" ] | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: wordpress | |
| MYSQL_DATABASE: wordpress_test | |
| MYSQL_USER: wordpress | |
| MYSQL_PASSWORD: wordpress | |
| ports: | |
| - 3306:3306 | |
| options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=3s --health-retries=5 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| extensions: mysqli, pdo_mysql | |
| coverage: none # Отключаем coverage для E2E — ускоряет тесты | |
| tools: composer:v2, wp-cli | |
| ini-values: memory_limit=512M | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: vendor | |
| key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-php-${{ matrix.php-version }}-composer- | |
| - name: Cache WordPress | |
| uses: actions/cache@v4 | |
| with: | |
| path: /tmp/wordpress | |
| key: wordpress-${{ matrix.wordpress-version }}-v1 | |
| restore-keys: | | |
| wordpress-${{ matrix.wordpress-version }}- | |
| - name: Install dependencies | |
| run: composer install --no-interaction --no-progress --prefer-dist | |
| - name: Setup WordPress | |
| run: | | |
| # Проверяем, есть ли WordPress в кэше | |
| if [ ! -f /tmp/wordpress/wp-load.php ]; then | |
| echo "Downloading WordPress..." | |
| mkdir -p /tmp/wordpress | |
| cd /tmp/wordpress | |
| if [ "${{ matrix.wordpress-version }}" = "latest" ]; then | |
| wp core download --version=latest --allow-root | |
| else | |
| wp core download --version=${{ matrix.wordpress-version }} --allow-root | |
| fi | |
| else | |
| echo "Using cached WordPress" | |
| fi | |
| cd /tmp/wordpress | |
| # Конфигурация (всегда пересоздаём — БД новая) | |
| wp config create \ | |
| --dbname=wordpress_test \ | |
| --dbuser=wordpress \ | |
| --dbpass=wordpress \ | |
| --dbhost=127.0.0.1 \ | |
| --force \ | |
| --allow-root | |
| # Установка WordPress | |
| wp core install \ | |
| --url=http://localhost:8080 \ | |
| --title="WP Queue Test" \ | |
| --admin_user=admin \ | |
| --admin_password=admin \ | |
| --admin_email=admin@example.com \ | |
| --skip-email \ | |
| --allow-root | |
| mkdir -p wp-content/uploads | |
| chmod 755 wp-content/uploads | |
| - name: Install Plugin | |
| run: | | |
| cd /tmp/wordpress | |
| rm -rf wp-content/plugins/wp-queue 2>/dev/null || true | |
| ln -s ${{ github.workspace }} wp-content/plugins/wp-queue | |
| wp plugin activate wp-queue --allow-root | |
| - name: Run E2E tests | |
| timeout-minutes: 5 # Таймаут на сами тесты | |
| run: | | |
| cd ${{ github.workspace }} | |
| ./vendor/bin/pest tests/Feature --configuration=phpunit-e2e.xml --stop-on-failure --no-coverage | |
| env: | |
| WP_TESTS_DIR: /tmp/wordpress-tests-lib | |
| WP_CORE_DIR: /tmp/wordpress | |
| lint: | |
| name: Fix Code Style | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| if: github.event_name != 'pull_request' | |
| uses: actions/checkout@v4 | |
| - name: Checkout | |
| if: github.event_name == 'pull_request' | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: "8.3" | |
| tools: composer:v2 | |
| - name: Install dependencies | |
| run: composer install --no-interaction --no-progress --prefer-dist | |
| - name: Laravel Pint | |
| run: ./vendor/bin/pint | |
| - name: Commit changes | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "style: apply Laravel Pint auto-format" |