-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
65 lines (53 loc) · 1.98 KB
/
Copy pathgulpfile.js
File metadata and controls
65 lines (53 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var gulp = require('gulp');
var spawn = require('child_process').spawn;
// How to define a new [platform]?
// Create ./test/platforms/[platform] directory (Check debian & centos for examples)
var platforms = [ 'centos', 'debian' ];
// steps when test_[PLATFORM] is called
// step 0
gulp.task( 'ohmage_test_setup', function( cb ) {
spawnDockerCompose( [ 'up', 'ohmage_test_setup' ], cb );
} );
platforms.forEach( function( platform ) {
gulp.task( 'build_' + platform, function( cb ) {
spawnDockerCompose( [ '-f', './docker-compose.yml',
'-f', './test/platforms/' + platform +'/docker-compose.yml',
'build', '--no-cache', 'test_' + platform
], cb );
} )
// This is a good way to enforce the order in which the services are created.
// ohmage_test_setup must be finished before starting webdriverio tests
// step 1
// this task could be directly called if you need to examine the containers
// after the tests are run.
gulp.task( 'start_test_' + platform, [ 'ohmage_test_setup' ], function ( cb ) {
spawnDockerCompose( [ '-f', './docker-compose.yml',
'-f', './test/platforms/' + platform +'/docker-compose.yml',
'up', 'test_' + platform
], cb );
} );
// step 2
gulp.task( 'test_' + platform, [ 'start_test_' + platform ], function ( cb ) {
gulp.start( 'stop_test_' + platform );
} );
// step 3
gulp.task( 'stop_test_' + platform, function ( cb ) {
spawnDockerCompose( [ '-f', './docker-compose.yml',
'-f', './test/platforms/' + platform + '/docker-compose.yml',
'down'
] );
} );
} );
function spawnDockerCompose( arguments, onExit ) {
cmd = spawn( 'docker-compose', arguments );
cmd.stdout.on( 'data', function (data) {
process.stdout.write( data.toString( ) );
});
cmd.stderr.on( 'data', function (data) {
process.stderr.write( data.toString( ) );
});
cmd.on( 'exit', function ( code ) {
console.log( '[] docker-compose exited with code:' + code.toString( ) );
!!onExit ? onExit( ) : null;
});
}