Bug 1229588: Add a taskcluster test for eslint. r?dustin
Adds a new lint docker image for linting tools and adds an eslint-gecko task
that uses it to run eslint over the tree.
new file mode 100644
--- /dev/null
+++ b/testing/docker/lint/Dockerfile
@@ -0,0 +1,24 @@
+FROM node:4.2
+MAINTAINER Dave Townsend <dtownsend@oxymoronical.com>
+
+RUN useradd -d /home/worker -s /bin/bash -m worker
+WORKDIR /home/worker
+
+# install necessary npm packages
+RUN npm install -g taskcluster-vcs@2.3.12
+RUN npm install -g eslint@1.10.3
+RUN npm install -g eslint-plugin-html@1.1.0
+RUN npm install -g eslint-plugin-react@3.13.1
+
+# Set variable normally configured at login, by the shells parent process, these
+# are taken from GNU su manual
+ENV HOME /home/worker
+ENV SHELL /bin/bash
+ENV USER worker
+ENV LOGNAME worker
+ENV HOSTNAME taskcluster-worker
+ENV LANG en_US.UTF-8
+ENV LC_ALL en_US.UTF-8
+
+# Set a default command useful for debugging
+CMD ["/bin/bash", "--login"]
--- 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:
+ - lint
+ 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/lint.yml
@@ -0,0 +1,40 @@
+# This is the "base" task which contains the common values all linting tests must
+# provide.
+---
+taskId: {{build_slugid}}
+
+task:
+ created: '{{now}}'
+ deadline: '{{#from_now}}24 hours{{/from_now}}'
+ metadata:
+ source: http://todo.com/soon
+ owner: mozilla-taskcluster-maintenance@mozilla.com
+
+ tags:
+ createdForUser: {{owner}}
+
+ workerType: b2gtest
+ provisionerId: aws-provisioner-v1
+ schedulerId: task-graph-scheduler
+
+ routes:
+ - 'index.gecko.v1.{{project}}.revision.linux.{{head_rev}}.{{build_name}}.{{build_type}}'
+ - 'index.gecko.v1.{{project}}.latest.linux.{{build_name}}.{{build_type}}'
+ scopes:
+ # Nearly all of our build tasks use tc-vcs so just include the scope across
+ # the board.
+ - 'docker-worker:cache:tc-vcs'
+
+ payload:
+ # Thirty minutes should be enough for lint checks
+ maxRunTime: 1800
+
+ cache:
+ tc-vcs: '/home/worker/.tc-vcs'
+
+ extra:
+ build_product: '{{build_product}}'
+ build_name: '{{build_name}}'
+ build_type: '{{build_type}}'
+ index:
+ rank: {{pushlog_id}}
new file mode 100644
--- /dev/null
+++ b/testing/taskcluster/tasks/tests/eslint-gecko.yml
@@ -0,0 +1,35 @@
+---
+$inherits:
+ from: 'tasks/lint.yml'
+
+task:
+ metadata:
+ name: '[TC] - ESLint'
+ description: 'ESLint test'
+
+ payload:
+ image:
+ type: 'task-image'
+ path: 'public/image.tar'
+ taskId: '{{#task_id_for_image}}lint{{/task_id_for_image}}'
+
+ command:
+ - bash
+ - -cx
+ - >
+ tc-vcs checkout ./gecko {{base_repository}} {{head_repository}} {{head_rev}} {{head_ref}} &&
+ cd gecko &&
+ 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: lint
+ 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}`);
+ }
+ }
+};