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

refactor(flake)!: setup crane #46

Merged
merged 15 commits into from
Jun 15, 2024
Merged

refactor(flake)!: setup crane #46

merged 15 commits into from
Jun 15, 2024

Conversation

kwaa
Copy link
Member

@kwaa kwaa commented Jun 9, 2024

#18

Summary by CodeRabbit

  • New Features

    • Added crane support for toolchain setup and package configurations.
  • Refactor

    • Simplified URL and ID handling by removing unnecessary .to_string() conversions.
    • Streamlined favicon file paths for easier asset management.
  • Bug Fixes

    • Corrected method calls involving ID lookups in various functions across multiple modules.
  • Chores

    • Updated dependencies, including commenting out openssl in Cargo.toml.
    • Improved CI workflows with enhanced Nix installation and caching actions.
  • Documentation

    • Added a #[must_use] attribute to the info() function in the AppEnv implementation for better usage guidance.

@kwaa kwaa added the enhancement New feature or request label Jun 9, 2024
@kwaa kwaa self-assigned this Jun 9, 2024
Copy link
Contributor

coderabbitai bot commented Jun 9, 2024

Walkthrough

Overall, the changes focus on code and configuration optimization, simplification, and dependency management. This includes refining method calls in various Rust files, streamlining configurations in flake.nix, and updating continuous integration workflows to use improved actions. The changes enhance the codebase's maintainability, readability, and efficiency without altering the core functionalities of public entities.

Changes

Files and Directories Change Summary
.envrc Removed an unnecessary argument in the use flake command, simplifying the environment setup.
Cargo.toml Commented out the openssl dependency, potentially impacting the use of this crate.
flake.nix Added crane, refactored toolchain and package setups, adjusted build dependencies, introduced cargoClippy checks, and defined default packages and development shells.
.github/workflows/check.yml Updated CI workflows to use improved Nix installation and caching actions.
crates/api_apub/src/... Simplified code logic by removing unnecessary references in method calls for post and user functions.
crates/api_mastodon/src/... Modified method calls to simplify ID usage in context.rs, status_favourited_by.rs, and status_reblogged_by.rs.
crates/apub/src/... Removed unnecessary references in methods related to user and post IDs in db_user.rs and db_post.rs.
crates/backend/src/favicon.rs Refactored paths to favicon files, simplifying their inclusion.
crates/nodeinfo/src/schema.rs Changed the new() function to a const fn for the NodeInfoServices struct.
crates/utils/src/data.rs Added #[must_use] attribute to the info() function in the AppEnv implementation.
crates/well_known/src/routes/webfinger.rs Removed unnecessary conversion of URL to string in the webfinger function call.

Sequence Diagram(s)

N/A

Poem

In code we dance, refactor, refine,
Simplify paths where bright lights shine.
Dependencies trimmed, methods made clear,
Fewer conversions, the goal is near.
CI flows smooth, with Nix in command,
Celebrate progress with a rabbit’s hand! 🐰✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

@kwaa kwaa marked this pull request as ready for review June 15, 2024 10:26
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7d49aef and a9ad0bf.

Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • flake.lock is excluded by !**/*.lock
Files selected for processing (3)
  • .envrc (1 hunks)
  • Cargo.toml (1 hunks)
  • flake.nix (1 hunks)
Files skipped from review due to trivial changes (1)
  • .envrc
Additional comments not posted (3)
flake.nix (2)

9-11: Ensure that the new input crane is correctly configured and follows the same versioning strategy as other dependencies.

Verification successful

Ensure that the new input crane is correctly configured and follows the same versioning strategy as other dependencies.

  • The output shows that both crane and fenix inputs follow the nixpkgs versioning strategy, ensuring consistency.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the `crane` input is correctly configured.

# Test: Search for the input configuration. Expect: A valid configuration similar to other inputs.
rg --type nix $'crane.url = "github:ipetkov/crane"'

Length of output: 102



Script:

#!/bin/bash
# Description: List all input configurations in flake.nix for comparison.

# Extract all input configurations from flake.nix
rg --type nix 'inputs\..*\.url' flake.nix

Length of output: 43



Script:

#!/bin/bash
# Description: List all input configurations in flake.nix for comparison.

# Extract all input configurations from flake.nix
rg --type nix 'inputs\..*' flake.nix

Length of output: 130


16-74: Review the comprehensive changes in the perSystem section to ensure they align with the intended refactoring and new toolchain setup using crane.

Verification successful

The provided output shows that the craneLib and toolchain are correctly defined and used within the flake.nix file. The new toolchain setup using crane appears to be properly implemented, and the configurations align with the intended refactoring.

  • craneLib is created with crane.mkLib pkgs and overrides the toolchain with toolchain.
  • toolchain is defined using fenix.packages.${system}.fromToolchainFile.
  • The commonArgs for building packages are set up correctly.
  • crateClippy and crate are built using craneLib functions.

No issues were found with the current implementation.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the new toolchain setup and configurations are correctly implemented.

# Test: Search for usage of `craneLib` and `toolchain`. Expect: Proper usage and no errors.
rg --type nix $'craneLib' -A 20

Length of output: 2259

Cargo.toml (1)

130-130: Consider the implications of commenting out the openssl dependency. If this is intended to be temporary, ensure there's a tracking issue or comment explaining why it's disabled.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a9ad0bf and 65bd892.

Files ignored due to path filters (2)
  • crates/backend/assets/favicon.ico is excluded by !**/*.ico
  • crates/backend/assets/favicon.svg is excluded by !**/*.svg
Files selected for processing (13)
  • .github/workflows/check.yml (1 hunks)
  • crates/api_apub/src/posts/post.rs (1 hunks)
  • crates/api_apub/src/users/user.rs (1 hunks)
  • crates/api_mastodon/src/entities/context.rs (1 hunks)
  • crates/api_mastodon/src/routes/statuses/status_favourited_by.rs (1 hunks)
  • crates/api_mastodon/src/routes/statuses/status_reblogged_by.rs (1 hunks)
  • crates/apub/src/actors/db_user.rs (1 hunks)
  • crates/apub/src/objects/db_post.rs (2 hunks)
  • crates/backend/src/favicon.rs (2 hunks)
  • crates/nodeinfo/src/schema.rs (1 hunks)
  • crates/utils/src/data.rs (1 hunks)
  • crates/well_known/src/routes/webfinger.rs (1 hunks)
  • flake.nix (1 hunks)
Files skipped from review due to trivial changes (2)
  • crates/apub/src/actors/db_user.rs
  • crates/backend/src/favicon.rs
Files skipped from review as they are similar to previous changes (1)
  • flake.nix
Additional comments not posted (11)
.github/workflows/check.yml (1)

25-27: Updated GitHub Actions for Nix installation and caching look appropriate. Ensure that all replaced functionalities are covered by these new actions.

crates/utils/src/data.rs (1)

42-42: Good addition of the #[must_use] attribute to ensure the function's return value is utilized, enhancing code safety.

crates/api_mastodon/src/entities/context.rs (1)

22-22: Simplification of parameter passing in find_by_id enhances readability and avoids unnecessary string conversions.

crates/api_apub/src/posts/post.rs (1)

50-50: Streamlining parameter passing in find_by_id aligns with overall PR goals of simplification and avoids redundant string conversions.

crates/well_known/src/routes/webfinger.rs (1)

51-51: Refactor to simplify URL handling and optimize user lookup.

The change from User::find_by_id(&url.to_string()) to User::find_by_id(url.to_string()) simplifies the code by removing unnecessary references, aligning with Rust's ownership model more idiomatically.

crates/api_mastodon/src/routes/statuses/status_favourited_by.rs (1)

36-36: Refactor to streamline post URL handling.

The change from Post::find_by_id(&post_url.to.string()) to Post::find_by_id(post_url.to_string()) removes redundant reference handling, making the code cleaner and more efficient.

crates/api_mastodon/src/routes/statuses/status_reblogged_by.rs (1)

36-36: Refactor to improve URL handling in reblog queries.

The change from Post::find_by_id(&post_url.to.string()) to Post::find_by_id(post_url.to_string()) is consistent with Rust's efficient handling of strings, reducing unnecessary data cloning.

crates/api_apub/src/users/user.rs (1)

78-78: Optimization of user URL handling in user lookup.

The refactoring from PreludeUser::find_by_id(&url.to_string()) to PreludeUser::find_by_id(url.to_string()) enhances code readability and efficiency by avoiding unnecessary reference wrapping.

crates/apub/src/objects/db_post.rs (2)

55-55: Simplified method call by removing unnecessary reference conversion.


121-121: Simplified method call by removing unnecessary reference conversion.

crates/nodeinfo/src/schema.rs (1)

78-78: Enhanced compile-time evaluation by converting new() to a const function.

@kwaa kwaa merged commit e39ff3d into main Jun 15, 2024
1 check passed
@kwaa kwaa deleted the refactor/crane branch June 15, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant