Skip to content

SEO checks: one file per check, so PRs adding checks stop conflicting - #1222

Merged
LukasWallrich merged 3 commits into
rebrand-doorsfrom
seo-checks-per-file
Dec 2, 2026
Merged

LukasWallrich merged 3 commits into
rebrand-doorsfrom
seo-checks-per-file

Conversation

@LukasWallrich

@LukasWallrich LukasWallrich commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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 changed citation_targets rules (data-cite, data-reference, truncated data-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-doors now 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, href or data-cite, a breadcrumb name that is not text, and malformed mainEntity data no longer abort the run. Results on valid input are the same.
  • Overlaps checked, all kept:
    • homepage_assets catches the highlight.js stylesheet, which conditional_assets doesn't look at.
    • search_heading catches the search overlay's <h1> (on every page via baseof.html) on pages with no heading of their own, where single_h1 can't.
    • homepage_share_image requires 1200×630 and summary_large_image, which share_image_metadata doesn'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/tests passes 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.yaml runs 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.

Each hard check in check_seo_html.py moves to scripts/seo_checks/<name>.py
(docstring plus check(site)), with its tests in
scripts/tests/test_seo_<name>.py. The runner loads every module in that
folder in name order, so adding a check touches no shared file. Numbers
are gone; the summary shows each check's module name and first docstring
line. CLI, exit code and report-only output are unchanged.

The newsletter third-party check ran twice (as 12 and 19); it now runs once.
The runner test that faked a whole site to get exit 0 is replaced by stub
checks, and the crumb-links test now runs the check, not the parser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LukasWallrich
LukasWallrich requested a review from a team as a code owner November 19, 2026 15:23
@github-actions

Copy link
Copy Markdown
Contributor

👍 All image files/references (if any) are in webp format, in line with our policy.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

📝 Spell Check Results

Found 2 potential spelling issue(s) when checking 70 changed file(s):

📄 scripts/seo_checks/extension_move.py

Line Issue
1 ORE ==> OR
3 ORE ==> OR

ℹ️ How to address these issues:

  1. Fix the typo: If it's a genuine typo, please correct it.
  2. Add to whitelist: If it's a valid word (e.g., a name, technical term), add it to .codespell-ignore.txt
  3. False positive: If this is a false positive, please report it in the PR comments.

🤖 This check was performed by codespell

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 43 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread AGENTS.md Resolved
Comment thread scripts/seo_checks/learning_resource.py Resolved
Comment thread scripts/seo_checks/_site.py Resolved
Comment thread scripts/seo_checks/clusters_map.py Resolved
Comment thread scripts/seo_checks/breadcrumb_jsonld.py Resolved
Comment thread scripts/seo_checks/homepage_img_dims.py Resolved
Comment thread scripts/seo_checks/breadcrumb_jsonld.py Resolved
Comment thread scripts/check_seo_html.py Resolved
It looked for one hard-coded DOI on one page: a content check, not a
template regression.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port the checks rebrand-doors added to the old check_seo_html.py into their own
modules in scripts/seo_checks/, with their tests, and restore the FLoRA citation
check in its DOI-independent form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

👍 All content rules passed (WebP images/references and canonical doi.org links).

@LukasWallrich
LukasWallrich merged commit 99089ec into rebrand-doors Dec 2, 2026
14 checks passed
@LukasWallrich
LukasWallrich deleted the seo-checks-per-file branch December 2, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant