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

Make overwritable experimental behind a cargo feature #160

Merged
merged 3 commits into from
Oct 27, 2024

Conversation

Veetaha
Copy link
Contributor

@Veetaha Veetaha commented Oct 27, 2024

Part of #149

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced an "experimental-overwritable" feature, allowing overwriting of fields in builder macros.
    • Added a new section in the issue template encouraging community feedback and voting on issues.
  • Documentation

    • Updated changelog to reflect significant changes, including new attributes and stricter validation.
    • Enhanced documentation for the "experimental-overwritable" feature and deployment instructions for the umami backend.
  • Bug Fixes

    • Improved validation and handling of attributes in the builder macros.

Copy link
Contributor

coderabbitai bot commented Oct 27, 2024

Warning

Rate limit exceeded

@Veetaha has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between 4561e7e and 991a6ea.

Walkthrough

The pull request introduces several changes across multiple files, primarily focusing on the addition of a new feature called experimental-overwritable in the Cargo.toml files of the bon and bon-macros packages. It also updates the CI workflow to incorporate this feature in testing commands. Additionally, the issue template is modified to encourage community engagement through voting and commenting on issues. The changelog reflects these updates, while the README for the website infrastructure includes a new section on deployment prerequisites.

Changes

File Change Summary
.github/workflows/ISSUE_TEMPLATE/main.md Added a section encouraging users to vote on issues and provide comments on their use cases.
.github/workflows/ci.yml Updated testing commands in the test-stable job to utilize the experimental-overwritable feature.
bon-macros/Cargo.toml Added a new feature experimental-overwritable under the [features] section.
bon/Cargo.toml Introduced the experimental-overwritable feature, allowing overwriting of fields in the builder.
e2e-tests/Cargo.toml Updated bon dependency to include the experimental-overwritable feature.
website/changelog.md Updated to reflect significant changes in version 2.3.0, including new features and deprecated attributes.
website/infra/README.md Added a "Deployment" section detailing prerequisites for deploying the umami backend.

Possibly related PRs

Suggested reviewers

  • anelson

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.

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

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

🧹 Outside diff range and nitpick comments (5)
website/infra/README.md (2)

13-23: Enhance security guidance for sensitive values.

The terraform.tfvars example includes sensitive values but lacks guidance on secure value generation and management.

Consider adding:

  1. Guidelines for generating secure passwords and tokens
  2. Instructions to use environment variables or a secrets manager
  3. Warning about not committing terraform.tfvars to version control

Example addition:

Important security notes:
- Generate a strong `umami_app_secret` (at least 32 characters)
- Use a password manager to generate secure `pg_password`
- Never commit terraform.tfvars to version control
- Consider using environment variables or a secrets manager in production

7-35: Documentation could be more comprehensive.

The deployment section would benefit from additional information to ensure successful deployment and maintenance.

Consider adding:

  1. Required/supported umami version
  2. Description of what each placeholder means and their format requirements
  3. Post-deployment verification steps
  4. Backup strategy for the Postgres volume
  5. Monitoring recommendations
  6. Troubleshooting guide

Example addition:

## Post-deployment
1. Verify deployment:
   ```bash
   terraform output
   # Visit the displayed IP address to confirm umami is running
  1. Backup strategy:
    • The Postgres data is stored on a separate volume at [location]
    • Recommended backup procedure: [steps]

</blockquote></details>
<details>
<summary>bon/Cargo.toml (1)</summary><blockquote>

`105-120`: **LGTM! Consider adding a version note.**

The feature declaration and documentation are well-structured and comprehensive. The experimental status, compatibility guarantees, and purpose are clearly communicated. The community engagement approach through GitHub reactions is a good practice.


Consider adding a version note to help users track when this feature was introduced:

```diff
 # 🔬 Experimental! There may be breaking changes to this feature between *minor* releases,
 # however, compatibility within patch releases is guaranteed though.
+# 
+# This feature was introduced in bon 2.3.0.
 #
 # This feature enables the #[builder(overwritable)] attribute that can be used to
website/changelog.md (2)

Line range hint 35-35: Update changelog entry for overwritable feature

The changelog entry for #[builder(overwritable)] should mention that this feature is experimental and requires enabling the experimental-overwritable cargo feature. This aligns with the PR objective of making the feature experimental.

Apply this diff to update the changelog entry:

-Add `#[builder(overwritable)]` and `#[builder(on(..., overwritable)]` to make it possible to call setters multiple times for the same member ([#145](https://github.com/elastio/bon/pull/145))
+Add `#[builder(overwritable)]` and `#[builder(on(..., overwritable)]` to make it possible to call setters multiple times for the same member (requires `experimental-overwritable` feature) ([#145](https://github.com/elastio/bon/pull/145))

48-48: Enhance documentation for analytics implementation

The addition of anonymous statistics tracking is a significant change that affects user privacy. Consider expanding this changelog entry to:

  1. Describe what data is being collected
  2. Explain how users can opt out of tracking
  3. Link to the privacy policy or data collection documentation
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3012ae6 and 4561e7e.

⛔ Files ignored due to path filters (2)
  • bon-macros/src/builder/builder_gen/member/config/mod.rs is excluded by !**/*.rs
  • bon-macros/src/builder/builder_gen/top_level_config/on.rs is excluded by !**/*.rs
📒 Files selected for processing (7)
  • .github/workflows/ISSUE_TEMPLATE/main.md (1 hunks)
  • .github/workflows/ci.yml (1 hunks)
  • bon-macros/Cargo.toml (1 hunks)
  • bon/Cargo.toml (1 hunks)
  • e2e-tests/Cargo.toml (1 hunks)
  • website/changelog.md (1 hunks)
  • website/infra/README.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/ISSUE_TEMPLATE/main.md
🧰 Additional context used
📓 Learnings (1)
e2e-tests/Cargo.toml (1)
Learnt from: Veetaha
PR: elastio/bon#145
File: benchmarks/runtime/Cargo.toml:34-34
Timestamp: 2024-10-20T00:49:04.064Z
Learning: In the `bon` project, the `bon` crate has been moved into a subfolder. Therefore, in `benchmarks/runtime/Cargo.toml`, the dependency path for `bon` is correctly set to `"../../bon"`. Future code reviews should consider this project structure when verifying dependency paths.
🪛 LanguageTool
website/infra/README.md

[uncategorized] ~3-~3: Possible missing comma found.
Context: ...code for our umami backend used for collecting anonymous statics a...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (4)
e2e-tests/Cargo.toml (2)

21-21: LGTM! Feature flag addition is appropriate.

The addition of the experimental-overwritable feature aligns with the PR objective to make the overwritable functionality experimental. This is particularly appropriate in a test crate where we want to verify the experimental features.


21-21: Verify the bon crate path.

The path looks correct for the current location, but let's verify it matches the project structure.

✅ Verification successful

The script results confirm that bon/Cargo.toml exists at the repository root, and the relative path ../bon from e2e-tests/Cargo.toml is correct since both files are at the root level. Let me generate the final response:

Path verification successful

The relative path ../bon in e2e-tests/Cargo.toml correctly points to the bon crate, and the experimental feature flag addition is appropriate for the test crate.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the bon crate location relative to e2e-tests
# Expected: Find Cargo.toml in ../bon relative to e2e-tests

# Test 1: Check if bon/Cargo.toml exists at the expected path
if [ -f "bon/Cargo.toml" ]; then
    echo "Found bon/Cargo.toml at repository root"
fi

# Test 2: List all Cargo.toml files to verify project structure
fd Cargo.toml

Length of output: 326

.github/workflows/ci.yml (1)

98-101: LGTM! Comprehensive test coverage for the experimental feature.

The new test commands properly validate the experimental-overwritable feature across all possible feature combinations:

  • Base feature
  • With alloc
  • With implied-bounds
  • With both alloc and implied-bounds

The use of --no-default-features ensures proper isolation of the feature flags.

Let's verify the feature flag is properly defined:

✅ Verification successful

Feature flag is properly defined and gated behind experimental feature

The verification confirms that:

  1. The experimental-overwritable feature is properly defined in bon-macros/Cargo.toml and propagated to the main crate through bon/Cargo.toml
  2. The feature is properly gated in code with runtime checks:
    if !cfg!(feature = "experimental-overwritable") && self.overwritable.is_present() {
        bail!(
            &self.overwritable.span(),
            "🔬 `overwritable` attribute is experimental and requires \"experimental-overwritable\" cargo feature to be enabled..."
        );
    }
  3. The feature is properly documented with a link to issue Stabilize #[builder(overwritable)] #149 for feedback
  4. The implementation is consistent across both member-level and type-level configurations

The CI workflow changes correctly test all feature combinations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify experimental-overwritable feature is properly defined
# Expected: Feature should be defined in Cargo.toml files

# Check bon/Cargo.toml for the feature definition
echo "Checking bon/Cargo.toml for experimental-overwritable feature:"
rg "experimental-overwritable" bon/Cargo.toml -A 2

# Check if the feature is used in the code
echo -e "\nChecking feature usage in code:"
rg "#\[cfg\(feature\s*=\s*\"experimental-overwritable\"\)\]" bon/src/

Length of output: 403


Script:

#!/bin/bash
# Let's do a more comprehensive check

# 1. Check both bon and bon-macros Cargo.toml files
echo "=== Checking Cargo.toml files ==="
echo "bon/Cargo.toml features section:"
rg "\[features\]" bon/Cargo.toml -A 10
echo -e "\nbon-macros/Cargo.toml features section:"
rg "\[features\]" bon-macros/Cargo.toml -A 10

# 2. Check for any overwritable-related code in both crates
echo -e "\n=== Checking overwritable-related code ==="
echo "In bon crate:"
rg "overwritable" bon/src/ -l
echo -e "\nIn bon-macros crate:"
rg "overwritable" bon-macros/src/ -l

# 3. Check for feature gates in both crates
echo -e "\n=== Checking feature gates ==="
echo "In bon crate:"
rg "#\[cfg.*feature.*overwritable" bon/src/
echo -e "\nIn bon-macros crate:"
rg "#\[cfg.*feature.*overwritable" bon-macros/src/

Length of output: 1865


Script:

#!/bin/bash
# Let's check the actual implementation of overwritable feature in the macro crate
# since we found the relevant files but need to see the feature gates

echo "=== Checking overwritable implementation in bon-macros ==="
echo "1. Checking setters implementation:"
cat bon-macros/src/builder/builder_gen/setters/mod.rs

echo -e "\n2. Checking member config implementation:"
cat bon-macros/src/builder/builder_gen/member/config/mod.rs

echo -e "\n3. Checking top level config:"
cat bon-macros/src/builder/builder_gen/top_level_config/on.rs

# Also check if there are any tests that verify this feature
echo -e "\n=== Checking tests ==="
rg "experimental-overwritable" bon-macros/src/tests/ -l

Length of output: 37075

website/changelog.md (1)

Line range hint 1-24: LGTM! Well-structured changelog

The changelog follows the Keep a Changelog format and properly documents changes with PR references.

website/infra/README.md Outdated Show resolved Hide resolved
Comment on lines +66 to +68
# See the docs on this feature in the `bon`'s crate `Cargo.toml`
experimental-overwritable = []

Copy link
Contributor

@coderabbitai coderabbitai bot Oct 27, 2024

Choose a reason for hiding this comment

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

💡 Codebase verification

Documentation reference in comment is misleading

The comment states "See the docs on this feature in the bon's crate Cargo.toml", but the bon crate's Cargo.toml only contains the feature declaration without any documentation. The feature is used in the codebase:

  • Declared in bon-macros/Cargo.toml
  • Referenced in bon/Cargo.toml for feature forwarding
  • Used in runtime checks in bon-macros/src/builder/builder_gen/ files
  • Used in e2e tests

Consider either:

  • Removing the misleading documentation reference comment, or
  • Adding actual documentation about this experimental feature in bon/Cargo.toml
🔗 Analysis chain

LGTM! Feature flag implementation looks correct.

The implementation of the experimental-overwritable feature flag follows Rust's best practices:

  • Empty feature flag is appropriate for compile-time toggles
  • Clear documentation reference helps maintainability
  • Not included in default features, which is correct for experimental features

Let's verify the feature documentation reference:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the referenced documentation exists in bon's Cargo.toml
# Expected: Find documentation about the experimental-overwritable feature

rg -A 5 "experimental-overwritable" ../bon/Cargo.toml

Length of output: 111


Script:

#!/bin/bash
# Let's first check if the bon crate exists in the repository
fd -t d "bon$"

# Then let's check all Cargo.toml files for the feature documentation
fd "Cargo.toml" -x rg -A 5 "experimental-overwritable" {}

# Also search for any documentation about this feature in other common places
rg -i "experimental.?overwritable" -g "!target/" -g "*.{md,rs,toml}"

Length of output: 1330

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The file bon/Cargo.toml contains the feature declaration as well, and it contains an extensive comment that documents that feature right on top of the feature declaration

Copy link
Contributor

Choose a reason for hiding this comment

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

@Veetaha, thank you for the clarification. I see that the bon/Cargo.toml file does contain extensive documentation for the experimental-overwritable feature as you mentioned. I've noted this information for future reviews.

(・ω・)ゞ


✏️ Learnings added
Learnt from: Veetaha
PR: elastio/bon#160
File: bon-macros/Cargo.toml:66-68
Timestamp: 2024-10-27T15:42:41.282Z
Learning: In the `bon` crate, the `bon/Cargo.toml` file contains extensive documentation for the `experimental-overwritable` feature above its feature declaration.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Veetaha and others added 2 commits October 27, 2024 15:39
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Veetaha Veetaha merged commit e24e23d into master Oct 27, 2024
26 checks passed
@Veetaha Veetaha deleted the feat/experimental-overwritable branch October 27, 2024 15:45
@Veetaha Veetaha mentioned this pull request Oct 27, 2024
18 tasks
@github-actions github-actions bot mentioned this pull request Nov 9, 2024
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