From 8b86909cf9d8e2258328c54676e144e17a80a30c Mon Sep 17 00:00:00 2001 From: Damian Taggart <4309872+attackant@users.noreply.github.com> Date: Mon, 30 Oct 2023 10:54:39 -0600 Subject: [PATCH] Refactor PHPUnit GitHub workflow for simplicity The PHPUnit GitHub workflow was significantly simplified by reducing the amount of work done in the YAML file. The previous workflow was manually setting up the test environment (downloading WordPress, setting up MySQL, etc.) within this file. The updated workflow uses a custom GitHub action that handles these setup steps, resulting in a cleaner and easier to read workflow file. Moreover, the PHP versions and WordPress version for testing have been updated to reflect more current versions. --- .github/workflows/phpunit.yml | 57 +++++++---------------------------- 1 file changed, 11 insertions(+), 46 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 04663c50..48e674cc 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -1,51 +1,16 @@ -name: Unit Tests +name: Testing Suite + on: pull_request: - workflow_dispatch: + jobs: - tests: - name: "PHP: ${{ matrix.php }} (MU: ${{ matrix.multisite }})" - runs-on: ubuntu-latest + php-tests: strategy: - fail-fast: true matrix: - multisite: [0, 1] - php: ['8.0', '7.4', '7.3', '7.2', '7.1'] - env: - WP_CORE_DIR: /tmp/wordpress/ - WP_MULTISITE: ${{ matrix.multisite }} - services: - mysql: - image: mysql:5.7 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.11.0 - with: - all_but_latest: true - - name: Checkout code - uses: actions/checkout@v3 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd - coverage: none - - name: Install dependencies - uses: ramsey/composer-install@v2 - - name: Set up WordPress - run: | - bash <(curl -s "https://raw.githubusercontent.com/wp-cli/sample-plugin/master/bin/install-wp-tests.sh") wordpress_unit_tests root '' 127.0.0.1 - rm -rf "${WP_CORE_DIR}wp-content/plugins" - mkdir -p "${WP_CORE_DIR}wp-content/plugins/publish-to-apple-news" - rsync -a --exclude=.git . "${WP_CORE_DIR}wp-content/plugins/publish-to-apple-news" - cd ${WP_CORE_DIR}wp-content/plugins/publish-to-apple-news && composer install - - name: Run tests - shell: bash - run: | - cd ${WP_CORE_DIR}/wp-content/plugins/publish-to-apple-news - composer run phpunit + php: ['8.2', '8.1', '8.0', '7.4'] + wordpress: ["latest"] + uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main + with: + command: "test" + php: ${{ matrix.php }} + wordpress: ${{ matrix.wordpress }}