You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2015/04/21 14:15:22 UTC

[1/2] cordova-medic git commit: [CB-8803] Properly fixing the intermittent cleanup issue.

Repository: cordova-medic
Updated Branches:
  refs/heads/master f7f91b5cb -> f5edd9ef9


[CB-8803] Properly fixing the intermittent cleanup issue.


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

Branch: refs/heads/master
Commit: b561debe91c100706eee9fd583a88fc025566a17
Parents: 639f9a6
Author: Dmitry Blotsky <dm...@gmail.com>
Authored: Fri Apr 17 14:34:52 2015 -0700
Committer: Dmitry Blotsky <dm...@gmail.com>
Committed: Mon Apr 20 15:52:30 2015 -0700

----------------------------------------------------------------------
 bin/medic.js               | 136 ++++++++++++++++++++++++++++++++++++++++
 buildbot-conf/cordova.conf |  27 +++-----
 package.json               |  14 +++--
 3 files changed, 153 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/b561debe/bin/medic.js
----------------------------------------------------------------------
diff --git a/bin/medic.js b/bin/medic.js
new file mode 100755
index 0000000..eaa5a05
--- /dev/null
+++ b/bin/medic.js
@@ -0,0 +1,136 @@
+#!/usr/bin/env node
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+"use strict";
+
+// node dependencies
+var fs = require("fs");
+var os = require("os");
+
+// external dependencies
+var shelljs  = require("shelljs");
+var optimist = require("optimist");
+
+// constants
+var MAX_REMOVAL_ATTEMPTS = 3;
+
+// parse args
+var argv = optimist
+    .usage("Usage: $0 [command]")
+    .demand(1)
+    .argv;
+
+// helpers
+function fatal(message) {
+    console.error("ERROR: " + message);
+    process.exit(1);
+}
+
+function contains(collection, item) {
+    return collection.indexOf(item) != (-1);
+}
+
+function exclusiveLs(lsPath, excludes) {
+    var paths = fs.readdirSync(lsPath);
+    return paths.filter(function (pathName) {
+        return !contains(excludes, pathName);
+    });
+}
+
+// subcommands
+function commandClean() {
+
+    // command-specific args
+    argv = optimist
+        .usage("Usage: $0 --exclude {name[,name[,...]]}")
+        .argv;
+
+    // get args
+    var excludeString = argv.exclude;
+    var excludedPaths = [".", ".."];
+
+    if (argv.exclude) {
+        excludedPaths = excludedPaths.concat(excludeString.split(","));
+    }
+
+    // get all directories except excluded ones
+    var pathsToRemove = exclusiveLs(".", excludedPaths);
+
+    console.log("NOT removing the following paths:");
+    console.log(excludedPaths);
+    console.log("removing the following paths:");
+    console.log(pathsToRemove);
+
+    // skip if no paths to delete
+    if (pathsToRemove.length <= 0) {
+        return;
+    }
+
+    // attempt to delete the paths
+    var attempts = 0;
+    var success  = false;
+    while (success === false) {
+
+        // try to remove the paths
+        shelljs.rm("-rf", pathsToRemove);
+
+        // check if any of them remain
+        var remainingPaths = exclusiveLs(".", excludedPaths);
+        if (remainingPaths.length === 0) {
+            success = true;
+        } else {
+            console.error("cleanup attempt #" + attempts + " failed");
+        }
+
+        // limit the number of attempts
+        attempts += 1;
+        if (attempts >= MAX_REMOVAL_ATTEMPTS) {
+            break;
+        }
+    }
+
+    // if loop exited without success, return an error
+    if (success === false) {
+        fatal("failed to remove files");
+    }
+}
+
+// main
+function main() {
+
+    // shell config
+    shelljs.config.fatal  = false;
+    shelljs.config.silent = false;
+
+    // get args
+    var command = argv._[0];
+
+    // run command
+    switch (command) {
+        case "clean":
+            commandClean();
+            break;
+        default:
+            fatal("unknown command " + command);
+    }
+}
+
+main();

http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/b561debe/buildbot-conf/cordova.conf
----------------------------------------------------------------------
diff --git a/buildbot-conf/cordova.conf b/buildbot-conf/cordova.conf
index f65d264..3b877b9 100644
--- a/buildbot-conf/cordova.conf
+++ b/buildbot-conf/cordova.conf
@@ -177,16 +177,6 @@ def MedicClone(config_path, excludes=list(), **kwargs):
 
     return SH(command=command, description=description)
 
-def RMRF(path, description=None, **kwargs):
-
-    if description is None:
-        description = 'removing ' + path
-
-    # this is better than 'rm -rf' because it removes excessively long paths on Windows
-    js_script = "var s = require('shelljs'); console.log('removing {path}'); s.rm('-rf', '{path}');".format(path=path)
-
-    return SH(command=['node', '-e', js_script], description=description, **kwargs)
-
 def Set(name, value, **kwargs):
     return DescribedStep(SetProperty, 'setting ' + name, property=name, value=value, **kwargs)
 
@@ -212,11 +202,15 @@ WINDOWS_SLAVES = ['cordova-windows-slave']
 
 ####### STEPS
 
-get_medic_steps = [
+medic_steps = [
 
+    # remove and re-clone medic
+    SH(command=['rm', '-rf', 'cordova-medic'], description='removing medic'),
     CordovaClone('cordova-medic'),
 
-    # --production switch is used to speed up installation + fruitstrap dev dependency is not supported on Windows
+    # install medic
+    # NOTE:
+    #      --production switch is used to speed up installation + fruitstrap dev dependency is not supported on Windows
     NPMInstall(command=['--production'], what='cordova-medic', workdir='cordova-medic'),
 ]
 
@@ -237,14 +231,11 @@ plugins_cleanup_steps = [
     ),
 
     # clean up
-    NPMInstall(command=['shelljs'], what='shelljs'),
-    RMRF('~/.cordova/*', description='removing cache', haltOnFailure=False),
-    RMRF(BASE_WORKDIR + '/*', description='cleaning workspace', haltOnFailure=False),
-    RMRF(BASE_WORKDIR + '/*', description='cleaning workspace again', haltOnFailure=False),
-    RMRF(BASE_WORKDIR + '/*', description='cleaning workspace yet again', haltOnFailure=True),
+    SH(command=['rm', '-rf', '~/.cordova/*'], description='removing cache'),
+    SH(command=['node', 'cordova-medic/bin/medic.js', 'clean', '--exclude', 'cordova-medic'], description='cleaning workspace'),
 ]
 
-common_plugins_steps = plugins_cleanup_steps + get_medic_steps + [
+common_plugins_steps = medic_steps + plugins_cleanup_steps + [
 
     # download medic's config to slave
     Download(mastersrc=MEDIC_CONFIG_FILE, slavedest='cordova-medic/config.json', description='downloading master\'s config'),

http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/b561debe/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index dff194b..1ba836a 100644
--- a/package.json
+++ b/package.json
@@ -4,21 +4,23 @@
   "description": "continuous integration setup for Apache Cordova",
   "author": "Fil Maj <ma...@gmail.com> (http://filmaj.ca)",
   "dependencies": {
-    "commander": "^2.5.0",
     "follow": "0.8.0",
-    "glob":"3.2.6",
+    "glob": "3.2.6",
     "mime": "1.2.9",
     "ncallbacks": "1.0.0",
     "optimist": "0.3.5",
-    "q":"0.8.6",
+    "q": "0.8.6",
     "request": "2.12.0",
-    "shelljs": "^0.3.0"
+    "shelljs": "^0.4.0"
   },
   "subdomain": "cordova.medic",
   "engines": {
     "node": ">=0.8.x"
   },
-  "contributors":[
-    {"name":"Don Coleman","email":"don.coleman@gmail.com"}
+  "contributors": [
+    {
+      "name": "Don Coleman",
+      "email": "don.coleman@gmail.com"
+    }
   ]
 }


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


[2/2] cordova-medic git commit: [CB-8803] Properly fixing the intermittent cleanup issue.

Posted by an...@apache.org.
[CB-8803] Properly fixing the intermittent cleanup issue.


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

Branch: refs/heads/master
Commit: f5edd9ef99d4a321ddb868cca913a63a550050c3
Parents: f7f91b5 b561deb
Author: Vladimir Kotikov <an...@ya.ru>
Authored: Tue Apr 21 15:15:13 2015 +0300
Committer: Vladimir Kotikov <an...@ya.ru>
Committed: Tue Apr 21 15:15:13 2015 +0300

----------------------------------------------------------------------
 bin/medic.js               | 136 ++++++++++++++++++++++++++++++++++++++++
 buildbot-conf/cordova.conf |  27 +++-----
 package.json               |  14 +++--
 3 files changed, 153 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/f5edd9ef/buildbot-conf/cordova.conf
----------------------------------------------------------------------


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