Skip to content

make loading projects from push configurable #2010

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

Merged
merged 2 commits into from
Jul 4, 2025

Conversation

motatoes
Copy link
Contributor

@motatoes motatoes commented Jul 4, 2025

we will need to make loading configurable (off for now) until we move it to a new service

Summary by CodeRabbit

  • Chores
    • Improved control over project loading on push events by making it conditional based on an environment setting. No visible changes to user-facing features.

Copy link
Contributor

coderabbitai bot commented Jul 4, 2025

Walkthrough

The handlePushEvent function in the GitHub controller was updated to check the DIGGER_LOAD_PROJECTS_ON_PUSH environment variable before loading projects on push events. Projects are now loaded only if this variable is set to "true" and the push is to the default branch; otherwise, the function logs that loading is skipped.

Changes

File(s) Change Summary
backend/controllers/github.go Modified handlePushEvent to conditionally load projects based on DIGGER_LOAD_PROJECTS_ON_PUSH.

Poem

A push to the branch, should projects appear?
Now a rabbit checks the env, to make it clear.
If "true" is the word, then loading is done,
Otherwise, skipped—no projects to run!
With logs as our guide, the code hops along,
Following the settings, where they belong.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a2391d6 and 41f9117.

📒 Files selected for processing (1)
  • backend/controllers/github.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/controllers/github.go
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Security Check
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in a Comment
  • Commit Unit Tests in branch feat/load-projects-on-push-make-arguments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this 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.

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.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added configurable project loading on push events through a new environment variable in the backend system.

  • Added DIGGER_LOAD_PROJECTS_ON_PUSH environment flag in backend/controllers/github.go to control project loading behavior on push events
  • Enhanced logging in push event handler with specific messages for project loading status

Note: This feature requires explicit environment configuration to enable project loading on push.

1 file reviewed, 2 comments
Edit PR Review Bot Settings | Greptile

Comment on lines 416 to 417
slog.Info("Loading projects from GitHub repo (push event)", "loadProjectsOnPush", loadProjectsOnPush, "ref", ref, "defaultBranch", defaultBranch)
err := services.LoadProjectsFromGithubRepo(gh, strconv.FormatInt(installationId, 10), repoFullName, repoOwner, repoName, cloneURL, defaultBranch)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Log level 'Info' for loading projects is inconsistent. For diagnostics, the key operation event should have level 'Debug' according to custom rules


if strings.HasSuffix(ref, defaultBranch) {
slog.Info("Loading projects from GitHub repo (push event)", "loadProjectsOnPush", loadProjectsOnPush, "ref", ref, "defaultBranch", defaultBranch)
err := services.LoadProjectsFromGithubRepo(gh, strconv.FormatInt(installationId, 10), repoFullName, repoOwner, repoName, cloneURL, defaultBranch)
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Prefer 'prNumber' over plain 'ref' in logs for easier troubleshooting

Copy link

delve-auditor bot commented Jul 4, 2025

No security or compliance issues detected. Reviewed everything up to 41f9117.

Security Overview
  • 🔎 Scanned files: 1 changed file(s)
Detected Code Changes
Change Type Relevant files
Enhancement ► github.go
    Add configuration toggle for project loading on push events
    Add debug logging for project loading decisions

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

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

🧹 Nitpick comments (1)
backend/controllers/github.go (1)

411-411: Consider documenting the case-sensitive requirement.

The environment variable check uses exact string matching with "true". This means "True", "TRUE", or "1" won't work. Consider documenting this requirement or using strconv.ParseBool() for more flexible boolean parsing.

Alternative implementation for more flexible boolean parsing:

-loadProjectsOnPush := os.Getenv("DIGGER_LOAD_PROJECTS_ON_PUSH")
+loadProjectsOnPushStr := os.Getenv("DIGGER_LOAD_PROJECTS_ON_PUSH")
+loadProjectsOnPush, _ := strconv.ParseBool(loadProjectsOnPushStr)

Then use if loadProjectsOnPush { instead of the string comparison.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5cf11a5 and a2391d6.

📒 Files selected for processing (1)
  • backend/controllers/github.go (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: motatoes
PR: diggerhq/digger#1855
File: backend/controllers/github.go:768-774
Timestamp: 2024-12-17T12:34:41.545Z
Learning: In the Digger project, the `DIGGER_GENERATION_WEBHOOK_SECRET` environment variable is optional and may be an empty string, so validation for its presence is not required in the code.
backend/controllers/github.go (1)
Learnt from: motatoes
PR: diggerhq/digger#1855
File: backend/controllers/github.go:768-774
Timestamp: 2024-12-17T12:34:41.545Z
Learning: In the Digger project, the `DIGGER_GENERATION_WEBHOOK_SECRET` environment variable is optional and may be an empty string, so validation for its presence is not required in the code.
🧬 Code Graph Analysis (1)
backend/controllers/github.go (1)
backend/services/repos.go (1)
  • LoadProjectsFromGithubRepo (13-58)
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Security Check
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: Build
🔇 Additional comments (1)
backend/controllers/github.go (1)

413-424: Backwards compatibility consideration.

This change introduces a breaking change where projects will no longer load on push events unless DIGGER_LOAD_PROJECTS_ON_PUSH=true is explicitly set. Ensure this is documented in the deployment/upgrade notes.

The implementation correctly follows the PR objective of making project loading configurable. The error handling appropriately logs failures without stopping execution, and the logging provides good context for debugging.

@motatoes motatoes merged commit 368b373 into develop Jul 4, 2025
13 checks passed
@motatoes motatoes deleted the feat/load-projects-on-push-make-arguments branch July 4, 2025 19:34
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.

1 participant