Skip to content
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

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

rajatagrawal
Copy link
Contributor

@rajatagrawal rajatagrawal commented Jul 30, 2024

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?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a pre-push hook to ensure integrity by preventing inadvertent pushes of certain files to the repository.
  • Improvements

    • Updated GitHub Actions workflow to enhance management of large files, ensuring the latest configurations are applied before builds.

Copy link
Contributor

coderabbitai bot commented Jul 30, 2024

Walkthrough

This 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

File Paths Change Summary
.github/workflows/client-build.yml Added git lfs update --force before git lfs install to ensure the latest LFS configurations are applied during builds.
app/client/.husky/pre-push Introduced a Bash pre-push hook to prevent pushes containing files from the app/client/src/ee directory unless directed at the Appsmith EE repository.

Poem

In the land of code where changes flow,
Hooks and workflows help us grow.
LFS updated, pushes refined,
With care and checks, our paths aligned.
Enterprise files kept at bay,
Our community thrives day by day!
✨💻🌟


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?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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)

  • @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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog CI labels Jul 30, 2024
@rajatagrawal rajatagrawal requested review from yatinappsmith and removed request for KelvinOm July 30, 2024 06:27
Copy link
Contributor

@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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e4fc6d2 and b6e5636.

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 of git 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.

Comment on lines +27 to +61
# 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
}
Copy link
Contributor

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.

Suggested change
# 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
}

Copy link
Contributor

@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: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b6e5636 and 0d0450c.

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

@rajatagrawal rajatagrawal merged commit d1a586e into release Jul 30, 2024
15 checks passed
@rajatagrawal rajatagrawal deleted the chore/fix-pre-push-hook branch July 30, 2024 06:41
@coderabbitai coderabbitai bot mentioned this pull request Nov 26, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants