Bug 1273634 - [mozlint] Create a flake8 task, r=dustin
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 17 May 2016 16:24:24 -0400
changeset 339195 cb90089f9a8a015f399fc584576b13fb91e04b9d
parent 339194 e4ae9ac1a071e07e369ef56ac30695a238f84b20
child 339196 40371bdc80888d7aa329e7ac15a5f20d45ca29b2
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1273634
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
@@ -521,16 +521,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):