From ce20bd0931e257810bb7eadeb6e585a4ba681280 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Wed, 10 Nov 2021 06:48:59 -0400 Subject: [PATCH] add generic container environment variable support for PHP, DB --- packages/js/e2e-environment/CHANGELOG.md | 1 + .../js/e2e-environment/bin/docker-compose.sh | 32 ++++++++++++------- packages/js/e2e-environment/builtin.md | 10 +++++- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/packages/js/e2e-environment/CHANGELOG.md b/packages/js/e2e-environment/CHANGELOG.md index 26c0ac4752e..4c1db86b56f 100644 --- a/packages/js/e2e-environment/CHANGELOG.md +++ b/packages/js/e2e-environment/CHANGELOG.md @@ -4,6 +4,7 @@ - Added quotes around `WORDPRESS_TITLE` value in .env file to address issue with docker compose 2 "key cannot contain a space" error. - Added `LATEST_WP_VERSION_MINUS` that allows setting a number to subtract from the current WordPress version for the WordPress Docker image. +- Support for PHP_VERSION, MARIADB_VERSION environment variables for built in container initialization ## Fixed diff --git a/packages/js/e2e-environment/bin/docker-compose.sh b/packages/js/e2e-environment/bin/docker-compose.sh index 55c9859055c..ee0be868de2 100755 --- a/packages/js/e2e-environment/bin/docker-compose.sh +++ b/packages/js/e2e-environment/bin/docker-compose.sh @@ -17,22 +17,30 @@ if [[ $1 ]]; then export WORDPRESS_VERSION=$(./bin/get-previous-version.js $WORDPRESS_VERSION $LATEST_WP_VERSION_MINUS 2> /dev/null) fi - if ! [[ $TRAVIS_PHP_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then - TRAVIS_PHP_VERSION=$(./bin/get-latest-docker-tag.js php 7 2> /dev/null) - fi - if [[ $TRAVIS_PHP_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then - export DC_PHP_VERSION=$TRAVIS_PHP_VERSION + if [[ $PHP_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then + export DC_PHP_VERSION=$PHP_VERSION else - export DC_PHP_VERSION="7.4.22" + if ! [[ $TRAVIS_PHP_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then + TRAVIS_PHP_VERSION=$(./bin/get-latest-docker-tag.js php 7 2> /dev/null) + fi + if [[ $TRAVIS_PHP_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then + export DC_PHP_VERSION=$TRAVIS_PHP_VERSION + else + export DC_PHP_VERSION="7.4.25" + fi fi - if ! [[ $TRAVIS_MARIADB_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then - TRAVIS_MARIADB_VERSION=$(./bin/get-latest-docker-tag.js mariadb 10 2> /dev/null) - fi - if [[ $TRAVIS_MARIADB_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then - export DC_MARIADB_VERSION=$TRAVIS_MARIADB_VERSION + if [[ $MARIADB_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then + export DC_MARIADB_VERSION=$MARIADB_VERSION else - export DC_MARIADB_VERSION="10.6.4" + if ! [[ $TRAVIS_MARIADB_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then + TRAVIS_MARIADB_VERSION=$(./bin/get-latest-docker-tag.js mariadb 10 2> /dev/null) + fi + if [[ $TRAVIS_MARIADB_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then + export DC_MARIADB_VERSION=$TRAVIS_MARIADB_VERSION + else + export DC_MARIADB_VERSION="10.6.5" + fi fi if [[ $1 == 'up' ]]; then diff --git a/packages/js/e2e-environment/builtin.md b/packages/js/e2e-environment/builtin.md index 80ab9064bc7..6ec0095f7c9 100644 --- a/packages/js/e2e-environment/builtin.md +++ b/packages/js/e2e-environment/builtin.md @@ -126,9 +126,17 @@ The built in container defaults to mapping the root folder of the repository to Since the introduction of the WooCommerce Monorepo, a `WC_CORE_PATH` environment variable maps to Core WooCommerce at `plugins/woocommerce`. It can also be overriden in a similar fashion. +### Specifying Server Software versions + +The built-in container supports these variables for use locally and in CI environments: + +- `WP_VERSION` - WordPress (default `latest`) +- `PHP_VERSION` - PHP (default `latest`) +- `MARIADB_VERSION` - MariaDB (default `latest`) + ### Travis CI Supported Versions -Travis CI uses environment variables to allow control of some software versions in the testing environment. The built in container supports these variables: +Travis CI uses environment variables to allow control of some software versions in the testing environment. The built-in container supports these variables: - `WP_VERSION` - WordPress (default `latest`) - `TRAVIS_PHP_VERSION` - PHP (default `latest`)