|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master, main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ master, main, develop ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + php-version: ['7.4', '8.0', '8.1', '8.2'] |
| 17 | + wordpress-version: ['6.2', '6.4', 'latest'] |
| 18 | + |
| 19 | + services: |
| 20 | + mysql: |
| 21 | + image: mysql:5.7 |
| 22 | + env: |
| 23 | + MYSQL_ROOT_PASSWORD: root |
| 24 | + MYSQL_DATABASE: wordpress_test |
| 25 | + ports: |
| 26 | + - 3306:3306 |
| 27 | + options: >- |
| 28 | + --health-cmd="mysqladmin ping" |
| 29 | + --health-interval=10s |
| 30 | + --health-timeout=5s |
| 31 | + --health-retries=3 |
| 32 | +
|
| 33 | + steps: |
| 34 | + - name: Checkout code |
| 35 | + uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - name: Setup PHP |
| 38 | + uses: shivammathur/setup-php@v2 |
| 39 | + with: |
| 40 | + php-version: ${{ matrix.php-version }} |
| 41 | + extensions: mbstring, intl, mysqli |
| 42 | + coverage: none |
| 43 | + |
| 44 | + - name: Get Composer cache directory |
| 45 | + id: composer-cache |
| 46 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 47 | + |
| 48 | + - name: Cache Composer dependencies |
| 49 | + uses: actions/cache@v3 |
| 50 | + with: |
| 51 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 52 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 53 | + restore-keys: ${{ runner.os }}-composer- |
| 54 | + |
| 55 | + - name: Install Composer dependencies |
| 56 | + run: composer install --prefer-dist --no-progress |
| 57 | + |
| 58 | + - name: Install subversion |
| 59 | + run: sudo apt-get update && sudo apt-get install -y subversion |
| 60 | + |
| 61 | + - name: Install WordPress test suite |
| 62 | + run: | |
| 63 | + bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wordpress-version }} true |
| 64 | + env: |
| 65 | + WP_TESTS_DIR: /tmp/wordpress-tests-lib |
| 66 | + WP_CORE_DIR: /tmp/wordpress |
| 67 | + |
| 68 | + - name: Run PHPUnit tests |
| 69 | + run: composer test |
| 70 | + env: |
| 71 | + WP_TESTS_DIR: /tmp/wordpress-tests-lib |
| 72 | + WP_CORE_DIR: /tmp/wordpress |
| 73 | + |
| 74 | + # Code style check (optional) |
| 75 | + phpcs: |
| 76 | + runs-on: ubuntu-latest |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Checkout code |
| 80 | + uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Setup PHP |
| 83 | + uses: shivammathur/setup-php@v2 |
| 84 | + with: |
| 85 | + php-version: '8.1' |
| 86 | + tools: phpcs |
| 87 | + |
| 88 | + - name: Check PHP syntax errors |
| 89 | + run: find . -name "*.php" -not -path "./vendor/*" -exec php -l {} \; |
0 commit comments