Giter Club home page Giter Club logo

funzzy's Introduction

funzzy (fzz) Crate version CI integration tests CI Checks

Yet another fancy watcher. (Inspired by antr / entr). See also funzzy.nvim

Configure auto-execution of different commands using semantic YAML and Unix shell style pattern match or stdin.

As simple as

find . -name '*.ts' | funzzy 'npx eslint .'

Or complicated as

# .watch.yaml (or .watch.yml)
# list here all the events and the commands that it should execute
# TIP: include '.watch.yaml' in your .git/info/exclude to ignore it.

- name: run my tests
  run: make test
  change: "tests/**"
  ignore: "tests/integration/**"

- name: Starwars
  run: telnet towel.blinkenlights.nl
  change: ".watch.yaml"

- name: say hello
  run: echo "hello on init"
  change: "./*.yaml"
  run_on_init: true

# Command templates for custom scripts
- name: run test & linter for a single file
  run: [
    "npm run lint -- {{filepath}}",
    "npm test -- $(echo '{{filepath}}' | sed -r s/.(j|t)sx?//)"
  ]
  change: ["src/**", "libs/**"]
  ignore: ["src/**/*.stories.*", "libs/**/*.log"]

Motivation

Create a lightweight watcher to run my tests every time something in my project change. So I won't forget to keep my tests passing. Funzzy was made with Rust which is why it consumes almost nothing to run.

Installing

OSX:

brew tap cristianoliveira/tap
brew update
brew install funzzy

Linux:

curl -s https://raw.githubusercontent.com/cristianoliveira/funzzy/master/linux-install.sh | sh

You can specify the versions:

curl -s https://raw.githubusercontent.com/cristianoliveira/funzzy/master/linux-install.sh | bash - 1.0.0

Nix

nix-env -iA nixpkgs.funzzy

or, if you use shell.nix:

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = [
    pkgs.funzzy
  ];
};

With Cargo

cargo install funzzy

*Make sure you have $HOME/.cargo/bin in your PATH export $PATH:$HOME/.cargo/bin

  • From source

Make sure you have installed the following dependencies:

  • Rust
  • Cargo

Execute:

cargo install --git https://github.com/cristianoliveira/funzzy.git

Or, clone this repo and run:

make install

Running

Initializing with boilerplate:

funzzy init

Change the config file .watch.yaml as you want. Then run:

funzzy
# or use the short version
fzz

Options

Use a different config file:

fzz -c ~/watch.yaml

Filtering task by target (contais in task name):

fzz -t "my task"

Run with some arbitrary command and stdin

find . -name '*.rs' | fzz 'cargo build'

Templates for composing commands

find . -name '*.[jt]s' | fzz 'npx eslint {{filepath}}'

Running in "non-block" mode which cancels the currently running task once something changes super useful if you need to run a long task and don't want to wait for it to finish after a change in the code. See: long task test

fzz --non-block

See more in examples or in the integration specs

Troubleshooting

Why the watcher is running the same task multiple times?

This might be due to different causes, the most common issue when using VIM is because of the default backup setting which causes changes to multiple files on save. See Why does Vim save files with a ~ extension?. For such cases either disable the backup or ignore them in your watch rules.

For other cases use the verbose funzzy -V to understand what is triggering a task to be executed.

Automated tests

Running unit tests:

cargo test

or simple make tests

Running integration tests:

make integration

Code Style

We use clippy for linting the funzzy's source code. Make sure you had validated it before committing.

Contributing

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

Pull Requests are really welcome! Others support also.

Pull Request should have unit tests

License

This project was made under MIT License.

funzzy's People

Contributors

andviera avatar chills42 avatar cristianoliveira avatar dependabot[bot] avatar kc1212 avatar llogiq avatar marceloboeira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

funzzy's Issues

bug: funnzy dies when a task fails

The original behaviour was that funzzy continues running after any of the tasks fails and wait for the next change.

Expected

  • Funzzy process continues running after any task is failed or errored

Current

  • Funzzy process dies if any task exits with 1

feat: propose of new yaml format.

Make more sense if run: be at same level of when:
example:

- name: run my tests
  run: make test
  when:
    change: ['lib/**', 'spec/**']
    ignore: 'tmp/**'

feat: verbose option

Add the verbose option for debug purposes. It should print all paths found during the Watches.watch.

feat: work with stdin

Provide a way to funzzy works with stdout then will be possible to run like entr runs:

ls -d * | funzzy sh -c 'make && make test'

It could create the yaml file also.

fix: better message when yaml file has bad format.

Today when yaml has bad format we get this error:

thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: ScanError { mark: Marker { index: 222, line: 10, col: 4 }, info: "while parsing a flow sequence, expectd \',\' or \']\'" }', ../src/libcore/result.rs:688

We need a better error message.

feat: allow a "dry-run" for debugging purposes

The idea is to be able to quickly validate your rules via some sort of dry-run feature. Very useful when trying to create a rule that is a bit more specific

Acceptance Criteria

  • The user is able to quickly verify if a file change will trigger their rule
  • The defined command for that rule should not be executed

Style: fix warnings

Today we have a bunch of warning that shows on the compilation. Would be nice to fix them.

warning: unused import: `std::process::*;`
 --> src/cmd.rs:3:5
  |
3 | use std::process::*;
  |     ^^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused extern crate
 --> src/lib.rs:4:1
  |
4 | extern crate rustc_serialize;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_extern_crates)] on by default

warning: unused extern crate
 --> src/lib.rs:5:1
  |
5 | extern crate docopt;
  | ^^^^^^^^^^^^^^^^^^^^

warning: unused extern crate
 --> src/cli/watch.rs:2:1
  |
2 | extern crate glob;
  | ^^^^^^^^^^^^^^^^^^

warning: unused extern crate
 --> src/yaml.rs:2:1
  |
2 | extern crate glob;
  | ^^^^^^^^^^^^^^^^^^

warning: unused import: `std::process::*;`
 --> src/cmd.rs:3:5
  |
3 | use std::process::*;
  |     ^^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused extern crate
 --> src/cli/watch.rs:2:1
  |
2 | extern crate glob;
  | ^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_extern_crates)] on by default

warning: unused extern crate
 --> src/yaml.rs:2:1
  |
2 | extern crate glob;
  | ^^^^^^^^^^^^^^^^^^

    Finished dev [unoptimized + debuginfo] target(s) in 24.30 secs

fix: homebrew install

Error: SHA256 mismatch
Expected: b34ee2d8339a54f7edaf122394a5074ad9c77b554629560322f5fc70c29a6b39
Actual: 6cfce5267b639fc9d2ef4cbbe299e6c304e0984f1e73f6977debdad6f92af343
Archive: /Library/Caches/Homebrew/funzzy-0.3.0.tar.gz

feat: allow configuring a log output

The idea is to allow a long-running fzz process to have a log output for debugging purposes.

  • By default, it shouldn't log,
  • Log output if --output /var/log/foo.log is passed

bug: cli panic when scaping chars

Try this:

- name: run tests
  run: ["yarn test {{filepath}}", "echo '{{filepath}}' | sed -r 's\/.tsx/\/'" ]
  change: 'src/**'

And once the cli attempts to load the rules it panics:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ScanError { mark: Marker { index: 258, line: 8, col: 34 }, info: "while parsing a quoted scalar, found unknown escape character" }', src/rules.rs:92:57
stack backtrace:
   0: rust_begin_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
   2: core::result::unwrap_failed
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/result.rs:1651:5
   3: fzz::rules::from_file
   4: fzz::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

No working with VScode

Hi, I'm not sure if this is out of scope.
Is working fine with vim or the default visual editor on the os but not working with editor like vscode, pulsar editor or sublime text
also not working with nano
the output is just
Funzzy: Watching...
I'm using Linux mint as OS

Here the yml file:

- name: run my test
  run: [
    'ls -a',
    'echo helooooo'
  ]
  change: "**"

also i want to point out that inotifywait is working fine:

while inotifywait -e close_write **; \
do clear && \
    date +"%T"
    ls -la
done

Any idea? Thank you

bug: no terminal feedback when more than one rule

For instance, I have the follow rules:

## Funzzy events file
# more details see: https://github.com/cristianoliveira/funzzy
#
# list here all the events and the commands that it should execute

- name: Run linter
  run: 'yarn lint'
  change: 'src/**'

- name: Trigger cypress
  run: 'touch ./cypress/integration/features/apm-validations.spec.js'
  change: 'src/**'

And if I remove one of them it goes back to have a feedback

feat: show available tasks when target has no match

Current behaviour

funzzy --target=lint                                                  
thread 'main' panicked at 'No rules found for the given filter', src/cli/watch.rs:141:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected

No rules were found for the given target

Available tasks:
 - checks
 - tests
 - build

docs: provide some use case examples

Would be nice to have some "real" examples. For example for a js/ruby/python/rust project. So we should create an examples folder with a bunch of them

feat: pass arguments to tasks

Just a required I had another day where I wanted to avoid changing my .watch.yml file just to add a new flag, while testing something. Maybe fzz could receive flags and pass down to the commands like:

fzz -t test -- --verbose
# --verbose is passed to the test task in this case `jest --verbose`

init command will produce incorrect yaml file

run "funzzy init" and then run "funzzy watch" will get some error:

thread 'main' panicked at 'Unable to load configuration: ScanError { mark: Marker { index: 179, line: 8, col: 2 }, info: "while parsing a block mapping, did not find expected key" }', ../src/libcore\result.rs:799 rc/cli/init.rs

it seems the init command produce incorrect .watch.yaml file:
run:'ls -a' should be run: 'ls -a' .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.