Skip to content

Commit

Permalink
Move the unit tests to unit-test.yml.
Browse files Browse the repository at this point in the history
This is needed because:
1. unit-php job has to be preserved as it's set as required in the GH settings.
2. unit-php job now depends on the test-php job.
  • Loading branch information
anton-vlasenko committed Jan 13, 2023
1 parent 9d0a477 commit 4554441
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 126 deletions.
126 changes: 0 additions & 126 deletions .github/workflows/phpunit-tests.yml

This file was deleted.

123 changes: 123 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- trunk
- 'release/**'
- 'wp/**'
# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
Expand Down Expand Up @@ -51,6 +53,127 @@ jobs:
- name: Running the date tests
run: npm run test:unit:date -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache"

test-php:
name: PHP ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }} on ubuntu-latest
runs-on: ubuntu-latest
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
fail-fast: true
matrix:
php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
multisite: [false, true]

env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0

- name: Set up Node.js
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1
with:
node-version-file: '.nvmrc'
cache: npm

##
# This allows Composer dependencies to be installed using a single step.
#
# Since the tests are currently run within the Docker containers where the PHP version varies,
# the same PHP version needs to be configured for the action runner machine so that the correct
# dependency versions are installed and cached.
##
- name: Set up PHP
uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2.22.0
with:
php-version: '${{ matrix.php }}'
ini-file: development
coverage: none

# Ensure that Composer installs the correct versions of packages.
- name: Override PHP version in composer.json
run: composer config platform.php ${{ matrix.php }}

# The spatie/phpunit-watcher package is not compatible with PHP < 7.2.
# It must be removed before running the tests.
- name: Remove incompatible Composer packages
if: ${{ matrix.php < '7.2' }}
run: composer remove spatie/phpunit-watcher --dev --no-update

# Since Composer dependencies are installed using `composer update` and no lock file is in version control,
# passing a custom cache suffix ensures that the cache is flushed at least once per week.
- name: Install Composer dependencies
uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0
with:
custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F")

- name: Install npm dependencies
run: |
npm ci
npm run build
- name: Docker debug information
run: |
docker -v
docker-compose -v
- name: General debug information
run: |
npm --version
node --version
curl --version
git --version
svn --version
locale -a
- name: Start Docker environment
run: npm run wp-env start

- name: Log running Docker containers
run: docker ps -a

- name: Docker container debug information
run: |
npm run wp-env run tests-mysql "mysql --version"
npm run wp-env run tests-wordpress "php --version"
npm run wp-env run tests-wordpress "php -m"
npm run wp-env run tests-wordpress "php -i"
npm run wp-env run tests-wordpress "/var/www/html/wp-content/plugins/gutenberg/vendor/bin/phpunit --version"
npm run wp-env run tests-wordpress "locale -a"
- name: Running single site unit tests
if: ${{ ! matrix.multisite }}
run: npm run test:unit:php

- name: Running multisite unit tests
if: ${{ matrix.multisite }}
run: npm run test:unit:php:multisite

# This job is deprecated but should temporarily be present for compatibility reasons.
# All PHPUnit checks have been moved to the "test-php" job.
unit-php:
name: PHP
runs-on: ubuntu-latest
needs: test-php
if: always()
steps:
- name: Fail the job if the PHPUnit tests fail
if: needs.test-php.result != 'success'
run: exit 1

- name: Mark the job as passed if the PHPUnit tests pass
if: needs.test-php.result == 'success'
run: exit 0

mobile-unit-js:
name: Mobile
runs-on: ubuntu-latest
Expand Down

0 comments on commit 4554441

Please sign in to comment.