SEO checks: one file per check, so PRs adding checks stop conflicting
PRs that add an SEO check kept conflicting with each other: each took the next free number and appended to the same four places in check_seo_html.py and its test file. #1093 and #1207 both claim check 14 on main, and here on rebrand-doors the newsletter check ran twice, once as "12" (colliding with the resource-subsets check) and once as "19".
Now each check is its own module, scripts/seo_checks/<name>.py: a docstring (its first line is the summary title) and a check(site) function. Its tests go in scripts/tests/test_seo_<name>.py. The runner loads every module in that folder in name order, so adding a check means adding two files and editing nothing shared. The numbers are gone, so the summary and FAIL headings now show module names in alphabetical order. The command line, exit code and report-only output are unchanged, so deploy.yaml, rebrand-preview.yaml and rehearse_launch.py need no change.
The runner refuses to start if the folder is empty or a module lacks a docstring or check, and a runner test confirms every module file is loaded, so a check can't silently drop out.
Audit of checks and tests
- Removed: the duplicate newsletter run (old 12 and 19).
- Moved in from
rebrand-doors: every check added there since this branch started (old 25–37) is its own module with tests, and the changedcitation_targetsrules (data-cite,data-reference, truncateddata-source) are included. There are now 37 checks. - Kept: the FLoRA citation check. This PR first dropped it because it looked for one hard-coded DOI;
rebrand-doorsnow accepts any DOI next to the dataset citation, so that reason no longer applies. - Tests replaced: the runner test that built a fake whole site just so
main()returned 0. Stub checks now cover it. The breadcrumb-links test now runs the check, not just the parser. - Tests added: for checks that had none (retired newsletter script, related card pictures, extension move), and for the crash guards.
- Crash guards: a bare
class,hrefordata-cite, a breadcrumb name that is not text, and malformedmainEntitydata no longer abort the run. Results on valid input are the same. - Overlaps checked, all kept:
homepage_assetscatches the highlight.js stylesheet, whichconditional_assetsdoesn't look at.search_headingcatches the search overlay's<h1>(on every page viabaseof.html) on pages with no heading of their own, wheresingle_h1can't.homepage_share_imagerequires 1200×630 andsummary_large_image, whichshare_image_metadatadoesn't.
Verification
- Built the merged branch with Hugo (3,774 pages checked). Old and new runners give the same result (all pass, exit 0), and the report-only output is identical.
- Injected 68 faults, at least one for each of the 37 checks, into a copy of the build. Old and new code flag exactly the same items every time. With one fault per check at once, both command lines exit 1 with the same 37 failing checks and items.
python3 -m unittest discover -s scripts/testspasses with CI's dependencies (365 tests, 107 of them SEO tests; 90 before, minus the fake-site test, plus 18), and so does the disciplines parser test.script-tests.yamlruns both on every PR.
If a PR adds a check in the old layout
Move its check_* function into scripts/seo_checks/<name>.py as check(site) with a docstring, and its tests to scripts/tests/test_seo_<name>.py.
Created with Claude Opus 5.5 in Claude Code (T3 Code); options reviewed by GPT-6.2 Sol in Codex.