diff --git a/plugins/woocommerce-blocks/.env b/plugins/woocommerce-blocks/.env index d80a92c4790..f3fe9ba8961 100644 --- a/plugins/woocommerce-blocks/.env +++ b/plugins/woocommerce-blocks/.env @@ -13,3 +13,4 @@ WORDPRESS_LOGIN=admin WORDPRESS_PASSWORD=password WORDPRESS_EMAIL=admin@woocommercecoree2etestsuite.com WP_VERSION=5.4 +WOO_VERSION=5.3.0 diff --git a/plugins/woocommerce-blocks/.github/workflows/unit-tests.yml b/plugins/woocommerce-blocks/.github/workflows/unit-tests.yml index 252293f971c..74df8b073ac 100644 --- a/plugins/woocommerce-blocks/.github/workflows/unit-tests.yml +++ b/plugins/woocommerce-blocks/.github/workflows/unit-tests.yml @@ -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 diff --git a/plugins/woocommerce-blocks/docker-compose.yml b/plugins/woocommerce-blocks/docker-compose.yml index 2f605b22013..2ada4bc8c7b 100644 --- a/plugins/woocommerce-blocks/docker-compose.yml +++ b/plugins/woocommerce-blocks/docker-compose.yml @@ -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 diff --git a/plugins/woocommerce-blocks/tests/bin/Dockerfile b/plugins/woocommerce-blocks/tests/bin/Dockerfile index 5f8d00fdd44..6803824026b 100644 --- a/plugins/woocommerce-blocks/tests/bin/Dockerfile +++ b/plugins/woocommerce-blocks/tests/bin/Dockerfile @@ -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 diff --git a/plugins/woocommerce-blocks/tests/bin/install-wp-tests.sh b/plugins/woocommerce-blocks/tests/bin/install-wp-tests.sh index 5fbea7f7b1d..0413872c916 100755 --- a/plugins/woocommerce-blocks/tests/bin/install-wp-tests.sh +++ b/plugins/woocommerce-blocks/tests/bin/install-wp-tests.sh @@ -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" }