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:
-
Building Storybook: Adds a new
build:gitlab-ui
script and includes it in theprecheck-links
step -
Serving Storybook: Configures
start-server-and-test
to serve both the main site and Storybook simultaneously - 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
#2887
What This Fixes from Issue
ALLOWED_HOST_PATTERNS
FAILURE_CODES
filtering
What This Won't Fix
#bar
in /foo#bar
actually exist on the target page. This would require additional logic to parse HTML and check for matching id
attributes.
Testing
The changes can be tested by running:
yarn check-links
This will now:
- Build both the main site and Storybook
- Serve both on separate ports
- Check links from the main site, including those pointing to Storybook
Closes #2887