Skip to content

Commit

Permalink
Merge branch 'develop' into add/2783-double_click_edit
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Aug 16, 2019
2 parents 483c72d + 252c08d commit 78d6275
Show file tree
Hide file tree
Showing 13 changed files with 329 additions and 87 deletions.
19 changes: 2 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,11 @@ jobs:
install:
- nvm install
- composer install
# npm is handled by `npm run env:start`
- npm install
script:
- npm run env:start # also install npm dependencies
- npm run build:js
- npm run build:css
- npm run env:reset-site
- npm run test:e2e:ci
- npm run env:stop

- name: E2E tests (Author)
php: "7.3"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs,eslint,xmllint,phpsyntax,phpunit PUPPETEER_SKIP_CHROMIUM_DOWNLOAD= E2E_ROLE=author
install:
- nvm install
- composer install
# npm is handled by `npm run env:start`
script:
- npm run env:start # also install npm dependencies
- npm run build:js
- npm run build:css
- npm run env:start
- npm run env:reset-site
- npm run test:e2e:ci
- npm run env:stop
Expand Down
4 changes: 2 additions & 2 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Plugin URI: https://amp-wp.org
* Author: AMP Project Contributors
* Author URI: https://github.com/ampproject/amp-wp/graphs/contributors
* Version: 1.2.1-beta1
* Version: 1.2.1-beta2
* Text Domain: amp
* Domain Path: /languages/
* License: GPLv2 or later
Expand All @@ -15,7 +15,7 @@

define( 'AMP__FILE__', __FILE__ );
define( 'AMP__DIR__', dirname( __FILE__ ) );
define( 'AMP__VERSION', '1.2.1-beta1' );
define( 'AMP__VERSION', '1.2.1-beta2' );

/**
* Errors encountered while loading the plugin.
Expand Down
1 change: 1 addition & 0 deletions bin/local-env/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ services:
depends_on:
- mysql
- wordpress
command: tail -f /dev/null

mysql:
image: mysql:5.7
Expand Down
34 changes: 34 additions & 0 deletions bin/local-env/includes.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash

# Common variables.
DOCKER_COMPOSE_FILE_OPTIONS="-f $(dirname "$0")/docker-compose.yml"
# These are the containers and values for the development site.
CLI='cli'
CONTAINER='wordpress'
SITE_TITLE='AMP Dev'

##
# Ask a Yes/No question, and way for a reply.
#
Expand Down Expand Up @@ -132,3 +139,30 @@ action_format() {
command_exists() {
type -t "$1" >/dev/null 2>&1
}

##
# Docker Compose helper
#
# Calls docker-compose with common options.
##
dc() {
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS "$@"
}

##
# WP CLI
#
# Executes a WP CLI request in the CLI container.
##
wp() {
dc exec -u xfs $CLI wp "$@"
}

##
# WordPress Container helper.
#
# Executes the given command in the wordpress container.
##
container() {
dc exec $CONTAINER "$@"
}
12 changes: 7 additions & 5 deletions bin/local-env/install-node-nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ if [ "$TRAVIS" != "true" ] && [ "$(nvm current)" != "$(nvm version-remote --lts)
exit 1
fi

# Install/update packages
echo -e $(status_message "Installing and updating NPM packages..." )
npm install
if [ "$TRAVIS" != "true" ]; then
# Install/update packages
echo -e $(status_message "Installing and updating NPM packages..." )
npm install

# Make sure npm is up-to-date
npm install npm -g
# Make sure npm is up-to-date
npm install npm -g
fi

# There was a bug in NPM that caused changes in package-lock.json. Handle that.
if [ "$TRAVIS" != "true" ] && ! git diff --no-ext-diff --exit-code package-lock.json >/dev/null; then
Expand Down
94 changes: 56 additions & 38 deletions bin/local-env/install-wordpress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
set -e

# Common variables.
DOCKER_COMPOSE_FILE_OPTIONS="-f $(dirname "$0")/docker-compose.yml"
WP_DEBUG=${WP_DEBUG-true}
SCRIPT_DEBUG=${SCRIPT_DEBUG-true}
WP_VERSION=${WP_VERSION-"latest"}

# Include useful functions
. "$(dirname "$0")/includes.sh"

# These are the containers and values for the development site.
CLI='cli'
CONTAINER='wordpress'
SITE_TITLE='AMP Dev'
# Make sure Docker containers are running
dc up -d >/dev/null 2>&1

# Get the host port for the WordPress container.
HOST_PORT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS port $CONTAINER 80 | awk -F : '{printf $2}')
HOST_PORT=$(dc port $CONTAINER 80 | awk -F : '{printf $2}')

# Wait until the Docker containers are running and the WordPress site is
# responding to requests.
Expand All @@ -32,72 +30,92 @@ echo ''
# dirty up the tests.
if [ "$1" == '--reset-site' ]; then
echo -e $(status_message "Resetting test database...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI db reset --yes --quiet
wp db reset --yes --quiet
fi

if [ ! -z "$WP_VERSION" ] && [ "$WP_VERSION" != "latest" ]; then
# Potentially downgrade WordPress
echo -e $(status_message "Downloading WordPress version $WP_VERSION...")
wp core download --version=${WP_VERSION} --force --quiet
fi

# Install WordPress.
echo -e $(status_message "Installing WordPress...")
# The `-u 33` flag tells Docker to run the command as a particular user and
# prevents permissions errors. See: https://github.com/WordPress/gutenberg/pull/8427#issuecomment-410232369
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI core install --title="$SITE_TITLE" --admin_user=admin --admin_password=password [email protected] --skip-email --url=http://localhost:$HOST_PORT --quiet

if [ "$E2E_ROLE" = "author" ]; then
echo -e $(status_message "Creating an additional author user for testing...")
# Create an additional author user for testing.
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI user create author [email protected] --role=author --user_pass=authpass --quiet
# Assign the existing Hello World post to the author.
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI post update 1 --post_author=2 --quiet
fi
wp core install --title="$SITE_TITLE" --admin_user=admin --admin_password=password [email protected] --skip-email --url=http://localhost:$HOST_PORT --quiet

# Create additional users.
echo -e $(status_message "Creating additional users...")
wp user create editor [email protected] --role=editor --user_pass=password --quiet
echo -e $(status_message "Editor created! Username: editor Password: password")
wp user create author [email protected] --role=author --user_pass=password --quiet
echo -e $(status_message "Author created! Username: author Password: password")
wp user create contributor [email protected] --role=contributor --user_pass=password --quiet
echo -e $(status_message "Contributor created! Username: contributor Password: password")
wp user create subscriber [email protected] --role=subscriber --user_pass=password --quiet
echo -e $(status_message "Subscriber created! Username: subscriber Password: password")

# Make sure the uploads and upgrade folders exist and we have permissions to add files.
echo -e $(status_message "Ensuring that files can be uploaded...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER mkdir -p /var/www/html/wp-content/uploads /var/www/html/wp-content/upgrade
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER chmod 767 /var/www/html/wp-content/plugins /var/www/html/wp-config.php /var/www/html/wp-settings.php /var/www/html/wp-content/uploads /var/www/html/wp-content/upgrade

CURRENT_WP_VERSION=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm $CLI core version)
container mkdir -p \
/var/www/html/wp-content/uploads \
/var/www/html/wp-content/upgrade
container chmod 767 \
/var/www/html/wp-content \
/var/www/html/wp-content/plugins \
/var/www/html/wp-config.php \
/var/www/html/wp-settings.php \
/var/www/html/wp-content/uploads \
/var/www/html/wp-content/upgrade

CURRENT_WP_VERSION=$(wp core version | tr -d '\r')
echo -e $(status_message "Current WordPress version: $CURRENT_WP_VERSION...")

if [ "$WP_VERSION" == "latest" ]; then
# Check for WordPress updates, to make sure we're running the very latest version.
echo -e $(status_message "Updating WordPress to the latest version...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI core update --quiet
wp core update --quiet
echo -e $(status_message "Updating The WordPress Database...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI core update-db --quiet
wp core update-db --quiet
fi

# If the 'wordpress' volume wasn't during the down/up earlier, but the post port has changed, we need to update it.
echo -e $(status_message "Checking the site's url...")
CURRENT_URL=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm $CLI option get siteurl)
CURRENT_URL=$(wp option get siteurl)
if [ "$CURRENT_URL" != "http://localhost:$HOST_PORT" ]; then
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI option update home "http://localhost:$HOST_PORT" --quiet
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI option update siteurl "http://localhost:$HOST_PORT" --quiet
wp option update home "http://localhost:$HOST_PORT" --quiet
wp option update siteurl "http://localhost:$HOST_PORT" --quiet
fi

# Install a dummy favicon to avoid 404 errors.
echo -e $(status_message "Installing a dummy favicon...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER touch /var/www/html/favicon.ico
container touch /var/www/html/favicon.ico
container chmod 767 /var/www/html/favicon.ico

# Activate AMP plugin.
echo -e $(status_message "Activating AMP plugin...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI plugin activate amp --quiet
wp plugin activate amp --quiet

# Install & activate Gutenberg plugin.
echo -e $(status_message "Installing and activating Gutenberg plugin...")
# todo: Use `wp plugin install --activate` once WP-CLI is updated, see https://github.com/wp-cli/extension-command/issues/176.
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI plugin install gutenberg --activate --quiet
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI plugin activate gutenberg --quiet
wp plugin install gutenberg --activate --force --quiet

# Set pretty permalinks.
echo -e $(status_message "Setting permalink structure...")
wp rewrite structure '%postname%' --hard --quiet

# Configure site constants.
echo -e $(status_message "Configuring site constants...")
WP_DEBUG_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG)
WP_DEBUG_CURRENT=$(wp config get --type=constant --format=json WP_DEBUG | tr -d '\r')

if [ "$WP_DEBUG" != $WP_DEBUG_CURRENT ]; then
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set WP_DEBUG $WP_DEBUG --raw --type=constant --quiet
WP_DEBUG_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG)
wp config set WP_DEBUG $WP_DEBUG --raw --type=constant --quiet
WP_DEBUG_RESULT=$(wp config get --type=constant --format=json WP_DEBUG | tr -d '\r')
echo -e $(status_message "WP_DEBUG: $WP_DEBUG_RESULT...")
fi
SCRIPT_DEBUG_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json SCRIPT_DEBUG)

SCRIPT_DEBUG_CURRENT=$(wp config get --type=constant --format=json SCRIPT_DEBUG | tr -d '\r')
if [ "$SCRIPT_DEBUG" != $SCRIPT_DEBUG_CURRENT ]; then
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set SCRIPT_DEBUG $SCRIPT_DEBUG --raw --type=constant --quiet
SCRIPT_DEBUG_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json SCRIPT_DEBUG)
wp config set SCRIPT_DEBUG $SCRIPT_DEBUG --raw --type=constant --quiet
SCRIPT_DEBUG_RESULT=$(wp config get --type=constant --format=json SCRIPT_DEBUG | tr -d '\r')
echo -e $(status_message "SCRIPT_DEBUG: $SCRIPT_DEBUG_RESULT...")
fi
9 changes: 3 additions & 6 deletions bin/local-env/launch-containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# Exit if any command fails.
set -e

# Common variables.
DOCKER_COMPOSE_FILE_OPTIONS="-f $(dirname "$0")/docker-compose.yml"

# Include useful functions.
. "$(dirname "$0")/includes.sh"

Expand All @@ -23,12 +20,12 @@ fi

# Stop existing containers.
echo -e $(status_message "Stopping Docker containers...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS down --remove-orphans >/dev/null 2>&1
dc down --remove-orphans >/dev/null 2>&1

# Download image updates.
echo -e $(status_message "Downloading Docker image updates...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS pull
dc pull

# Launch the containers.
echo -e $(status_message "Starting Docker containers...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS up -d >/dev/null
dc up -d >/dev/null
2 changes: 1 addition & 1 deletion bin/local-env/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
EOT

CURRENT_URL=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm cli option get siteurl)
CURRENT_URL=$(wp option get siteurl | tr -d '\r')

echo -e "\nWelcome to...\n"
echo -e "\033[95m$AMP\033[0m"
Expand Down
5 changes: 1 addition & 4 deletions bin/local-env/stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# Exit if any command fails.
set -e

# Common variables.
DOCKER_COMPOSE_FILE_OPTIONS="-f $(dirname "$0")/docker-compose.yml"

# Include useful functions.
. "$(dirname "$0")/includes.sh"

Expand All @@ -23,4 +20,4 @@ fi

# Stop existing containers.
echo -e $(status_message "Stopping Docker containers...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS down --remove-orphans >/dev/null 2>&1
dc down --remove-orphans >/dev/null 2>&1
1 change: 1 addition & 0 deletions includes/sanitizers/class-amp-style-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
'amp-live-list',
'[submit-error]',
'[submit-success]',
'amp-script',
],
'should_locate_sources' => false,
'parsed_cache_variant' => null,
Expand Down
Loading

0 comments on commit 78d6275

Please sign in to comment.