watchexec/CONTRIBUTING.md

123 lines
4.2 KiB
Markdown
Raw Normal View History

2020-07-03 13:51:46 +02:00
# Contribution guidebook
2021-12-23 14:47:55 +01:00
This is a fairly free-form project, with low contribution traffic.
2020-07-03 13:51:46 +02:00
Maintainers:
- Félix Saparelli (@passcod) (active)
2022-12-03 00:07:36 +01:00
- Matt Green (@mattgreen) (original author, mostly checked out)
2020-07-03 13:51:46 +02:00
2021-12-23 14:47:55 +01:00
There are a few anti goals:
2020-07-03 13:51:46 +02:00
- Calling watchexec is to be a **simple** exercise that remains intuitive. As a specific point, it
should not involve any piping or require xargs.
- Watchexec will not be tied to any particular ecosystem or language. Projects that themselves use
watchexec (the library) can be focused on a particular domain (for example Cargo Watch for Rust),
but watchexec itself will remain generic, usable for any purpose.
## Debugging
To enable verbose logging in tests, run with:
```console
$ env RUST_LOG=watchexec=trace,info RUST_TEST_THREADS=1 RUST_NOCAPTURE=1 cargo test --test testfile -- testname
```
To use [Tokio Console](https://github.com/tokio-rs/console):
1. Add `--cfg tokio_unstable` to your `RUSTFLAGS`.
2. Run the CLI with the `dev-console` feature.
2020-07-03 13:51:46 +02:00
## PR etiquette
- Maintainers are busy or may not have the bandwidth, be patient.
- Do _not_ change the version number in the PR.
- Do _not_ change Cargo.toml or other project metadata, unless specifically asked for, or if that's
the point of the PR (like adding a crates.io category).
Apart from that, welcome and thank you for your time!
## Releasing
2024-10-14 00:47:42 +02:00
```
cargo release -p crate-name --execute patch # or minor, major
```
2022-12-03 00:07:36 +01:00
2024-10-14 00:47:42 +02:00
When a CLI release is done, the [release notes](https://github.com/watchexec/watchexec/releases) should be edited with the changelog.
2022-12-03 00:07:36 +01:00
### Release order
2023-11-26 04:15:29 +01:00
Use this command to see the tree of workspace dependencies:
```console
$ cargo tree -p watchexec-cli | rg -F '(/' --color=never | sed 's/ v[0-9].*//'
```
2022-12-03 00:07:36 +01:00
## Overview
The architecture of watchexec is roughly:
- sources gather events
- events are debounced and filtered
- event(s) make it through the debounce/filters and trigger an "action"
- `on_action` handler is called, returning an `Outcome`
- outcome is processed into managing the command that watchexec is running
- outcome can also be to exit
- when a command is started, the `on_pre_spawn` and `on_post_spawn` handlers are called
- commands are also a source of events, so e.g. "command has finished" is handled by `on_action`
And this is the startup sequence:
- init config sets basic immutable facts about the runtime
- runtime starts:
- source workers start, and are passed their runtime config
- action worker starts, and is passed its runtime config
- (unless `--postpone` is given) a synthetic event is injected to kickstart things
## Guides
2020-07-03 13:51:46 +02:00
2022-12-03 00:07:36 +01:00
These are generic guides for implementing specific bits of functionality.
2020-07-03 13:51:46 +02:00
2022-12-03 00:07:36 +01:00
### Adding an event source
2020-07-03 13:51:46 +02:00
2022-12-03 00:07:36 +01:00
- add a worker for "sourcing" events. Looking at the [signal source
worker](https://github.com/watchexec/watchexec/blob/main/crates/lib/src/signal/source.rs) is
probably easiest to get started here.
2020-07-03 13:51:46 +02:00
2022-12-03 00:07:36 +01:00
- because we may not always want to enable this event source, and just to be flexible, add [runtime
config](https://github.com/watchexec/watchexec/blob/main/crates/lib/src/config.rs) for the source.
2020-07-03 13:51:46 +02:00
2022-12-03 00:07:36 +01:00
- for convenience, probably add [a method on the runtime
config](https://github.com/watchexec/watchexec/blob/main/crates/lib/src/config.rs) which
configures the most common usecase.
2020-07-03 13:51:46 +02:00
2022-12-03 00:07:36 +01:00
- because watchexec is reconfigurable, in the worker you'll need to react to config changes. Look at
how the [fs worker does it](https://github.com/watchexec/watchexec/blob/main/crates/lib/src/fs.rs)
for reference.
2020-07-03 13:51:46 +02:00
2022-12-03 00:07:36 +01:00
- you may need to [add to the event tag
enum](https://github.com/watchexec/watchexec/blob/main/crates/lib/src/event.rs).
2020-07-03 13:51:46 +02:00
2022-12-03 00:07:36 +01:00
- if you do, you should [add support to the "tagged
filterer"](https://github.com/watchexec/watchexec/blob/main/crates/filterer/tagged/src/parse.rs),
but this can be done in follow-up work.
2020-07-03 13:51:46 +02:00
2022-12-03 00:07:36 +01:00
### Process a new event in the CLI
2020-07-03 14:51:51 +02:00
2022-12-03 00:07:36 +01:00
- add an option to the
[args](https://github.com/watchexec/watchexec/blob/main/crates/cli/src/args.rs) if necessary
2020-07-03 13:51:46 +02:00
2022-12-03 00:07:36 +01:00
- add to the [runtime
config](https://github.com/watchexec/watchexec/blob/main/crates/cli/src/config/runtime.rs) when
the option is present
2020-07-03 13:51:46 +02:00
2022-12-03 00:07:36 +01:00
- process relevant events [in the action
handler](https://github.com/watchexec/watchexec/blob/main/crates/cli/src/config/runtime.rs)
2020-07-03 13:51:46 +02:00
---
vim: tw=100