Skip to content

Measure test coverage, upload it to Codecov, show it in the README - #577

Merged
whes1015 merged 4 commits into
mainfrom
ci/test-coverage
Sep 17, 2026
Merged

whes1015 merged 4 commits into
mainfrom
ci/test-coverage

Conversation

@whes1015

Copy link
Copy Markdown
Member

這個 PR 做了什麼

測試覆蓋率有了固定的量法和公開的呈現:產生的程式碼用 Dart 標準的
// coverage:ignore-file 排除,tool/dev/coverage.sh 跑整套測試並量 lib/ 的行
覆蓋率,CI 上傳到 Codecov,README 顯示徽章與旭日圖。

相關 issue

怎麼驗

合併前需要先啟用 Codecov:到 https://app.codecov.io/gh 用 GitHub 登入、授權
ExpTechTW 並啟用這個 repo,再安裝 Codecov 的 GitHub App
(PR 留言與狀態檢查靠它)。在那之前 CI 的上傳步驟會失敗但不會讓 CI 變紅
README 的旭日圖會是 404、徽章顯示 unknown。上傳用 OIDC,不需要任何 secret。

  1. tool/dev/coverage.shcoverage/lcov.info;本機裝了 lcov(brew install lcov
    還會產生 coverage/html/index.html。目前是 55.9%、32,985 行、449 個檔案。
  2. grep -c '\.g\.dart' coverage/lcov.info0:產生的程式碼不在報告裡。把任何一個
    .g.dartlib/l10n/gen/ 檔案開頭的 // coverage:ignore-file 刪掉,
    tool/dev/test.sh test/tool/generated_code_coverage_test.dart 會失敗並點名那個檔案
    和該跑的重新產生指令。
  3. tool/check.sh 的測試步驟就是這支腳本,和 CI 同一份;樹沒變就走快取。
  4. VS Code:Testing 面板 → Run Tests with Coverage,Test Coverage 檢視會出現每個
    資料夾與檔案的覆蓋率條,檔案總管顯示百分比。那是 Dart 擴充自己跑的一輪,沒有
    import 沒被測到的檔案,所以數字會比報告略高,這是預期的。

安全關鍵的部分沒有被碰到:這個 PR 不改任何 lib/ 手寫程式碼,只有產生器設定、
重新產生的檔案、工具腳本、CI 與文件。

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過
  • 一個 commit 一件事:產生檔標記 / 覆蓋率腳本 / CI 上傳 / README
  • tool/dev/analyze.shtool/dev/coverage.sh 通過(1870 個測試)
  • 沒有新的使用者可見字串
  • 沒有 UI 變更

@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@whes1015 whes1015 changed the title 測試覆蓋率:排除產生檔、CI 上傳 Codecov、README 徽章與旭日圖 Measure test coverage, upload it to Codecov, show it in the README Sep 17, 2026
@whes1015
whes1015 merged commit b5ae3f9 into main Sep 17, 2026
6 checks passed
@whes1015
whes1015 deleted the ci/test-coverage branch September 17, 2026 20:47
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