Skip to content

ci: make local checks portable across platforms - #638

Merged
whes1015 merged 13 commits into
mainfrom
fix/windows-mise-path-check
Oct 22, 2026
Merged

whes1015 merged 13 commits into
mainfrom
fix/windows-mise-path-check

Conversation

@bamboo0403

@bamboo0403 bamboo0403 commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

這個 PR 做了什麼

改善本機檢查與相關工具在 Windows Git Bash、macOS 和 Linux 上的相容性,修正 Windows 路徑、SHA-256 工具與文字編碼造成的檢查失敗。Windows 本機執行 tool/dev/analyze.sh,其餘 gates、codegen、測試與 coverage 交由 Linux CI。

正式工具程式碼:

  • 正規化 Git Bash 從 mise 取得的 Windows 路徑,並以 Bash 3.2 相容的方式進行不分大小寫比較,避免合法的 Flutter SDK 路徑被誤判為系統 SDK
  • 提供可在 shasum 與 sha256sum 間切換的 SHA-256 helper,並在目前 shell 中逐一計算 cache key 的檔案雜湊
  • 調整 tool/commit.sh 的跨平台檢查結果訊息,並保留使用 --no-check 時的警告
  • 明確以 UTF-8 讀取 Xcode project 與 localization catalog

測試程式碼:

  • 使用 Platform.pathSeparator 解析 DevFS 暫存路徑,使測試不依賴 POSIX /

這個 PR 沒有修改 App 功能、UI、EEW 推估、通知路徑或其他安全關鍵邏輯。

相關 issue

沒有對應的 issue。

怎麼驗

  • tool/check/commits.sh origin/main..HEAD 通過:8 個 commits
  • tool/check/tooling.sh 通過
  • macOS 內建 Bash 3.2 可解析 tool/dev/_lib.sh,不再因 ${variable,,} 出現 bad substitution
  • Linux CI 的 build 通過
  • 尚未在 Windows Git Bash 上完成本機驗證
  • 沒有 UI 變更,不需要實機或深色模式檢查

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過
    —— commit 訊息就是更新日誌,格式見 commit.md
  • 一個 commit 一件事(這條 gate 驗不了,靠自己和 review)
  • mise exec -- flutter analyze 與 mise exec -- flutter test 通過
  • 新的使用者可見字串都走 AppLocalizations,沒有寫死
  • CI 全部通過(gh pr checks:每一項都是 pass 或 skipped)—— 沒過不能合併,
    見 pr.md
  • 有 UI 變更的話:用的是 AppSpacing / AppRadius / AppMotion,
    深色模式看過,文字對比度可接受

@bamboo0403
bamboo0403 added this pull request to stack #640 October 21, 2026 00:42
@bamboo0403
bamboo0403 force-pushed the fix/windows-mise-path-check branch 5 times, most recently from 3f7d754 to 06fc721 Compare October 21, 2026 04:01
@lowrt
lowrt force-pushed the fix/windows-mise-path-check branch from 06fc721 to 32456bc Compare October 21, 2026 04:36
@lowrt lowrt changed the title ci: windows mise path check ci: make local checks portable across platforms Oct 21, 2026
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.49%. Comparing base (565bad4) to head (e297f1d).
⚠️ Report is 16 commits behind head on main.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lowrt
lowrt force-pushed the fix/windows-mise-path-check branch 2 times, most recently from 628b482 to 20b077e Compare October 21, 2026 10:25
@pull-request-size pull-request-size Bot added size/M and removed size/L labels Oct 21, 2026
@lowrt
lowrt force-pushed the fix/windows-mise-path-check branch from 20b077e to f415e79 Compare October 21, 2026 22:20
@whes1015
whes1015 removed this pull request from stack #640 October 21, 2026 23:56
@whes1015 whes1015 mentioned this pull request Oct 21, 2026
5 of 6 tasks
@whes1015

Copy link
Copy Markdown
Member

維護者調整:在這個分支上面加了 5 個 commit,沒有改寫你原本的 commit。#639 已經和這裡拆開,直接以 main 為 base。

方向:Windows 也跑全部檢查

  • ci: run full checks on Windows(作者是你):從 fix(android): preserve wind JNI callbacks #639 移過來的 32456bc5,內容沒改:township JSON 容忍 CRLF、_lib.sh 不要求執行權限、generated_hashes,並保留 --no-check 的警告。
  • ci: drop the Windows early exit left in tool/check.sh:32456bc5 只拿掉了兩段 Windows 提早結束中的一段,tool/check.sh 裡還有一段 exit 0,所以其實還沒做到全部都跑。這個 commit 把剩下那段拿掉。

效能:雜湊改回一個 batch

  • ci: hash cache keys in one batch on every platform:每個檔案各跑一次 sha256,在 macOS 上 shasum 是 Perl 腳本,每次都要啟動一次。實測(同一棵樹、1,265 個檔案、三個版本算出來的 key 相同):

    版本 cache_key 耗時
    main 0.18 s
    這個 PR 原本 12.2 s
    修正後 0.12 s

    tool/check.sh 一次會算好幾個 key,所以原本的寫法會讓每次 pre-push 多出幾十秒,就算快取全中也一樣。

    • 改成用陣列 SHA256=(shasum -a 256) 或 (sha256sum) 交給 xargs。xargs 的子程序看不到 shell 函式,但看得到陣列展開後的指令,所以 Git Bash 上也能用。
    • 新增 require_sha256:找不到任何 SHA-256 工具時會明確失敗。否則 xargs 會改跑 echo,key 會悄悄變成一串檔名。

其他

  • ci: fold path case only on Windows:_lib.sh 原本在所有平台都做大小寫折疊,但在 Linux 上大小寫不同就是不同的路徑。改成只在 Windows 做,is_windows 放在 repo_root 旁邊。
  • ci: say again that CI runs Linux when local gates pass:Windows 也跑全部 gate 之後,tool/commit.sh 原本的訊息和那段「CI 是 Linux,shell out 的測試在 macOS 過了不代表 CI 會過」的註解又是對的了,所以還原成 main 的版本。

驗證

  • macOS 上 tool/check.sh 全部通過,3,621 個測試全過。
  • 還沒在 Windows Git Bash 上跑過。

已知限制:check/workflows 和 check/workflow_security 用的 tool/internal/pinned_tool.sh 只有 macOS 和 Linux 版的 actionlint/zizmor,在 Windows 上會照 #621 的設計明確失敗(不是跳過),所以 Windows 上的 tool/check.sh 會停在那兩道 gate。要在 Windows 全部通過,需要在 pinned_tool.sh 加上 Windows 版的 release 檔案和 checksum(actionlint 是 windows_amd64.zip,zizmor 是 x86_64-pc-windows-msvc.zip),並處理 zip 解壓縮。這需要有 Windows 環境驗證,你方便的話可以接著做。

另外,PR 描述裡「Windows 本機執行 tool/dev/analyze.sh,其餘交由 Linux CI」這段已經不適用了,麻煩更新一下。

@whes1015
whes1015 force-pushed the fix/windows-mise-path-check branch from 6733832 to e297f1d Compare October 22, 2026 00:30
@whes1015
whes1015 merged commit f1fea15 into main Oct 22, 2026
6 checks passed
@whes1015
whes1015 deleted the fix/windows-mise-path-check branch October 22, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants