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 Flakeguard reports: Split commands and use data and presentation layers #1435

Merged
merged 24 commits into from
Dec 9, 2024

Conversation

lukaszcl
Copy link
Contributor

@lukaszcl lukaszcl commented Dec 5, 2024

Related PR in Core repo: smartcontractkit/chainlink#15541
Last Flakeguard Nightly that uses this version: https://github.com/smartcontractkit/chainlink/actions/runs/12204545695

1. Unified Command

Single report Command

  • Combines the functionality of the previously separate aggregate-results and generate-reports commands.
  • Features:
    • Aggregates test results into a single report with optional filtering and code owner mapping.
    • Generates reports in multiple formats (Markdown and/or JSON) by default or as specified via the --format flag.
    • Saves both:
      • All Tests Report: Includes all tests but excludes outputs and package outputs to reduce clutter.
      • Failed Tests Report: Includes only flaky/failed tests with outputs and package outputs for debugging purposes.

Rationale

  • Simplified CLI Interface:
    • Replaced multiple commands with a single unified command, making workflows more straightforward and intuitive.
    • Reduced cognitive load for users by aligning all reporting functionalities under one command.
  • Improved User Experience:
    • Added spinners to provide visual feedback for time-consuming operations like loading reports, aggregating data, and generating outputs.

2. Layer Enhancements

  • Refactored Architecture:

    • Data Layer: Handles aggregation, filtering, and transformations of test data.
    • Presentation Layer: Manages report generation, including Markdown and JSON outputs.
  • Benefits:

    • Improved maintainability by separating concerns.
    • Clear boundaries between data processing and presentation logic, making future enhancements easier to implement.

Below is a summarization created by an LLM (gpt-4-0125-preview). Be mindful of hallucinations and verify accuracy.

Why

The changes introduce several enhancements and fixes across multiple files in the Flakeguard tool, focusing on improving test results aggregation, error handling, and reporting. Notably, it refactors aggregate_results.go to use a more robust file system handling, improves error reporting, and adds functionality to generate a summary of all tests. Adjustments in other files like check_test_owners.go, generate_report.go, and run.go complement these enhancements by refining test ownership checks, report generation, and test execution processes. The introduction of new files data.go, io.go, and presentation.go modularizes code for better maintenance and clarity, while the removal of reports.go suggests a restructuring of how test results and reports are managed.

What

  • aggregate_results.go
    • Refactored to use reports.OSFileSystem for file operations.
    • Added functionality to generate a summary JSON file after aggregating test results.
    • Improved error handling and user feedback with spinner loading indicators.
  • check_test_owners.go
    • Simplified flag declaration for specifying the project path.
  • generate_report.go (New File)
    • Introduced to handle report generation from aggregated test results, including PR comment markdown generation.
  • run.go
    • Enhanced to collect raw output from test runs and improved handling of test execution with fail-fast logic.
  • data.go, io.go, presentation.go (New Files)
    • Added for managing test data structures, file I/O operations, and rendering test results, respectively.
  • reports.go
    • Removed, suggesting its responsibilities have been distributed among new files for better organization.
  • reports_test.go
    • Deleted, indicating that tests for reports.go functionalities have likely been moved or restructured.

@lukaszcl lukaszcl requested review from sebawo and a team as code owners December 5, 2024 15:07
@lukaszcl lukaszcl marked this pull request as draft December 5, 2024 15:43
@lukaszcl lukaszcl force-pushed the refactor-flakeguard-report branch from 9760bcf to d9043b4 Compare December 5, 2024 16:27
@lukaszcl lukaszcl marked this pull request as ready for review December 6, 2024 13:28
@lukaszcl lukaszcl requested a review from kalverra December 6, 2024 14:27
@lukaszcl lukaszcl marked this pull request as draft December 9, 2024 11:39
@lukaszcl lukaszcl force-pushed the refactor-flakeguard-report branch from caaac6d to 6653333 Compare December 9, 2024 11:52
@lukaszcl lukaszcl marked this pull request as ready for review December 9, 2024 13:55
@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
8.6% Duplication on New Code (required ≤ 5%)

See analysis details on SonarQube

@lukaszcl lukaszcl merged commit 8ab91a5 into main Dec 9, 2024
45 of 46 checks passed
@lukaszcl lukaszcl deleted the refactor-flakeguard-report branch December 9, 2024 14:14
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