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.
--- 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}`);
+ }
+ }
+};