fix(ci): Install project dependencies in Repomix action#892
Conversation
The pack-repository workflow was failing with "Cannot find module 'picocolors'" error. This occurred because repomix.config.ts imports from ./src/index.js, which requires project dependencies to be installed. Added a conditional step to install dependencies when package.json exists, ensuring that config files can successfully import from local source files. This is particularly necessary for the Repomix project itself, which uses local source imports in its configuration.
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a CI workflow failure in the Repomix action by ensuring project dependencies are installed before running the tool. The workflow was failing because repomix.config.ts imports from local source code that requires project dependencies to be available.
- Added conditional dependency installation step when
package.jsonexists - Removed explicit npm cache setting (auto-detected by setup-node v5)
Summary of ChangesHello @yamadashy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical CI workflow failure that occurred because the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds a conditional "Install project dependencies" step to the GitHub Action at .github/actions/repomix/action.yml, replacing the previous setup-node npm cache configuration. The new step runs npm install only if package.json exists. The "Install Repomix" step remains, with indentation adjusted. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor GH as GitHub Actions Runner
participant WF as repomix/action.yml
GH->>WF: Setup Node.js
alt package.json exists
GH->>WF: Install project dependencies (npm install)
else No package.json
note right of WF: Skip npm install
end
GH->>WF: Install Repomix
note over WF: setup-node npm cache removed
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #892 +/- ##
=======================================
Coverage 74.66% 74.66%
=======================================
Files 109 109
Lines 7653 7653
Branches 1433 1433
=======================================
Hits 5714 5714
Misses 1939 1939 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request resolves a CI failure within the Repomix action by ensuring project dependencies are installed. The approach of adding a conditional npm install step is a direct fix for the issue where repomix.config.ts requires local modules. Additionally, removing the explicit cache: "npm" setting is a good simplification, relying on the automatic detection capabilities of setup-node v5. I've included one suggestion to enhance the dependency installation process by using npm ci when a lockfile is available, which aligns with best practices for CI environments to achieve faster and more reliable builds.
Deploying repomix with
|
| Latest commit: |
ca369ec
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cbdf1d17.repomix.pages.dev |
| Branch Preview URL: | https://fix-ci-pack-repo.repomix.pages.dev |
PR ReviewThank you for fixing this workflow issue! The solution properly addresses the dependency problem when ✅ Strengths
🔍 Potential Issues & Suggestions1. Performance consideration: Full npm install may be slowThe current implementation runs a full Considerations:
Suggested optimization (if applicable): - name: Install project dependencies
shell: bash
run: |
# Install project dependencies if package.json exists
# This ensures repomix.config.ts can import from local source
if [ -f "package.json" ]; then
npm install --omit=dev
fiHowever, test this carefully - if the build process requires dev dependencies, keep the current approach. 2. Caching could improve performanceWhile you removed explicit You could add a comment or verify in testing that the cache is functioning: - name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: "24"
# cache is auto-detected from package-lock.json3. Error handling considerationThe - name: Install project dependencies
shell: bash
run: |
set -e
# Install project dependencies if package.json exists
# This ensures repomix.config.ts can import from local source
if [ -f "package.json" ]; then
npm install
fiThough bash defaults to continuing on error, explicit 4. Potential for a more targeted approachThis is more of a design consideration: The current solution installs all dependencies whenever
However, this adds complexity and the current approach is simpler and more robust. The overhead is acceptable for CI. 🧪 Testing SuggestionsConsider testing these scenarios:
📝 Minor: Commit MessageYour commit message follows Conventional Commits well:
SummaryThis is a solid fix that solves the immediate problem. The implementation is straightforward and safe. The main optimization opportunity is using Recommendation: ✅ Approve with optional optimization consideration The PR is ready to merge as-is. The suggested |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/actions/repomix/action.yml (1)
49-56: Prefernpm ciwhen a lockfile exists.Running plain
npm installcan mutatepackage-lock.jsonand produces non-deterministic dependency trees on CI. Consider usingnpm ciwhen a lockfile is present and falling back tonpm installotherwise to keep installs reproducible and avoid dirtying the workspace.Apply this diff to handle both cases:
- if [ -f "package.json" ]; then - npm install + if [ -f "package-lock.json" ]; then + npm ci + elif [ -f "package.json" ]; then + npm install fi
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/actions/repomix/action.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). (6)
- GitHub Check: Test (windows-latest, 22.x)
- GitHub Check: Build and run (windows-latest, 22.x)
- GitHub Check: Test (windows-latest, 24.x)
- GitHub Check: Test (windows-latest, 20.x)
- GitHub Check: Test with Bun (windows-latest, latest)
- GitHub Check: claude-review
Changed from @main reference to local reference (./.github/actions/repomix) to test action changes in feature branches before merging to main.
Code Review SummaryThis PR effectively addresses the CI workflow failure by ensuring project dependencies are installed before running Repomix. The fix is well-targeted and includes appropriate documentation. ✅ Positive Aspects
📝 Suggestions for Improvement1. Performance - Consider using npm ciIn CI environments,
if [ -f "package.json" ]; then
npm ci
fiCurrent 2. Error Handling - Add explicit error messageif [ -f "package.json" ]; then
echo "Installing project dependencies..."
npm install || {
echo "Error: Failed to install project dependencies"
exit 1
}
fi3. Caching - Verify auto-detection worksMonitor workflow runs to ensure npm caching is active. If not, explicitly add 4. Test Coverage - Add config import testConsider adding a test case that verifies 5. Documentation - Update action descriptionDocument that the action installs project dependencies when 🔒 Security & Best Practices
📊 Code Quality
Overall Assessment: ✅ Approve with minor suggestions The fix is solid. Suggestions above are optional enhancements, not blockers. |
Updated from v6.0.1 to v7.0.0 to fix race condition bug that caused push failures when the remote branch was updated during workflow execution.
PR ReviewThank you for this fix! The approach correctly addresses the workflow failure where ✅ What Works Well
🔍 Code Quality & Best PracticesDetails1. Missing npm Cache ConfigurationThe removal of Recommendation: Add caching for - name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: "24"
cache: 'npm' # Re-add for the global repomix install
- name: Install project dependencies
shell: bash
run: |
if [ -f "package.json" ]; then
# Check cache first
if [ -f "package-lock.json" ]; then
npm ci
else
npm install
fi
fi2. Performance ConsiderationInstalling all project dependencies (including devDependencies) when only runtime dependencies are needed for the config file could be optimized. Recommendation: Use 3. Error HandlingThe Recommendation: Add set -e or explicit error messages: - name: Install project dependencies
shell: bash
run: |
set -e
if [ -f "package.json" ]; then
echo "📦 Installing project dependencies for config file..."
npm install || {
echo "❌ Failed to install project dependencies"
exit 1
}
fi🐛 Potential IssuesDetails1. Schema File InclusionThe PR includes a newly generated schema file ( Questions:
Recommendation: Consider whether this schema file should be in a separate PR or if it was properly generated. 2. Action Version Reference ChangeThe workflow changed from: uses: yamadashy/repomix/.github/actions/repomix@mainto: uses: ./.github/actions/repomixThis is good for testing the local action, but means this specific workflow will always use the repository's version rather than a stable published version. Consideration: This is appropriate for the repomix repository itself (eating your own dog food), but external users should continue using the versioned reference. 3. Dependency Version ConflictsInstalling project dependencies could potentially conflict with the globally installed repomix version if there are version mismatches. Risk: Low, but worth monitoring in case the global 🔒 Security ConsiderationsDetails
🧪 Testing CoverageThe PR correctly mentions that Missing:
Recommendation: Consider adding a test workflow: name: Test Repomix Action
on: pull_request
jobs:
test-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/repomix
with:
output: test-output.xml
- name: Verify output
run: test -f test-output.xml📋 Minor SuggestionsDetails
🎯 Overall AssessmentVerdict: ✅ Approve with suggestions The PR successfully fixes the immediate issue and is ready to merge. The suggestions above are optimizations and nice-to-haves that could be addressed in follow-up PRs if desired. Priority Improvements (if any changes are made):
Great work on:
|
Summary
Fixes the pack-repository workflow failure caused by missing dependencies when loading
repomix.config.ts.Changes
npm installstep in the Repomix action whenpackage.jsonexistscache: "npm"setting (setup-node v5 detects it automatically)Background
The workflow was failing with "Cannot find module 'picocolors'" error because
repomix.config.tsimports from./src/index.js, which requires local project dependencies. This is specific to the Repomix project itself, where the config file imports from local source code.Checklist
npm run testnpm run lint