Skip to content

Enhance folder syncing configuration#4

Draft
sinazadeh wants to merge 13 commits intokeksiqc:mainfrom
sinazadeh:main
Draft

Enhance folder syncing configuration#4
sinazadeh wants to merge 13 commits intokeksiqc:mainfrom
sinazadeh:main

Conversation

@sinazadeh
Copy link

@sinazadeh sinazadeh commented Aug 2, 2025

Introduce new environment variable options for profile-specific folder URLs, improve URL cleaning in profile folder retrieval, and update documentation for clearer configuration instructions.

Summary by CodeRabbit

  • New Features

    • Per-profile folder configuration via indexed environment variables and a DEBUG-controlled verbose logging mode.
  • Documentation

    • Expanded example env configuration with comments and examples.
    • Updated README with detailed Secrets & Variables guidance and three folder-configuration options.
    • Added usage examples illustrating default, per-profile, and hybrid setups.
  • Chores

    • CI guidance updated to read profile and per-profile folder values from workflow Variables.

@coderabbitai
Copy link

coderabbitai bot commented Aug 2, 2025

Walkthrough

Adds per-profile folder configuration via indexed environment variables, updates main sync logic to use cached profile-specific folder lists, expands documentation (.env.example, README, USAGE_EXAMPLES.md) with configuration guidance, and adjusts GitHub workflow to source PROFILE and PROFILE_X_FOLDERS from repository/organization variables.

Changes

Cohort / File(s) Change Summary
Per-Profile Folder Logic
main.py
Adds get_profile_folders(profile_index: int), PROFILE_FOLDERS cache, uses profile-specific PROFILE_X_FOLDERS values when syncing, enhances logging and adds DEBUG env toggle.
Environment template
.env.example
Expanded with detailed comments and examples for TOKEN, required PROFILE (comma-separated IDs), optional indexed PROFILE_0_FOLDERS..PROFILE_n_FOLDERS, and guidance for per-profile overrides.
Documentation: examples
USAGE_EXAMPLES.md
New file describing three scenarios (default folders, per-profile PROFILE_X_FOLDERS, hybrid) with example .env / CI variable snippets.
Documentation: README updates
README.md
Adds Secrets & Variables section, explains three folder configuration options (Option 1/2/3), updates Configure/Run instructions and CI guidance to reflect variables vs secrets.
CI workflow env sourcing
.github/workflows/sync.yml
Switches PROFILE and PROFILE_*_FOLDERS values to be read from workflow vars (repo/org variables) instead of secrets; adds PROFILE_0_FOLDERS..PROFILE_3_FOLDERS env entries and docs comment block in workflow.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RepoVars as "Repo/Org Vars"
    participant RepoSecrets as "Repo Secrets"
    participant main as main.py
    participant ControlD as "Control D API"

    User->>RepoSecrets: Set `TOKEN`
    User->>RepoVars: Set `PROFILE`, `PROFILE_0_FOLDERS`..`PROFILE_n_FOLDERS`
    main->>RepoSecrets: Read `TOKEN`
    main->>RepoVars: Read `PROFILE` and indexed `PROFILE_X_FOLDERS`
    main->>main: Parse `PROFILE` into list of profile IDs
    loop per profile (index i)
        alt `PROFILE_i_FOLDERS` exists
            main->>main: get_profile_folders(i) -> use profile-specific URLs
        else
            main->>main: use DEFAULT_FOLDER_URLS
        end
        main->>ControlD: Sync folders for profile ID
        ControlD-->>main: Sync response/status
    end
    main->>User: Log results (DEBUG if enabled)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

In the warren where configs hop and play,
Each profile gets its own folder buffet.
Vars and secrets placed with care,
Debug lights show what’s fetching where.
Rabbits giggle — syncs now fair and gay. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Enhance folder syncing configuration" directly relates to the main changes throughout the PR. The primary objective is to introduce support for profile-specific folder URL configurations via environment variables (PROFILE_i_FOLDERS), which is implemented in main.py and reflected across the workflow configuration, example files, and documentation updates. The title is concise, clear, and avoids vague terminology, accurately capturing the essence of making folder syncing configuration more flexible and granular without overstating the scope.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 57b9844 and bbc4567.

📒 Files selected for processing (2)
  • .github/workflows/sync.yml (1 hunks)
  • README.md (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • README.md
  • .github/workflows/sync.yml

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@sinazadeh
Copy link
Author

Related to this.

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

🧹 Nitpick comments (3)
main.py (3)

390-404: Address redundant URL cleaning.

The URL cleaning is performed twice - once in get_profile_folders() and again here. Consider removing the redundant cleaning since URLs are already cleaned when cached in PROFILE_FOLDERS.

-            # Clean the URL again right before using it
-            cleaned_url = url.strip().replace('"', "").replace("'", "")
-            log.debug(f"Fetching folder data from: '{cleaned_url}'")
-            folder_data_list.append(fetch_folder_data(cleaned_url))
+            log.debug(f"Fetching folder data from: '{url}'")
+            folder_data_list.append(fetch_folder_data(url))

460-471: Fix unused loop variable flagged by static analysis.

The loop variable profile_id is not used within the loop body. Use an underscore to indicate it's intentionally unused, or use the variable if needed.

-    for i, profile_id in enumerate(PROFILE_IDS):
+    for i, _ in enumerate(PROFILE_IDS):

Alternatively, if you want to use the profile_id for logging:

     for i, profile_id in enumerate(PROFILE_IDS):
         env_key = f"PROFILE_{i}_FOLDERS"
         env_value = os.getenv(env_key)
         if env_value:
             log.info(
-                f"Profile {i + 1}: Found custom configuration with {len(env_value.split(','))} folders"
+                f"Profile {i + 1} ({profile_id}): Found custom configuration with {len(env_value.split(','))} folders"
             )
         else:
             log.info(
-                f"Profile {i + 1}: No custom configuration found, will use defaults"
+                f"Profile {i + 1} ({profile_id}): No custom configuration found, will use defaults"
             )

474-474: Consider including profile ID in sync start log.

The log message "Starting sync for profile" could be more informative by including the actual profile ID.

-        log.info("Starting sync for profile")
+        log.info(f"Starting sync for profile {profile_id}")
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c10d760 and 7de0b88.

📒 Files selected for processing (5)
  • .env.example (1 hunks)
  • .github/workflows/sync.yml (1 hunks)
  • README.md (1 hunks)
  • USAGE_EXAMPLES.md (1 hunks)
  • main.py (14 hunks)
🧰 Additional context used
🪛 Ruff (0.12.2)
main.py

460-460: Loop control variable profile_id not used within loop body

(B007)

🔇 Additional comments (9)
.env.example (1)

1-38: Excellent comprehensive documentation template!

The expanded .env.example file provides clear, well-structured guidance for configuring the enhanced folder syncing functionality. The explanations of the indexing approach and fallback behavior are particularly helpful for users.

.github/workflows/sync.yml (1)

30-31: Good addition of profile-specific secrets.

The workflow now properly supports the new per-profile folder configuration. Note that this currently supports up to 2 profiles (indices 0 and 1). If users need more profiles, they would need to add additional PROFILE_X_FOLDERS secrets manually.

README.md (1)

47-66: Excellent documentation of the new configuration options!

The expanded "Configure Folders" section clearly explains the three configuration approaches with concrete examples. The indexing concept is well-explained and the documentation aligns perfectly with the implementation.

USAGE_EXAMPLES.md (1)

1-52: Valuable addition of practical usage scenarios!

This documentation file effectively demonstrates the three main configuration approaches with concrete examples. The scenarios cover realistic use cases and help users understand how to apply the new functionality.

main.py (5)

13-24: Good documentation of the new configuration options.

The docstring clearly explains the new PROFILE_X_FOLDERS environment variables with helpful examples.


41-49: Good implementation of debug mode configuration.

The debug mode toggle using environment variables is well-implemented and provides useful flexibility for troubleshooting.


80-110: Well-implemented profile folder retrieval function.

The function properly handles environment variable lookup, URL cleaning, and fallback to defaults. The debug logging provides good visibility into the configuration process.


112-121: Good initialization and debug logging.

The profile folder initialization using index-based lookup is well-implemented. The debug logging of all PROFILE_* environment variables is helpful for troubleshooting configuration issues.


166-172: Good multiline formatting for readability.

The expanded multiline formatting improves code readability while maintaining the same functionality.

@sinazadeh sinazadeh marked this pull request as draft November 3, 2025 19:38
@whallin
Copy link

whallin commented Nov 7, 2025

Deployed this PR just now to use it for myself, seems to work flawlessly.

Something that may be worth considering; get the PROFILE_IDS to construct the expected environment variables for PROFILE_XXXXX_FOLDERS. I could see it being helpful for some as it'd be a slightly more straightforward way of, directly from the FOLDERS environment variables, knowing which profile the list of folders belong to.

Example: my profile ID is 123456abcde7, the expected variable to contain my comma-separated profile list would be PROFILE_123456abcde7_FOLDERS.

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