Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 77 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ jobs:
- name: Build the plugin
run: npm run build

- name: Save compiled assets
- name: Save build dir
uses: actions/upload-artifact@v2
with:
name: plugin-build-dir
path: ./build

- name: Save vendor_prefixed dir
uses: actions/upload-artifact@v2
with:
name: plugin-vendor_prefixed-dir
path: ./vendor_prefixed

lint_php:
runs-on: ubuntu-latest
needs: [build]
Expand Down Expand Up @@ -81,15 +87,83 @@ jobs:
- name: Linting code
run: npm run lint-css

# From the Gutenberg project
# https://github.com/WordPress/gutenberg/blob/trunk/.github/workflows/unit-test.yml#L78-L187
test_unit_php:
runs-on: ubuntu-latest
needs: [lint_php]

strategy:
fail-fast: true
matrix:
php: [7.4, 8.0, 8.1]
multisite: [0, 1]

env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: 'https://wordpress.org/wordpress-latest.zip'

steps:
- name: Placeholder
run: echo "Placeholder ${{ matrix.php }}"
- name: Checkout code
uses: actions/checkout@v2

- name: Restore npm dependency cache
uses: ./.github/actions/restore-npm-cache

- name: Restore composer dependency cache
uses: ./.github/actions/restore-composer-cache

- name: Download build dir
uses: actions/download-artifact@v2
with:
name: plugin-build-dir
path: ./build

- name: Download vendor_prefixed dir
uses: actions/download-artifact@v2
with:
name: plugin-vendor_prefixed-dir
path: ./vendor_prefixed

##
# 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@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # v2.24.0
with:
php-version: '${{ matrix.php }}'
ini-file: development
coverage: none

- 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"