Bug 1885550 - Port bug 1885361: Refactor for SkipUnlessMozlint moving to gecko_taskgraph. r=dandarnell
SkipUnlessMozlint is now in gecko_taskgraph and received a minor facelift so that the code can be used for Firefox CI as well as Thunderbird. The strategy needs to be registered in comm_taskgraph.optimize to set the the path to the mozlint config files. It does not need to be listed in `optimizations` as that will be brought in from gecko_taskgraph. This reduces the configuration needed in the job itself, all that's needed is the mozlint yaml filename. Differential Revision: https://phabricator.services.mozilla.com/D204768 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ea000b438f
Коммит
9eee1dc938
|
@ -7,67 +7,22 @@ Thunderbird specific taskgraph optimizers.
|
|||
|
||||
import logging
|
||||
|
||||
from taskgraph.optimize.base import OptimizationStrategy, register_strategy
|
||||
from taskgraph.util.path import join as join_path
|
||||
from taskgraph.util.path import match as match_path
|
||||
from taskgraph.util.yaml import load_yaml
|
||||
from voluptuous import Optional, Required
|
||||
from taskgraph.optimize.base import register_strategy, registry
|
||||
|
||||
from gecko_taskgraph import GECKO
|
||||
from gecko_taskgraph.optimize.mozlint import SkipUnlessMozlint
|
||||
from gecko_taskgraph.optimize.schema import default_optimizations
|
||||
from mozlint.pathutils import filterpaths
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Register "skip-unless-mozlint" with the correct mozlint path.
|
||||
del registry["skip-unless-mozlint"]
|
||||
register_strategy("skip-unless-mozlint", args=("comm/tools/lint",))(SkipUnlessMozlint)
|
||||
|
||||
@register_strategy("skip-unless-mozlint")
|
||||
class SkipUnlessMozlint(OptimizationStrategy):
|
||||
schema = {
|
||||
"root-path": Optional(str),
|
||||
"mozlint-config": Required(str),
|
||||
}
|
||||
|
||||
def should_remove_task(self, task, params, args):
|
||||
include = []
|
||||
exclude = []
|
||||
extensions = []
|
||||
support_files = []
|
||||
|
||||
root_path = join_path(GECKO, args.get("root-path", ""))
|
||||
mozlint_root = join_path(root_path, "tools", "lint")
|
||||
mozlint_yaml = join_path(mozlint_root, args["mozlint-config"])
|
||||
|
||||
logger.info(f"Loading file patterns for {task.label} from {mozlint_yaml}.")
|
||||
linter_config = load_yaml(mozlint_yaml)
|
||||
for check, config in linter_config.items():
|
||||
include += config.get("include", [])
|
||||
exclude += config.get("exclude", [])
|
||||
extensions += [e.strip(".") for e in config.get("extensions", [])]
|
||||
support_files += config.get("support-files", [])
|
||||
|
||||
changed_files = params["files_changed"]
|
||||
|
||||
# Support files may not be part of "include" patterns, so check first
|
||||
# Do not remove (return False) if any changed
|
||||
for pattern in support_files:
|
||||
for path in changed_files:
|
||||
if match_path(path, pattern):
|
||||
return False
|
||||
|
||||
to_lint, to_exclude = filterpaths(
|
||||
GECKO,
|
||||
list(changed_files),
|
||||
include=include,
|
||||
exclude=exclude,
|
||||
extensions=extensions,
|
||||
)
|
||||
|
||||
# to_lint should be an empty list if there is nothing to check
|
||||
if not to_lint:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
optimizations = ({"skip-unless-mozlint": SkipUnlessMozlint.schema},)
|
||||
# Currently no Thunderbird-specific optimization strategies. Keep for future
|
||||
# reference.
|
||||
# optimizations = (
|
||||
# {"skip-suite-only": None},
|
||||
# )
|
||||
|
||||
optimizations = ()
|
||||
thunderbird_optimizations = default_optimizations + optimizations
|
||||
|
|
|
@ -37,9 +37,7 @@ codespell:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: codespell.yml
|
||||
skip-unless-mozlint: codespell.yml
|
||||
|
||||
eslint:
|
||||
description: JS lint check
|
||||
|
@ -55,9 +53,7 @@ eslint:
|
|||
ln -s ../tools/lint/eslint/eslint-plugin-spidermonkey-js node_modules &&
|
||||
./mach commlint -v -l eslint -f treeherder -f json:/builds/worker/mozlint.json comm/
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: eslint.yml
|
||||
skip-unless-mozlint: eslint.yml
|
||||
|
||||
file-perm:
|
||||
description: Check for incorrect permissions on source files
|
||||
|
@ -73,9 +69,7 @@ file-perm:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: file-perm.yml
|
||||
skip-unless-mozlint: file-perm.yml
|
||||
|
||||
file-whitespace:
|
||||
description: Check for trailing whitespaces and Windows CR
|
||||
|
@ -91,9 +85,7 @@ file-whitespace:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: file-whitespace.yml
|
||||
skip-unless-mozlint: file-whitespace.yml
|
||||
|
||||
fluent-lint:
|
||||
description: Check for problems with Fluent files.
|
||||
|
@ -105,9 +97,7 @@ fluent-lint:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: fluent-lint.yml
|
||||
skip-unless-mozlint: fluent-lint.yml
|
||||
|
||||
license:
|
||||
description: Check for license blocks in source files.
|
||||
|
@ -119,9 +109,7 @@ license:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: license.yml
|
||||
skip-unless-mozlint: license.yml
|
||||
|
||||
l10n-conflicts:
|
||||
description: l10n tests for strings with errors and conflicts with cross-channel
|
||||
|
@ -135,9 +123,7 @@ l10n-conflicts:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: l10n.yml
|
||||
skip-unless-mozlint: l10n.yml
|
||||
|
||||
localization:
|
||||
description: l10n tests for strings with errors
|
||||
|
@ -150,9 +136,7 @@ localization:
|
|||
attributes:
|
||||
code-review: false
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: l10n.yml
|
||||
skip-unless-mozlint: l10n.yml
|
||||
|
||||
lintpref:
|
||||
description: Check for duplicates between all.js and StaticPrefList.yaml.
|
||||
|
@ -164,9 +148,7 @@ lintpref:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: lintpref.yml
|
||||
skip-unless-mozlint: lintpref.yml
|
||||
|
||||
mingw-cap:
|
||||
description: lint for MinGW Capitalization issues
|
||||
|
@ -178,9 +160,7 @@ mingw-cap:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: mingw-capitalization.yml
|
||||
skip-unless-mozlint: mingw-capitalization.yml
|
||||
|
||||
py-black:
|
||||
description: black run over the gecko codebase
|
||||
|
@ -192,9 +172,7 @@ py-black:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: black.yml
|
||||
skip-unless-mozlint: black.yml
|
||||
|
||||
py-ruff:
|
||||
description: Run ruff over the codebase
|
||||
|
@ -206,9 +184,7 @@ py-ruff:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: ruff.yml
|
||||
skip-unless-mozlint: ruff.yml
|
||||
|
||||
rustfmt:
|
||||
description: rustfmt on the Rust code
|
||||
|
@ -222,9 +198,7 @@ rustfmt:
|
|||
toolchain:
|
||||
- linux64-rust
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: rustfmt.yml
|
||||
skip-unless-mozlint: rustfmt.yml
|
||||
|
||||
shellcheck:
|
||||
description: shellcheck run over the Thunderbird codebase
|
||||
|
@ -237,9 +211,7 @@ shellcheck:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: shellcheck.yml
|
||||
skip-unless-mozlint: shellcheck.yml
|
||||
|
||||
stylelint:
|
||||
description: CSS lint check
|
||||
|
@ -254,9 +226,7 @@ stylelint:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: stylelint.yml
|
||||
skip-unless-mozlint: stylelint.yml
|
||||
|
||||
trojan-source:
|
||||
description: Trojan Source attack - CVE-2021-42572
|
||||
|
@ -269,9 +239,7 @@ trojan-source:
|
|||
-f json:/builds/worker/mozlint.json
|
||||
comm/*
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: trojan-source.yml
|
||||
skip-unless-mozlint: trojan-source.yml
|
||||
|
||||
yaml:
|
||||
description: yamllint run over the taskcluster configuration
|
||||
|
@ -285,6 +253,4 @@ yaml:
|
|||
comm/taskcluster
|
||||
comm/.*.yml
|
||||
optimization:
|
||||
skip-unless-mozlint:
|
||||
root-path: comm
|
||||
mozlint-config: yaml.yml
|
||||
skip-unless-mozlint: yaml.yml
|
||||
|
|
Загрузка…
Ссылка в новой задаче