summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Taubert <ttaubert@mozilla.com>2016-07-26 07:01:27 +0200
committerTim Taubert <ttaubert@mozilla.com>2016-07-26 07:01:27 +0200
commit7ad831ee030bc4db6624f8fc86e0a1ea6db786b2 (patch)
tree616f99956a71319f3032d772b211b91d056d2026
parent78aab4abe363cc04d9942db1993b3607fd842ae4 (diff)
downloadnss-hg-7ad831ee030bc4db6624f8fc86e0a1ea6db786b2.tar.gz
Bug 1286809 - Provide mechanism to run a subset of tasks in nss-try r=franziskus
-rw-r--r--.taskcluster.yml3
-rw-r--r--automation/taskcluster/docker/setup.sh3
-rw-r--r--automation/taskcluster/graph/build.js10
-rw-r--r--automation/taskcluster/graph/linux/_build_base.yml2
-rw-r--r--automation/taskcluster/graph/linux/_test_base.yml2
-rw-r--r--automation/taskcluster/graph/tools/_build_base.yml2
-rw-r--r--automation/taskcluster/graph/try_syntax.js136
-rwxr-xr-xautomation/taskcluster/scripts/extend_task_graph.sh3
8 files changed, 152 insertions, 9 deletions
diff --git a/.taskcluster.yml b/.taskcluster.yml
index 93fa5f5f6..d510fddcf 100644
--- a/.taskcluster.yml
+++ b/.taskcluster.yml
@@ -57,12 +57,13 @@ tasks:
- "tc-treeherder.v2.{{project}}.{{revision}}.{{pushlog_id}}"
payload:
- image: "ttaubert/nss-ci:0.0.17"
+ image: "ttaubert/nss-ci:0.0.18"
env:
TC_OWNER: {{owner}}
TC_SOURCE: {{{source}}}
TC_PROJECT: {{project}}
+ TC_COMMENT: '{{comment}}'
NSS_PUSHLOG_ID: '{{pushlog_id}}'
NSS_HEAD_REPOSITORY: '{{{url}}}'
NSS_HEAD_REVISION: '{{revision}}'
diff --git a/automation/taskcluster/docker/setup.sh b/automation/taskcluster/docker/setup.sh
index 8b094dbb9..789f30b59 100644
--- a/automation/taskcluster/docker/setup.sh
+++ b/automation/taskcluster/docker/setup.sh
@@ -58,9 +58,6 @@ update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 30
locale-gen en_US.UTF-8
dpkg-reconfigure locales
-# Install required Node modules.
-su -c "npm install flatmap js-yaml merge slugid" worker
-
# Cleanup.
rm -rf ~/.ccache ~/.cache
apt-get clean
diff --git a/automation/taskcluster/graph/build.js b/automation/taskcluster/graph/build.js
index 7a428c6dc..4d0c9a498 100644
--- a/automation/taskcluster/graph/build.js
+++ b/automation/taskcluster/graph/build.js
@@ -8,13 +8,14 @@ var merge = require("merge");
var yaml = require("js-yaml");
var slugid = require("slugid");
var flatmap = require("flatmap");
+var try_syntax = require("./try_syntax");
// Default values for debugging.
var TC_OWNER = process.env.TC_OWNER || "{{tc_owner}}";
var TC_SOURCE = process.env.TC_SOURCE || "{{tc_source}}";
var TC_PROJECT = process.env.TC_PROJECT || "{{tc_project}}";
+var TC_COMMENT = process.env.TC_COMMENT || "{{tc_comment}}";
var NSS_PUSHLOG_ID = process.env.NSS_PUSHLOG_ID || "{{nss_pushlog_id}}";
-var NSS_HEAD_REPOSITORY = process.env.NSS_HEAD_REPOSITORY || "{{nss_head_repo}}";
var NSS_HEAD_REVISION = process.env.NSS_HEAD_REVISION || "{{nss_head_rev}}";
// Register custom YAML types.
@@ -43,7 +44,7 @@ var YAML_SCHEMA = yaml.Schema.create([
},
construct: function (data) {
- return process.env[data];
+ return process.env[data] || "{{" + data.toLowerCase() + "}}";
}
})
]);
@@ -173,5 +174,10 @@ var graph = {
tasks: flatmap(["linux", "windows", "tools"], generatePlatformTasks)
};
+// Filter tasks when try syntax is given.
+if (TC_PROJECT == "nss-try") {
+ graph.tasks = try_syntax.filterTasks(graph.tasks, TC_COMMENT);
+}
+
// Output the final graph.
process.stdout.write(JSON.stringify(graph, null, 2));
diff --git a/automation/taskcluster/graph/linux/_build_base.yml b/automation/taskcluster/graph/linux/_build_base.yml
index a7e1dd547..669528d3f 100644
--- a/automation/taskcluster/graph/linux/_build_base.yml
+++ b/automation/taskcluster/graph/linux/_build_base.yml
@@ -14,7 +14,7 @@ task:
payload:
maxRunTime: 3600
- image: ttaubert/nss-ci:0.0.17
+ image: ttaubert/nss-ci:0.0.18
artifacts:
public:
diff --git a/automation/taskcluster/graph/linux/_test_base.yml b/automation/taskcluster/graph/linux/_test_base.yml
index 1e7c91ad6..4e3857c05 100644
--- a/automation/taskcluster/graph/linux/_test_base.yml
+++ b/automation/taskcluster/graph/linux/_test_base.yml
@@ -14,7 +14,7 @@ task:
payload:
maxRunTime: 3600
- image: ttaubert/nss-ci:0.0.17
+ image: ttaubert/nss-ci:0.0.18
command:
- "/bin/bash"
diff --git a/automation/taskcluster/graph/tools/_build_base.yml b/automation/taskcluster/graph/tools/_build_base.yml
index 6dff51349..e32766d47 100644
--- a/automation/taskcluster/graph/tools/_build_base.yml
+++ b/automation/taskcluster/graph/tools/_build_base.yml
@@ -14,7 +14,7 @@ task:
payload:
maxRunTime: 3600
- image: ttaubert/nss-ci:0.0.17
+ image: ttaubert/nss-ci:0.0.18
env:
NSS_HEAD_REPOSITORY: !env NSS_HEAD_REPOSITORY
diff --git a/automation/taskcluster/graph/try_syntax.js b/automation/taskcluster/graph/try_syntax.js
new file mode 100644
index 000000000..397009c66
--- /dev/null
+++ b/automation/taskcluster/graph/try_syntax.js
@@ -0,0 +1,136 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var intersect = require("intersect");
+var parse_args = require("minimist");
+
+function parseOptions(opts) {
+ opts = parse_args(opts.split(/\s+/), {
+ default: {build: "do", platform: "all", unittests: "none", tools: "none"},
+ alias: {b: "build", p: "platform", u: "unittests", t: "tools"},
+ string: ["build", "platform", "unittests", "tools"]
+ });
+
+ // Parse build types (d=debug, o=opt).
+ var builds = intersect(opts.build.split(""), ["d", "o"]);
+
+ // If the given value is nonsense default to debug and opt builds.
+ if (builds.length == 0) {
+ builds = ["d", "o"];
+ }
+
+ // Parse platforms.
+ var allPlatforms = ["linux", "linux64", "linux64-asan", "win64"];
+ var platforms = intersect(opts.platform.split(/\s*,\s*/), allPlatforms);
+
+ // If the given value is nonsense or "none" default to all platforms.
+ if (platforms.length == 0 && opts.platform != "none") {
+ platforms = allPlatforms;
+ }
+
+ // Parse unit tests.
+ var allUnitTests = ["crmf", "chains", "cipher", "db", "ec", "fips", "gtest",
+ "lowhash", "merge", "sdr", "smime", "tools", "ssl"];
+ var unittests = intersect(opts.unittests.split(/\s*,\s*/), allUnitTests);
+
+ // If the given value is "all" run all tests.
+ // If it's nonsense then don't run any tests.
+ if (opts.unittests == "all") {
+ unittests = allUnitTests;
+ } else if (unittests.length == 0) {
+ unittests = [];
+ }
+
+ // Parse tools.
+ var allTools = ["clang-format", "scan-build"];
+ var tools = intersect(opts.tools.split(/\s*,\s*/), allTools);
+
+ // If the given value is "all" run all tools.
+ // If it's nonsense then don't run any tools.
+ if (opts.tools == "all") {
+ tools = allTools;
+ } else if (tools.length == 0) {
+ tools = [];
+ }
+
+ return {
+ builds: builds,
+ platforms: platforms,
+ unittests: unittests,
+ tools: tools
+ };
+}
+
+function filterTasks(tasks, comment) {
+ // Check for try syntax in changeset comment.
+ var match = comment.match(/^\s*try:\s*(.*)\s*$/);
+ if (!match) {
+ return tasks;
+ }
+
+ var opts = parseOptions(match[1]);
+
+ return tasks.filter(function (task) {
+ var env = task.task.payload.env || {};
+ var th = task.task.extra.treeherder;
+ var symbol = th.symbol.toLowerCase();
+ var machine = th.machine.platform;
+ var coll = th.collection || {};
+ var found;
+
+ // Never include memleak builds, they'll go away soon.
+ if (coll.memleak) {
+ return false;
+ }
+
+ // Filter tools. We can immediately return here as those
+ // are not affected by platform or build type selectors.
+ if (machine == "nss-tools") {
+ return opts.tools.some(function (tool) {
+ return symbol.startsWith(tool);
+ });
+ }
+
+ // Filter unit tests.
+ if (env.NSS_TESTS && env.TC_PARENT_TASK_ID) {
+ found = opts.unittests.some(function (test) {
+ return symbol.startsWith(test);
+ });
+
+ if (!found) {
+ return false;
+ }
+ }
+
+ // Filter by platform.
+ found = opts.platforms.some(function (platform) {
+ var aliases = {
+ "linux": "linux32",
+ "linux64-asan": "linux64",
+ "win64": "windows2012-64"
+ };
+
+ // Check the platform name.
+ var keep = machine == (aliases[platform] || platform);
+
+ // Additional check for LSan.
+ if (platform == "linux64-asan") {
+ keep &= coll.asan || coll.lsan;
+ }
+
+ return keep;
+ });
+
+ if (!found) {
+ return false;
+ }
+
+ // Finally, filter by build type.
+ var isDebug = coll.debug || coll.asan || coll.lsan;
+ return (isDebug && opts.builds.indexOf("d") > -1) ||
+ (!isDebug && opts.builds.indexOf("o") > -1);
+ });
+}
+
+module.exports.filterTasks = filterTasks;
diff --git a/automation/taskcluster/scripts/extend_task_graph.sh b/automation/taskcluster/scripts/extend_task_graph.sh
index 8419716b4..11861b05d 100755
--- a/automation/taskcluster/scripts/extend_task_graph.sh
+++ b/automation/taskcluster/scripts/extend_task_graph.sh
@@ -9,5 +9,8 @@ fi
mkdir -p /home/worker/artifacts
+# Install Node.JS dependencies.
+npm install flatmap js-yaml merge slugid minimist intersect
+
# Build the task graph definition.
nodejs nss/automation/taskcluster/graph/build.js > /home/worker/artifacts/graph.json