cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dase...@apache.org
Subject [2/2] cordova-coho git commit: CB-7904 Built nightly releases using coho
Date Fri, 13 May 2016 11:12:58 GMT
CB-7904 Built nightly releases using coho

Updates code for the current version
Fixed the date format
Add 'ignore-test-failures' flag for debugging purposes
Clone repos if necessary before updating
Add commit short SHA to the lib/cli build version
Adds handling for separate CLI and LIB nightly versions unpublishing
Fixes npm-unpublish-nightly entryPoint


Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/9c698704
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/9c698704
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/9c698704

Branch: refs/heads/master
Commit: 9c6987041c7fbd649ed8f2c87e635bfd6ab7c09c
Parents: be7eb6e
Author: daserge <v-seshak@microsoft.com>
Authored: Fri May 13 14:00:22 2016 +0300
Committer: daserge <v-seshak@microsoft.com>
Committed: Fri May 13 14:04:37 2016 +0300

----------------------------------------------------------------------
 src/main.js         |   2 +-
 src/nightly.js      | 106 ++++++++++++++++++++---------------------------
 src/retrieve-sha.js |   2 +-
 3 files changed, 47 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/9c698704/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index b41b91e..ec7a9c3 100644
--- a/src/main.js
+++ b/src/main.js
@@ -121,7 +121,7 @@ module.exports = function() {
         },  {
             name: 'npm-unpublish-nightly',
             desc: 'Unpublishes last nightly versions for cli and lib',
-            entryPoint: lazyRequire('./npm-publish', 'unpublishNightly')
+            entryPoint: lazyRequire('./npm-publish', 'unpublish')
         }];
     var otherCommands = [{
             name: 'list-pulls',

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/9c698704/src/nightly.js
----------------------------------------------------------------------
diff --git a/src/nightly.js b/src/nightly.js
index aa81a3d..ad455e1 100644
--- a/src/nightly.js
+++ b/src/nightly.js
@@ -17,6 +17,7 @@ specific language governing permissions and limitations
 under the License.
 */
 
+var apputil = require('./apputil');
 var executil = require('./executil');
 var optimist = require('optimist');
 var flagutil = require('./flagutil');
@@ -29,9 +30,17 @@ var gitutil = require('./gitutil');
 var fs = require('fs');
 var path = require('path');
 var npmlink = require('./npm-link');
+var repoclone = require('./repo-clone');
+
+function pad(number) {
+    if (number < 10) {
+        return '0' + number;
+    }
+    return number;
+}
 
 module.exports = function*(argv) {
-    var repos = flagutil.computeReposFromFlag('nightly');
+    var repos = flagutil.computeReposFromFlag('tools');
     var cli = repoutil.getRepoById('cli');
     var cordovaLib = repoutil.getRepoById('lib');
     var opt = flagutil.registerHelpFlag(optimist);
@@ -45,59 +54,41 @@ module.exports = function*(argv) {
             desc: 'Don\'t actually publish to npm, just print what would be run.',
             type:'boolean'
         })
+        .options('ignore-test-failures', {
+            desc: 'Run the tests for cli and lib but don\'t fail the build if the tests are
failing',
+            type:'boolean',
+            alias : 'ignoreTestFailures'
+        })
         .argv;
 
     if(argv.h) {
         optimist.showHelp();
         process.exit(1);
     }
-    
-    //Grab currently published nightly version so we can unpublish it later
-    //Assumes lib and cli have same version
-    var oldNightlyVersion = yield executil.execHelper(executil.ARGS('npm view cordova dist-tags.nightly'));
-    console.log(oldNightlyVersion);
 
-    //Update Repos
+    // Clone and update Repos
+    yield repoclone.cloneRepos(repos, /*silent=*/true);
     yield repoupdate.updateRepos(repos);
 
     //remove local changes and sync up with remote master
     yield repoutil.forEachRepo(repos, function*() {
         yield gitutil.gitClean();
         yield gitutil.resetFromOrigin();
-    })
-
-    //get SHAS from platforms
-    var SHAJSON = yield retrieveSha(repos);
-
-    //save SHAJSON in cordova-cli repo
-    yield repoutil.forEachRepo([cli], function*() {
-        //need to get the path to cordova-cli using executil
-        var cordovaclidir = process.cwd();
-        fs.writeFileSync((path.join(cordovaclidir, 'shas.json')), JSON.stringify(SHAJSON,
null, 4), 'utf8', function(err) {
-            if (err) return console.log (err);
-        });
-
-    });
-
-    //Update platform references at cordova-lib/src/cordova/platformsConfig.json
-    var cordovalibdir;
-    yield repoutil.forEachRepo([cordovaLib], function*() {
-        //need to get the path to cordova-lib using executil
-        cordovalibdir = process.cwd();
     });
 
-    yield updatePlatformsFile(path.join(cordovalibdir, 'src/cordova/platformsConfig.json'),
SHAJSON);
-
+    // Get SHAS from repos
+    var SHAJSON = yield retrieveSha(repos);
 
     var currentDate = new Date();
     var nightlyVersion = '-nightly.' + currentDate.getFullYear() + '.' +
-                        currentDate.getMonth() + '.' + currentDate.getDate();
+                        pad(currentDate.getMonth() + 1) + '.' + pad(currentDate.getDate());
     var cordovaLibVersion;
     //update package.json version for cli + lib, update lib reference for cli
     yield repoutil.forEachRepo([cordovaLib, cli], function*(repo) {
         var dir = process.cwd();
         var packageJSON = require(dir+'/package.json');
-        packageJSON.version = versionutil.removeDev(packageJSON.version) + nightlyVersion;
+        packageJSON.version = versionutil.removeDev(packageJSON.version) + nightlyVersion
+
+            '+' + SHAJSON[repo.id];
 
         if(repo.id === 'lib'){
             cordovaLibVersion = packageJSON.version;
@@ -113,49 +104,42 @@ module.exports = function*(argv) {
     //npm link repos that should be linked
     yield npmlink();
 
+    // npm install cli
+    yield repoutil.forEachRepo([cli], function*(repo) {
+        yield executil.execHelper(executil.ARGS('npm install'), /*silent=*/true, false);
+    });
+
     //run CLI + cordova-lib tests
-    //NOTE: Commented out because of issues running on jenkins machine.
-    //Will rely on medic to test nightlys instead
-    //yield runTests(cli, cordovaLib);
+    yield runTests(cli, cordovaLib, argv.ignoreTestFailures);
 
-    //create options object
     var options = {};
     options.tag = 'nightly';
-    options.r = ['lib', 'cli'];
     options.pretend = argv.pretend;
 
-    //publish to npm under nightly tag
-    yield npmpublish.publishTag(options);
-
     //unpublish old nightly
-    options.version = oldNightlyVersion;
-    yield npmpublish.unpublish(options);
-}
-
-//updates platforms.js with the SHA
-function *updatePlatformsFile(file, shajson) {
-    var platformsJS = require(file);
+    yield repoutil.forEachRepo([cordovaLib, cli], function*(repo) {
+        var repoName = repo.id === 'cli' ? 'cordova' : repo.repoName;
+        var oldNightlyVersion = yield executil.execHelper(executil.ARGS('npm view ' + repoName
+ ' dist-tags.nightly'));
+        apputil.print('Latest ' + repoName + '@nightly version is ' + oldNightlyVersion);
 
-    var repos = flagutil.computeReposFromFlag('active-platform');
+        options.r = [repo.id];
+        options.version = oldNightlyVersion;
 
-    yield repoutil.forEachRepo(repos, function*(repo) {
-        if(repo.id === 'windows') {
-            platformsJS[repo.id].version = shajson[repo.id];
-            platformsJS['windows8'].version = shajson[repo.id];
-        } else if(repo.id === 'blackberry') {
-            platformsJS['blackberry10'].version = shajson[repo.id];
-        } else {
-            platformsJS[repo.id].version = shajson[repo.id];
-        }
+        yield npmpublish.unpublish(options);
     });
 
-    fs.writeFileSync(file, JSON.stringify(platformsJS, null, 4), 'utf8', function(err) {
-        if (err) return console.log (err);
-    });
+    options.r = ['lib', 'cli'];
+    //publish to npm under nightly tag
+    yield npmpublish.publishTag(options);
 }
 
-function *runTests(cli, lib) {
+function *runTests(cli, lib, ignoreTestFailures) {
     yield repoutil.forEachRepo([cli, lib], function *(repo) {
-           yield executil.execHelper(executil.ARGS('npm test'), false, false);
+        try {
+            yield executil.execHelper(executil.ARGS('npm test'), false, ignoreTestFailures);
+        } catch (e) {
+            if (!ignoreTestFailures) throw e;
+            apputil.print('Skipping failing tests due to "ignore-test-failures flag"');
+        }
     });
 }

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/9c698704/src/retrieve-sha.js
----------------------------------------------------------------------
diff --git a/src/retrieve-sha.js b/src/retrieve-sha.js
index a694cdc..713629a 100644
--- a/src/retrieve-sha.js
+++ b/src/retrieve-sha.js
@@ -22,7 +22,7 @@ var executil = require('./executil');
 module.exports = function *(repos) {
     var shas = {};
     yield repoutil.forEachRepo(repos, function*(repo) {
-        shas[repo.id] = yield executil.execHelper(executil.ARGS('git rev-parse HEAD'), true,
true);
+        shas[repo.id] = yield executil.execHelper(executil.ARGS('git rev-parse --short=8
HEAD'), true, true);
     });
     return shas;
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message