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
--- 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):