Skip to main content

Quality And CI

The project reports package quality in three places:

  • GitHub step summaries for quick CI scanning.
  • Sticky pull request comments for coverage, test performance, and cognitive complexity.
  • Uploaded artifacts for raw coverage, test, and complexity data.

Coverage

Coverage uses c8 over the package source:

npm run test:cov

The gate currently requires 100% statements, branches, functions, and lines. The PR coverage comment compares the pull request against cached base-branch coverage when base data is available.

CI runs package coverage on Node.js 20 and Node.js 22. The Node.js 22 quality job owns PR coverage, performance, and cognitive complexity comments so those reports stay single-source and easy to read.

Performance

Tests use node:test. npm run test:cov runs a small reporting wrapper that writes test-results.json with suite and individual test durations parsed from the test runner output.

The PR performance comment shows:

  • passed, failed, and skipped counts
  • suite count
  • total test step duration
  • test execution duration
  • slowest suites
  • slowest individual tests

When base data exists, each duration includes a diff against the base branch.

These numbers are lightweight regression signals, not a synthetic benchmark. Use them to notice suspicious changes, then inspect the related test, driver, or sample before refactoring. A slower run can be caused by service-container startup, dependency installation, or runner noise.

CI records two stable timing surfaces:

SignalWhere it appearsWhat it means
Package test step durationPR performance comment and package quality summaryEnd-to-end package coverage step, including real driver tests
Test execution durationPR performance commentTime reported by node:test for package tests
Slowest suites/testsPR performance commentReview hints for package tests that changed or became unexpectedly slow
Sample validation durationSample validation job summaryCoarse duration for showcase plus focused samples, including service-backed samples in CI

Keep precision readable. Reports round milliseconds and use two decimal places for second-scale values so small runner fluctuations do not look more exact than they are.

Cognitive Complexity

Cognitive complexity uses SonarJS through ESLint:

npm run complexity:check
npm run complexity:report

complexity:check enforces the default threshold of 15 per source function. complexity:report writes complexity/cognitive-complexity-summary.json with totals, per-file aggregates, and the most complex functions.

The PR comment treats complexity as a review signal. The hard gate remains the ESLint threshold.

Driver Integration

Package tests exercise real Drizzle clients for libSQL, better-sqlite3, PostgreSQL, and MySQL. GitHub Actions provides PostgreSQL and MySQL service containers for the coverage job. Local runs skip those networked drivers unless NEST_DRIZZLE_NATIVE_POSTGRES_URL and NEST_DRIZZLE_NATIVE_MYSQL_URL are set.

DriverPackage testFocused sampleLocal behaviorCI behaviorRequired env/service
libSQLdriver-integration.spec.tsMost local samples use @libsql/clientAlways runs with local file databasesAlways runs with local file databasesNone
better-sqlite3driver-integration.spec.ts14-better-sqlite3-driverAlways runs with a local SQLite fileAlways runs with a local SQLite fileNone
PostgreSQL / pgdriver-integration.spec.ts15-postgres-driverSkips unless NEST_DRIZZLE_NATIVE_POSTGRES_URL is setRuns against a PostgreSQL 16 service containerNEST_DRIZZLE_NATIVE_POSTGRES_URL or CI postgres service
MySQL / mysql2driver-integration.spec.ts16-mysql-driverSkips unless NEST_DRIZZLE_NATIVE_MYSQL_URL is setRuns against a MySQL 8.4 service containerNEST_DRIZZLE_NATIVE_MYSQL_URL or CI mysql service

The package coverage jobs and the Sample validation job both receive workflow-generated PostgreSQL and MySQL URLs. Those URLs are test-only and must not be copied into docs, samples, or logs beyond generic matrix summaries.

Release And Security

Release validation checks README/docs links, sample version sync, workspace resolution, the package tarball, and a temporary consumer app that installs the packed tarball:

npm run release:check

For the publish checklist, version sync rules, and post-publish verification, see Release Guide.

After publishing, verify the registry package with:

npm run release:check:published -- <version>

That command installs the published package in a clean consumer and in a temporary sample workspace so the checks cannot accidentally pass through a local workspace link.

Supply-chain auditing checks high-severity production risk:

npm run security:audit

Run the complete local gate with:

npm run ci

Samples

Samples are release blockers. GitHub Actions runs them in the dedicated Sample validation job, and the local gate includes the same matrix:

npm run ci:sample

release:check also verifies every sample/*/package.json depends on the current packages/drizzle version and that npm workspace resolution agrees with the lockfile.