|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, dev ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, dev ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + phpcs: |
| 11 | + name: PHPCS (WordPress Coding Standards) |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Setup PHP |
| 19 | + uses: shivammathur/setup-php@v2 |
| 20 | + with: |
| 21 | + php-version: '8.3' |
| 22 | + tools: composer |
| 23 | + coverage: none |
| 24 | + |
| 25 | + - name: Get Composer cache directory |
| 26 | + id: composer-cache |
| 27 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 28 | + |
| 29 | + - name: Cache Composer dependencies |
| 30 | + uses: actions/cache@v4 |
| 31 | + with: |
| 32 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 33 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 34 | + restore-keys: ${{ runner.os }}-composer- |
| 35 | + |
| 36 | + - name: Install dependencies |
| 37 | + run: composer install --prefer-dist --no-progress --no-suggest |
| 38 | + |
| 39 | + - name: Run PHPCS |
| 40 | + run: composer run-script phpcs |
| 41 | + |
| 42 | + phpunit: |
| 43 | + name: PHPUnit (PHP ${{ matrix.php }}) |
| 44 | + runs-on: ubuntu-latest |
| 45 | + |
| 46 | + strategy: |
| 47 | + fail-fast: false |
| 48 | + matrix: |
| 49 | + php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] |
| 50 | + |
| 51 | + services: |
| 52 | + mysql: |
| 53 | + image: mysql:5.7 |
| 54 | + env: |
| 55 | + MYSQL_ROOT_PASSWORD: root |
| 56 | + MYSQL_DATABASE: wordpress_test |
| 57 | + ports: |
| 58 | + - 3306:3306 |
| 59 | + options: >- |
| 60 | + --health-cmd="mysqladmin ping" |
| 61 | + --health-interval=10s |
| 62 | + --health-timeout=5s |
| 63 | + --health-retries=3 |
| 64 | +
|
| 65 | + steps: |
| 66 | + - name: Checkout code |
| 67 | + uses: actions/checkout@v4 |
| 68 | + |
| 69 | + - name: Setup PHP |
| 70 | + uses: shivammathur/setup-php@v2 |
| 71 | + with: |
| 72 | + php-version: ${{ matrix.php }} |
| 73 | + extensions: mysqli, zip |
| 74 | + coverage: ${{ matrix.php == '8.3' && 'xdebug' || 'none' }} |
| 75 | + tools: composer |
| 76 | + |
| 77 | + - name: Get Composer cache directory |
| 78 | + id: composer-cache |
| 79 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 80 | + |
| 81 | + - name: Cache Composer dependencies |
| 82 | + uses: actions/cache@v4 |
| 83 | + with: |
| 84 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 85 | + key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} |
| 86 | + restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-composer- |
| 87 | + |
| 88 | + - name: Install dependencies |
| 89 | + run: composer install --prefer-dist --no-progress --no-suggest |
| 90 | + |
| 91 | + - name: Install WordPress test suite |
| 92 | + run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest |
| 93 | + |
| 94 | + - name: Run tests (without coverage) |
| 95 | + if: matrix.php != '8.3' |
| 96 | + run: composer run-script test |
| 97 | + |
| 98 | + - name: Run tests (with coverage on PHP 8.3) |
| 99 | + if: matrix.php == '8.3' |
| 100 | + run: composer run-script test:coverage |
| 101 | + |
| 102 | + - name: Upload coverage to Codecov |
| 103 | + if: matrix.php == '8.3' |
| 104 | + uses: codecov/codecov-action@v4 |
| 105 | + with: |
| 106 | + files: ./coverage/clover.xml |
| 107 | + flags: unittests |
| 108 | + name: php-8.3 |
| 109 | + fail_ci_if_error: false |
0 commit comments