Skip to content

Conversation

@instinxt
Copy link

@instinxt instinxt commented May 5, 2025

πŸ“‹ Description

Implements PSMRI/AMRIT#3

Enable eslint and npm audit via github actions for the repository


βœ… Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • πŸ”₯ Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • πŸ›  Refactor (change that is neither a fix nor a new feature)
  • βš™οΈ Config change (configuration file or build script updates)
  • πŸ“š Documentation (updates to docs or readme)
  • πŸ§ͺ Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • πŸš€ Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

Summary by CodeRabbit

  • Chores
    • Updated the linting and auditing workflow to run only when relevant files are changed, improving efficiency for push and pull request events. The workflow now conditionally runs ESLint and npm audit steps based on detected file changes.

@coderabbitai
Copy link

coderabbitai bot commented May 5, 2025

Walkthrough

The GitHub Actions workflow for linting and auditing was refactored from referencing an external reusable workflow to an inline job definition. The workflow is now configured to trigger on pushes and pull requests to main, master, and develop branches, with pull request runs further filtered to only execute when relevant JavaScript/TypeScript or package files are changed. The workflow steps include repository checkout, Node.js setup, dependency installation, and conditional execution of ESLint and npm audit steps based on the types of files changed.

Changes

File(s) Change Summary
.github/workflows/lint_audit.yml Replaced reusable workflow reference with inline job definition; added conditional steps for lint and audit based on changed files; updated triggers and job steps for more granular control.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Actions
    participant Repo
    participant Node.js
    participant npm
    participant ESLint

    GitHub Actions->>Repo: Checkout repository (full history)
    GitHub Actions->>Node.js: Setup Node.js 16 (with npm cache)
    GitHub Actions->>npm: Install dependencies (npm ci)
    GitHub Actions->>Repo: Detect changed files (JS/TS/package files)
    alt JS/TS files changed
        GitHub Actions->>ESLint: Run ESLint on changed files
    end
    alt package.json or package-lock.json changed
        GitHub Actions->>npm: Run npm audit
    end
Loading

Possibly related PRs

  • Add ESLint and NPM Audit workflowΒ #38: Refactored the lint and audit workflow by introducing a reusable workflow reference, which is now replaced by an inline, conditionally executed job in this PR.

Suggested reviewers

  • drtechie

Poem

In the warren of workflows, a change hops in,
Inline and nimble, it checks where to begin.
Only the files that have changed get a look,
Linting and auditsβ€”no more than it took.
With carrots of logic and steps all precise,
This bunny approvesβ€”oh, isn’t that nice!
πŸ₯•βœ¨


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
πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 5, 2025

Copy link

@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/lint_audit.yml (1)

48-50: Duplicate: Audit condition depends on updated changed-files config
As noted above, the npm audit step’s if depends on all_changed_files containing package files. Once you update the patterns, this condition will work as intended.

🧹 Nitpick comments (1)
.github/workflows/lint_audit.yml (1)

30-32: Remove trailing whitespace
The blank line at line 32 contains trailing spaces; trimming it will satisfy YAML lint rules.

🧰 Tools
πŸͺ› YAMLlint (1.35.1)

[error] 32-32: trailing spaces

(trailing-spaces)

πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between d4c7b7a and cc539e4.

πŸ“’ Files selected for processing (1)
  • .github/workflows/lint_audit.yml (1 hunks)
🧰 Additional context used
πŸͺ› actionlint (1.7.4)
.github/workflows/lint_audit.yml

20-20: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


25-25: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

πŸͺ› YAMLlint (1.35.1)
.github/workflows/lint_audit.yml

[error] 32-32: trailing spaces

(trailing-spaces)

πŸ”‡ Additional comments (4)
.github/workflows/lint_audit.yml (4)

8-14: Pull request triggers scoped to relevant file changes
Filtering pull_request events to JS/TS and package files will prevent unnecessary CI runs on unrelated commits.


18-23: Full repository checkout for accurate diff detection
Using fetch-depth: 0 on actions/checkout@v3 is required for tj-actions/changed-files to compute the full diff correctly. Perfect.

🧰 Tools
πŸͺ› actionlint (1.7.4)

20-20: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


24-28: Node.js setup with caching is optimal
actions/setup-node@v3 with cache: 'npm' and pinned node-version: '16.x' ensures fast, repeatable installs.

🧰 Tools
πŸͺ› actionlint (1.7.4)

25-25: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


43-47: Conditional ESLint run on changed files
Running ESLint only when any_changed == 'true' is efficient and prevents full runs on unrelated commits.

Comment on lines +33 to +42
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.js
**/*.ts
**/*.tsx
**/*.jsx
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

⚠️ Potential issue

Include dependency files in changed-files patterns
Right now the changed-files action only watches JS/TS source, so changes to package.json or package-lock.json won’t be reported. This breaks your npm audit condition.
Apply this diff to capture dependency file changes:

 with:
   files: |
     **/*.js
     **/*.ts
     **/*.tsx
     **/*.jsx
+    package.json
+    package-lock.json
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.js
**/*.ts
**/*.tsx
**/*.jsx
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.js
**/*.ts
**/*.tsx
**/*.jsx
package.json
package-lock.json

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.

1 participant