Skip to content

Commit 874f71e

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents 2385f89 + ab5fd4d commit 874f71e

104 files changed

Lines changed: 2137 additions & 1254 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"username": "wordpress"
1212
},
1313
"ghcr.io/devcontainers/features/node:1": {
14-
"version": "14"
14+
"version": "16"
1515
},
1616
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
1717
"ghcr.io/devcontainers/features/git:1": {}
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
##
2+
# A callable workflow that runs the PHPUnit test suite with the specified configuration.
3+
##
4+
name: Run PHPUnit tests
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
os:
10+
description: 'Operating system to run tests on'
11+
required: false
12+
type: 'string'
13+
default: 'ubuntu-latest'
14+
php:
15+
description: 'The version of PHP to use, in the format of X.Y'
16+
required: true
17+
type: 'string'
18+
db-type:
19+
description: 'Database type. Valid types are mysql and mariadb'
20+
required: false
21+
type: 'string'
22+
default: 'mysql'
23+
db-version:
24+
description: 'Database version'
25+
required: false
26+
type: 'string'
27+
default: '8.0'
28+
multisite:
29+
description: 'Whether to run tests as multisite'
30+
required: false
31+
type: 'boolean'
32+
default: false
33+
memcached:
34+
description: 'Whether to test with memcached enabled'
35+
required: false
36+
type: 'boolean'
37+
default: false
38+
phpunit-config:
39+
description: 'The PHPUnit configuration file to use'
40+
required: false
41+
type: 'string'
42+
default: 'phpunit.xml.dist'
43+
report:
44+
description: 'Whether to report results to WordPress.org Hosting Tests'
45+
required: false
46+
type: 'boolean'
47+
default: false
48+
env:
49+
LOCAL_PHP: ${{ inputs.php }}-fpm
50+
LOCAL_DB_TYPE: ${{ inputs.db-type }}
51+
LOCAL_DB_VERSION: ${{ inputs.db-version }}
52+
LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }}
53+
PHPUNIT_CONFIG: ${{ inputs.phpunit-config }}
54+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
55+
56+
jobs:
57+
# Runs the PHPUnit tests for WordPress.
58+
#
59+
# Performs the following steps:
60+
# - Sets environment variables.
61+
# - Checks out the repository.
62+
# - Sets up Node.js.
63+
# - Sets up PHP.
64+
# - Installs Composer dependencies.
65+
# - Installs npm dependencies
66+
# - Logs general debug information about the runner.
67+
# - Logs Docker debug information (about the Docker installation within the runner).
68+
# - Starts the WordPress Docker container.
69+
# - Logs the running Docker containers.
70+
# - Logs debug information about what's installed within the WordPress Docker containers.
71+
# - Install WordPress within the Docker container.
72+
# - Run the PHPUnit tests.
73+
# - Ensures version-controlled files are not modified or deleted.
74+
# - Checks out the WordPress Test reporter repository.
75+
# - Submit the test results to the WordPress.org host test results.
76+
phpunit-tests:
77+
name: PHP ${{ inputs.php }} / ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }}${{ inputs.memcached && ' with memcached' || '' }}${{ inputs.report && ' (test reporting enabled)' || '' }}
78+
runs-on: ${{ inputs.os }}
79+
timeout-minutes: 20
80+
81+
steps:
82+
- name: Configure environment variables
83+
run: |
84+
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
85+
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
86+
87+
- name: Checkout repository
88+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
89+
90+
- name: Set up Node.js
91+
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
92+
with:
93+
node-version-file: '.nvmrc'
94+
cache: npm
95+
96+
##
97+
# This allows Composer dependencies to be installed using a single step.
98+
#
99+
# Since the tests are currently run within the Docker containers where the PHP version varies,
100+
# the same PHP version needs to be configured for the action runner machine so that the correct
101+
# dependency versions are installed and cached.
102+
##
103+
- name: Set up PHP
104+
uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # v2.24.0
105+
with:
106+
php-version: '${{ inputs.php }}'
107+
coverage: none
108+
109+
# Since Composer dependencies are installed using `composer update` and no lock file is in version control,
110+
# passing a custom cache suffix ensures that the cache is flushed at least once per week.
111+
- name: Install Composer dependencies
112+
uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0
113+
with:
114+
custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F")
115+
116+
- name: Install npm dependencies
117+
run: npm ci
118+
119+
- name: General debug information
120+
run: |
121+
npm --version
122+
node --version
123+
curl --version
124+
git --version
125+
svn --version
126+
composer --version
127+
locale -a
128+
129+
- name: Docker debug information
130+
run: |
131+
docker -v
132+
docker-compose -v
133+
134+
- name: Start Docker environment
135+
run: |
136+
npm run env:start
137+
138+
- name: Log running Docker containers
139+
run: docker ps -a
140+
141+
- name: WordPress Docker container debug information
142+
run: |
143+
docker-compose run --rm mysql ${{ env.LOCAL_DB_TYPE }} --version
144+
docker-compose run --rm php php --version
145+
docker-compose run --rm php php -m
146+
docker-compose run --rm php php -i
147+
docker-compose run --rm php locale -a
148+
149+
- name: Install WordPress
150+
run: npm run env:install
151+
152+
- name: Run PHPUnit tests
153+
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}
154+
155+
- name: Run AJAX tests
156+
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
157+
158+
- name: Run ms-files tests as a multisite install
159+
if: ${{ inputs.multisite }}
160+
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c tests/phpunit/multisite.xml --group ms-files
161+
162+
- name: Run external HTTP tests
163+
if: ${{ ! inputs.multisite }}
164+
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c phpunit.xml.dist --group external-http
165+
166+
# __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
167+
- name: Run (Xdebug) tests
168+
run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__
169+
170+
- name: Ensure version-controlled files are not modified or deleted
171+
run: git diff --exit-code
172+
173+
- name: Checkout the WordPress Test Reporter
174+
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && inputs.report }}
175+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
176+
with:
177+
repository: 'WordPress/phpunit-test-runner'
178+
path: 'test-runner'
179+
180+
- name: Submit test results to the WordPress.org host test results
181+
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && inputs.report }}
182+
env:
183+
WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}"
184+
run: docker-compose run --rm -e WPT_REPORT_API_KEY -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php

0 commit comments

Comments
 (0)