-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: terminates current running watcher upon config changes
relates to #106
- Loading branch information
1 parent
a98f59c
commit 0dd09bc
Showing
11 changed files
with
152 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This example shows the auto reload feature | ||
# | ||
# This workflow efectivelly creates a dependency between tasks with conditionals | ||
# I don't want to give ideas, but one can create some pretty crazy workflows | ||
# maybe even turing complete. | ||
# | ||
#@#CHANGED#@ | ||
# | ||
- name: task runs on init (1) | ||
run: | ||
- echo 'run me first' | ||
- sed -i '1,7s/#THIS_WILL_CHANGE#@$/#CHANGED#@/' examples/reload-config-example.yml | ||
- echo 1 > examples/workdir/trigger-first-task.txt | ||
change: | ||
- '__noop__' | ||
# LOL! To setup a LOOP uncomment this line | ||
# - examples/workdir/trigger-start.txt | ||
run_on_init: true | ||
|
||
- name: task that run at the end (3) | ||
run: | ||
- echo 'then me in third' | ||
- cat examples/reload-config-example.yml | ||
- echo 1 > examples/workdir/trigger-start.txt | ||
change: "examples/workdir/trigger-second-task.txt" | ||
|
||
- name: this task runs after on init (2) | ||
run: | ||
- echo 'then me in second' | ||
- sed -i '1,7s/#CHANGED#@$/#THIS_WILL_CHANGE#@/' examples/reload-config-example.yml | ||
- echo 1 > examples/workdir/trigger-second-task.txt | ||
change: "examples/workdir/trigger-first-task.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::io::prelude::*; | ||
|
||
#[path = "./common/lib.rs"] | ||
mod setup; | ||
|
||
#[test] | ||
fn it_terminates_the_current_running_watcher_when_config_changes() { | ||
setup::with_example( | ||
setup::Options { | ||
output_file: "it_terminates_the_current_running_watcher_when_config_changes.log", | ||
example_file: "examples/reload-config-example.yml", | ||
}, | ||
|fzz_cmd, mut output_log| { | ||
let mut child = fzz_cmd | ||
.arg("--non-block") | ||
.arg("-V") | ||
.spawn() | ||
.expect("failed to spawn child"); | ||
|
||
defer!({ | ||
child.kill().expect("failed to kill child"); | ||
}); | ||
|
||
let mut output = String::new(); | ||
wait_until!( | ||
{ | ||
output_log | ||
.read_to_string(&mut output) | ||
.expect("failed to read from file"); | ||
|
||
output.contains("The config file has changed") | ||
&& output.contains("Terminating watcher...") | ||
}, | ||
"No task in the example was configured with run_on_init {}", | ||
output | ||
); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters