Skip to content

Conversation

gfyrag
Copy link
Collaborator

@gfyrag gfyrag commented Jan 9, 2025

No description provided.

@gfyrag gfyrag requested a review from a team as a code owner January 9, 2025 13:51
Copy link

coderabbitai bot commented Jan 9, 2025

Walkthrough

The pull request introduces modifications to the Earthfile, focusing on enhancing the build and deployment processes. The changes include specifying a new base image, updating the deployment section to copy source files, and modifying the database schema export process. These alterations aim to improve the integration of source files and dependencies across different build stages, potentially streamlining the overall build and deployment workflow.

Changes

File Change Summary
Earthfile - Added FROM core+base-image as new base image
- Updated deploy section with COPY (+sources/*) /src
- Modified export-database-schema to use FROM +sources
- Added dependency installation for wait-for-it

Possibly related PRs

Poem

🐰 Earthly builds, a rabbit's delight,
Sources dancing, pipeline shining bright
Copy, deploy, with magical grace
Dependencies lined up in their place
A build so smooth, it makes me grin! 🚀

Finishing Touches

  • 📝 Generate Docstrings

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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.

@flemzord flemzord enabled auto-merge January 9, 2025 13:51
Copy link

@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

🔭 Outside diff range comments (1)
Earthfile (1)

Line range hint 64-87: Enhance error handling and security in database schema export.

The current implementation has several areas for improvement:

  1. No error handling for tool installation
  2. No timeout for database readiness check
  3. Missing cleanup for failure scenarios
  4. Credentials exposed in connection string

Consider applying these improvements:

 export-database-schema:
     FROM +sources
-    RUN go install github.com/roerohan/wait-for-it@latest
+    RUN go install github.com/roerohan/wait-for-it@latest || exit 1
     WITH DOCKER --load=postgres:15-alpine=+postgres --pull schemaspy/schemaspy:6.2.4
         RUN bash -c '
+            set -e  # Exit on any error
+            trap "docker kill $postgresContainerID 2>/dev/null || true" EXIT
             echo "Creating PG server...";
             postgresContainerID=$(docker run -d --rm -e POSTGRES_USER=root -e POSTGRES_PASSWORD=root -e POSTGRES_DB=formance --net=host postgres:15-alpine);
-            wait-for-it -w 127.0.0.1:5432;
+            wait-for-it -w -t 30 127.0.0.1:5432 || exit 1;
 
             echo "Creating bucket...";
-            go run main.go buckets upgrade _default --postgres-uri "postgres://root:root@127.0.0.1:5432/formance?sslmode=disable";
+            PGPASSWORD=root go run main.go buckets upgrade _default --postgres-uri "postgres://root@127.0.0.1:5432/formance?sslmode=disable";
 
             echo "Exporting schemas...";
             docker run --rm -u root \
               -v ./docs/database:/output \
               --net=host \
-              schemaspy/schemaspy:6.2.4 -u root -db formance -t pgsql11 -host 127.0.0.1 -port 5432 -p root -schemas _system,_default;
+              schemaspy/schemaspy:6.2.4 -u root -db formance -t pgsql11 -host 127.0.0.1 -port 5432 -p "$POSTGRES_PASSWORD" -schemas _system,_default;
 
-            docker kill "$postgresContainerID";
         '
     END
🧹 Nitpick comments (1)
Earthfile (1)

Line range hint 52-57: LGTM! Consider adding deployment logging.

The deployment process looks solid with deterministic versioning based on source content SHA1.

Consider adding echo statements for better deployment tracking:

 deploy:
     COPY (+sources/*) /src
     LET tag=$(tar cf - /src | sha1sum | awk '{print $1}')
+    RUN echo "Deploying version: $tag"
     WAIT
         BUILD --pass-args +build-image --tag=$tag
     END
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc9597c and e15674c.

📒 Files selected for processing (1)
  • Earthfile (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Tests
🔇 Additional comments (1)
Earthfile (1)

6-6: LGTM! Verify core module compatibility.

The base image specification looks correct and aligns with the project structure.

Let's verify the core module version compatibility:

✅ Verification successful

✅ Core module compatibility verified

The base image specification is correctly configured and consistently used across the codebase, with matching version references (v0.19.0) in both the main Earthfile and tools/generator/Earthfile.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the core module version is consistently referenced
rg -l "formancehq/earthly.*v0.19.0" 

Length of output: 73


Script:

#!/bin/bash
# Check the context of version references
echo "=== Main Earthfile ==="
rg "formancehq/earthly.*v0.19.0" Earthfile -C 2

echo -e "\n=== Generator Earthfile ==="
rg "formancehq/earthly.*v0.19.0" tools/generator/Earthfile -C 2

Length of output: 455

@flemzord flemzord added this pull request to the merge queue Jan 9, 2025
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.62%. Comparing base (8fe29fd) to head (e15674c).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #645      +/-   ##
==========================================
- Coverage   81.65%   81.62%   -0.03%     
==========================================
  Files         131      131              
  Lines        7070     7070              
==========================================
- Hits         5773     5771       -2     
- Misses        993      996       +3     
+ Partials      304      303       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Merged via the queue into main with commit dcad6bb Jan 9, 2025
9 of 10 checks passed
@flemzord flemzord deleted the fix/earthfile branch January 9, 2025 14:00
@coderabbitai coderabbitai bot mentioned this pull request Jan 9, 2025
@gfyrag gfyrag mentioned this pull request Mar 14, 2025
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.

3 participants