Skip to content

Conversation

@iguessthislldo
Copy link
Member

@iguessthislldo iguessthislldo commented Feb 26, 2025

Fixes #78

Summary by CodeRabbit

  • New Features

    • The updated scoreboard now shows both a timestamp and descriptive details for the latest build, providing real-time insights into build history and status. These enhancements offer a clearer, more intuitive view for users monitoring build progress.
  • Refactor

    • Log management has been streamlined by consolidating cleanup routines, ensuring consistent removal of outdated logs and output files while enhancing overall system reliability and performance.

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2025

Walkthrough

The changes refactor the way log files are cleaned up and how build information is handled. The clean_logs subroutine in the log processing module now delegates file deletion to a new function, delete_prettify_output, defined in the Prettify module. In addition, the scoreboard script has been updated to use a timestamp regex for log matching, change the return structure of build retrieval, and consolidate build update logic by removing a separate update function. Explicit file deletion calls have been replaced by centralized deletion logic.

Changes

File(s) Change Summary
command/process_logs.pm Updated the clean_logs subroutine to replace multiple unlink calls with a single call to delete_prettify_output for file deletion delegation.
common/prettify.pm Added the new delete_prettify_output method that iterates through a list of file suffixes (including .build.json) to remove the associated files.
scoreboard.pl Introduced a new timestamp regex for matching log files, modified list_logs and get_latest (now returning timestamp and text), integrated update logic, and replaced explicit deletions with a call to delete_prettify_output.

Sequence Diagram(s)

sequenceDiagram
    participant PL as Process_Logs
    participant PT as Prettify
    participant FS as File System

    PL->>PT: clean_logs(log_file)
    PT->>FS: Iterate over suffixes and delete files
    FS-->>PT: Deletion results
    PT-->>PL: Return status (1)
Loading
sequenceDiagram
    participant SB as Scoreboard
    participant PT as Prettify
    participant FS as File System

    SB->>SB: list_logs (scanning directory with $timestamp_re)
    SB->>SB: get_latest returns (timestamp, build text)
    SB->>PT: delete_prettify_output(log_prefix)
    PT->>FS: Delete files with defined suffixes
    FS-->>PT: Acknowledge deletion
    PT-->>SB: Return deletion status
Loading

Poem

I'm a rabbit in a field of code, so spry,
Watching logs vanish like clouds in the sky.
Instead of a fuss of unlink commands galore,
A single call now cleans files and more.
My whiskers twitch with each neat new line,
Hopping in joy at this update so fine!
🐰💻✨


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 generate docstrings to generate docstrings for this 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

@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 (2)
common/prettify.pm (1)

35-43: Good addition of a centralized cleanup function.

The new delete_prettify_output function centralizes the file deletion logic for prettified output files, making the code more maintainable. When file types change, only this function needs to be updated instead of multiple places in the codebase.

Consider adding error handling to catch and optionally log any issues that might occur during the deletion process:

sub delete_prettify_output
{
    my $prefix = shift();

    for my $suffix (".txt", "_JUnit.xml", "_Full.html", "_Brief.html", "_Totals.html", "_Config.html", ".build.json") {
-        unlink($prefix . $suffix);
+        my $file = $prefix . $suffix;
+        unlink($file) or warn "Could not delete $file: $!" if -e $file;
    }

}
scoreboard.pl (1)

114-127: Improved defensive programming in list_logs function.

The updated function now checks if the directory handle was successfully created before proceeding, preventing potential issues with undefined handles.

Consider returning a more descriptive error message that includes the reason for failure:

if (!defined($dh)) {
-    print STDERR ("ERROR: Could not read $dir\n");
+    print STDERR ("ERROR: Could not read $dir: $!\n");
    return 0;
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b157428 and 7b34c38.

📒 Files selected for processing (3)
  • command/process_logs.pm (1 hunks)
  • common/prettify.pm (1 hunks)
  • scoreboard.pl (9 hunks)
🔇 Additional comments (8)
command/process_logs.pm (1)

199-200: Good refactoring to use centralized deletion function.

The code now delegates file deletion to the delete_prettify_output function from the Prettify module, reducing code duplication and making maintenance easier.

scoreboard.pl (7)

107-107: Good addition of a reusable timestamp regex.

Defining a single timestamp regex pattern improves consistency and maintainability across the codebase.


140-141: Good refactoring to use centralized deletion function.

The code now delegates file deletion to the Prettify::delete_prettify_output function instead of directly calling unlink, improving code maintainability.


149-165: Improved get_latest function to return more useful information.

The function now returns both the timestamp and the text of the latest build, making it more useful for callers.


750-751: Updated code to use the new get_latest signature.

The call to get_latest now correctly captures both return values: the timestamp and the text.


753-753: Improved condition logic with more precise comparisons.

The condition now correctly uses the timestamp value instead of relying on just the latest build information existence.


767-772: Consolidated build update logic.

The code now directly checks if the latest text is defined before setting the latest build information, rather than using a separate function. This simplifies the code and makes it more straightforward.


839-841: Good refactoring to use centralized deletion function.

Similar to other instances, this code now uses the centralized Prettify::delete_prettify_output function for file deletion.

Copy link
Member

@jwillemsen jwillemsen left a comment

Choose a reason for hiding this comment

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

Not reviewed the code, thanks for looking at this

@iguessthislldo iguessthislldo merged commit 6870b37 into DOCGroup:master Feb 27, 2025
2 checks passed
@iguessthislldo iguessthislldo deleted the igtd/test-matrix-fixes2 branch February 27, 2025 15:54
iguessthislldo added a commit to iguessthislldo/autobuild that referenced this pull request Mar 7, 2025
Revert changes from DOCGroup#79 that
broke OpenDDS scoreboard.
@iguessthislldo iguessthislldo mentioned this pull request Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Old build.json files not removed

3 participants