Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

update travis.yml and karma to upload karma bundles to S3 for debugging

Christopher Hiller522d943be1a9
diff --git a/.travis.yml b/.travis.yml
index 9cc01a25..609b8dae 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,13 +9,19 @@ dist: trusty
language: node_js
env:
- global: PHANTOMJS_CDNURL='https://cnpmjs.org/downloads'
+ global:
+ # phantomjs hosts binaries @ bitbucket, which has fairly restrictive
+ # rate-limiting. pull it from this sketchy site in China instead.
+ - PHANTOMJS_CDNURL='https://cnpmjs.org/downloads'
+ # we're going to use s3 to temporarily store Karma test bundles for debugging
+ - AWS_ACCESS_KEY_ID=AKIAJ3QQTLQXWXYJ6PTA
+ - secure: k4musDC734E1NFOWaY5qb/l0B9K1cfusFTvMZFayTMs5ubKjeNYCgct2sDSvO5tO7Un935I0sYOOSRPvANPhs8dP1a/8/x0PnwIfnpoCFQCCaI0bWnIQj7nOZ2TaEB/fngZCerCFpNDlzqI6BmaR+XoMvA74v2YD/vVXnzvXNQk=
matrix:
fast_finish: true
include:
- node_js: '6'
- env: TARGET='clean lint test-node test-browser'
+ env: TARGET='clean lint test-node test-browser' S3=1
- node_js: '5'
env: TARGET=test-node
- node_js: '4'
@@ -29,7 +35,11 @@ matrix:
- node_js: '0.10'
env: TARGET=test-node
-script: travis_retry make $TARGET
+before_script: scripts/travis-before-script.sh
+
+script: make $TARGET
+
+after_script: scripts/travis-after-script.sh
notifications:
urls:
@@ -38,9 +48,7 @@ notifications:
on_success: change
on_failure: always
+# attempt to cache phantom binaries
cache:
directories:
- node_modules/phantomjs/lib/phantom
-
-addons:
- artifacts: true
diff --git a/karma.conf.js b/karma.conf.js
index 47867de1..926cb7c9 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -3,11 +3,10 @@
var fs = require('fs');
var path = require('path');
var mkdirp = require('mkdirp');
-var bundleDirpath = path.join(__dirname, '.karma');
+var baseBundleDirpath = path.join(__dirname, '.karma');
module.exports = function(config) {
- mkdirp.sync(bundleDirpath);
-
+ var bundleDirpath;
var cfg = {
frameworks: [
'browserify',
@@ -35,15 +34,11 @@ module.exports = function(config) {
.ignore('pug')
.ignore('supports-color')
.exclude('./lib-cov/mocha')
- .on('bundled', function (err, content) {
- var filepath = path.join(bundleDirpath,
- 'bundle.' + Date.now() + '.js');
+ .on('bundled', function(err, content) {
if (!err) {
- fs.writeFile(filepath, content, function (err) {
- if (!err) {
- console.error('Wrote test bundle to ' + filepath);
- }
- });
+ // write bundle to directory for debugging
+ fs.writeFileSync(path.join(bundleDirpath,
+ 'bundle.' + Date.now() + '.js'), content);
}
});
}
diff --git a/scripts/travis-after-script.sh b/scripts/travis-after-script.sh
new file mode 100755
index 00000000..e93c98f7
--- /dev/null
+++ b/scripts/travis-after-script.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+# syncs Karma test bundles to S3 if $S3 is set
+
+if [ ${S3} ]
+then
+ mkdir -p .karma/${TRAVIS_JOB_NUMBER}
+ cp ./mocha.js ".karma/${TRAVIS_JOB_NUMBER}/mocha.js"
+ aws s3 sync ".karma/${TRAVIS_JOB_NUMBER}" "s3://mochajs/karma-bundles/${TRAVIS_JOB_NUMBER}"
+fi
diff --git a/scripts/travis-before-script.sh b/scripts/travis-before-script.sh
new file mode 100755
index 00000000..e5c6b254
--- /dev/null
+++ b/scripts/travis-before-script.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+# installs awscli from pip if $S3 is set
+
+if [ ${S3} ]
+then
+ sudo pip install awscli
+fi