-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add make-generate to pre-commit #491
Conversation
WalkthroughThis pull request introduces modifications to the GitHub Actions workflow and pre-commit configuration files. A new step is added to the pre-commit workflow to install a tool called "generate," which involves setting up Node.js, cloning a repository, and compiling a binary. Additionally, a new pre-commit hook is introduced to run a Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (1)
.github/workflows/pre-commit.yml (1)
Line range hint
33-47
: Consider optimizing pre-commit hook executionThe current implementation runs hooks on all YAML and Markdown files when base commit is not found. This could be inefficient for large repositories.
Consider this optimization:
- name: Run pre-commit hooks run: | git fetch origin main || git fetch origin master - base_commit=$(git rev-parse --verify origin/main || git rev-parse --verify origin/master || echo "") + base_commit=$(git merge-base HEAD origin/main 2>/dev/null || git merge-base HEAD origin/master 2>/dev/null || echo "") if [ -z "$base_commit" ]; then - files=$(git ls-files '*.yaml' '*.md') + # Only check files in the current commit + files=$(git diff-index --cached --name-only HEAD | grep -E '\.(yaml|md)$') else files=$(git diff --name-only "$base_commit" -- '*.yaml' '*.md') fi
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
.github/workflows/pre-commit.yml
(1 hunks).pre-commit-config.yaml
(1 hunks)packages/apps/nats/README.md
(1 hunks)packages/apps/nats/values.schema.json
(1 hunks)packages/apps/postgres/values.schema.json
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- packages/apps/postgres/values.schema.json
- packages/apps/nats/README.md
"external": { | ||
"type": "boolean", | ||
"description": "Enable external access from outside the cluster", | ||
"default": false | ||
}, | ||
"default": {} | ||
} | ||
"replicas": { | ||
"type": "number", | ||
"description": "Persistent Volume size for NATS", | ||
"default": 2 | ||
}, | ||
"storageClass": { | ||
"type": "string", | ||
"description": "StorageClass used to store the data", | ||
"default": "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Removal of users property from schema conflicts with active usage
The users
property is actively used in both values.yaml
(as a default empty configuration) and templates/nats.yaml
(for generating credentials and NATS configuration). Removing it from the schema while keeping the functionality in the templates would lead to:
- Undocumented but required configuration option
- Potential breaking changes for existing deployments using user authentication
- Schema validation errors for valid configurations
Locations needing attention:
values.schema.json
: Keep theusers
property in the schema- If removal is intended, corresponding changes are needed in:
values.yaml
: Remove the users configurationtemplates/nats.yaml
: Remove the user authentication logic
🔗 Analysis chain
Schema structure looks good but verify impact of users removal
The schema properties are well-structured with clear descriptions and appropriate types. However, the removal of the users
property might impact existing configurations.
Let's verify the impact of removing the users configuration:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any references to NATS users configuration
rg -l "users:" ./packages/apps/nats/
Length of output: 110
Script:
#!/bin/bash
# Check the content of values.yaml and templates/nats.yaml to understand the usage of users configuration
echo "=== values.yaml ==="
cat ./packages/apps/nats/values.yaml
echo -e "\n=== templates/nats.yaml ==="
cat ./packages/apps/nats/templates/nats.yaml
Length of output: 2449
- id: run-make-generate | ||
name: Run 'make generate' in all app directories | ||
entry: | | ||
/bin/bash -c ' | ||
for dir in ./packages/apps/*/; do | ||
if [ -d "$dir" ]; then | ||
echo "Running make generate in $dir" | ||
(cd "$dir" && make generate) | ||
fi | ||
done | ||
' | ||
language: script | ||
files: ^.*$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance error handling and documentation for make-generate hook
The new hook implementation has several areas for improvement:
- No error handling for make generate failures
- Runs on all files (
^.*$
) which might impact performance - Missing documentation about what 'make generate' does
Consider this improved implementation:
- id: run-make-generate
name: Run 'make generate' in all app directories
entry: |
/bin/bash -c '
+ set -e # Exit on any error
+ if ! command -v make >/dev/null 2>&1; then
+ echo "Error: make is not installed"
+ exit 1
+ fi
for dir in ./packages/apps/*/; do
if [ -d "$dir" ]; then
echo "Running make generate in $dir"
- (cd "$dir" && make generate)
+ (cd "$dir" && make generate) || {
+ echo "Error: make generate failed in $dir"
+ exit 1
+ }
fi
done
'
language: script
- files: ^.*$
+ files: ^packages/apps/.*$
Also, please add documentation about what 'make generate' does and its purpose.
📝 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.
- id: run-make-generate | |
name: Run 'make generate' in all app directories | |
entry: | | |
/bin/bash -c ' | |
for dir in ./packages/apps/*/; do | |
if [ -d "$dir" ]; then | |
echo "Running make generate in $dir" | |
(cd "$dir" && make generate) | |
fi | |
done | |
' | |
language: script | |
files: ^.*$ | |
- id: run-make-generate | |
name: Run 'make generate' in all app directories | |
entry: | | |
/bin/bash -c ' | |
set -e # Exit on any error | |
if ! command -v make >/dev/null 2>&1; then | |
echo "Error: make is not installed" | |
exit 1 | |
fi | |
for dir in ./packages/apps/*/; do | |
if [ -d "$dir" ]; then | |
echo "Running make generate in $dir" | |
(cd "$dir" && make generate) || { | |
echo "Error: make generate failed in $dir" | |
exit 1 | |
} | |
fi | |
done | |
' | |
language: script | |
files: ^packages/apps/.*$ |
- name: Install generate | ||
run: | | ||
sudo apt update | ||
sudo apt install curl -y | ||
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - | ||
sudo apt install nodejs -y | ||
git clone https://github.com/bitnami/readme-generator-for-helm | ||
cd ./readme-generator-for-helm | ||
npm install | ||
npm install -g pkg | ||
pkg . -o /usr/local/bin/readme-generator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security and stability improvements needed for generate tool installation
Several concerns with the current implementation:
- Using Node.js 16 which is approaching EOL
- No version pinning for the external repository
- Direct sudo usage in GitHub Actions
- No verification of downloaded content
Consider these improvements:
- name: Install generate
run: |
- sudo apt update
- sudo apt install curl -y
- curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
- sudo apt install nodejs -y
- git clone https://github.com/bitnami/readme-generator-for-helm
+ sudo apt-get update
+ sudo apt-get install -y curl
+ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
+ sudo apt-get install -y nodejs
+ # Clone specific version and verify
+ git clone --depth 1 --branch v1.0.0 https://github.com/bitnami/readme-generator-for-helm
cd ./readme-generator-for-helm
+ # Verify repository content
+ git verify-commit HEAD || echo "Warning: Commit signature verification failed"
npm install
npm install -g pkg
pkg . -o /usr/local/bin/readme-generator
Also consider:
- Using GitHub's official Node.js setup action instead of manual installation
- Caching npm dependencies
- Adding SHA256 verification for downloaded content
Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> - **New Features** - Introduced a new pre-commit hook (`run-make-generate`) to automate the generation process in application directories. - **Documentation** - Enhanced readability of the Managed NATS Service README by adjusting formatting and removing unnecessary headers. - **Bug Fixes** - Corrected JSON structure in the Postgres values schema to ensure validity. - **Chores** - Updated pre-commit configuration for improved consistency and functionality. - Reorganized properties in the NATS values schema, removing the `users` property to reflect changes in user management capabilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
run-make-generate
) to automate the generation process in application directories.Documentation
Bug Fixes
Chores
users
property to reflect changes in user management capabilities.