Add Node.js CI workflow for testing and building#9
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughAdds a GitHub Actions workflow for Node.js CI that runs on pushes and pull requests to main, using a version matrix (18.x, 20.x, 22.x). It checks out code, sets up Node with npm caching, installs dependencies via npm ci, conditionally builds, and runs tests. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer
participant GH as GitHub
participant WF as Node.js CI Workflow
participant R1 as Runner (ubuntu-latest)
participant NPM as npm
Dev->>GH: Push / PR to main
GH->>WF: Trigger workflow
WF->>R1: Start job (matrix: Node 18.x/20.x/22.x)
R1->>R1: actions/checkout
R1->>R1: setup-node (with cache)
R1->>NPM: npm ci
alt build script exists
R1->>NPM: npm run build
else
R1->>R1: Skip build
end
R1->>NPM: npm test
R1-->>GH: Report status per Node version
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
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.
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 |
There was a problem hiding this comment.
Pull Request Overview
Adds a GitHub Actions workflow to run Node.js CI on Ubuntu, installing dependencies, building (if present), and running tests across multiple Node versions.
- Introduces a Node.js CI workflow triggered on pushes and pull requests to main.
- Sets up a matrix for Node 18.x, 20.x, and 22.x; runs npm ci, optional build, and tests.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| - run: npm ci | ||
| - run: npm run build --if-present | ||
| - run: npm test |
There was a problem hiding this comment.
The list items under steps are indented at the same level as the steps key, which is invalid YAML for GitHub Actions. Indent each list item two spaces under steps and shift the nested fields accordingly so the workflow parses (e.g., steps: followed by two-space-indented - uses..., and within a step, properties like uses/with indented two more spaces).
| - uses: actions/checkout@v4 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - run: npm ci | |
| - run: npm run build --if-present | |
| - run: npm test | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - run: npm ci | |
| - run: npm run build --if-present | |
| - run: npm test |
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
There was a problem hiding this comment.
Consider adding a least-privilege permissions block to restrict the GITHUB_TOKEN for this workflow. For example, add at the top level: permissions: contents: read (place it between the on: block and jobs:).
| permissions: | |
| contents: read |
Adding nodejs frontend with basic npm installation and npm test rules on ubuntu to make sure can run
Summary by CodeRabbit