Linting & Test #578
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: Linting & Test | |
| permissions: | |
| contents: read | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| - ready_for_review | |
| branches: | |
| - '**' | |
| jobs: | |
| validate-readme-spacing: | |
| name: Validate README Spacing | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - uses: pantheon-systems/validate-readme-spacing@229ea162621009cf8e09bf2beba405017150130e # v1.0.5 | |
| lint: | |
| name: PHPCS Linting | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: Cache dependencies | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/vendor | |
| key: test-lint-dependencies-{{ checksum "composer.json" }} | |
| restore-keys: test-lint-dependencies-{{ checksum "composer.json" }} | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2 | |
| with: | |
| php-version: 8.3 | |
| - name: Install dependencies | |
| run: composer install -n --prefer-dist | |
| - name: Run PHPCS | |
| run: composer lint | |
| php8-compatibility: | |
| name: PHP 8.x Compatibility | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - uses: pantheon-systems/phpcompatibility-action@bd72eb001d4fb9817c9d6e1a157a71e287f3ff80 # dev 2023-10-04T16:54:18Z | |
| with: | |
| paths: ${{ github.workspace }}/*.php ${{ github.workspace }}/inc/*.php | |
| test-versions: 8.3- | |
| wporg-validation: | |
| name: WP.org Plugin Validation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - uses: pantheon-systems/action-wporg-validator@4df6286ef133ca95bbc955728fc649322e433380 # 1.0.0 2023-06-09T19:59:09Z | |
| with: | |
| type: 'plugin' | |
| test: | |
| needs: lint | |
| name: Test | |
| runs-on: ubuntu-latest | |
| services: | |
| mariadb: | |
| image: mariadb:10.6 | |
| strategy: | |
| matrix: | |
| php_version: [7.4, 8.2, 8.3, 8.4] | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2 | |
| with: | |
| php-version: ${{ matrix.php_version }} | |
| extensions: mysqli, zip, imagick | |
| - name: Start MySQL Service | |
| run: sudo systemctl start mysql | |
| - name: Create wordpress_test database | |
| run: | | |
| mysql -h 127.0.0.1 -u root -proot -e "CREATE DATABASE IF NOT EXISTS wordpress_test;" | |
| mysql -h 127.0.0.1 -u root -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED BY ''; FLUSH PRIVILEGES;" | |
| - name: Install Subversion | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install subversion | |
| svn --version | |
| - name: Cache dependencies | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/vendor | |
| key: test-dependencies-{{ checksum "composer.json" }} | |
| restore-keys: test-dependencies-{{ checksum "composer.json" }} | |
| - name: Setup WP-CLI | |
| uses: godaddy-wordpress/setup-wp-cli@80c9a89bd347082429795c0f12acf567e2c390d4 # 1 2022-10-04T19:52:20Z | |
| - name: Install dependencies | |
| run: | | |
| if [ ${{ matrix.php_version }} = "7.4" ]; then | |
| composer require pantheon-systems/pantheon-wp-coding-standards:^2 --no-update | |
| composer update | |
| fi | |
| composer install | |
| - name: Setup WP Unit Tests | |
| run: | | |
| chmod +x ./bin/*.sh | |
| composer test:install | |
| - name: Setup WP-CLI | |
| uses: godaddy-wordpress/setup-wp-cli@80c9a89bd347082429795c0f12acf567e2c390d4 # 1 2022-10-04T19:52:20Z | |
| - name: Run PHPUnit | |
| run: composer test |