Skip to content

fix(ci): surface actionable broken link failures#564

Merged
hami-robot[bot] merged 1 commit into
Project-HAMi:masterfrom
spencercjh:fix/pr563-linkcheck-diagnostics
Jul 8, 2026
Merged

fix(ci): surface actionable broken link failures#564
hami-robot[bot] merged 1 commit into
Project-HAMi:masterfrom
spencercjh:fix/pr563-linkcheck-diagnostics

Conversation

@spencercjh

@spencercjh spencercjh commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • switch the broken-link check away from linkinator's fragile human formatter path
  • resolve pinned linkinator/sirv package binaries via npx --package ... and invoke the direct CLI JSON path
  • print a structured broken-link summary plus filtered non-2xx/3xx sirv responses when the check fails

Why

PR #563's red Broken Internal Link Check did not show a stable broken-link offender. The failing job only emitted:

  • Linkinator failed with exit code 13
  • → crawling http://127.0.0.1:3000
  • a long sirv log with no obvious offender URL

This patch keeps the failure semantics strict, but makes the failure output much easier to act on:

  • if linkinator returns structured broken entries, we print status / state / url / parent / failureDetails
  • if linkinator still fails without actionable entries, we surface the raw JSON and the filtered sirv non-2xx/3xx lines so the missing path is still visible

Validation

  • npx -y node@20 /usr/lib/node_modules/npm/bin/npm-cli.js run check-links
  • synthetic broken-link probe under Node 20 now reports the concrete missing path from the fallback summary:
    • 404 ... /missing.html

Summary by CodeRabbit

  • Bug Fixes
    • Improved link-checking output to show clearer, structured summaries when broken links or server issues are detected.
    • Reduced noisy error logs by reporting only the most relevant failures.
    • Added support for configuring tool versions through environment variables for more flexible checks.

Signed-off-by: spencercjh <jiahao.cai@dynamia.ai>
@netlify

netlify Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploy Preview for project-hami ready!

Name Link
🔨 Latest commit cb6a75c
🔍 Latest deploy log https://app.netlify.com/projects/project-hami/deploys/6a4e1ed01430250008f4f8f1
😎 Deploy Preview https://deploy-preview-564--project-hami.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@hami-robot hami-robot Bot requested review from mesutoezdil and windsonsea July 8, 2026 09:56
@hami-robot hami-robot Bot added the size/L label Jul 8, 2026
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The script scripts/check-links.sh is updated to allow configurable versions of sirv-cli and linkinator, resolve their concrete binary paths, invoke them via resolved binaries instead of npx, capture Linkinator output as JSON, and print structured summaries of non-2xx/3xx responses on failure.

Changes

Link checking script rework

Layer / File(s) Summary
Version overrides and binary resolution
scripts/check-links.sh
Adds env-var overrides for sirv-cli/linkinator versions, and resolve_npx_bin, print_linkinator_summary, print_sirv_summary helpers to resolve binaries and parse output.
Execution using resolved binaries
scripts/check-links.sh
Switches sirv build step to use resolved sirv_bin, and reworks linkinator execution to run via node on linkinator_cli with JSON capture and structured failure summaries.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: lgtm, approved

Suggested reviewers: wawa0210, rootsongjc

Poem

A rabbit hopped through scripts anew,
Resolving binaries, not just npx too,
JSON logs now neat and clean,
Sirv offenders finally seen,
Thump-thump hooray, the links check true! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the CI link-check improvement and the goal of making broken-link failures more actionable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@hami-robot

hami-robot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: spencercjh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/check-links.sh`:
- Around line 23-27: The resolve_npx_bin() helper currently relies on readlink
-f, which is GNU-specific and breaks on macOS/BSD. Update resolve_npx_bin() to
use a cross-platform binary path resolution approach before returning the
package bin path, keeping the existing npx --yes --package flow and command -v
lookup intact. Make the change within resolve_npx_bin() so local npm run
check-links works consistently across environments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: db484861-c44f-419b-bc0a-ee0b0a39f902

📥 Commits

Reviewing files that changed from the base of the PR and between 5f2a730 and cb6a75c.

📒 Files selected for processing (1)
  • scripts/check-links.sh

Comment thread scripts/check-links.sh
Comment on lines +23 to +27
resolve_npx_bin() {
local package="$1"
local bin_name="$2"
npx --yes --package "${package}" bash -lc "readlink -f \"\$(command -v ${bin_name})\""
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm the login shell adds stray stdout / mutates PATH in this environment.
bash -lc 'echo "PATH=$PATH"; command -v readlink' 2>&1 | head -n 20
# Check readlink -f availability/behavior
readlink -f "$(command -v bash)" || echo "readlink -f unsupported"

Repository: Project-HAMi/website

Length of output: 351


🏁 Script executed:

#!/bin/bash
sed -n '1,120p' scripts/check-links.sh

Repository: Project-HAMi/website

Length of output: 3654


🏁 Script executed:

#!/bin/bash
rg -n "resolve_npx_bin|sirv_bin|linkinator_bin|npx --yes --package|readlink -f" scripts/check-links.sh

Repository: Project-HAMi/website

Length of output: 488


🏁 Script executed:

#!/bin/bash
rg -n '"check-links"|scripts/check-links.sh|sirv-cli|linkinator' package.json .github scripts -g '!**/node_modules/**'

Repository: Project-HAMi/website

Length of output: 1756


🏁 Script executed:

#!/bin/bash
rg -n '"check-links"|scripts/check-links.sh|bash -lc|readlink -f|realpath' package.json README.md scripts -g '!**/node_modules/**'

Repository: Project-HAMi/website

Length of output: 398


Use a portable path resolver
readlink -f is GNU-only, so resolve_npx_bin() will fail on macOS/BSD. Switch to a cross-platform way to resolve the package binary before relying on this in local npm run check-links.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/check-links.sh` around lines 23 - 27, The resolve_npx_bin() helper
currently relies on readlink -f, which is GNU-specific and breaks on macOS/BSD.
Update resolve_npx_bin() to use a cross-platform binary path resolution approach
before returning the package bin path, keeping the existing npx --yes --package
flow and command -v lookup intact. Make the change within resolve_npx_bin() so
local npm run check-links works consistently across environments.

@hami-robot hami-robot Bot merged commit 6df0112 into Project-HAMi:master Jul 8, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant