Skip to content

Commit

Permalink
Merge branch 'develop' into add/4569-frontend-performance-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Jul 18, 2020
2 parents b55eb14 + fa47d90 commit 7b2a8c8
Show file tree
Hide file tree
Showing 421 changed files with 31,681 additions and 10,434 deletions.
27 changes: 22 additions & 5 deletions .dev-lib
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,33 @@ DEV_LIB_SKIP="$DEV_LIB_SKIP,jshint"
CHECK_SCOPE=all

function after_wp_install {
if [[ "$WP_VERSION" != "4.9" ]]; then
echo -n "Installing Gutenberg 7.1.0..."
gutenberg_plugin_svn_url=https://plugins.svn.wordpress.org/gutenberg/tags/7.1.0/
case "$WP_VERSION" in
"4.9")
gb_version=""
;;
"5.0" | "5.1")
gb_version="6.9.0"
;;
"5.2")
gb_version="7.6.1"
;;
*)
# WP 5.3 onwards can use the latest version of Gutenberg.
gb_version="trunk"
esac

if [[ "$gb_version" != "" ]]; then
echo -n "Installing Gutenberg ${gb_version}..."

url_path=$([ $gb_version == "trunk" ] && echo "trunk" || echo "tags/${gb_version}")
gutenberg_plugin_svn_url="https://plugins.svn.wordpress.org/gutenberg/${url_path}/"
svn export -q "$gutenberg_plugin_svn_url" "$WP_CORE_DIR/src/wp-content/plugins/gutenberg"
echo "done"
fi

if [[ ! -z $INSTALL_PWA_PLUGIN ]]; then
echo -n "Installing PWA 0.2-alpha2..."
wget -O "$WP_CORE_DIR/src/wp-content/plugins/pwa.zip" https://github.com/xwp/pwa-wp/releases/download/0.2-alpha2/pwa.zip
echo -n "Installing PWA plugin..."
wget -O "$WP_CORE_DIR/src/wp-content/plugins/pwa.zip" https://downloads.wordpress.org/plugin/pwa.zip
unzip -d "$WP_CORE_DIR/src/wp-content/plugins/pwa/" "$WP_CORE_DIR/src/wp-content/plugins/pwa.zip"
echo "done"
fi
Expand Down
13 changes: 12 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"react/no-unused-prop-types": "error",
"react/self-closing-comp": "error",
"import/no-unresolved": [ "error", {
"ignore": [ "jquery", "amp-block-editor-data", "amp-setup" ]
"ignore": [ "jquery", "amp-block-editor-data", "amp-settings" ]
} ],
"import/order": [ "error", { "groups": [ "builtin", [ "external", "unknown" ], "internal", "parent", "sibling", "index" ] } ],
"jsdoc/check-indentation": "error",
Expand Down Expand Up @@ -104,6 +104,17 @@
"jest/prefer-expect-assertions": "off",
"jest/prefer-inline-snapshots": "off"
}
},
{
"files": [
"assets/src/mobile-redirection.js"
],
"globals": {
"AMP_MOBILE_REDIRECTION": false,
"location": false,
"navigator": false,
"sessionStorage": false
}
}
]
}
7 changes: 4 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lib/optimizer/resources/local_fallback/* linguist-generated=true
lib/optimizer/tests/spec/* linguist-generated=true
*.snap linguist-generated=true
lib/optimizer/resources/local_fallback/* linguist-generated=true
lib/optimizer/tests/spec/* linguist-generated=true
*.snap linguist-generated=true
includes/sanitizers/class-amp-allowed-tags-generated.php linguist-generated=true
11 changes: 7 additions & 4 deletions .github/workflows/build-test-measure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
push:
branches:
- develop
- master
# Include all release branches.
- '*.*'
pull_request:
# Run workflow whenever a PR is opened, updated (synchronized), or marked ready for review.
types: [opened, synchronize, ready_for_review]
Expand All @@ -13,7 +14,8 @@ jobs:

dev-zip:
name: Build dev build ZIP and upload as GHA artifact
if: github.event.pull_request.draft == false
# Only run if it is not a draft PR and the PR is not from a forked repository.
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
outputs:
branch-name: ${{ steps.retrieve-branch-name.outputs.branch_name }}
Expand Down Expand Up @@ -84,7 +86,8 @@ jobs:

prod-zip:
name: Build prod build ZIP and upload as GHA artifact
if: github.event.pull_request.draft == false
# Only run if it is not a draft PR and the PR is not from a forked repository.
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
outputs:
branch-name: ${{ steps.retrieve-branch-name.outputs.branch_name }}
Expand Down Expand Up @@ -214,7 +217,7 @@ jobs:
id: get-comment-body
# Setting a multi-line output requires escaping line-feeds. See <https://github.community/t/set-output-truncates-multiline-strings/16852/3>.
run: |
body="Plugin builds for ${{ github.sha }} are ready :bellhop_bell:!
body="Plugin builds for ${{ github.event.pull_request.head.sha }} are ready :bellhop_bell:!
- Download [development build](https://storage.googleapis.com/ampwp_github_artifacts/${{ github.ref }}/dev/amp.zip)
- Download [production build](https://storage.googleapis.com/ampwp_github_artifacts/${{ github.ref }}/prod/amp.zip)"
body="${body//$'\n'/'%0A'}"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ built
.idea/
/lib/*/vendor/
/lib/*/composer.lock
/phpcs.xml
/phpunit.xml
/.lighthouseci
16 changes: 6 additions & 10 deletions phpcs.xml → .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<rule ref="WordPress-Core">
<exclude name="Generic.Arrays.DisallowShortArraySyntax" />
<exclude name="Generic.Commenting.DocComment.MissingShort" />
<exclude name="WordPress.PHP.DisallowShortTernary" />
</rule>

Expand All @@ -29,17 +30,12 @@
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>tests/*</exclude-pattern>
<exclude-pattern>src/*</exclude-pattern>
<exclude-pattern>includes/admin/class-amp-customizer.php</exclude-pattern>
<exclude-pattern>includes/embeds/class-amp-dailymotion-embed.php</exclude-pattern>
<exclude-pattern>includes/embeds/class-amp-facebook-embed.php</exclude-pattern>
<exclude-pattern>includes/embeds/class-amp-gallery-embed.php</exclude-pattern>
<exclude-pattern>includes/embeds/class-amp-instagram-embed.php</exclude-pattern>
<exclude-pattern>includes/embeds/class-amp-pinterest-embed.php</exclude-pattern>
<exclude-pattern>includes/embeds/class-amp-soundcloud-embed.php</exclude-pattern>
<exclude-pattern>includes/embeds/class-amp-twitter-embed.php</exclude-pattern>
<exclude-pattern>includes/embeds/class-amp-vimeo-embed.php</exclude-pattern>
<exclude-pattern>includes/embeds/class-amp-vine-embed.php</exclude-pattern>
</rule>

<rule ref="WordPress.WP.GlobalVariablesOverride.Prohibited">
<exclude-pattern>tests/*</exclude-pattern>
</rule>

<rule ref="WordPress.Arrays.MultipleStatementAlignment.LongIndexSpaceBeforeDoubleArrow">
<exclude-pattern>tests/test-tag-and-attribute-sanitizer.php</exclude-pattern>
</rule>
Expand Down
14 changes: 13 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
"no-descending-specificity": null,
"no-duplicate-selectors": null,
"number-leading-zero": null,
"selector-type-no-unknown": [ true, { "ignore": ["custom-elements"] } ]
"selector-type-no-unknown": [ true, { "ignore": ["custom-elements"] } ],
"selector-class-pattern": [
"^[a-z]+(-[a-z]+)*",
{
"message": "Selector should use lowercase and separate words with hyphens (selector-class-pattern)"
}
],
"selector-id-pattern": [
"^[a-z]+(-[a-z]+)*",
{
"message": "Selector should use lowercase and separate words with hyphens (selector-id-pattern)"
}
]
}
}
45 changes: 24 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Tell Travis CI we're using PHP
language: php

# Using trusty instead of precise because we don't need PHP 5.2 or 5.3 anymore.
dist: trusty
dist: xenial

services:
- mysql

addons:
apt:
Expand All @@ -25,7 +27,6 @@ cache:

branches:
only:
- master
- develop
- /^\d+\.\d+$/

Expand All @@ -34,6 +35,7 @@ install:
- composer install
- export DEV_LIB_PATH=vendor/xwp/wp-dev-lib/scripts
- export DIFF_HEAD=HEAD
- export DEFAULT_BASE_BRANCH=develop
- source "$DEV_LIB_PATH/travis.install.sh"

before_script:
Expand All @@ -60,13 +62,13 @@ jobs:
- env: WP_VERSION=trunk DEV_LIB_ONLY=phpunit INSTALL_PWA_PLUGIN=1
# PHP and JavaScript unit tests (7.3, WordPress trunk, with code coverage)
- env: WP_VERSION=latest DEV_LIB_ONLY=phpunit INSTALL_PWA_PLUGIN=1 RUN_PHPUNIT_COVERAGE=1
# PHP unit tests (7.4, WordPress trunk)
# PHP unit tests (8.0, WordPress trunk)
- env: WP_VERSION=trunk DEV_LIB_ONLY=phpunit INSTALL_PWA_PLUGIN=1
php: 7.4snapshot
php: nightly
include:
- stage: lint
name: Lint (PHP, JavaScript, and configuration files)
php: "7.3"
php: "7.4"
env: WP_VERSION=latest DEV_LIB_ONLY=phpsyntax
before_script:
- phpenv config-rm xdebug.ini || echo "xdebug.ini does not exist."
Expand All @@ -82,22 +84,22 @@ jobs:

- stage: analyze
name: Static analysis (PHP)
php: "7.3"
php: "7.4"
install:
- composer install
script:
- composer analyze

- stage: test
name: JavaScript unit tests
php: "7.3"
php: "7.4"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs,eslint,xmllint,phpsyntax,phpunit
script:
- source "$DEV_LIB_PATH/travis.script.sh"
- npm run test:js -- --ci --cacheDirectory="$HOME/.jest-cache"

- name: E2E tests
php: "7.3"
php: "7.4"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs,eslint,xmllint,phpsyntax,phpunit
install:
- nvm install
Expand All @@ -110,10 +112,14 @@ jobs:
- npm run test:e2e:ci
- npm run env:stop

- name: PHP unit tests w/ external-http (7.3, WordPress latest)
php: "7.3"
- name: PHP unit tests w/ external-http (7.4, WordPress latest)
php: "7.4"
env: WP_VERSION=latest DEV_LIB_ONLY=phpunit INSTALL_PWA_PLUGIN=1 PHPUNIT_EXTRA_SUITE=external-http

- name: PHP unit tests (7.3, WordPress latest)
php: "7.3"
env: WP_VERSION=latest DEV_LIB_ONLY=phpunit,phpsyntax INSTALL_PWA_PLUGIN=1

- name: PHP unit tests (7.2, WordPress latest)
php: "7.2"
env: WP_VERSION=latest DEV_LIB_ONLY=phpunit,phpsyntax INSTALL_PWA_PLUGIN=1
Expand All @@ -134,17 +140,13 @@ jobs:
php: "5.6"
env: WP_VERSION=4.9 DEV_LIB_ONLY=phpunit,phpsyntax PHPUNIT_EXTRA_SUITE=external-http

- name: PHP unit tests (7.3, WordPress trunk)
php: "7.3"
env: WP_VERSION=trunk DEV_LIB_ONLY=phpunit INSTALL_PWA_PLUGIN=1

- name: PHP unit tests (7.4, WordPress trunk)
php: "7.4snapshot"
- name: PHP unit tests (8.0, WordPress trunk)
php: "nightly"
env: WP_VERSION=trunk DEV_LIB_ONLY=phpunit INSTALL_PWA_PLUGIN=1

- name: PHP and JavaScript unit tests (7.3, WordPress trunk, with code coverage)
- name: PHP and JavaScript unit tests (7.4, WordPress trunk, with code coverage)
if: branch = develop AND type = push
php: "7.3"
php: "7.4"
env: WP_VERSION=latest DEV_LIB_ONLY=phpunit INSTALL_PWA_PLUGIN=1 RUN_PHPUNIT_COVERAGE=1
before_script:
- echo "Running unit tests with code coverage..."
Expand All @@ -166,8 +168,9 @@ jobs:
- composer --working-dir=lib/common test
- composer --working-dir=lib/optimizer test

- name: Libraries that are meant to be externalized (7.3)
php: "7.3"
- name: Libraries that are meant to be externalized (7.4)
php: "7.4"

install:
- composer --working-dir=lib/common install
- composer --working-dir=lib/optimizer install
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module.exports = function( grunt ) {
'use strict';

// Root paths to include in the plugin build ZIP when running `npm run build`.
// Root paths to include in the plugin build ZIP when running `npm run build:prod`.
const productionIncludedRootFiles = [
'LICENSE',
'amp.php',
Expand Down
8 changes: 4 additions & 4 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.6.0-alpha
* Version: 2.0.0-beta1
* Text Domain: amp
* Domain Path: /languages/
* License: GPLv2 or later
Expand All @@ -17,7 +17,7 @@

define( 'AMP__FILE__', __FILE__ );
define( 'AMP__DIR__', dirname( __FILE__ ) );
define( 'AMP__VERSION', '1.6.0-alpha' );
define( 'AMP__VERSION', '2.0.0-beta1' );

/**
* Errors encountered while loading the plugin.
Expand Down Expand Up @@ -158,9 +158,9 @@
$_amp_load_errors->add(
'build_required',
sprintf(
/* translators: %s: composer install && npm install && npm run build */
/* translators: %s: composer install && npm install && npm run build:prod */
__( 'You appear to be running the AMP plugin from source. Please do %s to finish installation.', 'amp' ), // phpcs:ignore WordPress.Security.EscapeOutput
'<code>composer install &amp;&amp; npm install &amp;&amp; npm run build</code>'
'<code>composer install &amp;&amp; npm install &amp;&amp; npm run build:prod</code>'
)
);
}
Expand Down
15 changes: 15 additions & 0 deletions assets/css/src/amp-block-editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,18 @@
.wp-core-ui .edit-post-header .editor-post-preview {
height: 34px;
}

.amp-unavailable-notice {
width: 100%;
margin: 5px 0 2px;
}

.amp-unavailable-notice details > summary {
font-weight: bold;
user-select: none;
cursor: pointer;
}

.amp-unavailable-notice details[open] > summary {
margin-bottom: 1em;
}
Loading

0 comments on commit 7b2a8c8

Please sign in to comment.