Bug 1821117 [wpt PR 38888] - Expose desired{Execution|Render}Start in LoAF+ScriptTimi...
[gecko.git] / taskcluster / scripts / misc / verify-devtools-bundle.py
blobf5bcd6147853f4f29f58132c3cbf16e8ba14e794
1 #!/usr/bin/env python3
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, # You can obtain one at http://mozilla.org/MPL/2.0/.
6 """
7 Check that the current sourcemap and worker bundles built for DevTools are up to date.
8 This job should fail if any file impacting the bundle creation was modified without
9 regenerating the bundles.
11 This check should be run after building the bundles via:
12 cd devtools/client/debugger
13 yarn && node bin/bundle.js
15 Those steps are done in the devtools-verify-bundle job, prior to calling this script.
16 The script will only run `hg status devtools/` and check that no change is detected by
17 mercurial.
18 """
20 import argparse
21 import json
22 import subprocess
23 import sys
25 print("Run `hg status devtools/`")
26 status = (
27 subprocess.check_output(["hg", "status", "-n", "devtools/"])
28 .decode("utf-8")
29 .split("\n")
31 print(" status:")
32 print("-" * 80)
34 doc = "https://firefox-source-docs.mozilla.org/devtools/tests/node-tests.html#devtools-bundle"
36 failures = {}
37 for l in status:
38 if not l:
39 # Ignore empty lines
40 continue
42 if "module-manifest.json" in l:
43 # Ignore module-manifest.json updates which can randomly happen when
44 # building bundles.
45 continue
47 failures[l] = [
49 "path": l,
50 "line": None,
51 "column": None,
52 "level": "error",
53 "message": l
54 + " is outdated and needs to be regenerated, "
55 + f"instructions at: {doc}",
59 # Revert all the changes created by `node bin/bundle.js`
60 subprocess.check_output(["hg", "revert", "-C", "devtools/"])
62 parser = argparse.ArgumentParser()
63 parser.add_argument("--output", required=True)
64 args = parser.parse_args()
66 with open(args.output, "w") as fp:
67 json.dump(failures, fp, indent=2)
69 if len(failures) > 0:
70 print(
71 "TEST-UNEXPECTED-FAIL | devtools-bundle | DevTools bundles need to be regenerated, "
72 + f"instructions at: {doc}"
75 print("The following devtools bundles were detected as outdated:")
76 for failure in failures:
77 print(failure)
79 sys.exit(1)