gritql icon indicating copy to clipboard operation
gritql copied to clipboard

feat: watch mode for patterns test

Open Ashu999 opened this issue 1 year ago • 1 comments

Fixes: #51 /claim #51

WIP: tests are left

Summary by CodeRabbit

  • New Features

    • Introduced watch mode for pattern testing, enabling real-time file modification monitoring and automatic test reruns.
  • Enhancements

    • Added new dependencies like notify and notify-debouncer-mini to enhance functionality.
    • Simplified and streamlined dependency lists for remote_workflows and workflow_server for better maintenance.
  • Improvements

    • Enhanced pattern testing by adding additional arguments and improving the structure.
    • Added the Clone trait to various structs for improved data handling.
  • Bug Fixes

    • Improved the handling of file modifications during watch mode to ensure accurate test results.

Ashu999 avatar May 01 '24 14:05 Ashu999

Walkthrough

Walkthrough

This update introduces a watch mode for the grit patterns test command. The watch mode monitors changes in pattern files in the .grit directory and automatically reruns the relevant tests. The system efficiently manages dependencies, ensuring only affected patterns are retested. Key changes involve new dependencies, updated function signatures, and additional test cases to verify the watch functionality.

Changes

Files/Paths Change Summary
.../Cargo.toml Added dependencies (notify, notify-debouncer-mini) and features for axoupdater and grit_beta.
.../commands/mod.rs Added an argument to run_patterns_test in the run_command function.
.../commands/patterns.rs Added Clone trait to PatternsTestArgs struct and added watch field with #[clap(long = "watch")] attribute.
.../commands/patterns_test.rs Introduced functions like enable_watch_mode, and enhanced logic for testing patterns, handling file changes.
.../commands/plumbing.rs Passed reference to PatternsTestArgs with watch: false in run_plumbing function.
.../tests/patterns_test.rs Added new test functions to verify watch mode functionality.
.grit/test/test.yaml Introduced new integration testing patterns related to dependency management in Cargo.toml.
.grit/grit.yaml Added new pattern cargo_use_long_dependency with error level for detecting long dependencies in Cargo.toml.
.../pattern_compiler/compiler.rs Added get_dependents_of_target_patterns_by_traversal_from_src function for dependency traversal in patterns.
.../gritmodule/src/config.rs Added Clone and Debug traits to GritPatternTestConfig and GritPatternTestInfo structs.
.../gritmodule/src/parser.rs Added support for YAML pattern files and updated PatternFileExt enum to handle them.
.../gritmodule/src/resolver.rs Updated arguments for get_patterns_from_yaml function in resolver module.
.../gritmodule/src/yaml.rs Function get_patterns_from_yaml now accepts Option<ModuleRepo> type; switched to tokio::task::spawn_local.
.../cli_bin/fixtures/.grit/.gitignore Added patterns to ignore .gritmodules* files and .log files.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant FileSystem
    participant TestRunner
    
    User->>+CLI: run `grit patterns test --watch`
    CLI->>+FileSystem: Watch for changes in .grit directory
    FileSystem-->>CLI: Notify on file changes
    CLI->>+TestRunner: Re-run affected pattern tests
    TestRunner->>CLI: Return test results
    CLI-->>User: Display test results

Assessment against linked issues

Objective (Issue #51) Addressed Explanation
Implement grit patterns test --watch mode
Watch mode should monitor .grit directory for file changes
Re-run only affected pattern tests on file changes
Handle pattern dependencies for re-running tests
Include at least two tests, including integration tests for the final binary

Recent review details

Configuration used: .coderabbit.yaml Review profile: CHILL

Commits

Files that changed from the base of the PR and between 69c48e228279fb5e0421207492e1ac805b44d152 and 43dc81e65a72c602a6406f93093dcd11b064aa77.

Files selected for processing (7)
  • crates/cli/src/commands/patterns_test.rs (4 hunks)
  • crates/cli_bin/fixtures/.grit/.gitignore (1 hunks)
  • crates/core/src/pattern_compiler/compiler.rs (1 hunks)
  • crates/gritmodule/src/config.rs (3 hunks)
  • crates/gritmodule/src/parser.rs (5 hunks)
  • crates/gritmodule/src/resolver.rs (2 hunks)
  • crates/gritmodule/src/yaml.rs (3 hunks)
Files skipped from review due to trivial changes (1)
  • crates/cli_bin/fixtures/.grit/.gitignore
Files skipped from review as they are similar to previous changes (6)
  • crates/cli/src/commands/patterns_test.rs
  • crates/core/src/pattern_compiler/compiler.rs
  • crates/gritmodule/src/config.rs
  • crates/gritmodule/src/parser.rs
  • crates/gritmodule/src/resolver.rs
  • crates/gritmodule/src/yaml.rs

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.

coderabbitai[bot] avatar May 20 '24 19:05 coderabbitai[bot]

@Ashu999 Tests and linters are failing. Please make sure everything passes.

morgante avatar Jul 05 '24 18:07 morgante