Skip to content

feat(tibuild): enhance devbuild_poll command with templated markdown response #256

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 1 commit into from
Apr 8, 2025

Conversation

wuhuizuo
Copy link
Contributor

@wuhuizuo wuhuizuo commented Apr 8, 2025

No description provided.

@ti-chi-bot ti-chi-bot bot requested a review from purelind April 8, 2025 12:02
Copy link

ti-chi-bot bot commented Apr 8, 2025

I have already done a preliminary review for you, and I hope to help you do a better job.

Overview

This pull request enhances the runCommandDevbuildPoll function in the devbuild_poll.go file by using a templated markdown response to display build status, pipeline view links, and build report in a structured format. It also adds a template file devbuild_poll.md.tmpl for formatting the response.

Code Quality

  • Readability: The code has been improved by introducing a templated markdown response, making it easier to understand the structure of the response data.
  • Consistency: The use of templates for formatting the response is consistent with the existing codebase.
  • Efficiency: The addition of a templated response does not have any obvious impact on performance.
  • Maintainability: The use of templates makes it easier to modify the response format in the future without changing the code logic.

Functionality

  • Correctness: The changes appear to correctly format and display the build status, pipeline view links, and build report information.
  • Completeness: The addition of the templated markdown response covers the key information that needs to be displayed in a structured format.
  • Testing: No new tests are added in this PR, but testing the runCommandDevbuildPoll function with different build statuses, pipeline view URLs, and build reports would ensure the functionality works as expected.

Documentation

  • Comments: The code changes are well-commented, explaining the purpose of the added template and how it formats the response.
  • Documentation: No updates to external documentation like README or API docs are included in this PR.

Security

No security issues were identified in the provided diff patch.

Suggestions

  1. Consider adding test cases to cover different scenarios of build statuses, pipeline view URLs, and build reports to ensure the templated response works correctly in all cases.
  2. It would be beneficial to update the documentation to include information on how to modify the template or the response format in case of future changes.
  3. It might be worth considering adding a section in the README to explain the new templated response feature and how it can be used or customized.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @wuhuizuo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request enhances the devbuild_poll command in the chatops-lark application to provide a more informative and readable response in Markdown format. Instead of returning a simple JSON representation of the build status, it now uses a templated Markdown response that includes the build status, pipeline view links (if available), and a build report (if available), formatted as YAML. The changes also include removing some logging in root.go and adding more detailed logging within the goroutine that handles commands.

Highlights

  • Templated Markdown Response: The devbuild_poll command now returns a formatted Markdown response using a template file (devbuild_poll.md.tmpl) instead of a JSON string. This makes the output more readable and user-friendly.
  • Template Functionality: The template utilizes the sprig library for additional functions and defines a custom toYaml function to format the build report data into YAML within the Markdown response.
  • Logging Enhancement: The logging in root.go was moved inside the goroutine to provide more detailed asynchronous logging, including command name, arguments, and sender information.
  • Error Handling: The error handling within the command processing goroutine in root.go has been enhanced to log different error types (SkipError, InformationError, default error) with appropriate messages.

Changelog

Click here to see the changelog
  • chatops-lark/pkg/events/handler/devbuild_poll.go
    • Replaced JSON marshaling with Markdown templating for the devbuild_poll command response.
    • Introduced devBuildPollResponseTmpl variable to store the Markdown template from devbuild_poll.md.tmpl.
    • Added sprig functions and a custom toYaml function to the template for formatting the output.
    • Modified the runCommandDevbuildPoll function to execute the template with the build result data.
  • chatops-lark/pkg/events/handler/devbuild_poll.md.tmpl
    • Created a new template file to define the Markdown structure for the devbuild_poll command response.
    • Implemented conditional rendering for pipeline view links and build report sections.
    • Used toYaml function to format the build report data as YAML within the Markdown output.
  • chatops-lark/pkg/events/handler/root.go
    • Removed the initial logging statement before command handling.
    • Added more detailed logging within the command processing goroutine, including command name, arguments, and sender information.
    • Enhanced error handling within the goroutine to log different error types with appropriate messages.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A command's response,
In Markdown, it finds its form,
Data now so clear.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ti-chi-bot ti-chi-bot bot added the size/M label Apr 8, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request enhances the devbuild_poll command by introducing a templated markdown response. This change improves the readability and presentation of the build status information. The use of Go templates and the sprig library allows for more flexible and dynamic formatting of the output. Additionally, the integration of YAML formatting for build reports provides a structured and easily understandable view of the data.

Summary of Findings

  • Error Handling in YAML Marshaling: The current error handling for YAML marshaling in the toYaml function returns a string with the error message. While this prevents the application from crashing, it might be better to return an error to the caller function so that it can handle the error appropriately. This would allow the caller to log the error or take other actions based on the error type. I have not commented on this due to the review settings.
  • Logging Enhancement: The logging statements in root.go have been improved by adding more context, such as command name, arguments, and sender information. This enhancement provides better visibility into the command processing flow and helps in debugging issues. I have not commented on this due to the review settings.

Merge Readiness

The pull request is well-structured and introduces a valuable enhancement to the devbuild_poll command. The use of templated markdown responses improves the user experience by providing a more readable and informative output. The changes in root.go enhance the logging capabilities, making it easier to track and debug command executions. Overall, the code is in good shape, and I recommend merging it after addressing the error handling in YAML marshaling. I am unable to approve this pull request, and recommend that others review and approve this code before merging.

@wuhuizuo
Copy link
Contributor Author

wuhuizuo commented Apr 8, 2025

/approve

Copy link

ti-chi-bot bot commented Apr 8, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wuhuizuo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Apr 8, 2025
@ti-chi-bot ti-chi-bot bot merged commit b009fdc into main Apr 8, 2025
6 checks passed
@ti-chi-bot ti-chi-bot bot deleted the feature/pretty-devbuild-poll branch April 8, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant