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

Tr/ablejobs #46

Merged
merged 20 commits into from
Oct 31, 2023
Merged

Tr/ablejobs #46

merged 20 commits into from
Oct 31, 2023

Conversation

tapishr
Copy link
Member

@tapishr tapishr commented Oct 30, 2023

Please check the action items covered in the PR -

  • Build is running
  • Eventing is functional and tested
  • Unit or integration tests added and running
  • Manual QA

Summary by CodeRabbit

New Features:

  • Introduced a new Docker build command with build arguments to enhance the build process.
  • Added modules to handle pull requests and webhooks from Bitbucket, improving integration.
  • Implemented functions to retrieve, process, and store pull request information from Bitbucket, enhancing data management.
  • Added a new struct PrInfo to better manage pull request information.

Refactor:

  • Updated function to handle pull requests concurrently, improving efficiency.
  • Modified functions to handle errors and parse responses correctly, enhancing reliability.

Chores:

  • Added new dependencies: reqwest, serde_json, and std::collections::HashMap.
  • Minor changes include variable renaming and formatting for better code readability.

@tapishr tapishr self-assigned this Oct 30, 2023
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2023

Walkthrough

The changes introduced a new Docker build command with several build arguments and added new functionalities to the vibi-dpu project. The new functionalities include retrieving and storing pull request information from Bitbucket, processing install callbacks, and deserializing message data. The changes also introduced new modules and dependencies, modified existing functions, and added print statements for debugging.

Changes

File(s) Summary
ablejobs_command.txt Added a new Docker build command with several build arguments.
vibi-dpu/src/bitbucket/... Added two new modules, prs and webhook. Introduced functions to retrieve and store pull request information from Bitbucket.
vibi-dpu/src/core/review.rs Added print statements for debugging.
vibi-dpu/src/core/setup.rs Removed and added import statements. Modified the handle_install_bitbucket function to retrieve and process pull requests.
vibi-dpu/src/db/... Added two new modules, prs and repo_config. Introduced functions to save and update pull request information in the database.
vibi-dpu/src/pubsub/listener.rs Modified the process_message function to check the event type and process the review. Added functions to handle install callbacks and deserialize message data.
vibi-dpu/src/utils/... Added two new modules, repo_config and pr_info. Introduced a new struct PrInfo with getter and setter methods.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.json

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.

Review Status

Actionable comments generated: 13

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 53f3ff2 and 3a591cf.
Files selected for processing (10)
  • ablejobs_command.txt (1 hunks)
  • vibi-dpu/src/bitbucket/mod.rs (1 hunks)
  • vibi-dpu/src/bitbucket/prs.rs (1 hunks)
  • vibi-dpu/src/core/review.rs (1 hunks)
  • vibi-dpu/src/core/setup.rs (4 hunks)
  • vibi-dpu/src/db/mod.rs (1 hunks)
  • vibi-dpu/src/db/prs.rs (1 hunks)
  • vibi-dpu/src/pubsub/listener.rs (4 hunks)
  • vibi-dpu/src/utils/mod.rs (1 hunks)
  • vibi-dpu/src/utils/pr_info.rs (1 hunks)
Files skipped from review due to trivial changes (5)
  • vibi-dpu/src/bitbucket/mod.rs
  • vibi-dpu/src/core/review.rs
  • vibi-dpu/src/db/mod.rs
  • vibi-dpu/src/utils/mod.rs
  • vibi-dpu/src/utils/pr_info.rs
Additional comments: 9
vibi-dpu/src/pubsub/listener.rs (6)
  • 1-4: The import statements are clean and organized. Good job.

  • 7-18: The import statements are well organized and the InstallCallback struct is correctly defined.

  • 77-100: The prcoess_install_callback function seems to have a typo in its name. It should be process_install_callback. Also, the function handles different repository providers correctly. However, the Github case is commented out and marked as "To be Implemented". Make sure to implement this case before merging.

- async fn prcoess_install_callback(data_bytes: &[u8]) {
+ async fn process_install_callback(data_bytes: &[u8]) {
  • 46-104: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [102-105]

The get_pubsub_client_config function is correctly implemented and handles errors gracefully.

  • 1-4: > Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [106-165]

The setup_subscription and listen_messages functions are correctly implemented and handle errors gracefully.

  • 171-181: The deserialized_data function is correctly implemented and handles errors gracefully.
vibi-dpu/src/core/setup.rs (3)
  • 3-8: No changes were made in this hunk. The imports are standard and necessary for the rest of the code.

  • 12-18: The import statements have been updated to include the new functions list_prs_bitbucket and get_and_store_pr_info from the prs module. Ensure that these functions are correctly implemented and tested.

  • 94-100: No changes were made in this hunk. The send_setup_info function is correctly implemented and handles errors appropriately.

ablejobs_command.txt Outdated Show resolved Hide resolved
vibi-dpu/src/bitbucket/prs.rs Outdated Show resolved Hide resolved
vibi-dpu/src/bitbucket/prs.rs Outdated Show resolved Hide resolved
vibi-dpu/src/db/prs.rs Outdated Show resolved Hide resolved
vibi-dpu/src/db/prs.rs Outdated Show resolved Hide resolved
vibi-dpu/src/bitbucket/prs.rs Outdated Show resolved Hide resolved
vibi-dpu/src/pubsub/listener.rs Outdated Show resolved Hide resolved
vibi-dpu/src/pubsub/listener.rs Outdated Show resolved Hide resolved
vibi-dpu/src/core/setup.rs Outdated Show resolved Hide resolved
avikalpg and others added 2 commits October 30, 2023 13:37
2. removed duplicated function (save and update pr_info functions were doing the same thing)
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.

Review Status

Actionable comments generated: 7

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3a591cf and 824dfce.
Files selected for processing (3)
  • vibi-dpu/src/bitbucket/prs.rs (1 hunks)
  • vibi-dpu/src/db/prs.rs (1 hunks)
  • vibi-dpu/src/pubsub/listener.rs (4 hunks)
Additional comments: 5
vibi-dpu/src/bitbucket/prs.rs (3)
  • 9-20: The function list_prs_bitbucket has been updated to return Option instead of Result. This change is acceptable as it simplifies the error handling process. However, it's important to ensure that all calls to this function throughout the codebase have been updated to handle the new return type.

  • 22-66: The function get_list_prs has been updated to return Option instead of Result. This change is acceptable as it simplifies the error handling process. However, it's important to ensure that all calls to this function throughout the codebase have been updated to handle the new return type.

  • 103-110: The function get_and_store_pr_info retrieves and stores PR information. It's well written and handles errors gracefully. However, it's important to ensure that all calls to this function throughout the codebase have been updated to handle the new return type.

vibi-dpu/src/pubsub/listener.rs (2)
  • 1-4: The import statement for std::collections::HashMap has been removed but it is still being used in the code. Please verify if this is intentional.

  • 170-180: The deserialized_data function has been added to deserialize message data into a serde_json::Value object. This function is well implemented and handles errors gracefully.

vibi-dpu/src/bitbucket/prs.rs Outdated Show resolved Hide resolved
vibi-dpu/src/pubsub/listener.rs Outdated Show resolved Hide resolved
vibi-dpu/src/db/prs.rs Outdated Show resolved Hide resolved
vibi-dpu/src/db/prs.rs Outdated Show resolved Hide resolved
vibi-dpu/src/db/prs.rs Outdated Show resolved Hide resolved
vibi-dpu/src/db/prs.rs Outdated Show resolved Hide resolved
* bug fix: removed IVec of value while inserting pr_info

* bug fix: database key changed for PR-info to resolve key collision.
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.

Review Status

Actionable comments generated: 6

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 824dfce and 6836c1e.
Files selected for processing (2)
  • vibi-dpu/src/db/prs.rs (1 hunks)
  • vibi-dpu/src/pubsub/listener.rs (4 hunks)
Additional comments: 4
vibi-dpu/src/pubsub/listener.rs (3)
  • 1-4: The import statements are well organized and only necessary modules are imported. Good job on that.

  • 7-16: The import statements are well organized and only necessary modules are imported. Good job on that.

  • 7-18: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [18-22]

The InstallCallback struct is well defined with the necessary fields.

vibi-dpu/src/db/prs.rs (1)
  • 55-72: The function parse_webhook_data should return a Result instead of just printing the error and returning an Option. This would allow the caller to handle the error in a way that makes sense in its context.
- fn parse_webhook_data(webhook_data: &Value) -> Option<PrInfo> {
+ fn parse_webhook_data(webhook_data: &Value) -> Result<PrInfo, Box<dyn std::error::Error>> {

vibi-dpu/src/pubsub/listener.rs Outdated Show resolved Hide resolved
vibi-dpu/src/pubsub/listener.rs Outdated Show resolved Hide resolved
vibi-dpu/src/pubsub/listener.rs Outdated Show resolved Hide resolved
vibi-dpu/src/db/prs.rs Outdated Show resolved Hide resolved
vibi-dpu/src/db/prs.rs Outdated Show resolved Hide resolved
vibi-dpu/src/db/prs.rs Outdated Show resolved Hide resolved
ablejobs_command.txt Outdated Show resolved Hide resolved
vibi-dpu/src/bitbucket/prs.rs Outdated Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6836c1e and 04ea8c8.
Files selected for processing (1)
  • vibi-dpu/src/bitbucket/prs.rs (3 hunks)
Additional comments: 2
vibi-dpu/src/bitbucket/prs.rs (2)
  • 2-5: The import statement for the save_pr_info_to_db function has been replaced with an import statement for the update_pr_info_in_db function. Ensure that the update_pr_info_in_db function is implemented and behaves as expected.

  • 103-109: The save_pr_info_to_db function call has been replaced with an update_pr_info_in_db function call. Ensure that the update_pr_info_in_db function is implemented and behaves as expected.

vibi-dpu/src/bitbucket/prs.rs Show resolved Hide resolved
Comment on lines 90 to +98
return None;
}
let pr_data: Value = response.json().await.expect("Error parsing PR data");

Some(PrInfo {
let pr_info = PrInfo {
base_head_commit: pr_data["destination"]["commit"]["hash"].to_string().trim_matches('"').to_string(),
pr_head_commit: pr_data["source"]["commit"]["hash"].to_string().trim_matches('"').to_string(),
state: pr_data["state"].to_string().trim_matches('"').to_string(),
pr_branch: pr_data["source"]["branch"]["name"].to_string().trim_matches('"').to_string(),
})
};
Copy link
Contributor

Choose a reason for hiding this comment

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

The PrInfo struct is being populated directly from the JSON response without any error checking. If the response does not contain the expected fields, this could cause a panic. Consider adding error handling to ensure that the expected fields are present in the response.

let pr_info = match (pr_data["destination"]["commit"]["hash"].as_str(), pr_data["source"]["commit"]["hash"].as_str(), pr_data["state"].as_str(), pr_data["source"]["branch"]["name"].as_str()) {
    (Some(base_head_commit), Some(pr_head_commit), Some(state), Some(pr_branch)) => PrInfo {
        base_head_commit: base_head_commit.to_string(),
        pr_head_commit: pr_head_commit.to_string(),
        state: state.to_string(),
        pr_branch: pr_branch.to_string(),
    },
    _ => {
        eprintln!("Failed to parse PR data: {:?}", pr_data);
        return None;
    }
};

@sonarcloud
Copy link

sonarcloud bot commented Oct 31, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@avikalpg avikalpg merged commit 9da8060 into main Oct 31, 2023
3 checks passed
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