Bug 1229588: Add taskcluster test for eslint. r?ahal draft
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 16 Dec 2015 13:46:49 -0800
changeset 319810 6506e7bef4b31e58eaecc31011137d8b9908cb31
parent 319809 641ef71a5a8a8da580a818d393046d211e016c5e
child 512655 e6f799e13781401540fd6c6c3bc338806dc8c3a8
push id9098
push userdtownsend@mozilla.com
push dateThu, 07 Jan 2016 23:13:02 +0000
reviewersahal
bugs1229588
milestone46.0a1
Bug 1229588: Add taskcluster test for eslint. r?ahal This adds the eslint_gecko task to run eslint over the entire tree using a custom formatter to output the failures in a format that treeherder will parse.
testing/taskcluster/tasks/branches/base_job_flags.yml
testing/taskcluster/tasks/branches/base_jobs.yml
testing/taskcluster/tasks/tests/eslint_gecko.yml
tools/lint/eslint-formatter.js
--- a/testing/taskcluster/tasks/branches/base_job_flags.yml
+++ b/testing/taskcluster/tasks/branches/base_job_flags.yml
@@ -100,16 +100,17 @@ flags:
     - android-api-11
     - android-partner-sample1
     - android-b2gdroid
     - linux
     - linux64
     - linux64-st-an
     - macosx64
     - macosx64-st-an
+    - eslint_gecko
 
   tests:
     - cppunit
     - crashtest
     - crashtest-e10s
     - crashtest-ipc
     - gaia-build
     - gaia-build-unit
--- a/testing/taskcluster/tasks/branches/base_jobs.yml
+++ b/testing/taskcluster/tasks/branches/base_jobs.yml
@@ -171,16 +171,22 @@ builds:
       opt:
         task: tasks/builds/opt_macosx64_st-an.yml
   android-b2gdroid:
     platforms:
       - Android
     types:
       opt:
         task: tasks/builds/android_api_11_b2gdroid.yml
+  eslint_gecko:
+    platforms:
+      - ESLint
+    types:
+      opt:
+        task: tasks/tests/eslint_gecko.yml
 
 tests:
   cppunit:
     allowed_build_tasks:
       tasks/builds/b2g_emulator_x86_kk_opt.yml:
         task: tasks/tests/b2g_emulator_cpp_unit.yml
       tasks/builds/b2g_emulator_x86_kk_debug.yml:
         task: tasks/tests/b2g_emulator_cpp_unit.yml
new file mode 100644
--- /dev/null
+++ b/testing/taskcluster/tasks/tests/eslint_gecko.yml
@@ -0,0 +1,31 @@
+---
+$inherits:
+    from: 'tasks/build.yml'
+
+task:
+  metadata:
+    name: '[TC] - ESLint'
+    description: ESLint test
+
+  payload:
+    image: '{{#docker_image}}desktop-test{{/docker_image}}'
+    command:
+      - bash
+      - -cx
+      - >
+          source ./bin/checkout-sources.sh &&
+          cd /home/worker/workspace/build/src &&
+          npm link testing/eslint-plugin-mozilla &&
+          eslint --plugin html --ext [.js,.jsm,.jsx,.xml,.html] -f tools/lint/eslint-formatter .
+  extra:
+    locations:
+        build: null
+        tests: null
+    treeherder:
+        machine:
+            platform: linux64
+        groupSymbol: tc
+        symbol: ES
+    treeherderEnv:
+        - production
+        - staging
new file mode 100644
--- /dev/null
+++ b/tools/lint/eslint-formatter.js
@@ -0,0 +1,23 @@
+/* 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/. */
+"use strict";
+
+const path = require("path")
+
+module.exports = function(results) {
+  for (let file of results) {
+    let filePath = path.relative(".", file.filePath);
+    for (let message of file.messages) {
+      let status = message.message;
+
+      if ("ruleId" in message) {
+        status = `${status} (${message.ruleId})`;
+      }
+
+      let severity = message.severity == 1 ? "TEST-UNEXPECTED-WARNING"
+                                           : "TEST-UNEXPECTED-ERROR";
+      console.log(`${severity} | ${filePath}:${message.line}:${message.column} | ${status}`);
+    }
+  }
+};