-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
ci: Add pre push hook to not allow ee changes in ce #35276
Conversation
WalkthroughThis update enhances the GitHub Actions workflow and introduces a pre-push hook for Git. The workflow ensures that Git Large File Storage (LFS) is updated prior to installation, improving large file handling. The pre-push hook validates commits to prevent accidental pushes of enterprise-specific files, preserving the integrity of the community codebase. Together, these changes improve both build reliability and code management practices. Changes
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 as PR comments)
Additionally, you can add 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: 1
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- .github/workflows/client-build.yml (1 hunks)
- app/client/.husky/pre-push (1 hunks)
Additional comments not posted (3)
app/client/.husky/pre-push (2)
1-19
: Good job on the initial setup and comments!The shebang line and detailed comments provide clarity on the script's purpose and parameters.
63-95
: Well done on the main script logic!The logic effectively handles different scenarios and the echo statements are useful for debugging.
.github/workflows/client-build.yml (1)
237-237
: Great addition ofgit lfs update --force
!Updating Git LFS before installation is a good practice to avoid conflicts.
However, ensure that this change does not introduce any new issues in the build process.
# Function to get list of files between two commits | ||
do_commits_contain_ee_files() { | ||
# Store the commit hashes | ||
from_commit=$1 | ||
to_commit=$2 | ||
string_to_match="app/client/src/ee" | ||
|
||
# to_commit sha can be null if a branch is being pushed for the first to remote | ||
# In that case, we would need to compare the diff against a default branch, like release. | ||
if [ "$to_commit" == "$null_sha" ]; then | ||
echo "comparing changes against release" | ||
|
||
remote_name=$(git remote -v | grep -i $appsmith_ce_url | grep -i fetch | awk '{print $1}') | ||
echo "remote name is $remote_name" | ||
|
||
git fetch $remote_name release | ||
to_commit=$remote_name/release | ||
fi | ||
|
||
echo "to_commit in function is $to_commit" | ||
echo "from_commit is $from_commit" | ||
|
||
# Get the list of files between the two commits | ||
files=$(git diff --name-only $from_commit $to_commit) | ||
|
||
# Iterate over each file | ||
for file in $files; do | ||
# Check if the file path contains the string | ||
if [[ "$file" == *"$string_to_match"* ]]; then | ||
echo "File '$file' matches the string '$string_to_match'" | ||
return 0 | ||
fi | ||
done | ||
return 1 | ||
} |
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.
Consider using local
for variables within the function.
Using local
for from_commit
, to_commit
, and string_to_match
will limit their scope to the function and prevent potential conflicts.
- from_commit=$1
- to_commit=$2
- string_to_match="app/client/src/ee"
+ local from_commit=$1
+ local to_commit=$2
+ local string_to_match="app/client/src/ee"
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.
# Function to get list of files between two commits | |
do_commits_contain_ee_files() { | |
# Store the commit hashes | |
from_commit=$1 | |
to_commit=$2 | |
string_to_match="app/client/src/ee" | |
# to_commit sha can be null if a branch is being pushed for the first to remote | |
# In that case, we would need to compare the diff against a default branch, like release. | |
if [ "$to_commit" == "$null_sha" ]; then | |
echo "comparing changes against release" | |
remote_name=$(git remote -v | grep -i $appsmith_ce_url | grep -i fetch | awk '{print $1}') | |
echo "remote name is $remote_name" | |
git fetch $remote_name release | |
to_commit=$remote_name/release | |
fi | |
echo "to_commit in function is $to_commit" | |
echo "from_commit is $from_commit" | |
# Get the list of files between the two commits | |
files=$(git diff --name-only $from_commit $to_commit) | |
# Iterate over each file | |
for file in $files; do | |
# Check if the file path contains the string | |
if [[ "$file" == *"$string_to_match"* ]]; then | |
echo "File '$file' matches the string '$string_to_match'" | |
return 0 | |
fi | |
done | |
return 1 | |
} | |
do_commits_contain_ee_files() { | |
# Store the commit hashes | |
local from_commit=$1 | |
local to_commit=$2 | |
local string_to_match="app/client/src/ee" | |
# to_commit sha can be null if a branch is being pushed for the first to remote | |
# In that case, we would need to compare the diff against a default branch, like release. | |
if [ "$to_commit" == "$null_sha" ]; then | |
echo "comparing changes against release" | |
remote_name=$(git remote -v | grep -i $appsmith_ce_url | grep -i fetch | awk '{print $1}') | |
echo "remote name is $remote_name" | |
git fetch $remote_name release | |
to_commit=$remote_name/release | |
fi | |
echo "to_commit in function is $to_commit" | |
echo "from_commit is $from_commit" | |
# Get the list of files between the two commits | |
files=$(git diff --name-only $from_commit $to_commit) | |
# Iterate over each file | |
for file in $files; do | |
# Check if the file path contains the string | |
if [[ "$file" == *"$string_to_match"* ]]; then | |
echo "File '$file' matches the string '$string_to_match'" | |
return 0 | |
fi | |
done | |
return 1 | |
} |
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: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- .github/workflows/client-build.yml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- .github/workflows/client-build.yml
Description
This PR fixes failure in the CI build workflow. The workflow was failing in
Put release build in cache
job. The workflow was failing because while installing git lfs, there was a conflict with the newly added pre push hook. git lfs also contains its pre push hooks which was conflicting with our hooks. In this PR, I have configured the workflow for git lfs pre push hooks to override appsmith pre push commit since appsmith git hooks are not required during workflows.Fixes #
Issue Number
or
Fixes
Issue URL
Warning
If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.
Automation
/ok-to-test tags=""
🔍 Cypress test results
Caution
If you modify the content in this section, you are likely to disrupt the CI result for your PR.
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
New Features
Improvements