From 5472a22988627acb25fa36559ffc4927395da981 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 23 Jul 2015 12:08:38 -0500 Subject: [PATCH] snapshot updates --- gulpfile.js | 17 ++---- .../nav/test/basic/pages/first-page.ts | 7 +-- .../nav/test/basic/pages/second-page.ts | 2 - scripts/e2e/e2e-publish.js | 60 ++++++++++++++++--- scripts/snapshot/snapshot.task.js | 16 +++-- 5 files changed, 71 insertions(+), 31 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 08e2ccc1a6..8a9812be07 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -61,7 +61,6 @@ gulp.task('clean.build', function(done) { 'e2e', 'sass', 'fonts', - 'vendor', done ); }) @@ -73,7 +72,6 @@ gulp.task('build', function(done) { 'e2e', 'sass', 'fonts', - 'vendor', done ); }) @@ -86,7 +84,6 @@ gulp.task('watch', function(done) { 'e2e', 'sass', 'fonts', - 'vendor', 'serve', function() { watch( @@ -173,9 +170,12 @@ gulp.task('tests', function() { }) gulp.task('copy-scripts', function(){ - gulp.src(['scripts/resources/*.js', 'config.js', 'dist/js/ionic.bundle.js', - 'dist/vendor/web-animations-js/web-animations.min.js']) - .pipe(gulp.dest('dist/lib')); + gulp.src([ + 'scripts/resources/*.js', + 'scripts/vendor/web-animations-js/web-animations.min.js', + 'config.js', + 'dist/js/ionic.bundle.js' + ]).pipe(gulp.dest('dist/lib')); }) gulp.task('e2e', ['copy-scripts'], function() { @@ -279,11 +279,6 @@ gulp.task('fonts', function() { .pipe(gulp.dest('dist/fonts')); }); -gulp.task('vendor', function() { - return gulp.src(['scripts/vendor/**/*']) - .pipe(gulp.dest('dist/vendor')); -}); - require('./scripts/snapshot/snapshot.task')(gulp, argv, buildConfig); gulp.task('karma', function() { diff --git a/ionic/components/nav/test/basic/pages/first-page.ts b/ionic/components/nav/test/basic/pages/first-page.ts index b43704bd6e..235cad22a9 100644 --- a/ionic/components/nav/test/basic/pages/first-page.ts +++ b/ionic/components/nav/test/basic/pages/first-page.ts @@ -8,13 +8,13 @@ import {ThirdPage} from './third-page'; @IonicView({ template: '' + '' + - 'First Page: {{ val }}' + + 'First Page' + '' + '' + '' + '' + '' + - '

First Page: {{ val }}

' + + '

First Page

' + '

' + '

' + '

' + @@ -29,10 +29,7 @@ export class FirstPage { app: IonicApp, config: IonicConfig ) { - console.log('FirstPage constructor'); - this.nav = nav; - this.val = Math.round(Math.random() * 8999) + 1000; this.pushPage = SecondPage; this.pushData = { diff --git a/ionic/components/nav/test/basic/pages/second-page.ts b/ionic/components/nav/test/basic/pages/second-page.ts index 7e7d25cca0..dd34d485fe 100644 --- a/ionic/components/nav/test/basic/pages/second-page.ts +++ b/ionic/components/nav/test/basic/pages/second-page.ts @@ -11,7 +11,6 @@ import {FirstPage} from './first-page';

-

Random: {{ val }}

` @@ -23,7 +22,6 @@ export class SecondPage { ) { this.nav = nav; this.params = params; - this.val = Math.round(Math.random() * 8999) + 1000; console.log('Second page params:', params); } diff --git a/scripts/e2e/e2e-publish.js b/scripts/e2e/e2e-publish.js index ba592dbba5..0a9d94452b 100644 --- a/scripts/e2e/e2e-publish.js +++ b/scripts/e2e/e2e-publish.js @@ -5,7 +5,7 @@ module.exports = function(options) { var path = require('path'); var request = require('request'); var inputDir = path.join(__dirname, '../../dist'); - + var uploadQueue = []; function uploadFiles(dir, urlPath) { fs.readdir(dir, function(err, list) { @@ -26,27 +26,60 @@ module.exports = function(options) { }); }); + + setTimeout(postNextUpload, 100); } function uploadFile(archiveFileUrlPath, archiveFileLocalPath) { - var formData = { + uploadQueue.push({ url_path: archiveFileUrlPath, + local_path: archiveFileLocalPath, group_id: options.groupId, app_id: options.appId, test_id: options.testId, access_key: process.env.IONIC_SNAPSHOT_KEY - }; + }); + } + + function postNextUpload() { + var uploadData = null; + + var totalUploading = 0; + + for (var i = 0; i < uploadQueue.length; i++) { + if (uploadQueue[i].status === 'uploaded') { + continue; + + } else if (uploadQueue[i].status === 'uploading') { + totalUploading++; + continue; + + } else { + uploadData = uploadQueue[i]; + } + } + + if (!uploadData || totalUploading > 20) { + return; + + } else if (options.verbose) { + console.log('Uploading: ' + uploadData.url_path); + } + + uploadData.status = 'uploading'; request.post({ uri: 'http://' + options.domain + '/e2e/upload-url', - formData: formData + formData: uploadData }, function(err, httpResponse, body) { if (err) { + uploadData.status = 'failed'; console.error('Get upload failed:', err); + } else { if (httpResponse.statusCode == 200) { - uploadE2E(body, archiveFileUrlPath, archiveFileLocalPath); + uploadE2E(body, uploadData); } else { console.error('Get upload error:', httpResponse.statusCode, body); } @@ -55,9 +88,9 @@ module.exports = function(options) { ); } - function uploadE2E(uploadUrl, archiveFileUrlPath, archiveFileLocalPath) { + function uploadE2E(uploadUrl, uploadData) { var formData = { - file: fs.createReadStream(archiveFileLocalPath) + file: fs.createReadStream(uploadData.local_path) }; request.post({ @@ -65,11 +98,22 @@ module.exports = function(options) { formData: formData }, function(err, httpResponse, body) { + setTimeout(postNextUpload, 100); + if (err) { console.error('Upload failed:', err); + uploadData.status = 'failed'; + } else { - if (httpResponse.statusCode != 200) { + if (httpResponse.statusCode == 200) { + uploadData.status = 'uploaded'; + + if (options.verbose) { + console.error('Uploaded:', uploadData.url_path); + } + } else { console.error('Upload error:', httpResponse.statusCode, body); + uploadData.status = 'failed'; } } } diff --git a/scripts/snapshot/snapshot.task.js b/scripts/snapshot/snapshot.task.js index 40247037d6..7fe1d7a702 100644 --- a/scripts/snapshot/snapshot.task.js +++ b/scripts/snapshot/snapshot.task.js @@ -28,10 +28,17 @@ module.exports = function(gulp, argv, buildConfig) { snapshot(done, true); }); + gulp.task('e2e-publish', function(done) { + var testId = uuid.v4().split('-')[0]; + e2ePublish(testId, true); + }); + function snapshot(done, quickMode) { + var testId = uuid.v4().split('-')[0]; + var protractorConfigFile = path.resolve(projectRoot, 'scripts/snapshot/protractor.config.js'); - snapshotValues.params.test_id = uuid.v4().split('-')[0]; + snapshotValues.params.test_id = testId; snapshotValues.params.upload = !quickMode; var protractorArgs = [ @@ -48,9 +55,7 @@ module.exports = function(gulp, argv, buildConfig) { return _.template(argument, snapshotValues); }); - if (!quickMode) { - e2ePublish(snapshotValues.params.test_id); - } + e2ePublish(testId, false); return protractor(done, [protractorConfigFile].concat(protractorArgs)); } @@ -73,9 +78,10 @@ module.exports = function(gulp, argv, buildConfig) { }); } - function e2ePublish(testId) { + function e2ePublish(testId, verbose) { console.log('e2ePublish: ' + testId); snapshotConfig.testId = testId; + snapshotConfig.verbose = verbose; require('../e2e/e2e-publish')(snapshotConfig); }