fix(site): take the site base from the Pages URL
What changed
The live results page rendered unstyled, with its inline diagrams at natural size. The Astro config hardcoded site: https://gitlab-com.gitlab.io and base: /public-sector/offline-lab, but the project serves from its Pages unique domain at the root, https://duo-selfhosted-iac-ff1f21.gitlab.io/. The built stylesheet, the favicon and every /runs/ link pointed at a path that does not exist on that origin. Only the absolute reference chrome stylesheet loaded.
site and base now come from CI_PAGES_URL, which GitLab sets in the pages job. A local build with the variable unset serves at the root. The pages component runs build_command inside the job, so the variable reaches npm run build with no component change. Pages settings are untouched, and the site works at a domain root or under a path.
scripts/check_site_links.py now reads every href and src in every built page and fails when:
- a relative or root-relative reference does not resolve to a file in the output after the base is stripped, or
- a stylesheet, script, image or icon loads from anywhere but the pinned reference chrome prefix.
Plain navigation links may go anywhere, and the result-chip anchor check stays. A new site:links job builds for a domain root and for a project path on every merge request, so a wrong base fails here and not after merge.
Proof
Old config built with CI_PAGES_URL=https://duo-selfhosted-iac-ff1f21.gitlab.io: the check fails with 52 broken references. Fixed config: passes at the domain root and at https://gitlab-com.gitlab.io/public-sector/offline-lab. astro check reports 0 errors. The full scripts/ unittest suite passes.
flowchart LR
A[CI_PAGES_URL in the pages job] --> B[astro site and base]
B --> C[built links and assets]
C --> D[check_site_links.py]
D -->|any miss| E[build fails]