Skip to content

Conversation

@kotAPI
Copy link
Collaborator

@kotAPI kotAPI commented Sep 12, 2025

Summary

  • add npm script for sharded jest runs
  • run sharded tests in GitHub Actions CI

Testing

  • JEST_SHARD=1/2 npm run test:shard
  • npm run build:rollup (fails: [plugin dts] RollupError: src/components/ui/Select/fragments/SelectItem.tsx: Failed to compile)

Summary by CodeRabbit

  • New Features

    • Exposed theme assets for direct consumption, enabling import of the default CSS theme and a Tailwind preset.
  • Tests

    • Added a shard-capable test command to support parallel Jest runs.
  • Chores

    • Added a consolidated CI workflow to run tests and builds with parallelization, concurrency controls, and dependency caching.
    • Replaced the previous CI workflow with the new unified test+build workflow.
    • Updated the build pipeline to clean before building for more reliable outputs.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 12, 2025

Walkthrough

Adds a new CI workflow (.github/workflows/test.yml) that shards Jest tests and runs a dependent build; updates package.json exports and build/test scripts; removes an existing workflow (.github/workflows/build-rad-ui.yml).

Changes

Cohort / File(s) Summary of Changes
New CI workflow
.github/workflows/test.yml
Adds "Tests" workflow triggered on push/PR to main with concurrency. Defines test job on ubuntu-latest using Node 20, matrix shards (shard: [1,2], total: [2]), checkout, setup-node, npm ci, and runs npm run test:shard with JEST_SHARD. Adds build job depending on test that runs Node setup, npm ci, and npm run build:rollup.
Removed CI workflow
.github/workflows/build-rad-ui.yml
Deletes the previous "Build RAD UI" workflow which ran build steps (checkout, setup-node, npm ci, npm run build:rollup) on PRs/branches affecting source/build files.
Package configuration (exports & scripts)
package.json
Sets exports to expose ./themes/default.css -> ./dist/themes/default.css and ./themes/tailwind-presets/default.js -> ./dist/themes/tailwind-presets/default.js. Adds test:shard script: jest --shard=$JEST_SHARD. Updates build:rollup:process to npm run clean && (npm run build:css & npm run build:components & wait) && npm run build:generate-exports.

Sequence Diagram(s)

sequenceDiagram autonumber actor Dev as Push/PR to main participant GH as GitHub Actions participant Runner as ubuntu-latest participant Node as actions/setup-node@v4 (Node 20) participant npm as npm participant Jest as Jest Dev->>GH: push / open PR targeting main rect rgba(230,240,255,0.6) note over GH: concurrency per workflow+ref\ncancel in-progress runs end GH->>Runner: start test job (matrix shards 1/2 & 2/2) Runner->>Runner: actions/checkout@v4 Runner->>Node: setup Node (v20, npm cache) Runner->>npm: npm ci Runner->>Jest: npm run test:shard (JEST_SHARD=1/2 or 2/2) Jest-->>Runner: test results Runner-->>GH: report shard status GH->>Runner: start build job (after tests) Runner->>Runner: checkout + setup-node Runner->>npm: npm ci Runner->>npm: npm run build:rollup (clean -> parallel builds -> generate-exports) Runner-->>GH: build status GH-->>Dev: workflow result 
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

I nibble bytes beneath the moon,
Two shards sprint in tidy tune,
Exports tucked on little shelves,
Clean commands wake busy elves,
A hopping dev hums, carrot soon. 🥕

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 "feat: parallelize jest tests with sharding" succinctly and accurately describes the PR's primary change—adding sharded Jest test runs and CI configuration to run tests in parallel—which aligns with the package.json script and workflow updates in the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kotapi/introduce-sharding-for-parallel-testing

📜 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 0a70d62 and 00be46d.

📒 Files selected for processing (2)
  • .github/workflows/build-rad-ui.yml (0 hunks)
  • .github/workflows/test.yml (1 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/build-rad-ui.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/test.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). (2)
  • GitHub Check: Build
  • GitHub Check: coverage

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews: pre_merge_checks: custom_checks: - name: "Undocumented Breaking Changes" mode: "warning" instructions: |  Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
package.json (1)

15-15: Make shard script cross‑platform

package.json has "test:shard": "jest --shard=$JEST_SHARD" (line 15) and .github/workflows/test.yml sets JEST_SHARD via matrix. $JEST_SHARD won't expand on Windows shells — either use cross-env-shell or inject the matrix value in CI.

Apply:

- "test:shard": "jest --shard=$JEST_SHARD", + "test:shard": "cross-env-shell \"jest --shard=$JEST_SHARD\"",

And add devDep (outside this hunk):

 "devDependencies": { + "cross-env": "^7.0.3",

If you prefer no new deps, call Jest directly in the workflow with the matrix value instead (workflow already sets JEST_SHARD).

.github/workflows/test.yml (3)

38-41: Pass shard value directly; avoid env expansion dependency

Simplifies CI and works regardless of package script/env quirks.

- - name: Run tests - env: - JEST_SHARD: ${{ matrix.shard }}/${{ matrix.total }} - run: npm run test:shard + - name: Run tests + run: npx jest --shard=${{ matrix.shard }}/${{ matrix.total }}

13-15: Concurrency key: use PR number when available

Prevents accidental grouping across different refs for PR events.

-concurrency: - group: ${{ github.workflow }}-${{ github.ref }} +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true

18-26: Optional: add a job timeout

Avoids hung jobs blocking CI.

 test: + timeout-minutes: 20
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07797cf and 8182a4c.

📒 Files selected for processing (2)
  • .github/workflows/test.yml (1 hunks)
  • package.json (2 hunks)
⏰ 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). (1)
  • GitHub Check: coverage
🔇 Additional comments (1)
package.json (1)

7-10: Add "." export and types — verify built entry paths first

When "exports" is defined consumers cannot import the package root; add a "." export mapping to the built JS and typings. dist/ is not present in the workspace — confirm the built entry and .d.ts path (e.g. dist/index.js or dist/index.cjs and dist/index.d.ts) before merging. Verify with: fd -a 'index.@(js|mjs|cjs|d.ts)' .

Apply (if those files exist):

- "exports": { - "./themes/default.css": "./dist/themes/default.css", - "./themes/tailwind-presets/default.js": "./dist/themes/tailwind-presets/default.js" - }, + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + }, + "./themes/default.css": "./dist/themes/default.css", + "./themes/tailwind-presets/default.js": "./dist/themes/tailwind-presets/default.js" + },
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
.github/workflows/test.yml (2)

29-34: Upgrade to supported Node LTS (Node 18 is EOL).

Use Node 20 (or 22 LTS) to avoid security and tooling issues. Mirror this in all jobs.

- node-version: '18' + node-version: '20'

49-54: Also bump Build job to Node 20.

- node-version: '18' + node-version: '20'
🧹 Nitpick comments (5)
.github/workflows/test.yml (2)

38-41: Pass shard via CLI arg; avoid env interpolation dependency.

This makes the command portable and removes reliance on shell expansion. Adjust workflow and simplify the script.

Workflow change:

- - name: Run tests - env: - JEST_SHARD: ${{ matrix.shard }}/${{ matrix.total }} - run: npm run test:shard + - name: Run tests + run: npm test -- --shard=${{ matrix.shard }}/${{ matrix.total }}

Then in package.json (see separate comment), update "test:shard" to just "jest" or drop it.


19-26: Optional: Add timeouts to prevent hung jobs.

Helpful for stuck shards/builds.

 test: name: Jest ${{ matrix.shard }}/${{ matrix.total }} runs-on: ubuntu-latest + timeout-minutes: 20 ... build: name: Build runs-on: ubuntu-latest needs: test + timeout-minutes: 20
package.json (3)

7-10: Verify published files align with new subpath exports.

Ensure these files exist post-build and are included in the npm package. Consider a "files" whitelist to guarantee inclusion.

 { "name": "@radui/ui", ... - "exports": { + "exports": { "./themes/default.css": "./dist/themes/default.css", "./themes/tailwind-presets/default.js": "./dist/themes/tailwind-presets/default.js" }, + "files": [ + "dist/**" + ], ... }

15-15: Make sharded test script portable or drop it.

Env interpolation $JEST_SHARD isn’t portable on Windows shells. Simplest: let CI pass the arg and keep script as plain jest.

Option A (portable, keep script):

- "test:shard": "jest --shard=$JEST_SHARD", + "test:shard": "jest"

Then run in CI: npm run test:shard -- --shard=${{ matrix.shard }}/${{ matrix.total }}.

Option B (keep env-based UX, add cross-env-shell):

+ "test:shard": "cross-env-shell \"jest --shard=\\${JEST_SHARD:-1/1}\"",

And add devDependency: cross-env.


33-33: Cross-platform parallel build.

& ... & wait is bash-specific; use a cross-platform runner to avoid Windows dev friction.

Using npm-run-all:

- "build:rollup:process": "npm run clean && (npm run build:css & npm run build:components & wait) && npm run build:generate-exports", + "build:rollup:process": "npm run clean && npm-run-all -p build:css build:components && npm run build:generate-exports",

Add devDependency:

+ "npm-run-all": "^4.1.5",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8182a4c and 9352d34.

📒 Files selected for processing (2)
  • .github/workflows/test.yml (1 hunks)
  • package.json (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-14T18:13:36.606Z
Learnt from: GoldGroove06 PR: rad-ui/ui#1214 File: package.json:64-64 Timestamp: 2025-07-14T18:13:36.606Z Learning: In npm, lifecycle scripts with `pre` and `post` prefixes automatically run before and after their corresponding main scripts. For example, a `prebuild` script will automatically run before the `build` script when executing `npm run build`, so there's no need to explicitly call `npm run prebuild` in the build script. 

Applied to files:

  • package.json
⏰ 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). (2)
  • GitHub Check: Build
  • GitHub Check: coverage
🔇 Additional comments (1)
.github/workflows/test.yml (1)

43-59: Build currently fails (Rollup dts). Decide gating strategy.

If the failure is known and being fixed separately, consider temporarily marking build as non-blocking, or keep it blocking to enforce green PRs. Your call—just confirming intent.

Option (temporary, not generally recommended):

 build: name: Build runs-on: ubuntu-latest needs: test + continue-on-error: true
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/test.yml (1)

29-34: Node 20 LTS + npm cache: LGTM (resolves prior comment).

Consider explicitly keying the cache to all lockfiles in a workspace.

Apply:

 uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' + cache-dependency-path: | + package-lock.json + **/package-lock.json
🧹 Nitpick comments (5)
.github/workflows/test.yml (5)

18-26: Add job timeouts to avoid hanging runs.

Set conservative timeouts for matrix shards.

 test: name: Jest ${{ matrix.shard }}/${{ matrix.total }} runs-on: ubuntu-latest + timeout-minutes: 20

42-46: Add timeout to build job.

Prevents indefinite hangs on type generation/build.

 build: name: Build runs-on: ubuntu-latest needs: test + timeout-minutes: 20

58-59: Fail faster with a pre-build typecheck.

Catches d.ts/TS errors before Rollup (use --if-present to avoid breaking).

- - name: Build package - run: npm run build:rollup + - name: Type-check + run: npm run typecheck --if-present + + - name: Build package + run: npm run build:rollup

3-7: Optional: Add manual trigger.

Allows on-demand runs without a push/PR.

 on: push: branches: [ main ] pull_request: branches: [ main ] + workflow_dispatch:

49-54: Mirror cache path tweak in build job.

Keep cache keys consistent across jobs.

 uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' + cache-dependency-path: | + package-lock.json + **/package-lock.json
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9352d34 and 0a70d62.

📒 Files selected for processing (1)
  • .github/workflows/test.yml (1 hunks)
⏰ 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). (2)
  • GitHub Check: Build
  • GitHub Check: coverage
🔇 Additional comments (2)
.github/workflows/test.yml (2)

9-12: Principle-of-least-privilege looks good.

Read-only perms for contents and PRs are appropriate for this workflow.


13-15: Good use of concurrency to auto-cancel superseded runs.

Grouping by workflow and ref is correct for both pushes and PRs.

@github-actions
Copy link
Contributor

Coverage

This report compares the PR with the base branch. “Δ” shows how the PR affects each metric.

Metric PR Δ
Statements 89.67% +0.00%
Branches 66.03% +0.00%
Functions 73.06% +0.00%
Lines 88.55% +0.00%

Coverage improved or stayed the same. Great job!

Run npm run coverage locally for detailed reports and target untested areas to raise these numbers.

@kotAPI kotAPI merged commit b997c83 into main Sep 13, 2025
10 checks passed
@kotAPI kotAPI deleted the kotapi/introduce-sharding-for-parallel-testing branch September 13, 2025 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants