* allow for WOO_VERSION config in tests setup

* pass through WOO_VERSION environment var to container

* force specific WOO_VERSION value for phpunit test run

* try passing through environment variable via docker arg

Also set .env for controlling local runs of phpunit
This commit is contained in:
Darren Ethier 2021-06-03 03:35:52 -04:00 committed by GitHub
parent 44f31606c3
commit c391899258
5 changed files with 31 additions and 17 deletions

View File

@ -13,3 +13,4 @@ WORDPRESS_LOGIN=admin
WORDPRESS_PASSWORD=password
WORDPRESS_EMAIL=admin@woocommercecoree2etestsuite.com
WP_VERSION=5.4
WOO_VERSION=5.3.0

View File

@ -94,6 +94,8 @@ jobs:
echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini
- name: Run PHP Unit tests
env:
WOO_VERSION: 5.3.0
run: |
npm run phpunit

View File

@ -18,17 +18,20 @@ services:
- db
build:
context: ./tests/bin
args:
WOO_INSTALL_VERSION: ${WOO_VERSION}
ports:
- 8085:80
restart: on-failure
environment:
WORDPRESS_DB_HOST:
WORDPRESS_DB_NAME:
WORDPRESS_DB_USER:
WORDPRESS_DB_PASSWORD:
WORDPRESS_TABLE_PREFIX: wp_test_
WP_CORE_DIR: /var/www/html
WP_TESTS_DIR: /tmp/wordpress-tests-lib
- WORDPRESS_DB_HOST
- WORDPRESS_DB_NAME
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_TABLE_PREFIX=wp_test_
- WP_CORE_DIR=/var/www/html
- WP_TESTS_DIR=/tmp/wordpress-tests-lib
- WOO_VERSION
volumes:
- "./:/var/www/html/wp-content/plugins/woocommerce-gutenberg-products-block"
- wordpress:/var/www/html

View File

@ -1,5 +1,7 @@
FROM wordpress:latest
ARG WOO_INSTALL_VERSION=latest
CMD echo "Installing dependencies..."
RUN apt-get update && \
@ -9,6 +11,7 @@ CMD echo "Installing tests..."
ENV WP_TESTS_DIR=/tmp/wordpress-tests-lib
ENV WP_CORE_DIR=/tmp/src/wordpress
ENV WOO_VERSION=$WOO_INSTALL_VERSION
COPY install-wp-tests.sh /usr/local/bin/dockerInit
RUN chmod +x /usr/local/bin/dockerInit

View File

@ -11,6 +11,7 @@ DB_PASS=$3
DB_HOST=${4-localhost}
WP_VERSION=${5-latest}
SKIP_DB_CREATE=${6-false}
WOO_VERSION=${WOO_VERSION-latest}
# directories
TMPDIR=${TMPDIR-/tmp}
@ -149,21 +150,25 @@ install_db() {
}
install_woocommerce() {
WOO_INSTALL_VERSION=$WOO_VERSION
echo "Woo Version: $WOO_VERSION"
if [ $WOO_VERSION == 'latest' ] ; then
WOO_INSTALL_VERSION=latest-stable
fi
echo "Woo Install Version: $WOO_INSTALL_VERSION";
# get built plugin from .org
download https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip "$TMPDIR/woocommerce.zip"
download "https://downloads.wordpress.org/plugin/woocommerce.$WOO_INSTALL_VERSION.zip" "$TMPDIR/woocommerce.zip"
unzip -q $TMPDIR/woocommerce.zip -d "$WP_CORE_DIR/wp-content/plugins"
# Script Variables
BRANCH=$TRAVIS_BRANCH
REPO=$TRAVIS_REPO_SLUG
# Get github version
if [ "$TRAVIS_PULL_REQUEST_BRANCH" != "" ]; then
BRANCH=$TRAVIS_PULL_REQUEST_BRANCH
REPO=$TRAVIS_PULL_REQUEST_SLUG
git clone "https://github.com/woocommerce/woocommerce.git" "$TMPDIR/woocommerce-git"
# if specific version, then checkout the tag
if [ $WOO_VERSION != 'latest' ] ; then
echo "Checking out specific Woo Version test suite (tag)"
cd "$TMPDIR/woocommerce-git"
git checkout ${WOO_VERSION}
cd ..
fi
git clone --depth 1 "https://github.com/woocommerce/woocommerce.git" "$TMPDIR/woocommerce-git"
mv "$TMPDIR/woocommerce-git/tests" "$WP_CORE_DIR/wp-content/plugins/woocommerce"
}