v0.7.0 #11
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 Tests | |
| on: [pull_request] | |
| jobs: | |
| test-wp: | |
| name: Test WordPress Plugin | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| php-version: ['7.4', '8.0', '8.1', '8.2', '8.3'] | |
| wp-version: ['6.6', '6.7', 'latest'] | |
| include: | |
| - php-version: '7.4' | |
| php-image: php:7.4-cli | |
| - php-version: '8.0' | |
| php-image: php:8.0-cli | |
| - php-version: '8.1' | |
| php-image: php:8.1-cli | |
| - php-version: '8.2' | |
| php-image: php:8.2-cli | |
| - php-version: '8.3' | |
| php-image: php:8.3-cli | |
| container: | |
| image: ${{ matrix.php-image }} | |
| options: --user root | |
| services: | |
| mysql: | |
| image: mysql:5.7 | |
| env: | |
| MYSQL_DATABASE: wordpress_test | |
| MYSQL_ROOT_PASSWORD: root | |
| options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install tools and PHP extensions | |
| run: | | |
| apt-get update && apt-get install -y unzip git curl subversion default-mysql-client | |
| docker-php-ext-install mysqli | |
| if [ "${{ matrix.php-version }}" != "7.4" ]; then pecl install xdebug; fi | |
| if [ "${{ matrix.php-version }}" != "7.4" ]; then docker-php-ext-enable xdebug; fi | |
| - name: Configure Xdebug for coverage | |
| if: ${{ matrix.php-version != '7.4' }} | |
| run: | | |
| echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini | |
| echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini | |
| echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini | |
| - name: Install Composer | |
| run: | | |
| curl -sS https://getcomposer.org/installer | php | |
| mv composer.phar /usr/local/bin/composer | |
| - name: Install dependencies | |
| run: | | |
| if [ "${{ matrix.php-version }}" = "7.4" ]; then composer require phpunit/phpunit:^9 --no-update --no-interaction; fi | |
| if [ "${{ matrix.php-version }}" = "8.0" ] || [ "${{ matrix.php-version }}" = "8.1" ]; then composer require phpunit/phpunit:^9 --no-update --no-interaction; fi | |
| composer update --no-interaction | |
| - name: Install WP test suite | |
| run: | | |
| mysql -u root -proot -h mysql -P 3306 -e "DROP DATABASE IF EXISTS wordpress_test;" | |
| bash ./bin/install-wp-tests.sh wordpress_test root 'root' mysql ${{ matrix.wp-version }} | |
| - name: Run PHPUnit with coverage | |
| run: | | |
| if [ "${{ matrix.php-version }}" = "7.4" ]; then vendor/bin/phpunit --configuration phpunit.xml.dist; else vendor/bin/phpunit --configuration phpunit.xml.dist --coverage-clover=coverage.xml; fi | |
| - name: Cleanup | |
| if: ${{ always() }} | |
| uses: rtCamp/action-cleanup@master | |
| test-npm: | |
| name: Test Blocks | |
| runs-on: ubuntu-latest | |
| container: | |
| image: node:20 | |
| options: --user root | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install npm dependencies | |
| working-directory: ./src/documentcloud/blocks # Run npm commands from the blocks folder | |
| run: | | |
| npm install --force | |
| - name: Run npm tests | |
| working-directory: ./src/documentcloud/blocks # Run npm tests from the blocks folder | |
| run: | | |
| npm run test | |
| - name: Cleanup | |
| if: ${{ always() }} | |
| uses: rtCamp/action-cleanup@master |