Skip to content

fix(coverage): switch from whitelist to full-source coverage reporting#1491

Merged
piorpua merged 2 commits intomainfrom
fix/coverage-reporting
Mar 20, 2026
Merged

fix(coverage): switch from whitelist to full-source coverage reporting#1491
piorpua merged 2 commits intomainfrom
fix/coverage-reporting

Conversation

@loonghao
Copy link
Copy Markdown
Collaborator

Summary

Fix the root cause of PRs not reporting coverage to Codecov: the coverage configuration used a manual whitelist of ~40 specific files, meaning all other source code (~660 files) was completely invisible to coverage reporting.

Problem

vitest.config.ts used an explicit include list for coverage:

include: [
  'src/process/tray.ts',
  'src/process/deepLink.ts',
  // ... ~40 manually curated files
]

This meant:

  • ❌ New files added by PRs were never reported to Codecov unless someone manually updated the list
  • ❌ Codecov's diff coverage showed 0% for any file not in the whitelist
  • ❌ ~94% of source code was invisible to coverage tracking

Solution

Switch from a whitelist approach to a full-source coverage approach with targeted exclusions:

vitest.config.ts

  • Before: Manual include list of ~40 files
  • After: include: ['src/**/*.{ts,tsx}'] with exclude for files that genuinely can't be tested:
    • *.d.ts (type declarations, no runtime code)
    • src/index.ts, src/preload.ts (Electron entry points)
    • src/shims/**, src/types/** (polyfills, pure types)
    • src/shared/** (JSON config only)
  • Result: Coverage now spans 697 source files (was ~40)
  • Thresholds temporarily set to 0 to avoid CI failures while coverage ramps up

codecov.yml

  • Expanded ignore list to match vitest excludes (consistency)
  • Changed project target from fixed 80% to auto (track against previous baseline)
  • Added patch target of 50% (informational) to encourage PR-level coverage

Verification

  • vitest run --coverage produces coverage/lcov.info with 697 source files
  • No lint errors
  • CI workflow (pr-checks.yml) unchanged — coverage upload logic remains the same
  • The Codecov upload step will now have a much larger lcov.info covering all core code

Impact

After this change:

  • ✅ Every PR touching source code will show coverage diff on Codecov
  • ✅ New files are automatically included — no manual whitelist maintenance
  • ✅ Codecov PR comments will show meaningful coverage data for all changed files
  • ✅ Team can identify untested areas across the entire codebase

Switch coverage.include from a manual 40-file whitelist to src/**/*.{ts,tsx} so that all core source code is reported to Codecov by default. New files are automatically included without manual vitest.config.ts edits.

Changes:

- vitest.config.ts: replace manual include list with src/**/*.{ts,tsx} glob + targeted excludes (*.d.ts, entry points, shims, type-only files)

- codecov.yml: expand ignore list to match vitest excludes, set project target to auto, add patch target 50% (informational)

- Coverage now spans 697 source files (was ~40)
…load

The explicit slug parameter may conflict with repository-level tokens, causing 404 'Repository not found' errors. Remove slug (Codecov auto-detects from the repo context) and add OIDC-based auth as a fallback when CODECOV_TOKEN is empty.

Changes:

- Remove slug: iOfficeAI/AionUi (let Codecov auto-detect)

- Add use_oidc fallback when token is not set

- Add id-token: write permission for OIDC support
Comment on lines +10 to +15
runs-on: ubuntu-latest
steps:
- uses: usthe/[email protected]
with:
IS_MODIFY_TITLE: false
CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Check warning

Code scanning / CodeQL

Workflow does not contain permissions

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{}}

Copilot Autofix

AI 16 days ago

In general, the fix is to explicitly define a permissions: block for the workflow or the specific job so that the GITHUB_TOKEN has only the minimal required scopes. For a workflow that responds to issues and issue_comment events and runs a translation action, the likely required permission is the ability to read issue/PR content and post back translations as comments or edits, which is typically issues: write (and possibly pull-requests: write if it also interacts with PRs). We can avoid granting broad repository contents: write access.

The best minimal fix without changing functionality is to add a permissions: section under the translate job (line 9), directly above runs-on. This keeps the scope limited to that job and avoids changing semantics of other workflows. Assuming the action needs to write translations back onto the issue or comment, we should grant contents: read (safe, common baseline) and issues: write. If in this repository the action only needs to read issue text and not write anything, issues: read could suffice, but that would risk breaking expected behavior if the action posts translations. Since we cannot see the rest of the setup and the workflow is for “issue-translator”, granting issues: write is the safer choice to preserve existing behavior.

Concretely:

  • Edit .github/workflows/issue-translator.yml.
  • Under jobs: translate:, insert:
    permissions:
      contents: read
      issues: write
  • Leave the rest of the workflow unchanged.

No extra imports or code changes are needed beyond this YAML edit.

Suggested changeset 1
.github/workflows/issue-translator.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/issue-translator.yml b/.github/workflows/issue-translator.yml
--- a/.github/workflows/issue-translator.yml
+++ b/.github/workflows/issue-translator.yml
@@ -7,6 +7,9 @@
 
 jobs:
   translate:
+    permissions:
+      contents: read
+      issues: write
     runs-on: ubuntu-latest
     steps:
       - uses: usthe/[email protected]
EOF
@@ -7,6 +7,9 @@

jobs:
translate:
permissions:
contents: read
issues: write
runs-on: ubuntu-latest
steps:
- uses: usthe/[email protected]
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@loonghao loonghao force-pushed the fix/coverage-reporting branch from ee11788 to 005c465 Compare March 19, 2026 14:54
@loonghao loonghao requested a review from kaizhou-lab March 19, 2026 14:58
@piorpua piorpua merged commit 7465a48 into main Mar 20, 2026
30 checks passed
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.

3 participants