Skip to content

Commit d77cb23

Browse files
committed
[docs] Harden deploy workflows, strict link checks, and site tooling
1 parent f7e6713 commit d77cb23

9 files changed

Lines changed: 270 additions & 56 deletions

File tree

‎.github/workflows/check-docs.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ on:
99
- scenedetect/**
1010
- scenedetect.cfg
1111
- website/**
12+
- pyproject.toml
13+
- .github/workflows/check-docs.yml
1214
push:
1315
paths:
1416
- docs/**
1517
- scenedetect/**
1618
- scenedetect.cfg
1719
- website/**
20+
- pyproject.toml
21+
- .github/workflows/check-docs.yml
1822
branches:
1923
- main
2024
- 'releases/**'
@@ -28,6 +32,8 @@ jobs:
2832
# workflow author, who then gets emailed when a fork's nightly build fails.
2933
if: github.repository_owner == 'Breakthrough' || github.event_name != 'schedule'
3034
runs-on: ubuntu-latest
35+
permissions:
36+
contents: read
3137

3238
steps:
3339
- uses: actions/checkout@v7.0.1
@@ -61,7 +67,7 @@ jobs:
6167
- name: Build Website (--strict)
6268
shell: bash
6369
run: |
64-
python website/build.py --strict
70+
python website/build.py --strict --sphinx-dir docs/_build/html
6571
6672
- name: Check Responsive Layout & Capture Screenshots
6773
shell: bash

‎.github/workflows/generate-docs.yml‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
workflow_dispatch:
1515

1616
concurrency:
17-
group: gh-pages
17+
group: gh-pages-docs
1818
cancel-in-progress: false
1919

2020
jobs:
@@ -93,7 +93,7 @@ jobs:
9393
DOCS_DEST: ${{ env.scenedetect_docs_dest }}
9494
run: |
9595
git fetch origin gh-pages
96-
git checkout gh-pages
96+
git checkout -B gh-pages origin/gh-pages
9797
git clean -ffdx
9898
git rm "docs/${DOCS_DEST}" -r -f --ignore-unmatch
9999
mkdir -p "docs/${DOCS_DEST}"
@@ -121,5 +121,17 @@ jobs:
121121
git commit -a -m "[docs] @${TRIGGER_ACTOR}: Generate Documentation" \
122122
-m "Source: ${GITHUB_REF_NAME} (${GITHUB_SHA})" \
123123
-m "Destination: ${DOCS_DEST}"
124-
git push
124+
for attempt in 1 2 3 4 5; do
125+
if git push origin gh-pages; then
126+
break
127+
fi
128+
if [[ "${attempt}" -eq 5 ]]; then
129+
echo "Failed to push to gh-pages after ${attempt} attempts." >&2
130+
exit 1
131+
fi
132+
echo "Push failed (attempt ${attempt}/5); rebasing onto origin/gh-pages and retrying..."
133+
sleep $((attempt * 2))
134+
git fetch origin gh-pages
135+
git pull --rebase origin gh-pages
136+
done
125137
fi

‎.github/workflows/generate-website.yml‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
- clear-staging
2525

2626
concurrency:
27-
group: gh-pages
27+
group: gh-pages-website
2828
cancel-in-progress: false
2929

3030
jobs:
@@ -94,7 +94,7 @@ jobs:
9494
shell: bash
9595
run: |
9696
git fetch origin gh-pages
97-
git checkout gh-pages
97+
git checkout -B gh-pages origin/gh-pages
9898
git clean -ffdx
9999
100100
if [[ "${DEPLOY_TARGET}" == "production" ]]; then
@@ -126,7 +126,19 @@ jobs:
126126
git commit -a -m "[docs] @${TRIGGER_ACTOR}: Generate Website (${DEPLOY_TARGET})" \
127127
-m "Source: ${GITHUB_REF_NAME} (${GITHUB_SHA})" \
128128
-m "Target: ${DEPLOY_TARGET}"
129-
git push
129+
for attempt in 1 2 3 4 5; do
130+
if git push origin gh-pages; then
131+
break
132+
fi
133+
if [[ "${attempt}" -eq 5 ]]; then
134+
echo "Failed to push to gh-pages after ${attempt} attempts." >&2
135+
exit 1
136+
fi
137+
echo "Push failed (attempt ${attempt}/5); rebasing onto origin/gh-pages and retrying..."
138+
sleep $((attempt * 2))
139+
git fetch origin gh-pages
140+
git pull --rebase origin gh-pages
141+
done
130142
fi
131143
env:
132144
DEPLOY_TARGET: ${{ env.deploy_target }}

‎docs/_ext/doc_versions.py‎

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,69 @@ def _entry(slug: str, label: str, group: str) -> dict[str, Any]:
2020
def load_doc_versions(
2121
repo_dir: Path, fallback_version: str = ""
2222
) -> tuple[str, list[dict[str, Any]]]:
23-
"""Load (latest_version, version_entries) from docs/LATEST_VERSION and website/pages/docs.md."""
23+
"""Load (latest_version, version_entries) from docs/LATEST_VERSION and website/pages/docs.md.
24+
25+
Raises:
26+
ValueError: If LATEST_VERSION cannot be resolved, website/pages/docs.md is missing or
27+
yields no stable/legacy version entries, or LATEST_VERSION is not listed under
28+
the Stable section of website/pages/docs.md.
29+
"""
2430
latest_file = repo_dir / "docs" / "LATEST_VERSION"
2531
latest_ver = (
2632
latest_file.read_text(encoding="utf-8").strip().lstrip("v")
2733
if latest_file.is_file()
28-
else fallback_version.lstrip("v")
34+
else fallback_version.strip().lstrip("v")
2935
)
36+
if not latest_ver:
37+
raise ValueError(
38+
f"Could not determine latest documentation version from {latest_file} "
39+
"(and no fallback_version was provided)."
40+
)
41+
42+
docs_md = repo_dir / "website" / "pages" / "docs.md"
43+
if not docs_md.is_file():
44+
raise ValueError(f"Missing documentation version index: {docs_md}")
3045

3146
stable_slugs: list[str] = []
3247
legacy_slugs: list[str] = []
33-
docs_md = repo_dir / "website" / "pages" / "docs.md"
34-
if docs_md.is_file():
35-
section = ""
36-
for raw_line in docs_md.read_text(encoding="utf-8").splitlines():
37-
line = raw_line.strip()
38-
if line.startswith("## "):
39-
section = line[3:].strip().lower()
40-
continue
41-
match = _DOC_LINK_RE.match(line)
42-
if not match:
43-
continue
44-
slug = match.group(2).strip()
45-
if slug in {"latest", "head"}:
46-
continue
47-
if section == "legacy":
48-
legacy_slugs.append(slug)
49-
else:
50-
stable_slugs.append(slug)
48+
section = ""
49+
for raw_line in docs_md.read_text(encoding="utf-8").splitlines():
50+
line = raw_line.strip()
51+
if line.startswith("## "):
52+
section = line[3:].strip().lower()
53+
continue
54+
match = _DOC_LINK_RE.match(line)
55+
if not match:
56+
continue
57+
slug = match.group(2).strip()
58+
if slug in {"latest", "head"}:
59+
continue
60+
if section == "legacy":
61+
legacy_slugs.append(slug)
62+
elif section == "stable":
63+
stable_slugs.append(slug)
5164

52-
if not stable_slugs and latest_ver:
53-
stable_slugs = [latest_ver, "0.7"]
65+
if not stable_slugs:
66+
raise ValueError(
67+
f"No stable version links found under '## Stable' in {docs_md}; "
68+
"expected '- [vX.Y.Z](/docs/X.Y.Z/)' list items."
69+
)
5470
if not legacy_slugs:
55-
legacy_slugs = ["0.6.7"]
71+
raise ValueError(
72+
f"No legacy version links found under '## Legacy' in {docs_md}; "
73+
"expected '- [vX.Y.Z](/docs/X.Y.Z/)' list items."
74+
)
75+
if latest_ver not in stable_slugs:
76+
raise ValueError(
77+
f"LATEST_VERSION '{latest_ver}' is not listed under '## Stable' in {docs_md} "
78+
f"(found: {', '.join(stable_slugs)})."
79+
)
5680

5781
entries = [
5882
_entry("latest", f"v{latest_ver} (latest)", "channel"),
5983
_entry("head", "dev (head)", "channel"),
6084
]
6185
# Avoid duplicating `latest` as a separate row when it is the current stable release.
6286
entries += [_entry(slug, f"v{slug}", "release") for slug in stable_slugs if slug != latest_ver]
63-
if legacy_slugs:
64-
entries.append(_entry(legacy_slugs[0], f"v{legacy_slugs[0]} (legacy)", "legacy"))
87+
entries.append(_entry(legacy_slugs[0], f"v{legacy_slugs[0]} (legacy)", "legacy"))
6588
return latest_ver, entries

‎docs/_templates/layout.html‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
</script>
2929
{%- endif %}
3030
<script type="module">
31-
if (!Object.hasOwn(HTMLElement.prototype, "popover")) {
32-
import("https://unpkg.com/@oddbird/popover-polyfill@0.6.1/dist/popover.min.js").catch(() => {});
33-
}
34-
3531
(() => {
3632
const meta = document.querySelector('meta[name="color-scheme"]');
3733
if (meta) {

0 commit comments

Comments
 (0)