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 : fix build cache #37712

Merged
merged 2 commits into from
Nov 26, 2024
Merged

CI : fix build cache #37712

merged 2 commits into from
Nov 26, 2024

Conversation

yatinappsmith
Copy link
Contributor

@yatinappsmith yatinappsmith commented Nov 26, 2024

Description

fix build cache

Fixes #Issue Number
or
Fixes Issue URL

Automation

/ok-to-test tags=""

🔍 Cypress test results

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced client build workflow with a new input parameter for branch specification.
    • Added support for PostgreSQL builds in the server build workflow.
  • Improvements

    • Improved caching mechanisms for both client and server builds to optimize build times.
    • Enhanced test execution logic to provide detailed reports on failed tests.
  • Bug Fixes

    • Streamlined conditions for running builds and tests based on previous execution states.

Copy link
Contributor

coderabbitai bot commented Nov 26, 2024

Walkthrough

The pull request modifies two GitHub workflow files for client and server builds. The client build workflow now includes a new input parameter branch, and changes the skip-tests parameter from a boolean to a string type. The server build workflow introduces an is-pg-build parameter and enhances the handling of PostgreSQL builds, caching, and test execution. Both workflows have improved conditional checks and caching mechanisms to streamline their respective build processes.

Changes

File Change Summary
.github/workflows/client-build.yml - Added input parameter branch.
- Changed skip-tests type from boolean to string with default value "false".
- Refined checkout steps and added caching logic for client build.
.github/workflows/server-build.yml - Added input parameter is-pg-build with default value "false".
- Enhanced PostgreSQL service handling and streamlined previous run checks.
- Updated caching mechanisms for Maven dependencies and introduced Git LFS migration command.

Possibly related PRs

Suggested labels

skip-changelog, CI, ok-to-test

Suggested reviewers

  • sharat87
  • pratapaprasanna
  • ApekshaBhosale

🎉 In the land of code where workflows thrive,
New branches and inputs help builds come alive!
With caching and checks, the processes flow,
Enhancing our CI, watch our efficiency grow!
So here's to the changes, both big and small,
Together we build, we conquer, we stand tall! 🚀


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>, 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.

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

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.

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

🧹 Outside diff range and nitpick comments (3)
.github/workflows/client-build.yml (1)

209-209: Consider performance impact of Git LFS migration

The git lfs migrate import --everything command rewrites Git history and could significantly impact build time. Consider:

  1. Running this only when necessary
  2. Using selective migration instead of --everything
.github/workflows/server-build.yml (2)

Line range hint 141-144: Consider using environment variables for PostgreSQL configuration

While the PostgreSQL setup is correct, consider extracting configuration values (port, password) to environment variables for better maintainability.

 docker run --name appsmith-pg -p 5432:5432 -d \
-  -e POSTGRES_PASSWORD=password postgres:alpine postgres -N 1500
+  -e POSTGRES_PASSWORD=${{ env.PG_PASSWORD }} \
+  -e POSTGRES_MAX_CONNECTIONS=1500 \
+  postgres:alpine

Line range hint 237-307: Consider modularizing test reporting logic

The test reporting logic is complex and handles multiple responsibilities. Consider extracting this into a separate shell script for better maintainability and reusability.

Create a new file scripts/test-reporter.sh and move the test reporting logic there. Then update the workflow to:

-            # Process mvn_test.log for FAILURE and SKIPPED statuses
-            while IFS= read -r line; do
-                if [[ $line == *"FAILURE"* ]]; then
-                    module_name=$(echo "$line" | awk '{print $2}')
-                    failed_modules+=("$module_name")
-                elif [[ $line == *"SKIPPED"* ]]; then
-                    module_name=$(echo "$line" | awk '{print $2}')
-                    skipped_modules+=("$module_name")
-                fi
-            done < mvn_test.log
+            ./scripts/test-reporter.sh mvn_test.log
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8cb0bee and e721174.

📒 Files selected for processing (2)
  • .github/workflows/client-build.yml (1 hunks)
  • .github/workflows/server-build.yml (1 hunks)
🔇 Additional comments (4)
.github/workflows/client-build.yml (3)

Line range hint 171-184: LGTM: Robust cache implementation

The cache handling implementation is well-structured with:

  • Proper cache key versioning
  • Clear separation between CE and EE builds
  • Efficient artifact restoration strategy

Line range hint 134-157: LGTM: Secure environment configuration

The environment setup demonstrates good security practices:

  • Proper use of GitHub secrets
  • Clear branch-based configuration
  • Secure handling of analytics keys

Line range hint 9-19: Verify workflow calls after skip-tests type change

The type change of skip-tests from boolean to string could break existing workflow calls. Ensure all dependent workflows are updated accordingly.

✅ Verification successful

Type change for skip-tests parameter is safe

The change of skip-tests from boolean to string type is safe as all existing workflow calls are already passing the value as a string:

  • build-client-server-count.yml and build-client-server.yml use "true"
  • on-demand-build-docker-image-deploy-preview.yml passes a variable that would be stringified
  • Other workflows don't use the parameter, defaulting to "false"
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for workflow files that might be calling this workflow
rg -l "client-build.yml" .github/workflows/

Length of output: 487


Script:

#!/bin/bash
# Check how client-build.yml is referenced in the identified workflow files
rg -A 5 "client-build.yml" .github/workflows/ad-hoc-docker-image.yml .github/workflows/test-build-docker-image.yml .github/workflows/pr-cypress.yml .github/workflows/on-demand-build-docker-image-deploy-preview.yml .github/workflows/quality-checks.yml .github/workflows/build-client-server.yml .github/workflows/build-client-server-count.yml

Length of output: 3297

.github/workflows/server-build.yml (1)

Line range hint 12-14: Verify compatibility with existing workflow calls

The skip-tests parameter type has been changed from boolean to string. This might break existing workflow calls that pass boolean values.

Also applies to: 21-24

✅ Verification successful

Type change for skip-tests parameter appears safe to proceed

From the workflow calls inspection, none of the calling workflows are currently passing the skip-tests parameter, making this type change from boolean to string safe for existing usage.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for existing workflow calls that might be affected
rg -l 'uses: .*server-build.yml.*\n.*skip-tests:\s*(true|false)\s*$' .github/workflows/

Length of output: 281


Script:

#!/bin/bash
# Search for workflow calls with multiline mode enabled
rg -U 'uses:.*server-build\.yml.*\nskip-tests:' .github/workflows/

# Also search for direct references to the workflow
rg 'server-build\.yml' .github/workflows/

Length of output: 1322


Script:

#!/bin/bash
# Check the actual parameters being passed in the workflow calls
for file in .github/workflows/test-build-docker-image.yml .github/workflows/on-demand-build-docker-image-deploy-preview.yml .github/workflows/pr-cypress.yml .github/workflows/quality-checks.yml .github/workflows/build-client-server.yml .github/workflows/build-client-server-count.yml .github/workflows/ad-hoc-docker-image.yml; do
  echo "=== $file ==="
  rg -A 3 'uses:.*server-build\.yml' "$file"
done

Length of output: 4615

@@ -338,6 +338,7 @@ jobs:
git config --global user.name "$gituser"
git clone https://$cachetoken@github.com/appsmithorg/cibuildcache.git
git lfs install
git lfs migrate import --everything
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Git LFS setup is missing but required for large files

The repository contains multiple large files (>1MB), particularly video files up to 45MB, but Git LFS is not configured (.gitattributes missing). This will cause the git lfs migrate import command to fail.

  • Add .gitattributes file with appropriate patterns:
    *.y4m filter=lfs diff=lfs merge=lfs -text
    *.mov filter=lfs diff=lfs merge=lfs -text
    *.gif filter=lfs diff=lfs merge=lfs -text
    
  • Install Git LFS before running the migration command
🔗 Analysis chain

Verify Git LFS migration impact

The git lfs migrate import --everything command might cause issues if not all files are properly tracked in Git LFS. Consider using selective migration or verifying the tracked patterns first.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check Git LFS tracked patterns
git lfs track

# Verify size of files that would be migrated
git lfs migrate info --everything

Length of output: 221


Script:

#!/bin/bash
# Check if .gitattributes exists and contains LFS configurations
if [ -f ".gitattributes" ]; then
    echo "Content of .gitattributes:"
    cat .gitattributes
else
    echo ".gitattributes not found"
fi

# Search for large files in the repository
echo -e "\nLarge files (>1MB) in the repository:"
find . -type f -size +1M -not -path "*/\.*" -exec ls -lh {} \;

# Check if there are any existing LFS references
echo -e "\nSearching for LFS pointers:"
find . -type f -not -path "*/\.*" -exec grep -l "version https://git-lfs.github.com/spec/" {} \;

Length of output: 4157

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.

2 participants