Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use local tooling to run PHPUnit tests instead of wp-dev-lib #1124

Merged
merged 28 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
93171e6
PHPUnit tests CI configuration fixed.
kidunot89 Jul 2, 2020
576f807
Docker service added to .travis.yml
kidunot89 Jul 2, 2020
6f59bdf
Limit the timeout to 10 minutes instead of unlimited
kasparsd Jul 3, 2020
b966f74
Copy right in since we can always rebuild
kasparsd Jul 3, 2020
da94955
Use dependencies for running PHP unit tests instead of wp-dev-lib
kasparsd Jul 3, 2020
3002b98
Add the latest version of PHP 7.4
kasparsd Jul 3, 2020
4f3072d
No longer needed since we don’t use wp-dev-lib
kasparsd Jul 3, 2020
a773fef
Currently not enabled
kasparsd Jul 3, 2020
9479513
Use the latest version of PHP to create the bundle
kasparsd Jul 3, 2020
1a8614f
Use environmental variables to control this behaviour
kasparsd Jul 3, 2020
275a83f
Account for missing terminal
kasparsd Jul 3, 2020
c7b8cfc
Support for multisite tests
kasparsd Jul 3, 2020
d0c1ed9
Use the multisite command instead
kasparsd Jul 3, 2020
16cf3e0
Pass the current user ID instead
kasparsd Jul 3, 2020
19c87c4
Use something that is available on all OSes
kasparsd Jul 3, 2020
0fcf906
Allow custom versions of PHP
kasparsd Jul 3, 2020
5d65bf8
No longer used
kasparsd Jul 3, 2020
b42cbbc
Test with different versions of PHP
kasparsd Jul 3, 2020
cf3d3f1
Use an older version which supports PHP 5.6
kasparsd Jul 3, 2020
ac4f172
Use proper comment style here
kasparsd Jul 3, 2020
5d0686f
Pass the current user ID instead
kasparsd Jul 3, 2020
aaa4054
Install a specific version of Xdebug
kasparsd Jul 3, 2020
023b673
Do the default build
kasparsd Jul 3, 2020
942dc4e
Indicate an build arg
kasparsd Jul 3, 2020
e44f942
Debug the test reports directory
kasparsd Jul 3, 2020
dc5483c
Hardcode 1000 since provision happens with root
kasparsd Jul 3, 2020
18da2c6
Introduce a helper to fix coverage reporting
kasparsd Jul 3, 2020
5e86ca8
Remove the double reference
kasparsd Jul 3, 2020
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
47 changes: 23 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,50 @@ dist: xenial

language: php

php:
- "5.6"
- "7.0"
- "7.2"
- "7.3"

addons:
apt:
packages:
# For xmllint.
- libxml2-utils
env:
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=1
- WP_VERSION=trunk WP_MULTISITE=0
- WP_VERSION=trunk WP_MULTISITE=1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now have npm run phpunit-multisite for this.

php: "7.4"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis jobs now handle the different types of runs we need.


jobs:
include:
- name: Release Package
php: "7.3"
env: WP_VERSION=latest WP_MULTISITE=0 WP_RELEASE=1

- stage: test
name: Test with PHP 5.6
before_script: docker-compose build --build-arg PHP_VERSION=5.6 --build-arg XDEBUG_VERSION=2.5.5 wordpress

- name: Test with PHP 7.2
before_script: docker-compose build --build-arg PHP_VERSION=7.2 wordpress

- name: Default Test
before_script: docker-compose build

- stage: deploy
name: Release Package
env: WP_RELEASE=1

services:
- mysql
- docker

before_install:
- docker load -i /tmp/docker_images/images.tar || true
- nvm install
- nvm use

install:
- npm install
- export DEV_LIB_PATH="vendor/xwp/wp-dev-lib/scripts"
- export DEV_LIB_ONLY="phpunit"
- source "$DEV_LIB_PATH/travis.install.sh"

script:
- npm run lint
- source "$DEV_LIB_PATH/travis.script.sh"
- npm run phpunit
- npm run phpunit-multisite

after_script:
- test -f ./tests/reports/clover.xml && composer test-report || true

before_deploy:
- npm run release

before_cache:
- docker save -o /tmp/docker_images/images.tar $(docker images -a -q)

deploy:
provider: releases
api_key:
Expand All @@ -69,3 +67,4 @@ cache:
npm: true
directories:
- $HOME/.composer/cache
- /tmp/docker_images
12 changes: 2 additions & 10 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ load File.join(
Vagrant.configure(2) do |config|
config.vm.hostname = "stream"

# Wait 10 seconds before the docker containers are up.
config.vm.provision "shell",
inline: "sleep 10",
run: "always"

# Setup the WP sites.
config.vm.provision "shell",
path: "local/vagrant/setup-wp.sh",
run: "always",
env: {
"DOCKER_COMPOSE_FILE" => "/vagrant/docker-compose.yml"
}
inline: "docker-compose -f /vagrant/docker-compose.yml exec -T --user 1000 wordpress xwp_wait mysql:3306 -t 60 -- wp core multisite-install --url=stream.local",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the bash script with an inline command that does the same thing.

run: "always"
end
28 changes: 14 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,29 @@
"homepage": "https://wordpress.org/plugins/stream/",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"repositories": [
{
"type": "git",
"url": "https://github.com/WordPress/wordpress-develop.git"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use https://github.com/johnpbloch/wordpress now which doesn't require any build steps and is much faster to install, and can be used in combination of wp-phpunit/wp-phpunit to run the unit tests with any version of WP core.

}
],
"require": {
"composer/installers": "~1.0"
},
"require-dev": {
"johnpbloch/wordpress": "^5.4",
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^5.7",
"wordpress/wordpress": "^5.2",
"wp-cli/wp-cli-bundle": "^2.2",
"wp-coding-standards/wpcs": "^2.2",
"wpsh/local": "^0.2.3",
"xwp/wp-dev-lib": "^1.5"
"wp-phpunit/wp-phpunit": "^5.4",
"wpsh/local": "^0.2.3"
},
"config": {
"process-timeout": 600,
"sort-packages": true,
"platform": {
"php": "5.6"
"php": "5.6.20"
}
},
"extra": {
"wordpress-install-dir": "local/public"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously we were using the WP core files provisioned by the wordpress docker container during the entrypoint setup. We now have full control of the source files used for development which is much more reliable and provisions the container much faster, too.

},
"scripts": {
"pre-install-cmd": [
"Composer\\Config::disableProcessTimeout"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with a 600 second timeout for all commands as a sane default.

Copy link
Contributor

@kidunot89 kidunot89 Jul 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kasparsd I don't know the original purpose of this timeout.
@kopepasah You implemented this originally. Are you okay with this change?

],
"release": [
"composer install --no-dev --prefer-dist --optimize-autoloader"
],
Expand All @@ -43,7 +38,12 @@
"@lint-php"
],
"test": [
"phpunit --coverage-text"
"phpunit --coverage-text",
"php local/scripts/make-clover-relative.php ./tests/reports/clover.xml"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This converts all file paths inside the coverage reports to be relative to the project root instead of absolute paths inside the Docker container which was causing issues to Coveralls reporting.

],
"test-multisite": [
"WP_MULTISITE=1 phpunit --coverage-text",
"php local/scripts/make-clover-relative.php ./tests/reports/clover.xml"
],
"test-report": [
"php-coveralls --verbose"
Expand Down
Loading