diff --git a/.travis.yml b/.travis.yml index 2836952f..91e23d00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,42 @@ language: node_js node_js: - - '4' +- stable +- '4' sudo: false env: + matrix: - CXX=g++-4.9 + global: + - secure: QD8wgggmlF0PPOSdQ84JLO9quLMlTDXu3Cg0+UM9yFSyih2ukL/XGn5wxR3B3XmaHfzRqxtrfhjMX6LT7DKFsriolhNVu0kER4zGyrKWK5irxAy2veosyj8qs/R1pXh9qnItlgXrz0fJwpH9o/08q8X+ZjXb0veZ34EMODLbV5zBJXoaHVC6WN62GzInAEEfdB0AEacb44sDIdK++1ujcTFLGnc+LJw8Ck2C/eOWwRhJyiNUrHHTQV3KaM0YtHz+DCz5InC9vWl+BG656AOU5C6PMTvnZ1M3CGfjmXydZoBbDvCQIcB5ylf17tXGoJKevHnmLWm6U3fPVwUwiPiKvisxyNShZw4BEDS7m1b799GnzGOiYsi37aH3G+iAORg1QVqoCAK/yQ77MkkA6a3tlLVHRaInVA6QlFxlbqc8WNlx+fa8lo4L7Y9KPGfr1Bpix/kHQV5JCzKS16Zc7wblTrOvIR/qb8qPfLoxhXi5fUZ3eRuXgR699X1IHJ1LlhkOoBfSiWl88qba01FBLrYSCPeVGb6/N91OFpIlq6eORnzBbc4mtoJSYttvZ45Hu3M5V0KDrGIHr7kNyPThdKr7PVaMXHLCpNrnmBSaxVCU5uhb8Ae3bnLAq/aBxHWZNA8cQ43/s6rS7QqOVJfquXNFYa6V9/QjbU3sJyqIgRzMkAM= addons: apt: sources: - - ubuntu-toolchain-r-test + - ubuntu-toolchain-r-test + - git-core packages: - - g++-4.9 - - libcairo2-dev - - libpango1.0-dev - - libssl-dev - - libjpeg62-dev - - libgif-dev -before_script: - - npm install -g gulp - - npm install -script: - - gulp jshint - - gulp minify - - gulp test + - g++-4.9 + - git + - libcairo2-dev + - libpango1.0-dev + - libssl-dev + - libjpeg62-dev + - libgif-dev +cache: + directories: + - ~/.assets + - ~/.nvm + - node_modules install: - - | - wget http://sourceforge.net/p/tellmatic/git/ci/master/tree/img/arial.ttf?format=raw -O arial.ttf - mkdir -p ~/.fonts - mv arial.ttf ~/.fonts - fc-cache -f -v +- travis/install-assets.sh +before_script: +- travis/setup-git.sh +- npm set progress=false +- which gulp || npm install -g gulp +- npm install +script: +- gulp jshint +- gulp minify +- gulp test +- gulp dist +after_script: +- '[ "${TRAVIS_BRANCH}" = "develop" ] && [ "${TRAVIS_NODE_VERSION}" = "stable" ] && travis/deploy-prebuilt.sh' diff --git a/gulp/tasks/build.js b/gulp/tasks/build.js index 19a53ac9..7fb687e5 100644 --- a/gulp/tasks/build.js +++ b/gulp/tasks/build.js @@ -70,7 +70,7 @@ buildNames.forEach(function(name) { gulp.task('clean:build:' + name, function() { return del([ - 'dist/paper-' + name + '.js' + 'dist/paper-' + name + '*.js' ]); }); }); diff --git a/gulp/tasks/dist.js b/gulp/tasks/dist.js index 5376ca8a..33f0dc9e 100644 --- a/gulp/tasks/dist.js +++ b/gulp/tasks/dist.js @@ -11,10 +11,11 @@ */ var gulp = require('gulp'), + del = require('del'), merge = require('merge-stream'), zip = require('gulp-zip'); -gulp.task('dist', ['minify', 'docs'], function() { +gulp.task('dist', ['minify', 'docs', 'clean:dist'], function() { return merge( gulp.src([ 'dist/paper-full*.js', @@ -26,6 +27,12 @@ gulp.task('dist', ['minify', 'docs'], function() { 'dist/docs/**/*' ], { base: 'dist' }) ) - .pipe(zip('/paperjs.zip')) + .pipe(zip('paperjs.zip')) .pipe(gulp.dest('dist')); }); + +gulp.task('clean:dist', function() { + return del([ + 'dist/paperjs.zip' + ]); +}); diff --git a/gulp/tasks/test.js b/gulp/tasks/test.js index b85e970e..8c471149 100644 --- a/gulp/tasks/test.js +++ b/gulp/tasks/test.js @@ -36,6 +36,6 @@ gulp.task('test:node', ['minify:acorn'], function(callback) { // present and handles the loading transparently. { path: '../dist/paper-full.js', namespace: 'paper' } ], - timeout: 20 + timeout: 40 })); }); diff --git a/projects/paperjs.sublime-project b/projects/paperjs.sublime-project index 5671ec4e..7275b5be 100644 --- a/projects/paperjs.sublime-project +++ b/projects/paperjs.sublime-project @@ -14,6 +14,9 @@ "path": "../gulp", "folder_exclude_patterns": ["jsdoc"] }, + { + "path": "../travis", + }, { "path": "..", "name": "root", diff --git a/travis/deploy-prebuilt.sh b/travis/deploy-prebuilt.sh new file mode 100755 index 00000000..491eabc8 --- /dev/null +++ b/travis/deploy-prebuilt.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# Paper.js - The Swiss Army Knife of Vector Graphics Scripting. +# http://paperjs.org/ +# +# Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ +# +# Distributed under the MIT license. See LICENSE file for details. +# +# All rights reserved. + +# Determine target for commit messages. +if [ -n "${TRAVIS_TAG}" ]; then + TARGET=$TRAVIS_TAG +else + TARGET="commit ${TRAVIS_COMMIT}" +fi + +# Set up a temporary folder to prepare distribution files. +TMP=~/tmp +mkdir $TMP +# Copy everything to the this folder first, then clean up. +cp -a dist $TMP/ +# Copy all visible root files (LICENSE.txt, README.md, package.json, etc.). +cp -p *.* $TMP/ +# No need for .gitignore or build files. +rm $TMP/dist/.gitignore +rm $TMP/gulpfile.js +# Reset the branch so we can switch to prebuilt/module and prebuilt/dist after. +git clean -fdx --quiet # Remove all ignored and untracked files from the build. +git checkout -- . # Reset all tracked files to the original state. + +# Create a new orphaned buid/dist branch and switch to it. +git checkout --orphan prebuilt/dist +# Remove and delete all tracked files left after the switch. +git rm -rf --quiet . +# Move the zipped dist file into the branch and commit. +mv $TMP/dist/paperjs.zip . +git add --all * +git commit -m "Prebuilt package for ${TARGET}" +# Push with --force since we're always overriding the previous built version. +git push -u origin prebuilt/dist --force + +# Specifically fetch and check out the prebuilt/module branch from origin. +git fetch origin +refs/heads/prebuilt/module:refs/remotes/origin/prebuilt/module +git checkout -b prebuilt/module -t origin/prebuilt/module +# Remove everything so we can fully replace it. Git will create the diffs. +rm -fr * +mv $TMP/* . +git add --all * +git commit -m "Prebuilt module for ${TARGET}" +git push -u origin prebuilt/module +rmdir $TMP diff --git a/travis/install-assets.sh b/travis/install-assets.sh new file mode 100755 index 00000000..9ca3d767 --- /dev/null +++ b/travis/install-assets.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Paper.js - The Swiss Army Knife of Vector Graphics Scripting. +# http://paperjs.org/ +# +# Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ +# +# Distributed under the MIT license. See LICENSE file for details. +# +# All rights reserved. + +# Download and instal assets, but only if they haven't been installed from the +# cache yet. +if [ ! -d ~/.assets ] || [ -z "$(ls -A ~/.assets)" ]; then + mkdir -p ~/.assets + wget http://sourceforge.net/p/tellmatic/git/ci/master/tree/img/arial.ttf?format=raw -O ~/.assets/arial.ttf +fi + +# Install fonts each time, as they can't be cached in Travis. +mkdir -p ~/.fonts +cp -p ~/.assets/arial.ttf ~/.fonts +fc-cache -f -v diff --git a/travis/setup-git.sh b/travis/setup-git.sh new file mode 100755 index 00000000..3365f305 --- /dev/null +++ b/travis/setup-git.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Paper.js - The Swiss Army Knife of Vector Graphics Scripting. +# http://paperjs.org/ +# +# Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey +# http://scratchdisk.com/ & http://jonathanpuckey.com/ +# +# Distributed under the MIT license. See LICENSE file for details. +# +# All rights reserved. + +# Setup the git user with the right credentials so we can push to the paper.js +# repository. The GH_TOKEN is generated as a secure environment variable: +# +# travis encrypt GH_TOKEN= --add +git config user.name "Paper.js Bot" +git config user.email "bot@paperjs.org" +git config credential.helper "store --file=.git/credentials" +echo "https://${GH_TOKEN}:@github.com" > .git/credentials + +# It took ages to figures this one out: +# Travis CI sets up the origin to only fetch the specific branch, e.g.: +# fetch = +refs/heads/develop:refs/remotes/origin/develop +# Since we want to deploy to prebuilt/module also, we need to change that: +# fetch = +refs/heads/*:refs/remotes/origin/* +# We can change the fetch setting by removing and adding the origin again: +git remote remove origin +git remote add origin https://github.com/paperjs/paper.js.git + +# Avoid detached head... +git checkout $TRAVIS_BRANCH