Skip to content

Conversation

@pkuczynski
Copy link
Collaborator

@pkuczynski pkuczynski commented Nov 10, 2025

Description of change

Replace nyc with faster alternative c8 - a newer, faster alternative that uses Node.js's native V8 coverage.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • This pull request links relevant issues as Fixes #00000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change

Summary by CodeRabbit

  • Chores
    • Migrated test coverage tooling to a new runner and updated CI workflows to use it.
    • Adjusted coverage configuration and reporting format.
    • Updated development tooling dependencies accordingly.
    • Changed ignore rules to stop excluding build and coverage artifacts and to begin tracking node_modules.

✏️ Tip: You can customize this high-level summary in your review settings.

@pkuczynski pkuczynski self-assigned this Nov 10, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 10, 2025

Walkthrough

Migrates CI coverage tooling from nyc to c8: updates .c8rc.json, replaces npx nyc with npx c8 in Linux and Windows workflows, adds c8 and removes nyc from devDependencies, and adjusts .gitignore entries related to coverage and node_modules.

Changes

Cohort / File(s) Summary
C8 configuration
\.c8rc.json``
Updated exclusion list to include node_modules, added exclude-after-remap: true, and changed reporter from a string to an array (["lcov"]).
CI workflows
\.github/workflows/tests-linux.yml`, `.github/workflows/tests-windows.yml``
Replaced npx nyc invocations with npx c8 for test coverage steps across multiple test jobs; workflow structure unchanged.
Dependencies
\package.json``
Removed devDependency nyc and added devDependency c8 ("c8": "^10.1.3").
Ignored files
\.gitignore``
Removed ignore entries for build/, coverage/, .nyc_output/, and node_modules/; other entries like npm-debug.log* and *.lcov remain.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant CI as CI runner
  participant Shell as Shell
  participant Tests as Test script

  Note over CI,Shell: Previous flow (nyc)
  CI->>Shell: run "npx nyc npm run test:ci"
  Shell->>Tests: npm run test:ci (instrumented by nyc)
  Tests-->>Shell: test results + nyc output
  Shell-->>CI: exit status + coverage artifacts

  Note over CI,Shell `#DDEEFF`: Updated flow (c8)
  CI->>Shell: run "npx c8 npm run test:ci"
  Shell->>Tests: npm run test:ci (instrumented by c8)
  Tests-->>Shell: test results + c8 output
  Shell-->>CI: exit status + coverage artifacts
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify .c8rc.json keys/values (reporter array, exclude-after-remap) match c8 expectations.
  • Confirm all npx nyc occurrences were replaced and CI artifact/log paths still align.
  • Ensure removal of .nyc_output/, coverage/, and node_modules/ from .gitignore is intentional.

Suggested reviewers

  • sgarner
  • naorpeled
  • alumni
  • mguida22
  • gioboa

Poem

🐰 I hopped from nyc to c8 tonight,

swapping tools by soft moonlight.
Workflows tuned and dev deps swapped,
configs trimmed, the pipelines hopped.
A carrot cheer — the tests all bright!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'ci: migrate from nyc to c8' directly and concisely summarizes the main change: replacing the nyc coverage tool with c8 across CI workflows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a1409ba and 6a1c5d3.

📒 Files selected for processing (1)
  • .github/workflows/tests-linux.yml (11 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/tests-linux.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: tests-linux (20) / sqlite
  • GitHub Check: tests-linux (20) / mysql_mariadb_latest
  • GitHub Check: tests-linux (20) / better-sqlite3
  • GitHub Check: tests-linux (20) / cockroachdb
  • GitHub Check: tests-linux (18) / mysql_mariadb_latest
  • GitHub Check: tests-linux (18) / sap
  • GitHub Check: tests-linux (18) / sqlite
  • GitHub Check: tests-linux (18) / mysql_mariadb
  • GitHub Check: tests-linux (18) / mssql
  • GitHub Check: tests-linux (18) / mongodb
  • GitHub Check: tests-linux (18) / oracle
  • GitHub Check: tests-linux (18) / sqljs
  • GitHub Check: tests-linux (18) / postgres (17)
  • GitHub Check: tests-linux (18) / postgres (14)
  • GitHub Check: tests-linux (18) / better-sqlite3
  • GitHub Check: tests-windows / better-sqlite3
  • GitHub Check: tests-windows / sqlite
  • GitHub Check: tests-windows / sqljs
  • GitHub Check: Analyze (javascript-typescript)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 10, 2025

typeorm-sql-js-example

npm i https://pkg.pr.new/typeorm/typeorm@11759

commit: 6a1c5d3

@pkuczynski pkuczynski requested review from OSA413, gioboa, mguida22, naorpeled and sgarner and removed request for OSA413 November 10, 2025 08:26
@OSA413
Copy link
Collaborator

OSA413 commented Nov 10, 2025

We were going to switch to Vitest in the future, is this change necessary?

@pkuczynski
Copy link
Collaborator Author

pkuczynski commented Nov 10, 2025

We were going to switch to Vitest in the future, is this change necessary?

TLDR: not absolutely necessary but should bring immediate CI speed improvement

Vitest is used to use c8 (no using native v8 coverage), but seems that migration will take a while. And this should bring immediate benefit of speeding up CI. It's a drop in replacement so not a lot of work to do it and not much to remove it in the future...

I fired it up to do a quick comparison (c8 vs nyc)

  • MongoDB on linux: 49s vs 59s
  • MSSQL on linux: 4m 3s vs 4m 18s
  • PostgreSQL on linux: 2m 3s vs 2m 17s
  • Sqlite on windows: 2m 24s vs 2m 47s

Two random runs is not enough to calculate fair speed improvement, but it shaves off 10-20s, which is not bad given how little effort it is to do it.

And migration to vitest might take a while given how little progress has been made so far: master...next

@OSA413
Copy link
Collaborator

OSA413 commented Nov 10, 2025

I wonder why the coverage CI/CD part is skipped

@pkuczynski
Copy link
Collaborator Author

I wonder why the coverage CI/CD part is skipped

It's not. It just wait for all tests to fininsh:

https://github.com/typeorm/typeorm/blob/master/.github/workflows/commit-validation.yml#L67

Its a good question though why oracle on linux started to fail now...

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks great to me 👍

@OSA413
Copy link
Collaborator

OSA413 commented Nov 10, 2025

Can you please add html reporter?

@OSA413
Copy link
Collaborator

OSA413 commented Nov 10, 2025

Looks like lcov already provides html report.

After testing it generates 0 coverage, which is no good. Can you please investigate what's wrong?

@OSA413
Copy link
Collaborator

OSA413 commented Nov 10, 2025

At least it generate 0 coverage on my machine.

@OSA413
Copy link
Collaborator

OSA413 commented Nov 10, 2025

Switching back to nyc shows the correct coverage on my local machine.

@pkuczynski
Copy link
Collaborator Author

Looks like lcov already provides html report.

After testing it generates 0 coverage, which is no good. Can you please investigate what's wrong?

Yes, I am investigating. But I can't get the tests pass on my local machine :/ Testing with mysql-9...

@coveralls
Copy link

coveralls commented Nov 10, 2025

Coverage Status

coverage: 80.769% (+4.3%) from 76.433%
when pulling a1409ba on pkuczynski:ci/c8
into 51fbcf4 on typeorm:master.

OSA413
OSA413 previously requested changes Nov 16, 2025
Copy link
Collaborator

@OSA413 OSA413 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocked until fixed

@alumni
Copy link
Collaborator

alumni commented Nov 20, 2025

This PR would be nice to have if the reporting gets fixed.

Currently, nyc brings in baseline-browser-mapping which logs a warning that breaks our tests. If we get c8 working, we wouldn't need to figure out a way to fix that test :)

@OSA413
Copy link
Collaborator

OSA413 commented Nov 20, 2025

After adding --exclude-after-remap parameter to c8 like this: npx c8 --exclude-after-remap npm run test:ci it started to show the coverage.

@OSA413
Copy link
Collaborator

OSA413 commented Nov 20, 2025

I'm still wondering why the coverage is marked as skipped though all tests are passed/failed.

@OSA413 OSA413 merged commit bec548a into typeorm:master Nov 20, 2025
65 checks passed
@alumni
Copy link
Collaborator

alumni commented Nov 20, 2025

@OSA413 That's nice, thanks!

Do you happen to know where does the extra 4% coverage comes from?

BTW, Both nyc and c8 pass their options to test-exclude (which uses glob after that), so I doubt that anything related to the file globs should be changed. test-exclude automatically adds **/node_modules/** if you pass excludeNodeModules: true - which is correct, while node_modules without ** at the end does not do anything - so I doubt this change was responsible for the increased coverage.

@pkuczynski
Copy link
Collaborator Author

Thank you for help @OSA413!

@alumni possibly it comes from how all: true + exclude-after-remap: true behaves differently than in nyc?

@pkuczynski pkuczynski deleted the ci/c8 branch November 20, 2025 17:45
@OSA413
Copy link
Collaborator

OSA413 commented Nov 20, 2025

Here's the difference example (you can run SQLite tests locally and see it):

Old:
{BC411B59-000F-47FC-86E5-6230A405EF8A}

New:
{0507BA23-9474-40F7-8DF7-B23916F1C0FB}

Probably something related to TS -> JS (build) -> TS (Map back to source code) mapping.

@OSA413
Copy link
Collaborator

OSA413 commented Nov 20, 2025

I think that C8 can handle/track more things, that's why the coverage changed.

ThbltLmr pushed a commit to ThbltLmr/typeorm that referenced this pull request Dec 2, 2025
Co-authored-by: Oleg "OSA413" Sokolov <OSA413@users.noreply.github.com>
mgohin pushed a commit to mgohin/typeorm that referenced this pull request Jan 15, 2026
Co-authored-by: Oleg "OSA413" Sokolov <OSA413@users.noreply.github.com>
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.

5 participants