Skip to content

Commit

Permalink
Merge branch '0.7' of https://github.com/Automattic/amp-wp into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Apr 18, 2018
2 parents 286381c + c90f4a1 commit ac53ee7
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 71 deletions.
74 changes: 36 additions & 38 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,53 +20,51 @@ cache:
- $HOME/phpunit-bin
- $HOME/deployment-targets

matrix:
include:
- php: "5.3"
env: WP_VERSION=latest DEV_LIB_SKIP=composer,phpcs
- php: "5.4"
env: WP_VERSION=4.7 DEV_LIB_SKIP=composer,phpcs
- php: "5.5"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs
- php: "5.6"
env: WP_VERSION=4.8 DEV_LIB_SKIP=phpcs
- php: "5.6"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs
- php: "7.0"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs
- php: "7.1"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs
- php: "7.2"
env: WP_VERSION=trunk DEPLOY_TEST_SITE=true

install:
- if [[ $DEV_LIB_SKIP =~ composer ]]; then composer install --no-dev; fi
- nvm install 6 && nvm use 6
- export DEV_LIB_PATH=dev-lib
- source $DEV_LIB_PATH/travis.install.sh
- echo "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST"
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH"
- echo "TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE"
- echo "TRAVIS_PULL_REQUEST_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH"

script:
- source $DEV_LIB_PATH/travis.script.sh

after_script:
- source $DEV_LIB_PATH/travis.after_script.sh

after_success:
- |
if [[ $DEPLOY_TEST_SITE == true ]] &&
[[ $TRAVIS_PULL_REQUEST == false ]] &&
[[ $TRAVIS_SECURE_ENV_VARS == true ]] &&
( [[ $TRAVIS_BRANCH =~ ^[a-z][a-z0-9-]{0,10}$ ]] || [[ $TRAVIS_BRANCH =~ [0-9]+\.[0-9]+ ]] ) &&
! [[ $TRAVIS_BRANCH =~ ^(live|test|dev|settings|team|support|debug|multidev|files|tags|billing)$ ]];
then
pantheon_branch=$( echo $TRAVIS_BRANCH | sed 's/^\([0-9]\)/v\1/' | sed 's/[^a-z0-9-]/-/' )
echo "Initializing deployment to Pantheon branch: $pantheon_branch"
eval "$(ssh-agent -s)"
openssl aes-256-cbc -K $encrypted_7eb11f40d4e9_key -iv $encrypted_7eb11f40d4e9_iv -in bin/keys/id_rsa_ampconfdemo.enc -out bin/keys/id_rsa_ampconfdemo -d && chmod 600 bin/keys/id_rsa_ampconfdemo
./bin/deploy-travis-pantheon.sh ampconfdemo db7f3307-9808-4753-aaa4-acb387c94472 $(pwd)/bin/keys/id_rsa_ampconfdemo $pantheon_branch
fi
jobs:
include:
- stage: test
php: "7.2"
env: WP_VERSION=trunk
- php: "5.3"
env: WP_VERSION=latest DEV_LIB_SKIP=composer,phpcs
- php: "5.4"
env: WP_VERSION=4.7 DEV_LIB_SKIP=composer,phpcs
- php: "5.5"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs
- php: "5.6"
env: WP_VERSION=4.8 DEV_LIB_SKIP=phpcs
- php: "5.6"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs
- php: "7.0"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs
- php: "7.1"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs
- stage: deploy
if: type = push AND fork = false AND ( branch =~ ^[a-z][a-z0-9-]{0,10}$ OR branch =~ ^[0-9]+\.[0-9]+$ ) AND NOT branch IN ( live, test, dev, settings, team, support, debug, multidev, files, tags, billing )
php: "7.1"
env: WP_VERSION=latest DEV_LIB_ONLY=composer,grunt
script:
- |
eval "$(ssh-agent -s)"
pantheon_branch=$( echo $TRAVIS_BRANCH | sed 's/^\([0-9]\)/v\1/' | sed 's/[^a-z0-9-]/-/' )
echo "Initializing deployment to Pantheon branch: $pantheon_branch"
openssl aes-256-cbc -K $encrypted_7eb11f40d4e9_key -iv $encrypted_7eb11f40d4e9_iv -in bin/keys/id_rsa_ampconfdemo.enc -out bin/keys/id_rsa_ampconfdemo -d
chmod 600 bin/keys/id_rsa_ampconfdemo
./bin/deploy-travis-pantheon.sh \
ampconfdemo \
db7f3307-9808-4753-aaa4-acb387c94472 \
$(pwd)/bin/keys/id_rsa_ampconfdemo \
$pantheon_branch
after_script: skip
105 changes: 77 additions & 28 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env node */
/* jshint node:true */
/* eslint-disable camelcase */
/* eslint-disable camelcase, no-console, no-param-reassign */

module.exports = function( grunt ) {
'use strict';
Expand Down Expand Up @@ -77,39 +77,89 @@ module.exports = function( grunt ) {
] );

grunt.registerTask( 'build', function() {
var done = this.async();
var done, spawnQueue, stdout;
done = this.async();
spawnQueue = [];
stdout = [];

grunt.util.spawn(
spawnQueue.push(
{
cmd: 'git',
args: [ 'ls-files' ]
args: [ '--no-pager', 'log', '-1', '--format=%h', '--date=short' ]
},
function( err, res ) {
var paths;
if ( err ) {
throw new Error( err.message );
{
cmd: 'git',
args: [ 'ls-files' ]
}
);

function finalize() {
var commitHash, lsOutput, versionAppend, paths;
commitHash = stdout.shift();
lsOutput = stdout.shift();
versionAppend = commitHash + '-' + new Date().toISOString().replace( /\.\d+/, '' ).replace( /-|:/g, '' );

paths = lsOutput.trim().split( /\n/ ).filter( function( file ) {
return ! /^(\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|tests|wp-assets|dev-lib|readme\.md|composer\..*)/.test( file );
} );
paths.push( 'vendor/autoload.php' );
paths.push( 'vendor/composer/**' );
paths.push( 'vendor/sabberworm/php-css-parser/lib/**' );

grunt.task.run( 'clean' );
grunt.config.set( 'copy', {
build: {
src: paths,
dest: 'build',
expand: true,
options: {
noProcess: [ '*/**', 'LICENSE', 'jetpack-helper.php', 'wpcom-helper.php' ], // That is, only process amp.php and readme.txt.
process: function( content, srcpath ) {
var matches, version, versionRegex;
if ( /amp\.php$/.test( srcpath ) ) {
versionRegex = /(\*\s+Version:\s+)(\d+(\.\d+)+-\w+)/;

// If not a stable build (e.g. 0.7.0-beta), amend the version with the git commit and current timestamp.
matches = content.match( versionRegex );
if ( matches ) {
version = matches[ 2 ] + '-' + versionAppend;
console.log( 'Updating version in amp.php to ' + version );
content = content.replace( versionRegex, '$1' + version );
content = content.replace( /(define\(\s*'AMP__VERSION',\s*')(.+?)(?=')/, '$1' + version );
}
}
return content;
}
}
}
} );
grunt.task.run( 'readme' );
grunt.task.run( 'copy' );

grunt.task.run( 'shell:create_release_zip' );

done();
}

paths = res.stdout.trim().split( /\n/ ).filter( function( file ) {
return ! /^(\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|tests|wp-assets|dev-lib|readme\.md|composer\..*)/.test( file );
} );
paths.push( 'vendor/autoload.php' );
paths.push( 'vendor/composer/**' );
paths.push( 'vendor/sabberworm/php-css-parser/lib/**' );

grunt.config.set( 'copy', {
build: {
src: paths,
dest: 'build',
expand: true
function doNext() {
var nextSpawnArgs = spawnQueue.shift();
if ( ! nextSpawnArgs ) {
finalize();
} else {
grunt.util.spawn(
nextSpawnArgs,
function( err, res ) {
if ( err ) {
throw new Error( err.message );
}
stdout.push( res.stdout );
doNext();
}
} );
grunt.task.run( 'readme' );
grunt.task.run( 'copy' );
grunt.task.run( 'shell:create_release_zip' );
done();
);
}
);
}

doNext();
} );

grunt.registerTask( 'create-release-zip', [
Expand All @@ -122,7 +172,6 @@ module.exports = function( grunt ) {
'jshint',
'shell:phpunit',
'shell:verify_matching_versions',
'wp_deploy',
'clean'
'wp_deploy'
] );
};
4 changes: 0 additions & 4 deletions bin/deploy-travis-pantheon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ if [ ! -e node_modules/.bin ]; then
fi
PATH="node_modules/.bin/:$PATH"
grunt build
version_append=$(git --no-pager log -1 --format="%h" --date=short)-$(date "+%Y%m%dT%H%M%S")
rsync -avz --delete ./build/ "$repo_dir/wp-content/plugins/amp/"
cat ./build/amp.php |
sed "/^ \* Version:/ s/$/-$version_append/" |
sed "/^define( 'AMP__VERSION/ s/' );/-$version_append' );/" > "$repo_dir/wp-content/plugins/amp/amp.php"
git --no-pager log -1 --format="Build AMP plugin at %h: %s" > /tmp/commit-message.txt

# Commit and deploy.
Expand Down
2 changes: 1 addition & 1 deletion dev-lib
Submodule dev-lib updated 4 files
+1 −0 .gitignore
+26 −0 composer.json
+10 −0 readme.md
+14 −12 travis.install.sh
1 change: 1 addition & 0 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ public static function purge_amp_query_vars() {
'__amp_source_origin',
'_wp_amp_action_xhr_converted',
'amp_latest_update_time',
'amp_last_check_time',
);

// Scrub input vars.
Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public function test_purge_amp_query_vars() {
// phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification
$bad_query_vars = array(
'amp_latest_update_time' => '1517199956',
'amp_last_check_time' => '1517599126',
'__amp_source_origin' => home_url(),
);
$ok_query_vars = array(
Expand Down

0 comments on commit ac53ee7

Please sign in to comment.