fix(coverage): switch from whitelist to full-source coverage reporting#1491
fix(coverage): switch from whitelist to full-source coverage reporting#1491
Conversation
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
| 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
Show autofix suggestion
Hide autofix suggestion
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.
| @@ -7,6 +7,9 @@ | ||
|
|
||
| jobs: | ||
| translate: | ||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: usthe/[email protected] |
ee11788 to
005c465
Compare
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.tsused an explicitincludelist for coverage:This meant:
Solution
Switch from a whitelist approach to a full-source coverage approach with targeted exclusions:
vitest.config.tsincludelist of ~40 filesinclude: ['src/**/*.{ts,tsx}']withexcludefor 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)codecov.ymlignorelist to match vitest excludes (consistency)80%toauto(track against previous baseline)patchtarget of50%(informational) to encourage PR-level coverageVerification
vitest run --coverageproducescoverage/lcov.infowith 697 source filespr-checks.yml) unchanged — coverage upload logic remains the sameImpact
After this change: