Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@ Features:
| Trigger | Target | Schedule |
|---------|--------|----------|
| Push to `rebrand-doors` | forrt.org/rebrand-doors/ (`forrtproject/rebrand-doors`) | On push |
| PR into `rebrand-doors` | Checks only, no deployment | On PR events |
| Same-repository PR into `rebrand-doors` | Checks only | On PR events |
| Same-repository PR from `rebrand-doors` into `main` | Launch checks | On PR events |
| Manual run on `rebrand-doors` | Launch checks | On dispatch |

Features:
- Uses the same data and announcement artifacts as `deploy.yaml`, with noindex and no analytics
- Compares each build with its merge base with `main`: URL list, structured data, SEO tags and internal links. See `scripts/rebrand/README.md`
- A failed check marks the run red but still updates the preview
- After the build, the comparison, the designed-screens check and the accessibility check run as three jobs side by side; the designed-screens check runs four browsers at once
- Pushes, manual runs and the launch PR compare URLs, structured data and SEO tags with the merge base with `main`. Both sites use the same pinned production artifacts.
- The source rules, internal links and built HTML checks run from the branch build alongside the browser checks. Only pushes update the preview, even if a check fails.
- Eligible PRs into `rebrand-doors` build their PR base (or reuse the last push build when its inputs match) and limit browser checks to the pages that differ.
- CSS or JS changes add the core design and axe samples to the changed-page checks. Core design covers the named screens, breakpoints, sample pages, home, floating controls at 390 and 1440 px, and every fourth article in the usual article set.
- Pushes, PRs labeled `full-checks`, PRs changing this workflow or the check scripts, and diffs over 60 pages run the full browser suite. With no relevant changes, both browser jobs report success without starting Chromium.
- Design and axe cache Chromium by Playwright version.
- Delete this workflow when the redesign launches

## Data Workflows
Expand Down
530 changes: 429 additions & 101 deletions .github/workflows/rebrand-preview.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion content/syllabus/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# FORRT page
type = "widget_page"
headless = false # Homepage is headless, other widget pages are not.
title = "Syllabus"
title = "Syllabus and teaching resources"
+++
92 changes: 92 additions & 0 deletions scripts/rebrand/changed_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env python3
"""Compare built pages and CSS/JS, and select the browser check mode."""

import argparse
import hashlib
import json
import re
from pathlib import Path

FINGERPRINT = re.compile(r"\.(?:[0-9a-f]{128}|[0-9a-f]{96}|[0-9a-f]{64}|[0-9a-f]{32})(?=\.(?:css|js)\b)")
INTEGRITY = re.compile(r"""\s+integrity=(?:"[^"]*"|'[^']*'|[^\s>]+)""")


def normalize(html):
def clean_tag(match):

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.

P2: normalize drops SRI from every <link>/<script>, including unfingerprinted vendor resources. An sri-only change in data/assets.toml therefore selects no checks, even though it can change whether that dependency loads.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/rebrand/changed_pages.py, line 15:

<comment>`normalize` drops SRI from every `<link>`/`<script>`, including unfingerprinted vendor resources. An `sri`-only change in `data/assets.toml` therefore selects no checks, even though it can change whether that dependency loads.</comment>

<file context>
@@ -0,0 +1,92 @@
+
+
+def normalize(html):
+    def clean_tag(match):
+        return INTEGRITY.sub("", match[0])
+
</file context>

return INTEGRITY.sub("", match[0])

return re.sub(r"<(?:link|script)\b[^>]*>", clean_tag, FINGERPRINT.sub("", html))


def page_path(path):
path = "/" + path.lstrip("/")
return path[:-len("index.html")] if path.endswith("/index.html") else path


def inventory(root):
pages, bundles = {}, {}
for path in sorted(root.rglob("*")):
suffix = path.suffix
if suffix not in {".html", ".css", ".js"} or not path.is_file():
continue
relative = path.relative_to(root).as_posix()
if suffix == ".html":
pages[page_path(relative)] = hashlib.sha256(normalize(path.read_text(encoding="utf-8")).encode()).digest()
else:
bundles.setdefault(FINGERPRINT.sub("", relative), set()).add(hashlib.sha256(path.read_bytes()).digest())
return pages, bundles


def compare(base, head):
before, old_bundles = inventory(base)
after, new_bundles = inventory(head)
return {
"changed": sorted(path for path in before.keys() & after.keys() if before[path] != after[path]),
"added": sorted(after.keys() - before.keys()),
"removed": sorted(before.keys() - after.keys()),
"bundles_changed": old_bundles != new_bundles,
}


def load_selection(path):
if path is None:
print("Check mode: full (all pages)")
return "full", set()
diff = json.loads(Path(path).read_text(encoding="utf-8"))
live = set(diff["changed"]) | set(diff["added"])
total = len(live) + len(diff["removed"])
if diff.get("force_full") or total > 60:
mode = "full"
elif diff["bundles_changed"]:
mode = "core"
elif live:
mode = "changed"
else:
mode = "none"
print(f"Check mode: {mode}")
for field in ("changed", "added", "removed"):
print(f"{field.capitalize()} pages: {', '.join(diff[field]) or '(none)'}")
if mode == "none":
print("no changed pages")
return mode, live


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("base", type=Path, nargs="?")
parser.add_argument("head", type=Path, nargs="?")
parser.add_argument("--out", type=Path, required=True)
parser.add_argument("--full", action="store_true")
args = parser.parse_args()
if args.full:
diff = {"changed": [], "added": [], "removed": [], "bundles_changed": False, "force_full": True}
else:
if not all(path and (path / "index.html").is_file() for path in (args.base, args.head)):
parser.error("base and head must each contain a built index.html")
diff = compare(args.base, args.head)
args.out.write_text(json.dumps(diff, indent=2) + "\n", encoding="utf-8")
load_selection(args.out)


if __name__ == "__main__":
main()
14 changes: 14 additions & 0 deletions scripts/rebrand/check_axe.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
sys.path.insert(0, HERE)
from check_design import serve # noqa: E402

from changed_pages import load_selection # noqa: E402

LEVEL_A = {"wcag2a", "wcag21a", "wcag22a"}
LEVEL_AA = {"wcag2aa", "wcag21aa", "wcag22aa"}
EXTRA = {
Expand Down Expand Up @@ -57,14 +59,26 @@ def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("public", nargs="?")
parser.add_argument("--url")
parser.add_argument("--pages", help="JSON from changed_pages.py")
parser.add_argument("--base", default="/")
parser.add_argument("--axe", required=True, help="path to axe.min.js")
parser.add_argument("--out", help="write every finding to this JSON file")
args = parser.parse_args()
mode, pages = load_selection(args.pages)

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.

P2: The scoped selection reintroduces /404.html even though full runs explicitly exclude it. A diff touching the error page will now run axe against it and can fail on unrelated 404-only markup; remove /404.html from pages before either scoped branch selects URLs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/rebrand/check_axe.py, line 67:

<comment>The scoped selection reintroduces `/404.html` even though full runs explicitly exclude it. A diff touching the error page will now run axe against it and can fail on unrelated 404-only markup; remove `/404.html` from `pages` before either scoped branch selects URLs.</comment>

<file context>
@@ -57,14 +59,26 @@ def main():
     parser.add_argument("--axe", required=True, help="path to axe.min.js")
     parser.add_argument("--out", help="write every finding to this JSON file")
     args = parser.parse_args()
+    mode, pages = load_selection(args.pages)
+    if mode == "none":
+        if args.out:
</file context>
Suggested change
mode, pages = load_selection(args.pages)
mode, pages = load_selection(args.pages)
pages.discard("/404.html")

if mode == "none":
if args.out:
with open(args.out, "w", encoding="utf-8") as handle:
json.dump([], handle)
return
base = args.url.rstrip("/") + "/" if args.url else serve(os.path.abspath(args.public), args.base)
with open(os.path.join(HERE, "sample_pages.json"), encoding="utf-8") as handle:
sample = {**json.load(handle), **EXTRA}
sample.pop("404", None)
if mode == "changed":
names = {path: name for name, path in sample.items()}
sample = {names.get(path, path): path for path in sorted(pages)}
elif mode == "core":
sample.update({path: path for path in sorted(pages - set(sample.values()))})
with open(args.axe, encoding="utf-8") as handle:
axe = handle.read()
findings, failures, practice = [], [], collections.Counter()
Expand Down
Loading
Loading