fix(ci): surface actionable broken link failures#564
Conversation
Signed-off-by: spencercjh <jiahao.cai@dynamia.ai>
✅ Deploy Preview for project-hami ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughThe 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. ChangesLink checking script rework
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[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 DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
scripts/check-links.sh
| resolve_npx_bin() { | ||
| local package="$1" | ||
| local bin_name="$2" | ||
| npx --yes --package "${package}" bash -lc "readlink -f \"\$(command -v ${bin_name})\"" | ||
| } |
There was a problem hiding this comment.
🩺 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.shRepository: 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.shRepository: 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.
Summary
npx --package ...and invoke the direct CLI JSON pathsirvresponses when the check failsWhy
PR #563's red
Broken Internal Link Checkdid not show a stable broken-link offender. The failing job only emitted:Linkinator failed with exit code 13→ crawling http://127.0.0.1:3000sirvlog with no obvious offender URLThis patch keeps the failure semantics strict, but makes the failure output much easier to act on:
status / state / url / parent / failureDetailssirvnon-2xx/3xx lines so the missing path is still visibleValidation
npx -y node@20 /usr/lib/node_modules/npm/bin/npm-cli.js run check-links404 ... /missing.htmlSummary by CodeRabbit