Skip to content

Commit c3dbd40

Browse files
committed
[IMP] tests: enable additional resource file-related checkers
The following custom checkers were never run by the `ci/documentation_guidelines` build and had to be run locally with `make review`: - `check_image_size`: Check that images are not larger than the maximum file size allowed for their extension. - `check_image_color_depth`: Check that PNG images are compressed to 8-bit color depth with PNGQuant. - `check_resource_file_name`: Check that resource file names use hyphens rather than underscores. Since reviewers systematically perform these checks manually, it makes sense to include them in the standard test suite. Should a check raise a false positive (e.g., an `example_db.zip` resource file is added and hyphens should not be used), the red CI can be safely ignored as it is not required for merging. closes #14715 X-original-commit: 41f2e20 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
1 parent 4e0d1dc commit c3dbd40

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

tests/main.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,23 @@
1818
]
1919

2020
ADDITIONAL_CHECKERS = [
21-
checkers.resource_files.check_resource_file_referenced
21+
checkers.resource_files.check_image_size,
22+
checkers.resource_files.check_image_color_depth,
23+
checkers.resource_files.check_resource_file_name,
24+
checkers.resource_files.check_resource_file_referenced,
2225
]
2326

2427

2528
def run_additional_checks(argv=None):
2629
_enabled_checkers, args = sphinxlint.parse_args(argv)
2730
for path in chain.from_iterable(sphinxlint.walk(path, args.ignore) for path in args.paths):
28-
if path.startswith('content') and not path.endswith('.rst'):
31+
if 'content/' in path and not path.endswith('.rst'): # Leave root and locale files alone.
2932
for checker in ADDITIONAL_CHECKERS:
3033
checker(path)
3134

3235

3336
"""
34-
The following checkers are selected for `make test`.
37+
The following built-in checkers are enabled for `make test`:
3538
- backtick-before-role: Search for roles preceded by a backtick.
3639
- bad-dedent: Check for mis-alignment in indentation in code blocks.
3740
- carriage-return: Check for carriage returns (\r) in lines.
@@ -55,13 +58,11 @@ def run_additional_checks(argv=None):
5558
- role-without-backticks: Search roles without backticks.
5659
- trailing-whitespace: Check for trailing whitespaces at end of lines.
5760
- unbalanced-inline-literals-delimiters: Search for unbalanced inline literals delimiters.
58-
---
59-
- all the checkers defined in checkers/* files.
6061
61-
The following checkers are only selected for `make review`.
62-
- line-too-long: Check for line length.
62+
All the custom checkers defined in checkers/* files are also enabled, except for the following ones,
63+
which are only enabled for `make review`:
64+
- line-too-long: Check for line lengths.
6365
- early-line-break: Check for early line breaks.
64-
6566
"""
6667
if __name__ == '__main__':
6768
# Patch sphinxlint's global constants to include our custom directives and parse their content.
@@ -87,10 +88,5 @@ def run_additional_checks(argv=None):
8788
if os.getenv('REVIEW') == '1': # Enable checkers for `make review`.
8889
setattr(sphinxlint.check_line_too_long, 'enabled', True)
8990
setattr(checkers.rst_style.check_early_line_breaks, 'enabled', True)
90-
ADDITIONAL_CHECKERS.extend([
91-
checkers.resource_files.check_image_size,
92-
checkers.resource_files.check_image_color_depth,
93-
checkers.resource_files.check_resource_file_name,
94-
])
9591
run_additional_checks()
9692
sys.exit(sphinxlint.main())

0 commit comments

Comments
 (0)