Skip to content

Fix check_links job by building and serving Storybook

What does this MR do?

This MR addresses several issues with the check_links job that has been failing since its creation. The changes enable proper link checking by:

  1. Building Storybook: Adds a new build:gitlab-ui script and includes it in the precheck-links step
  2. Serving Storybook: Configures start-server-and-test to serve both the main site and Storybook simultaneously
  3. URL Rewriting: Adds URL rewriting to redirect Storybook links from the main site to the dedicated Storybook server

Changes Made

package.json

  • Added build:gitlab-ui script to build the GitLab UI Storybook
  • Updated check-links to serve both main site (port 8080) and Storybook (port 9001)
  • Updated precheck-links to build both the main site and Storybook

scripts/check_links.mjs

  • Added STORYBOOK_HOST constant for localhost:9001
  • Added Storybook host to ALLOWED_HOST_PATTERNS
  • Added URL rewriting rule to redirect /storybook paths to the dedicated Storybook server

What This Fixes from Issue #2887

Builds Storybook: The script now builds Storybook to avoid broken links
Verifies links to Storybook: Links pointing to Storybook are now properly checked
Skips external hosts: Already implemented via ALLOWED_HOST_PATTERNS
Disallows failures: Already implemented via FAILURE_CODES filtering

What This Won't Fix

Anchor/URL fragment checking: The current implementation doesn't verify that anchors like #bar in /foo#bar actually exist on the target page. This would require additional logic to parse HTML and check for matching id attributes.

Recursing into Storybook: The current setup serves Storybook but doesn't recurse into it for link checking. This is intentional per the issue requirements, but could be added later if needed.

Testing

The changes can be tested by running:

yarn check-links

This will now:

  1. Build both the main site and Storybook
  2. Serve both on separate ports
  3. Check links from the main site, including those pointing to Storybook

Closes #2887

Merge request reports

Loading