Skip to content

ci(lighthouse): 自動探索編譯後頁面並聚焦無障礙把關#77

Open
ross-nics wants to merge 4 commits into
mainfrom
ci/lighthouse-ci
Open

ci(lighthouse): 自動探索編譯後頁面並聚焦無障礙把關#77
ross-nics wants to merge 4 commits into
mainfrom
ci/lighthouse-ci

Conversation

@ross-nics

@ross-nics ross-nics commented Jun 11, 2026

Copy link
Copy Markdown

摘要

改善 Lighthouse CI 設定,讓它自動探索 Hugo 編譯後的所有頁面,不再維護手動 URL 清單,並將 CI 的硬性把關聚焦在「無障礙(accessibility)」。效能與最佳實務項目改為警示(warn),不阻擋 CI。

本 PR 僅變更 .lighthouserc.json(workflow lhci.yml 已存在於 main)。

變更內容

1. 改用自動探索(staticDistDir)

  • 移除 startServerCommand: "hugo server" 與手動維護的 24 筆 url 清單。
  • 改用 staticDistDir: "./public",由 LHCI 啟動內建靜態伺服器並自動掃描 public/ 下所有 HTML。
  • 設定 maxAutodiscoverUrls: 0 解除預設「只掃 5 頁」的限制,改為掃描全部頁面。
  • 好處:日後新增頁面(含 feature 分支上的新元件)合併後會自動納入檢測,無需再手動維護清單。

2. 排除非正式頁面(autodiscoverUrlBlocklist)

排除 7 個不適合嚴格無障礙稽核的頁面:

  • Hugo 自動產生的 taxonomy 空殼頁:categories/tags/
  • iframe 示範骨架頁:landmark/blanklandmark/one-columnskip-to/skip-toskip-to/skip-to-multipledigital-info/digital-info
    (這些頁面標有 noindex,屬被嵌入的範例片段,非導覽頁。)

3. 斷言聚焦無障礙

  • categories:accessibility 維持 ["error", { minScore: 1 }] —— 唯一的硬性把關
  • 效能/最佳實務項目(unused-javascriptunsized-imageserrors-in-consolecrawlable-anchorsinspector-issuesuses-optimized-imagesuses-responsive-imagesunminified-javascript 等)改為 warn,在報告中提示但不阻擋 CI。

4. 先前修正(沿用)

  • 單頁 URL 改用 .html 結尾,對齊 uglyURLs=true 的輸出格式。

驗證

  • 本機 hugo --minify 產出 44 個受測頁面(已排除 7 個非正式頁)。
  • 本機跑 lhci autorun:44/44 頁 accessibility 全數 1.00 滿分
  • lhci assert 結果:exit 0,僅餘 warning,無 error。

注意事項

  • 嚴格的 accessibility minScore: 1 現在套用於所有自動探索頁面;未來新增頁面若無障礙不達標會擋下 CI(這是預期的把關行為)。

accessibility-statement and contact are single pages output as *.html (uglyURLs=true), so the trailing-slash URLs returned 404 in Lighthouse CI
@ross-nics ross-nics added the ci-lighthouse trigger lighthouse check label Jun 11, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request updates the Lighthouse configuration in .lighthouserc.json by appending .html extensions to the URLs for the accessibility statement and contact pages. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

@ross-nics ross-nics changed the title fix(lhci): 修正 Lighthouse CI 單頁網址 404 ci(lighthouse): 自動探索編譯後頁面並聚焦無障礙把關 Jun 12, 2026
@ross-nics ross-nics added ci-lighthouse trigger lighthouse check and removed ci-lighthouse trigger lighthouse check labels Jun 12, 2026
@ross-nics ross-nics removed the ci-lighthouse trigger lighthouse check label Jun 12, 2026
- upgrade @lhci/cli to 0.15.x and add workflow_dispatch checkout fallback\n- set staticDirFileDiscoveryDepth to 4 and simplify non-a11y assertions to category warnings\n- avoid redundant alt text on home feature icons for Lighthouse a11y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant