Skip to content

Check newly introduced external FAQ links before publishing - #68

Draft
lyzhang0113 wants to merge 1 commit into
previewfrom
link-check-before-publish
Draft

lyzhang0113 wants to merge 1 commit into
previewfrom
link-check-before-publish

Conversation

@lyzhang0113

Copy link
Copy Markdown
Contributor

Changes

  • Rewrite check_links.py to scan published FAQ Markdown only, verify HTTPS certificates, distinguish confirmed broken URLs from inconclusive remote responses, and fail on confirmed breakage.
  • Compare external URLs against the base revision in CI so existing broken links do not block unrelated changes.
  • Add a separate Check-Links job for PRs and pushes to main/preview; build/sync jobs depend on its success. Add behavior tests and contributor documentation.

Verification

  • python -B -m unittest discover -s tests -v — 2 passed.
  • python -B check_links.py --base-ref origin/preview — 0 newly introduced URLs, exit 0.
  • Full python check_links.py — found 2 pre-existing GitHub 404s in barcode-reader/mobile/scan-setting/disable-continuous-scanning.md and 2 inconclusive npm 403s in barcode-reader/web/configuration/nodejs-implementation.md (exit 1); these pages are untouched.

Note: inconclusive network/access errors remain warnings, not publish-blocking failures; relative links and anchors are outside this external-link check.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 06:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Valid Markdown URLs containing balanced parentheses are truncated and checked incorrectly.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Adds CI enforcement for newly introduced broken external FAQ links while allowing inconclusive responses as warnings.

Changes:

  • Rewrites the external-link checker with TLS verification and base-revision comparison.
  • Adds tests, CI gating, and contributor documentation.
  • Excludes generated Python cache files.
File Description
check_links.py Implements external-link discovery and validation.
tests/​test_check_links.py Tests scanning and changed-link behavior.
.github/​workflows/​main.yml Adds link-check CI gating.
README.md Documents link-check behavior.
.gitignore Ignores Python cache directories.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread check_links.py

ROOT = Path(__file__).resolve().parent
PUBLISHED_ROOTS = {"barcode-reader", "mrz-scanner", "license"}
MARKDOWN_LINK = re.compile(r"!?\[[^\]\n]*\]\(\s*<?(https?://[^\s)>]+)", re.I)
Comment thread check_links.py
Comment on lines +94 to +98
with urlopen(request, timeout=15) as response: # default verified TLS context
final_host = urlsplit(response.url).hostname or ""
if final_host == "dynamsoft.com" or final_host.endswith(".dynamsoft.com"):
body = response.read(50000).decode("utf-8", errors="replace").lower()
if (re.search(r'id=["\']pagenotfound["\']', body) or
@lyzhang0113
lyzhang0113 marked this pull request as draft September 30, 2026 07:39
@lyzhang0113

Copy link
Copy Markdown
Contributor Author

There are existing broken links. Fix them before merging.

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.

2 participants