forked from mirrors/gecko-dev
Bug 1666491 - Add a eslint-build tester (tier 3) that depends on xpt artifacts. r=nalexander,releng-reviewers,gbrown
Depends on D161641 Differential Revision: https://phabricator.services.mozilla.com/D162072
This commit is contained in:
parent
3d1bbcf060
commit
9e831a03d2
8 changed files with 78 additions and 13 deletions
10
.cron.yml
10
.cron.yml
|
|
@ -361,3 +361,13 @@ jobs:
|
|||
- mozilla-central
|
||||
when:
|
||||
- {hour: 0, minute: 00}
|
||||
|
||||
- name: eslint-build
|
||||
job:
|
||||
type: decision-task
|
||||
treeherder-symbol: eslint-build
|
||||
target-tasks-method: eslint-build
|
||||
run-on-projects:
|
||||
- mozilla-central
|
||||
when:
|
||||
- {hour: 0, minute: 00}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,32 @@ eslint:
|
|||
- 'tools/lint/eslint/eslint-plugin-mozilla/**'
|
||||
- 'tools/lint/eslint/eslint-plugin-spidermonkey-js/**'
|
||||
|
||||
eslint-build:
|
||||
description: ESLint checks with build data
|
||||
treeherder:
|
||||
symbol: js(ES-B)
|
||||
tier: 3
|
||||
run:
|
||||
using: run-task
|
||||
cwd: '{checkout}'
|
||||
command: >
|
||||
export MOZ_XPT_ARTIFACTS_DIR="$MOZ_FETCHES_DIR/$MOZ_XPT_ARTIFACTS_DIRNAME" &&
|
||||
find "$MOZ_XPT_ARTIFACTS_DIR" &&
|
||||
cp -r /build/node_modules_eslint node_modules &&
|
||||
cp -r /build/node_modules_eslint-plugin-mozilla/ tools/lint/eslint/eslint-plugin-mozilla/node_modules &&
|
||||
ln -s ../tools/lint/eslint/eslint-plugin-mozilla node_modules &&
|
||||
ln -s ../tools/lint/eslint/eslint-plugin-spidermonkey-js node_modules &&
|
||||
./mach lint -v -l eslint -f treeherder -f json:/builds/worker/mozlint.json * --rule "mozilla/valid-services-property: error" --rule "mozilla/valid-ci-uses: error"
|
||||
worker:
|
||||
env:
|
||||
MOZ_XPT_ARTIFACTS_DIRNAME: xpt_artifacts
|
||||
require-build:
|
||||
.*: build-linux64/opt
|
||||
fetches:
|
||||
build:
|
||||
- artifact: target.xpt_artifacts.zip
|
||||
dest: xpt_artifacts
|
||||
|
||||
license:
|
||||
description: Check for license blocks in source files.
|
||||
treeherder:
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ apt_packages+=('python-is-python3')
|
|||
apt_packages+=('shellcheck')
|
||||
apt_packages+=('sudo')
|
||||
apt_packages+=('wget')
|
||||
apt_packages+=('unzip')
|
||||
apt_packages+=('tar')
|
||||
apt_packages+=('zstd')
|
||||
|
||||
apt-get update
|
||||
apt-get install "${apt_packages[@]}"
|
||||
|
|
|
|||
|
|
@ -1389,3 +1389,14 @@ def target_tasks_are_we_esmified_yet(full_task_graph, parameters, graph_config):
|
|||
return [
|
||||
l for l, t in full_task_graph.tasks.items() if t.kind == "are-we-esmified-yet"
|
||||
]
|
||||
|
||||
|
||||
@_target_task("eslint-build")
|
||||
def target_tasks_eslint_build(full_task_graph, parameters, graph_config):
|
||||
"""Select the task to run additional ESLint rules which require a build."""
|
||||
|
||||
for name, task in full_task_graph.tasks.items():
|
||||
if task.kind != "source-test":
|
||||
continue
|
||||
if name == "eslint-build":
|
||||
yield name
|
||||
|
|
|
|||
|
|
@ -74,31 +74,40 @@ module.exports = {
|
|||
* A map of interface names to the interface details.
|
||||
*/
|
||||
get xpidlData() {
|
||||
let objdir;
|
||||
if (process.env.MOZ_OBJDIR) {
|
||||
objdir = `${process.env.MOZ_OBJDIR}/config/makefiles/xpidl/`;
|
||||
} else if (process.env.TEST_XPIDLDIR) {
|
||||
objdir = process.env.TEST_XPIDLDIR;
|
||||
}
|
||||
if (!objdir) {
|
||||
let xpidlDir;
|
||||
|
||||
if (process.env.TASK_ID && !process.env.MOZ_XPT_ARTIFACTS_DIR) {
|
||||
throw new Error(
|
||||
"This rule needs MOZ_OBJDIR defining in the environment. It must be a full build."
|
||||
"MOZ_XPT_ARTIFACTS_DIR must be set for this rule in automation"
|
||||
);
|
||||
}
|
||||
xpidlDir = process.env.MOZ_XPT_ARTIFACTS_DIR;
|
||||
|
||||
if (!xpidlDir && process.env.MOZ_OBJDIR) {
|
||||
xpidlDir = `${process.env.MOZ_OBJDIR}/dist/xpt_artifacts/`;
|
||||
if (!fs.existsSync(xpidlDir)) {
|
||||
xpidlDir = `${process.env.MOZ_OBJDIR}/config/makefiles/xpidl/`;
|
||||
}
|
||||
}
|
||||
if (!xpidlDir) {
|
||||
throw new Error(
|
||||
"MOZ_OBJDIR must be defined in the environment for this rule, i.e. MOZ_OBJDIR=objdir-ff ./mach ..."
|
||||
);
|
||||
}
|
||||
if (xpidlData) {
|
||||
return xpidlData;
|
||||
}
|
||||
let files = fs.readdirSync(`${objdir}`);
|
||||
let files = fs.readdirSync(`${xpidlDir}`);
|
||||
// `Makefile` is an expected file in the directory.
|
||||
if (files.length <= 1) {
|
||||
throw new Error("Missing xpidl files, this rule needs a full build.");
|
||||
throw new Error("Missing xpidl data files, maybe you need to build?");
|
||||
}
|
||||
xpidlData = new Map();
|
||||
for (let file of files) {
|
||||
if (!file.endsWith(".xpt")) {
|
||||
continue;
|
||||
}
|
||||
let data = JSON.parse(fs.readFileSync(path.join(`${objdir}`, file)));
|
||||
let data = JSON.parse(fs.readFileSync(path.join(`${xpidlDir}`, file)));
|
||||
for (let details of data) {
|
||||
xpidlData.set(details.name, details);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,15 @@ const platformSpecificInterfaces = new Map([
|
|||
["nsIWindowsRegKey", "windows"],
|
||||
["nsIWindowsPackageManager", "windows"],
|
||||
["nsIWindowsShellService", "windows"],
|
||||
["nsIAccessibleMacEvent", "darwin"],
|
||||
["nsIAccessibleMacInterface", "darwin"],
|
||||
["nsILocalFileMac", "darwin"],
|
||||
["nsIAccessibleMacEvent", "darwin"],
|
||||
["nsIMacAttributionService", "darwin"],
|
||||
["nsIMacShellService", "darwin"],
|
||||
["nsIMacDockSupport", "darwin"],
|
||||
["nsIMacFinderProgress", "darwin"],
|
||||
["nsIMacPreferencesReader", "darwin"],
|
||||
["nsIMacSharingService", "darwin"],
|
||||
["nsIMacUserActivityUpdater", "darwin"],
|
||||
["nsIMacWebAppUtils", "darwin"],
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ function invalidCode(code, messageId, data) {
|
|||
return { code, errors: [{ messageId, data }] };
|
||||
}
|
||||
|
||||
process.env.TEST_XPIDLDIR = `${__dirname}/xpidl`;
|
||||
process.env.MOZ_XPT_ARTIFACTS_DIR = `${__dirname}/xpidl`;
|
||||
|
||||
const tests = {
|
||||
valid: ["Ci.nsIURIFixup", "Ci.nsIURIFixup.FIXUP_FLAG_NONE"],
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ function invalidCode(code, messageId, data) {
|
|||
return { code, errors: [{ messageId, data }] };
|
||||
}
|
||||
|
||||
process.env.TEST_XPIDLDIR = `${__dirname}/xpidl`;
|
||||
process.env.MOZ_XPT_ARTIFACTS_DIR = `${__dirname}/xpidl`;
|
||||
|
||||
ruleTester.run("valid-services-property", rule, {
|
||||
valid: [
|
||||
|
|
|
|||
Loading…
Reference in a new issue