From 3626bbda1428d59c7e1893bc53111f13fc023d4c Mon Sep 17 00:00:00 2001 From: ross-nics Date: Thu, 11 Jun 2026 16:34:29 +0800 Subject: [PATCH 1/5] fix(lhci): use .html URLs for single pages to match uglyURLs output accessibility-statement and contact are single pages output as *.html (uglyURLs=true), so the trailing-slash URLs returned 404 in Lighthouse CI --- .lighthouserc.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.lighthouserc.json b/.lighthouserc.json index ef7ae85e..259d49cf 100644 --- a/.lighthouserc.json +++ b/.lighthouserc.json @@ -5,8 +5,8 @@ "startServerCommand": "hugo server --environment production", "url": [ "http://localhost:1313/", - "http://localhost:1313/accessibility-statement/", - "http://localhost:1313/contact/", + "http://localhost:1313/accessibility-statement.html", + "http://localhost:1313/contact.html", "http://localhost:1313/components/", "http://localhost:1313/components/landmark/", "http://localhost:1313/components/checkable/", From e6e1bd5404ba99f5cb63e2465a35318d6143bceb Mon Sep 17 00:00:00 2001 From: ross-nics Date: Fri, 12 Jun 2026 15:47:08 +0800 Subject: [PATCH 2/5] ci(lighthouse): auto-discover pages and relax non-a11y assertions to warn --- .lighthouserc.json | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/.lighthouserc.json b/.lighthouserc.json index 259d49cf..700424b6 100644 --- a/.lighthouserc.json +++ b/.lighthouserc.json @@ -2,32 +2,16 @@ "ci": { "collect": { "numberOfRuns": 1, - "startServerCommand": "hugo server --environment production", - "url": [ - "http://localhost:1313/", - "http://localhost:1313/accessibility-statement.html", - "http://localhost:1313/contact.html", - "http://localhost:1313/components/", - "http://localhost:1313/components/landmark/", - "http://localhost:1313/components/checkable/", - "http://localhost:1313/components/button-and-link/", - "http://localhost:1313/components/digital-info/", - "http://localhost:1313/components/form/", - "http://localhost:1313/components/official-document/", - "http://localhost:1313/components/skip-to/", - "http://localhost:1313/components/table/", - "http://localhost:1313/components/textarea/", - "http://localhost:1313/components/warning-text/", - "http://localhost:1313/components/accordion/", - "http://localhost:1313/components/tabs/", - "http://localhost:1313/technology/", - "http://localhost:1313/technology/anti_patterns/", - "http://localhost:1313/technology/internationalization/", - "http://localhost:1313/technology/progressive_enhancement/", - "http://localhost:1313/visual/", - "http://localhost:1313/visual/colors/", - "http://localhost:1313/visual/internationalization/", - "http://localhost:1313/visual/typography/" + "staticDistDir": "./public", + "maxAutodiscoverUrls": 0, + "autodiscoverUrlBlocklist": [ + "http://localhost/categories/index.html", + "http://localhost/tags/index.html", + "http://localhost/components/landmark/blank.html", + "http://localhost/components/landmark/one-column.html", + "http://localhost/components/skip-to/skip-to.html", + "http://localhost/components/skip-to/skip-to-multiple.html", + "http://localhost/components/digital-info/digital-info.html" ], "settings": { "preset": "desktop" @@ -43,7 +27,15 @@ "meta-description": "warn", "unminified-css": "warn", "unused-css-rules": "warn", - "uses-text-compression": "warn" + "uses-text-compression": "warn", + "unused-javascript": "warn", + "unminified-javascript": "warn", + "unsized-images": "warn", + "errors-in-console": "warn", + "crawlable-anchors": "warn", + "inspector-issues": "warn", + "uses-optimized-images": "warn", + "uses-responsive-images": "warn" } }, "upload": { From 8d24ffcd043bf7ec616e9c53d2c6447fc71e41c6 Mon Sep 17 00:00:00 2001 From: ross-nics Date: Fri, 12 Jun 2026 16:30:52 +0800 Subject: [PATCH 3/5] ci(lighthouse): run on every PR commit and cancel in-progress runs --- .github/workflows/lhci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lhci.yml b/.github/workflows/lhci.yml index 7db3448c..1e418d00 100644 --- a/.github/workflows/lhci.yml +++ b/.github/workflows/lhci.yml @@ -5,12 +5,15 @@ on: # Triggers the workflow when pull request is opened or updated pull_request: - types: [opened, synchronize, reopened, labeled] + types: [opened, synchronize, reopened] + +# Cancel an in-progress run for the same PR/branch when a new commit arrives +concurrency: + group: lighthouse-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: lighthouseci: - # Run this job if labeled with 'ci-lighthouse' - if: ${{ github.event.label.name == 'ci-lighthouse' }} runs-on: ubuntu-latest steps: #ref: https://github.com/actions/starter-workflows/tree/main/pages From 43cd53da2f1dd2f8e39ec369b3ed33164e368ed5 Mon Sep 17 00:00:00 2001 From: ross-nics Date: Tue, 16 Jun 2026 14:38:13 +0800 Subject: [PATCH 4/5] ci(lighthouse): upgrade lhci and scope PR trigger paths - 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 --- .github/workflows/lhci.yml | 13 ++++++++++--- .lighthouserc.json | 18 +++--------------- layouts/home.html | 2 +- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/lhci.yml b/.github/workflows/lhci.yml index 1e418d00..1b2779a3 100644 --- a/.github/workflows/lhci.yml +++ b/.github/workflows/lhci.yml @@ -6,6 +6,11 @@ on: # Triggers the workflow when pull request is opened or updated pull_request: types: [opened, synchronize, reopened] + paths: + - 'assets/**' + - 'content/**' + - 'layouts/**' + - 'static/js/**' # Cancel an in-progress run for the same PR/branch when a new commit arrives concurrency: @@ -20,8 +25,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name }} + # Fall back to the triggering ref/repo when not run from a pull request + # (e.g. manual workflow_dispatch), where github.event.pull_request is empty + ref: ${{ github.event.pull_request.head.ref || github.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: @@ -35,7 +42,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 20 - - run: npm install -g @lhci/cli@0.11.x + - run: npm install -g @lhci/cli@0.15.x # Collect Lighthouse results - run: lhci autorun env: diff --git a/.lighthouserc.json b/.lighthouserc.json index 700424b6..701557b8 100644 --- a/.lighthouserc.json +++ b/.lighthouserc.json @@ -4,6 +4,7 @@ "numberOfRuns": 1, "staticDistDir": "./public", "maxAutodiscoverUrls": 0, + "staticDirFileDiscoveryDepth": 4, "autodiscoverUrlBlocklist": [ "http://localhost/categories/index.html", "http://localhost/tags/index.html", @@ -18,24 +19,11 @@ } }, "assert": { - "preset": "lighthouse:no-pwa", "assertions": { "categories:performance": ["warn", { "minScore": 0.9 }], "categories:accessibility": ["error", { "minScore": 1 }], - "csp-xss": "warn", - "is-crawlable": "warn", - "meta-description": "warn", - "unminified-css": "warn", - "unused-css-rules": "warn", - "uses-text-compression": "warn", - "unused-javascript": "warn", - "unminified-javascript": "warn", - "unsized-images": "warn", - "errors-in-console": "warn", - "crawlable-anchors": "warn", - "inspector-issues": "warn", - "uses-optimized-images": "warn", - "uses-responsive-images": "warn" + "categories:best-practices": ["warn"], + "categories:seo": ["warn"] } }, "upload": { diff --git a/layouts/home.html b/layouts/home.html index 0830bc02..e98bd1c7 100644 --- a/layouts/home.html +++ b/layouts/home.html @@ -28,7 +28,7 @@

設計制度內容

- {{ .Title }} +
{{ .Title }}
From b74c8e1f8826fa29321fa3d95f21208514cf698f Mon Sep 17 00:00:00 2001 From: ross-nics Date: Wed, 17 Jun 2026 10:59:23 +0800 Subject: [PATCH 5/5] ci(lighthouse): trigger on lhci config and hugo.toml changes --- .github/workflows/lhci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/lhci.yml b/.github/workflows/lhci.yml index 1b2779a3..4938d75c 100644 --- a/.github/workflows/lhci.yml +++ b/.github/workflows/lhci.yml @@ -11,6 +11,9 @@ on: - 'content/**' - 'layouts/**' - 'static/js/**' + - '.github/workflows/lhci.yml' + - '.lighthouserc.json' + - 'hugo.toml' # Cancel an in-progress run for the same PR/branch when a new commit arrives concurrency: