This repository has been archived by the owner on Feb 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from DominikGuzei/chore/fix-circle-ci-tests
improve and speedup circle ci setup
- Loading branch information
Showing
11 changed files
with
179 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path'); | ||
const spawn = require('child_process').spawn; | ||
const baseDir = path.resolve(__dirname, '../'); | ||
const srcDir = baseDir; | ||
|
||
const cacheMeteor = function() { | ||
console.log('Caching build & dependencies (can take a while the first time)'); | ||
const childProcess = spawn('meteor', ['--raw-logs'], { | ||
cwd: srcDir, | ||
env: process.env | ||
}); | ||
childProcess.stdout.setEncoding('utf8'); | ||
childProcess.stderr.setEncoding('utf8'); | ||
childProcess.stdout.on('data', function(line) { | ||
process.stdout.write(line); | ||
}); | ||
childProcess.stderr.on('data', function(line) { | ||
process.stderr.write(line); | ||
}); | ||
const exitAfterBuild = function exitAfterBuild(line) { | ||
if (line.indexOf('App running at') !== -1) { | ||
childProcess.kill(); | ||
console.log('Done caching build & dependencies'); | ||
} else if ( | ||
line.indexOf('Your application is crashing') !== -1 || | ||
line.indexOf('Errors prevented startup') !== -1) { | ||
childProcess.kill(); | ||
console.error('There were issues whilst trying to cache build & dependencies'); | ||
throw new Error(line); | ||
} | ||
}; | ||
childProcess.stdout.on('data', exitAfterBuild); | ||
childProcess.stderr.on('data', exitAfterBuild); | ||
}; | ||
|
||
cacheMeteor(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export MONGO_URL="mongodb://localhost:27017/cache" | ||
echo "Running meteor to cache it …" | ||
node ./.testing/cache_build_and_dependencies.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Cache Meteor | ||
if [ -d ~/.meteor ]; then sudo ln -s ~/.meteor/meteor /usr/local/bin/meteor; fi | ||
if [ ! -e $HOME/.meteor/meteor ]; then curl https://install.meteor.com | sh; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Cache npm deps | ||
if [ ! -e /home/ubuntu/nvm/versions/node/v5.2.0/lib/node_modules/chimp/bin/chimp.js ]; then npm install -g chimp; fi | ||
if [ ! -e /home/ubuntu/nvm/versions/node/v5.2.0/lib/node_modules/spacejam/bin/spacejam ]; then npm install -g spacejam; fi | ||
npm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
|
||
var path = require('path'); | ||
var extend = require('util')._extend; | ||
var baseDir = path.resolve(__dirname, '../'); | ||
var srcDir = path.resolve(baseDir); | ||
var source = require(srcDir + '/node_modules/shell-source'); | ||
var processes = require('./processes.js'); | ||
var isCi = process.argv[2] === '--ci'; | ||
|
||
var startTestApp = function(onStarted, options) { | ||
return processes.start({ | ||
name: 'Test App', | ||
command: 'meteor --port=3100', | ||
waitForMessage: 'App running at: http://localhost:3100', | ||
options: { | ||
cwd: srcDir, | ||
env: extend(process.env, options) | ||
} | ||
}, function() { | ||
console.log("Test app is running …"); | ||
onStarted(); | ||
}); | ||
}; | ||
|
||
var startChimpWatch = function() { | ||
processes.start({ | ||
name: 'Chimp Watch', | ||
command: 'chimp --ddp=http://localhost:3100 --watch --path=tests --mocha --chai --browser=chrome', | ||
options: { cwd: baseDir } | ||
}); | ||
}; | ||
|
||
var startChimpCi = function() { | ||
var command = 'chimp --ddp=http://localhost:3100 --path=tests --browser=chrome --mocha --chai'; | ||
processes.start({ | ||
name: 'Chimp CI', | ||
command: command, | ||
options: { cwd: baseDir } | ||
}); | ||
}; | ||
|
||
if (isCi) { | ||
// CI mode -> run once | ||
if (process.env.CIRCLECI) { | ||
startTestApp(startChimpCi); | ||
} else { | ||
// Use a different db for local ci testing to avoid nuking of the dev db | ||
startTestApp(startChimpCi, { | ||
MONGO_URL: 'mongodb://localhost:3001/chimp_db' | ||
}); | ||
} | ||
} else { | ||
// DEV mode -> watch | ||
startTestApp(startChimpWatch, { | ||
MONGO_URL: 'mongodb://localhost:3001/chimp_db' | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"use strict"; | ||
var fs = require('fs'); | ||
var exec = require('child_process').exec; | ||
var processes = []; | ||
|
||
/** | ||
* Helper function to start a process and listen for | ||
* specific stdout console output and invoke a callback. | ||
* This is used in this case to listen when the normal dev | ||
* app started its mongoDb, so we can reuse that for the test app. | ||
*/ | ||
module.exports = { | ||
start: function(opts, callback) { | ||
var proc = exec( | ||
opts.command, | ||
opts.options | ||
); | ||
if (opts.waitForMessage) { | ||
proc.stdout.on('data', function waitForMessage(data) { | ||
if (data.toString().match(opts.waitForMessage)) { | ||
if (callback) { | ||
callback(); | ||
} | ||
} | ||
}); | ||
} | ||
if (!opts.silent) { | ||
proc.stdout.pipe(process.stdout); | ||
proc.stderr.pipe(process.stderr); | ||
} | ||
if (opts.logFile) { | ||
var logStream = fs.createWriteStream(opts.logFile, {flags: 'a'}); | ||
proc.stdout.pipe(logStream); | ||
proc.stderr.pipe(logStream); | ||
} | ||
proc.on('close', function(code) { | ||
console.log(opts.name, 'exited with code ' + code); | ||
for (var i = 0; i < processes.length; i += 1) { | ||
processes[i].kill(); | ||
} | ||
process.exit(code); | ||
}); | ||
processes.push(proc); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
machine: | ||
node: | ||
version: 0.10.40 | ||
version: 5.2.0 | ||
dependencies: | ||
cache_directories: | ||
- "~/.npm" | ||
- "~/.meteor" | ||
- "node_modules" | ||
- "./.meteor/local/build" | ||
- "./.meteor/local/bundler-cache" | ||
- "./.meteor/local/isopacks" | ||
- "./.meteor/local/plugin-cache" | ||
- "/home/ubuntu/nvm/versions/node/v5.2.0/bin" | ||
- "/home/ubuntu/nvm/versions/node/v5.2.0/lib/node_modules" | ||
override: | ||
- curl https://install.meteor.com | /bin/sh | ||
- meteor npm install | ||
- ./.testing/cache_meteor.sh | ||
- ./.testing/cache_npm_dependencies.sh | ||
- ./.testing/cache_build_and_dependencies.sh | ||
- chimp --path=features # Cache chimp deps by running it without any tests | ||
checkout: | ||
post: | ||
- git submodule update --init | ||
test: | ||
pre: | ||
- mkdir -p $CIRCLE_TEST_REPORTS/cucumber | ||
override: | ||
- meteor npm test | ||
- ./tests/acceptance_run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
node ./.testing/chimp.js --ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
node ./.testing/chimp.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters