Bug 1273634 - [mozlint] Create a flake8 task, r?dustin draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 17 May 2016 16:24:24 -0400
changeset 374049 e76904071cb3e4fdffbba677cf2774ff7acd5e45
parent 374048 f3504acb27a58255d2cfb39ea79f0fa4f4e95dbb
child 522534 f42f9a8953ce1b503aa28d60fac9531ff8da98d2
push id19910
push userahalberstadt@mozilla.com
push dateWed, 01 Jun 2016 18:16:04 +0000
reviewersdustin
bugs1273634
milestone49.0a1
Bug 1273634 - [mozlint] Create a flake8 task, r?dustin Enables flake8 linting! To start, only these directories are actually linted: - python/mozlint - tools/lint To enable new directories, add them to the 'include' directive at the bottom of: tools/lint/flake8.lint Edit topsrcdir/.flake8 to modify global configuration. Add a new .flake8 to a subdirectory to override the global. The current configuration is more or less just the default and we should tweak it to our needs. MozReview-Commit-ID: iXbToRhm3b
testing/taskcluster/tasks/branches/base_jobs.yml
testing/taskcluster/tasks/tests/mozlint-flake8.yml
tools/lint/mach_commands.py
--- a/testing/taskcluster/tasks/branches/base_jobs.yml
+++ b/testing/taskcluster/tasks/branches/base_jobs.yml
@@ -505,16 +505,26 @@ tasks:
         # Run when eslint policies change.
         - '**/.eslintignore'
         - '**/*eslintrc*'
         # The plugin implementing custom checks.
         - 'testing/eslint/eslint-plugin-mozilla/**'
         # Other misc lint related files.
         - 'tools/lint/**'
         - 'testing/docker/lint/**'
+  flake8-gecko:
+    task: tasks/tests/mozlint-flake8.yml
+    root: true
+    when:
+      file_patterns:
+        - '**/*.py'
+        - '**/.flake8'
+        - 'python/mozlint/**'
+        - 'tools/lint/**'
+        - 'testing/docker/lint/**'
   android-api-15-gradle-dependencies:
     task: tasks/builds/android_api_15_gradle_dependencies.yml
     root: true
     when:
       file_patterns:
         - 'mobile/android/config/**'
         - 'testing/docker/android-gradle-build/**'
         - 'testing/mozharness/configs/builds/releng_sub_android_configs/*gradle_dependencies.py'
new file mode 100644
--- /dev/null
+++ b/testing/taskcluster/tasks/tests/mozlint-flake8.yml
@@ -0,0 +1,37 @@
+---
+$inherits:
+  from: 'tasks/lint.yml'
+  variables:
+    build_product: 'lint'
+    build_name: 'flake8-gecko'
+    build_type: 'opt'
+
+task:
+  metadata:
+    name: '[TC] - Flake8'
+    description: 'Python flake8 linter'
+  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 &&
+          ./mach lint -l flake8 -f treeherder
+  extra:
+    locations:
+      build: null
+      tests: null
+    treeherder:
+      machine:
+        platform: lint
+      groupSymbol: tc
+      symbol: f8
+      tier: 2
+    treeherderEnv:
+      - production
+      - staging
--- a/tools/lint/mach_commands.py
+++ b/tools/lint/mach_commands.py
@@ -50,18 +50,23 @@ class MachCommands(MachCommandBase):
 
         lintargs['exclude'] = ['obj*']
         lint = LintRoller(**lintargs)
         lint.read(lint_files)
 
         # run all linters
         results = lint.roll(paths)
 
+        status = 0
+        if results:
+            status = 1
+
         formatter = formatters.get(fmt)
         print(formatter(results))
+        return status
 
     @SubCommand('lint', 'setup',
                 "Setup required libraries for specified lints.")
     @CommandArgument(
         '-l', '--linter', dest='linters', default=None, action='append',
         help="Linters to run, e.g 'eslint'. By default all linters are run "
              "for all the appropriate files.")
     def lint_setup(self, linters=None, **lintargs):