Skip to content

ci: add unit tests on commit workflow - #5

Merged
shijistar merged 3 commits into
masterfrom
ci/test-on-commit-workflow
Jul 15, 2026
Merged

shijistar merged 3 commits into
masterfrom
ci/test-on-commit-workflow

Conversation

@shijistar

@shijistar shijistar commented Jul 15, 2026 •

Copy link
Copy Markdown
Owner

Background

This PR adds a commit-time unit test workflow for jsoneo, following the structure of enum-plus's test-on-commit workflow.

Changes

  • Add .github/workflows/test-on-commit.yml to run unit tests on pushes to master, next, and v* branches, and on pull requests targeting master.
  • Add .github/workflows/reusable-test.yml as a reusable workflow with matrix and single-version modes.
  • Run the unit-test workflow with Node.js 24.x, matching the currently green CI/runtime path for the Vitest coverage suite.
  • Install dependencies with npm ci and run npm test.
  • Install Playwright browsers and system dependencies for the browser Vitest suite.

Intentional exclusions

  • No legacy Node.js mode.
  • No node_modules cache or actions/cache setup.

Verification

Local:

  • npm test
  • npx prettier --check .github/workflows/test-on-commit.yml .github/workflows/reusable-test.yml
  • npx tsc --noEmit -p tsconfig.json
  • npm run ts2lib
  • npm run ts2es
  • git diff --check

GitHub Actions:

  • Unit Tests on Commit / test-matrix (24.x) passed.
  • test-single is skipped because test-on-commit.yml calls the reusable workflow with use-matrix: true.
  • CodeRabbit passed.

Summary by CodeRabbit

  • Tests
    • Added reusable automated test workflows with configurable Node.js versions.
    • Tests now install required browser dependencies and run consistently across supported environments.
    • Commit and pull request checks can cancel outdated runs, reducing redundant test executions.

Copilot AI review requested due to automatic review settings July 15, 2026 12:45
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@shijistar, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5229d778-28a6-4e5c-9b45-5a5c460eac2a

📥 Commits

Reviewing files that changed from the base of the PR and between c66557b and 2f635b1.

📒 Files selected for processing (2)
  • .github/workflows/npm-publish.yml
  • .github/workflows/reusable-test.yml
📝 Walkthrough

Walkthrough

Adds a reusable GitHub Actions test workflow with configurable Node.js execution and a commit workflow that invokes matrix testing for selected branches and pull requests.

Changes

Test workflow automation

Layer / File(s) Summary
Reusable test execution
.github/workflows/reusable-test.yml
Defines callable single-version and matrix jobs using Node.js 24.x, installing dependencies and Playwright before running npm test.
Commit and pull request delegation
.github/workflows/test-on-commit.yml
Adds branch and pull request triggers, concurrency cancellation, read-only contents permissions, and invocation of the reusable workflow with matrix testing enabled.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a commit-time unit test workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/test-on-commit-workflow

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a commit-time unit test CI workflow for jsoneo, using a reusable workflow to run npm ci + npm test across supported Node versions and installing Playwright dependencies for the browser Vitest suite.

Changes:

  • Added a test-on-commit workflow that runs on pushes to master, next, and v* branches and on PRs targeting master, with concurrency cancellation.
  • Added a reusable workflow that supports both matrix (20.x/22.x/24.x) and single-version test runs.
  • Ensured Playwright browsers/system deps are installed before running tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/test-on-commit.yml Adds a push/PR-triggered workflow that delegates to the reusable test workflow with concurrency cancellation.
.github/workflows/reusable-test.yml Implements the reusable unit test workflow with matrix/single modes, Node setup, dependency install, Playwright install, and test execution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/reusable-test.yml Resolved
Comment thread .github/workflows/reusable-test.yml Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/reusable-test.yml:
- Line 49: Update the actions/checkout@v4 step to disable GitHub credential
persistence by configuring persist-credentials as false, leaving the rest of the
workflow unchanged.
- Line 29: Update the actions/checkout@v4 step to disable credential persistence
by setting persist-credentials to false, while leaving the existing checkout
behavior unchanged.
- Line 1: Update both checkout steps in the test-matrix and test-single jobs to
include the with setting persist-credentials: false, ensuring actions/checkout
does not persist the GitHub token in local Git configuration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 04e8607b-58dd-40fd-b985-b702cadf485f

📥 Commits

Reviewing files that changed from the base of the PR and between f6fe952 and e654532.

📒 Files selected for processing (2)
  • .github/workflows/reusable-test.yml
  • .github/workflows/test-on-commit.yml

Comment thread .github/workflows/reusable-test.yml Resolved
Comment thread .github/workflows/reusable-test.yml Resolved
Comment thread .github/workflows/reusable-test.yml Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (1)
.github/workflows/reusable-test.yml (1)

39-43: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid installing Playwright twice.

The supplied package.json context indicates that npm test already runs the Playwright installation chain. If so, these explicit npx playwright install --with-deps steps repeat browser setup and add unnecessary CI time; keep the installation in one place.

Also applies to: 59-63

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/reusable-test.yml around lines 39 - 43, Remove the
explicit “Install Playwright browsers and system dependencies” steps from the
workflow, including both occurrences, and retain the existing npm test flow so
Playwright installation is performed only once through package.json.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/reusable-test.yml:
- Around line 31-34: Add package-manager-cache: false to the with configuration
of both actions/setup-node@v6 invocations in the workflow, including the step
identified by “Use Node.js ${{ matrix.node-version }}”, so npm caching remains
disabled.

---

Nitpick comments:
In @.github/workflows/reusable-test.yml:
- Around line 39-43: Remove the explicit “Install Playwright browsers and system
dependencies” steps from the workflow, including both occurrences, and retain
the existing npm test flow so Playwright installation is performed only once
through package.json.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ca13daca-145d-4b5a-ae39-e9bf241ea490

📥 Commits

Reviewing files that changed from the base of the PR and between e654532 and c66557b.

📒 Files selected for processing (2)
  • .github/workflows/reusable-test.yml
  • .github/workflows/test-on-commit.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/test-on-commit.yml

Comment on lines +31 to +34
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
python - <<'PY'
import json
from pathlib import Path

package_json = json.loads(Path("package.json").read_text())
print("packageManager:", package_json.get("packageManager"))
PY
rg -n 'setup-node@v6|package-manager-cache' .github/workflows/reusable-test.yml

Repository: shijistar/jsoneo

Length of output: 259


🏁 Script executed:

#!/bin/bash
sed -n '1,90p' .github/workflows/reusable-test.yml | cat -n

Repository: shijistar/jsoneo

Length of output: 2103


🌐 Web query:

actions/setup-node v6 package-manager-cache default packageManager npm cache

💡 Result:

In actions/setup-node v6, the package-manager-cache input controls automatic dependency caching and defaults to true [1][2]. When package-manager-cache is enabled (the default), caching is automatically activated for npm projects if your package.json file includes either the devEngines.packageManager field or the top-level packageManager field set to npm, and no explicit cache input is provided [1][3]. For other package managers (such as Yarn or pnpm), automatic caching is disabled by default, and you must configure the cache input manually [1][2]. You can disable the automatic npm caching behavior by explicitly setting package-manager-cache to false in your workflow configuration [1][3].

Citations:


🌐 Web query:

GitHub Actions setup-node v6 package-manager-cache default npm packageManager field

💡 Result:

In GitHub Actions setup-node version 6, the package-manager-cache input controls automatic dependency caching for npm projects. This feature is enabled by default (true) [1][2][3]. When package-manager-cache is set to true and no explicit cache input is provided, the action automatically enables caching if your package.json file contains either a top-level packageManager field or a devEngines.packageManager field set to npm (e.g., "npm", "npm@x.x.x") [1][4][5][6]. Key points regarding this behavior: - Automatic Detection: The action reads the package.json file to identify the package manager [6]. It specifically checks for "npm" in the designated fields [1][6]. - Control: You can disable this automatic caching behavior by setting the package-manager-cache input to false in your workflow configuration [1][4][5]. - Exclusions: If your project uses a package manager other than npm (such as Yarn or pnpm), automatic caching for that manager is not enabled by this feature; you must still configure caching manually using the cache input [1][7][4]. - Security Recommendation: For workflows with elevated privileges or access to sensitive information, it is recommended to set package-manager-cache: false if caching is not explicitly required [1][4].

Citations:


Disable npm caching in both setup-node steps. packageManager: npm@11.4.2 makes actions/setup-node@v6 enable automatic npm caching by default; add package-manager-cache: false to both invocations to keep the workflow uncached.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/reusable-test.yml around lines 31 - 34, Add
package-manager-cache: false to the with configuration of both
actions/setup-node@v6 invocations in the workflow, including the step identified
by “Use Node.js ${{ matrix.node-version }}”, so npm caching remains disabled.

Repository owner deleted a comment from coderabbitai Bot Jul 15, 2026
Repository owner deleted a comment from coderabbitai Bot Jul 15, 2026
Repository owner deleted a comment from coderabbitai Bot Jul 15, 2026
Repository owner deleted a comment from coderabbitai Bot Jul 15, 2026
@shijistar
shijistar merged commit a1808c5 into master Jul 15, 2026
2 of 3 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