Skip to content

Commit

Permalink
Merge branch '0.7' of https://github.com/Automattic/amp-wp into fix/0…
Browse files Browse the repository at this point in the history
….7-vip-review
  • Loading branch information
westonruter committed Apr 26, 2018
2 parents ce239b5 + dcb882f commit ac936d3
Show file tree
Hide file tree
Showing 76 changed files with 8,516 additions and 1,552 deletions.
2 changes: 2 additions & 0 deletions .dev-lib
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PATH_EXCLUDES_PATTERN=includes/lib/
DEFAULT_BASE_BRANCH=develop
ASSETS_DIR=wp-assets
PROJECT_SLUG=amp
SKIP_ECHO_PATHS_SCOPE=1

function after_wp_install {
echo "Installing REST API..."
Expand Down
77 changes: 38 additions & 39 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,10 @@ language: php
# Opt to use Travis container-based environment.
sudo: false

# PHP version used in first build configuration.
php:
- "7.1"

# WordPress version used in first build configuration.
env:
- WP_VERSION=latest

# Newer versions like trusty don't have PHP 5.2 or 5.3
# https://blog.travis-ci.com/2017-07-11-trusty-as-default-linux-is-coming
dist: precise

# Next we define our matrix of additional build configurations to test against.
# The versions listed above will automatically create our first configuration,
# so it doesn't need to be re-defined below.

# WP_VERSION specifies the tag to use. The way these tests are configured to run
# requires at least WordPress 3.8. Specify "latest" to test against SVN trunk.

# Note that Travis CI supports listing these above to automatically build a
# matrix of configurations, but we're being nice here by manually building a
# total of four configurations even though we're testing 4 versions of PHP
# along with 2 versions of WordPress (which would build 8 configs otherwise).
# This takes half as long to run while still providing adequate coverage.

notifications:
email:
on_success: never
Expand All @@ -39,24 +18,7 @@ cache:
- node_modules
- vendor
- $HOME/phpunit-bin

matrix:
include:
- php: "5.3"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs
- php: "5.3"
env: WP_VERSION=4.7 DEV_LIB_SKIP=phpcs
- php: "5.4"
env: WP_VERSION=latest
- php: "5.4"
env: WP_VERSION=4.7
- php: "7.0"
env: WP_VERSION=latest
- php: "7.0"
env: WP_VERSION=4.7
# 7.1 / latest already included above as first build.
- php: "7.1"
env: WP_VERSION=4.7
- $HOME/deployment-targets

install:
- nvm install 6 && nvm use 6
Expand All @@ -68,3 +30,40 @@ script:

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

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
90 changes: 69 additions & 21 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-env node */
/* jshint node:true */
/* eslint-disable no-param-reassign */

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

grunt.registerTask( 'build', function() {
var done = this.async();
var 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 ) {
if ( err ) {
throw new Error( err.message );
{
cmd: 'git',
args: [ 'ls-files' ]
}
);

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

grunt.task.run( 'clean' );
grunt.config.set( 'copy', {
build: {
src: lsOutput.trim().split( /\n/ ).filter( function( file ) {
return ! /^(\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|tests|wp-assets|dev-lib|readme\.md|composer\..*)/.test( file );
} ),
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();
}

grunt.config.set( 'copy', {
build: {
src: res.stdout.trim().split( /\n/ ).filter( function( file ) {
return ! /^(\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|tests|wp-assets|dev-lib|readme\.md)/.test( file );
} ),
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 @@ -115,7 +164,6 @@ module.exports = function( grunt ) {
'jshint',
'shell:phpunit',
'shell:verify_matching_versions',
'wp_deploy',
'clean'
'wp_deploy'
] );
};
Loading

0 comments on commit ac936d3

Please sign in to comment.