mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
snapshot updates
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user