diff --git a/README.md b/README.md index 09e5599..b5a4c54 100644 --- a/README.md +++ b/README.md @@ -34,15 +34,18 @@ There are several options for configuring your local environment so that you cod - For example, in IntelliJ you have "Limited WIP": https://github.com/dkandalov/limited-wip (though, to be honest, it didn't work too well for me...). - In VS Studio you could play with "Watched Path Autoexec": https://marketplace.visualstudio.com/items?itemName=hexix.watched-path-autoexec * Option 2: scripts - - A more agnostic solution: use the scripts included under the folder `/scripts` of each java/python/generic folder of this repo (or create your own). The scripts are based on [these](https://medium.com/@tdeniffel/real-world-tcr-bb9958234bf8). - - You can either: - - install `inotifywait` or something similar depending on your OS: - - E.g. in Ubuntu run `sudo apt-get install inotify-tools` - - On Mac OS X: https://superuser.com/questions/371354/inotifywait-alternative-command-for-mac - - On Windows, one option is to use Cygwin and run the Linux scripts. - - If you use something different to `inotifywait`, modify your `watch.sh` file. - - install the `watch` utility (it exists in both Linux and Mac OSX), and use the `watch-generic.sh` script included under the folder `tcr-generic` - - To run the scripts, go to your specific folder (e.g. `tcr-python`), and run `./watch.sh` or `watch-generic.sh` (if using the generic one with `watch`) + - A more agnostic solution: use the scripts included under the folder `/scripts` of each language-specific folder of this repo (or create your own). The scripts are based on [these](https://medium.com/@tdeniffel/real-world-tcr-bb9958234bf8). + - You'll need: + - Linux: install `inotifywait` e.g. in Ubuntu run `sudo apt-get install inotify-tools` + - Mac OS X: `brew install fswatch` + - Windows: one option is to use Cygwin and run the Linux scripts. + - Alternately, install the `watch` utility (it exists in both Linux and Mac OS X) + - To run the scripts, go to your specific folder (e.g. `tcr-python`), and run the watch script + - `../scripts/watch-linux.sh` for `inotifywait` + - `../scripts/watch-osx.sh` for `fswatch` + - `../scripts/watch-generic.sh` for `watch` + + If your OS doesn't have any of these options, then you'll need to find a similar watchdog tool and make a new watch script. ## Proposed exercise diff --git a/scripts/commit.sh b/scripts/commit.sh new file mode 100755 index 0000000..fb8a153 --- /dev/null +++ b/scripts/commit.sh @@ -0,0 +1 @@ +git commit -m working $(PWD) \ No newline at end of file diff --git a/scripts/revert.sh b/scripts/revert.sh new file mode 100755 index 0000000..45ec183 --- /dev/null +++ b/scripts/revert.sh @@ -0,0 +1 @@ +git checkout HEAD -- $(PWD) \ No newline at end of file diff --git a/scripts/tcr.sh b/scripts/tcr.sh new file mode 100755 index 0000000..ca16af5 --- /dev/null +++ b/scripts/tcr.sh @@ -0,0 +1 @@ +./scripts/buildIt.sh && (./scripts/test.sh && $(PWD)/../scripts/commit.sh || $(PWD)/../scripts/revert.sh) \ No newline at end of file diff --git a/tcr-generic/watch-generic.sh b/scripts/watch-generic.sh similarity index 69% rename from tcr-generic/watch-generic.sh rename to scripts/watch-generic.sh index 3dcbc98..7067908 100755 --- a/tcr-generic/watch-generic.sh +++ b/scripts/watch-generic.sh @@ -1,2 +1,2 @@ # You just need to install watch, e.g. in Mac `brew install watch` -watch ./tcr.sh \ No newline at end of file +watch $(PWD)/../scripts/tcr.sh \ No newline at end of file diff --git a/scripts/watch-linux.sh b/scripts/watch-linux.sh new file mode 100755 index 0000000..4ba70fa --- /dev/null +++ b/scripts/watch-linux.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -eux -o pipefail + +while true +do + inotifywait -r -e modify $(PWD) + $(PWD)/../scripts/tcr.sh +done \ No newline at end of file diff --git a/scripts/watch-osx.sh b/scripts/watch-osx.sh new file mode 100755 index 0000000..72c6575 --- /dev/null +++ b/scripts/watch-osx.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -eux -o pipefail + +while true +do + fswatch --recursive --one-event $(PWD) + $(PWD)/../scripts/tcr.sh || true +done \ No newline at end of file diff --git a/tcr-csharp/README.md b/tcr-csharp/README.md index f042b6d..0b91732 100644 --- a/tcr-csharp/README.md +++ b/tcr-csharp/README.md @@ -1,16 +1,13 @@ # Template for trying TCR in DotNet Core ## Prerequisites -1. You need **.Net Core 2.2.x** +1. You need **.Net Core 2.2.x** * https://dotnet.microsoft.com/download -2. If you are using Mac OS you should install **watchexec** - * https://github.com/watchexec/watchexec -3. Connectiviy to the Internet! - +2. Connectivity to the Internet! ## How to verify that everything works From the terminal, run `dotnet build` or `dotnet test`: it should download all the dependencies and finish showing that the tests were successfully executed. ## How to run TCR -* Run the script `./watch.sh` +* Run the watch script as specified in the top-level README * Only the business code gets reverted when failing the tests \ No newline at end of file diff --git a/tcr-csharp/scripts/commit.sh b/tcr-csharp/scripts/commit.sh deleted file mode 100755 index f86f286..0000000 --- a/tcr-csharp/scripts/commit.sh +++ /dev/null @@ -1 +0,0 @@ -git commit -am working \ No newline at end of file diff --git a/tcr-csharp/scripts/revert.sh b/tcr-csharp/scripts/revert.sh deleted file mode 100755 index 4a7bcca..0000000 --- a/tcr-csharp/scripts/revert.sh +++ /dev/null @@ -1 +0,0 @@ -git reset --hard tcr-chsarp \ No newline at end of file diff --git a/tcr-csharp/tcr.sh b/tcr-csharp/tcr.sh deleted file mode 100755 index 1e17bf4..0000000 --- a/tcr-csharp/tcr.sh +++ /dev/null @@ -1 +0,0 @@ -./scripts/buildIt.sh && (./scripts/test.sh && ./scripts/commit.sh || ./scripts/revert.sh) \ No newline at end of file diff --git a/tcr-csharp/watch.sh b/tcr-csharp/watch.sh deleted file mode 100755 index 6be6ad7..0000000 --- a/tcr-csharp/watch.sh +++ /dev/null @@ -1 +0,0 @@ -watchexec -i target ./tcr.sh -w src/tcr-app \ No newline at end of file diff --git a/tcr-elixir/README.md b/tcr-elixir/README.md index e6c43d3..4ec4c01 100644 --- a/tcr-elixir/README.md +++ b/tcr-elixir/README.md @@ -2,10 +2,4 @@ Requirements -- Elixir 1.7 or above - -How to run - -``` -sh watch.sh -``` +- Elixir 1.7 or above \ No newline at end of file diff --git a/tcr-elixir/scripts/commit.sh b/tcr-elixir/scripts/commit.sh deleted file mode 100755 index f86f286..0000000 --- a/tcr-elixir/scripts/commit.sh +++ /dev/null @@ -1 +0,0 @@ -git commit -am working \ No newline at end of file diff --git a/tcr-elixir/scripts/revert.sh b/tcr-elixir/scripts/revert.sh deleted file mode 100755 index f5c87c3..0000000 --- a/tcr-elixir/scripts/revert.sh +++ /dev/null @@ -1 +0,0 @@ -git checkout HEAD -- . \ No newline at end of file diff --git a/tcr-elixir/tcr.sh b/tcr-elixir/tcr.sh deleted file mode 100755 index 1e17bf4..0000000 --- a/tcr-elixir/tcr.sh +++ /dev/null @@ -1 +0,0 @@ -./scripts/buildIt.sh && (./scripts/test.sh && ./scripts/commit.sh || ./scripts/revert.sh) \ No newline at end of file diff --git a/tcr-elixir/watch.sh b/tcr-elixir/watch.sh deleted file mode 100755 index 9da5e81..0000000 --- a/tcr-elixir/watch.sh +++ /dev/null @@ -1,5 +0,0 @@ -while true -do - inotifywait -r -e modify ./ - ./tcr.sh -done \ No newline at end of file diff --git a/tcr-generic/README.md b/tcr-generic/README.md index d61b8cd..bc4cae8 100644 --- a/tcr-generic/README.md +++ b/tcr-generic/README.md @@ -4,6 +4,4 @@ You only need to adapt two scripts to your language: * `buildIt.sh` * `test.sh` -Then, if you're on a Linux system, you can use the `watch.sh` script (you need to install inotify-tools first). A more generic solution, working in both Linux and Mac OSX, would be the `watch-generic.sh` script (you just need to install hte `watch` utility, e.g. `brew install watch` in OSX). - -Finally, just include your code under the /src folder or change that path in the `watch.sh` and `revert.sh` scripts. +Then you should be able to run the watch script as specified in the top-level README \ No newline at end of file diff --git a/tcr-generic/scripts/commit.sh b/tcr-generic/scripts/commit.sh deleted file mode 100755 index f86f286..0000000 --- a/tcr-generic/scripts/commit.sh +++ /dev/null @@ -1 +0,0 @@ -git commit -am working \ No newline at end of file diff --git a/tcr-generic/scripts/revert.sh b/tcr-generic/scripts/revert.sh deleted file mode 100755 index 39e1593..0000000 --- a/tcr-generic/scripts/revert.sh +++ /dev/null @@ -1 +0,0 @@ -git checkout HEAD -- src/ \ No newline at end of file diff --git a/tcr-generic/tcr.sh b/tcr-generic/tcr.sh deleted file mode 100755 index 1e17bf4..0000000 --- a/tcr-generic/tcr.sh +++ /dev/null @@ -1 +0,0 @@ -./scripts/buildIt.sh && (./scripts/test.sh && ./scripts/commit.sh || ./scripts/revert.sh) \ No newline at end of file diff --git a/tcr-generic/watch-mac.sh b/tcr-generic/watch-mac.sh deleted file mode 100644 index ebc71c1..0000000 --- a/tcr-generic/watch-mac.sh +++ /dev/null @@ -1,2 +0,0 @@ -# brew install fswatch -fswatch -o --event=Updated -e ".*" -i "\\.ext$" -r ./folder-to-watch | ./tcr.sh diff --git a/tcr-generic/watch.sh b/tcr-generic/watch.sh deleted file mode 100755 index bf86dcd..0000000 --- a/tcr-generic/watch.sh +++ /dev/null @@ -1,5 +0,0 @@ -while true -do - inotifywait -r -e modify ./src - ./tcr.sh -done \ No newline at end of file diff --git a/tcr-java/README.md b/tcr-java/README.md index 9498080..deb8a17 100644 --- a/tcr-java/README.md +++ b/tcr-java/README.md @@ -3,20 +3,20 @@ ## Prerequisites 1. You need **Maven 3.x** (variables M2_HOME, M2, MAVEN_OPTS, PATH...) * https://maven.apache.org/install.html - * Example en Ubuntu: https://www.vultr.com/docs/how-to-install-apache-maven-on-ubuntu-16-04 + * Example on Ubuntu: https://www.vultr.com/docs/how-to-install-apache-maven-on-ubuntu-16-04 2. Having installed **JDK 1.8** (or you can just change the pom.xml to whatever version fits you) - * E.g. para Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04 + * E.g. for Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04 * Configure the JAVA_HOME env variable. -3. Connectiviy to the Internet! +3. Connectivity to the Internet! ## How to verify that everything works There are several ways to do it: -* From you favourite IDE: run the test and see it going green -* From the terminal, run `mvn clean test`: it should download all the dependencies and finish showing that the tests were successfully executed. +* From your favourite IDE: run the test and see it going green +* From the terminal, run `mvn clean test`: it should download all the dependencies and finish showing that the tests were successfully executed ## How to run TCR -* Run the script `./watch.sh` +* Run the watch script as per the top-level README * Only the business code gets reverted when failing the tests \ No newline at end of file diff --git a/tcr-java/scripts/commit.sh b/tcr-java/scripts/commit.sh deleted file mode 100755 index f86f286..0000000 --- a/tcr-java/scripts/commit.sh +++ /dev/null @@ -1 +0,0 @@ -git commit -am working \ No newline at end of file diff --git a/tcr-java/scripts/revert.sh b/tcr-java/scripts/revert.sh deleted file mode 100755 index d6becaa..0000000 --- a/tcr-java/scripts/revert.sh +++ /dev/null @@ -1 +0,0 @@ -git checkout HEAD -- src/main/ \ No newline at end of file diff --git a/tcr-java/tcr.sh b/tcr-java/tcr.sh deleted file mode 100755 index 1e17bf4..0000000 --- a/tcr-java/tcr.sh +++ /dev/null @@ -1 +0,0 @@ -./scripts/buildIt.sh && (./scripts/test.sh && ./scripts/commit.sh || ./scripts/revert.sh) \ No newline at end of file diff --git a/tcr-java/watch.sh b/tcr-java/watch.sh deleted file mode 100755 index bf86dcd..0000000 --- a/tcr-java/watch.sh +++ /dev/null @@ -1,5 +0,0 @@ -while true -do - inotifywait -r -e modify ./src - ./tcr.sh -done \ No newline at end of file diff --git a/tcr-python/scripts/commit.sh b/tcr-python/scripts/commit.sh deleted file mode 100755 index f86f286..0000000 --- a/tcr-python/scripts/commit.sh +++ /dev/null @@ -1 +0,0 @@ -git commit -am working \ No newline at end of file diff --git a/tcr-python/scripts/revert.sh b/tcr-python/scripts/revert.sh deleted file mode 100755 index 39e1593..0000000 --- a/tcr-python/scripts/revert.sh +++ /dev/null @@ -1 +0,0 @@ -git checkout HEAD -- src/ \ No newline at end of file diff --git a/tcr-python/tcr.sh b/tcr-python/tcr.sh deleted file mode 100755 index 1e17bf4..0000000 --- a/tcr-python/tcr.sh +++ /dev/null @@ -1 +0,0 @@ -./scripts/buildIt.sh && (./scripts/test.sh && ./scripts/commit.sh || ./scripts/revert.sh) \ No newline at end of file diff --git a/tcr-python/watch.sh b/tcr-python/watch.sh deleted file mode 100755 index bf86dcd..0000000 --- a/tcr-python/watch.sh +++ /dev/null @@ -1,5 +0,0 @@ -while true -do - inotifywait -r -e modify ./src - ./tcr.sh -done \ No newline at end of file diff --git a/tcr-ruby/README.md b/tcr-ruby/README.md index 0b65a66..45639c0 100644 --- a/tcr-ruby/README.md +++ b/tcr-ruby/README.md @@ -6,6 +6,6 @@ ## How to run it 1. Run `rspec --init` -2. Run `./watch.sh` +2. Run relevant watch script (see README) It should work! :-) diff --git a/tcr-ruby/scripts/commit.sh b/tcr-ruby/scripts/commit.sh deleted file mode 100755 index f86f286..0000000 --- a/tcr-ruby/scripts/commit.sh +++ /dev/null @@ -1 +0,0 @@ -git commit -am working \ No newline at end of file diff --git a/tcr-ruby/scripts/revert.sh b/tcr-ruby/scripts/revert.sh deleted file mode 100755 index 9a9e8fd..0000000 --- a/tcr-ruby/scripts/revert.sh +++ /dev/null @@ -1 +0,0 @@ -git checkout HEAD -- spec/ \ No newline at end of file diff --git a/tcr-ruby/tcr.sh b/tcr-ruby/tcr.sh deleted file mode 100755 index 1e17bf4..0000000 --- a/tcr-ruby/tcr.sh +++ /dev/null @@ -1 +0,0 @@ -./scripts/buildIt.sh && (./scripts/test.sh && ./scripts/commit.sh || ./scripts/revert.sh) \ No newline at end of file diff --git a/tcr-ruby/watch.sh b/tcr-ruby/watch.sh deleted file mode 100755 index a737af8..0000000 --- a/tcr-ruby/watch.sh +++ /dev/null @@ -1,5 +0,0 @@ -while true -do - inotifywait -r -e modify ./spec - ./tcr.sh -done \ No newline at end of file diff --git a/tcr-rust/scripts/commit.sh b/tcr-rust/scripts/commit.sh deleted file mode 100755 index f86f286..0000000 --- a/tcr-rust/scripts/commit.sh +++ /dev/null @@ -1 +0,0 @@ -git commit -am working \ No newline at end of file diff --git a/tcr-rust/scripts/revert.sh b/tcr-rust/scripts/revert.sh deleted file mode 100755 index 39e1593..0000000 --- a/tcr-rust/scripts/revert.sh +++ /dev/null @@ -1 +0,0 @@ -git checkout HEAD -- src/ \ No newline at end of file diff --git a/tcr-rust/tcr.sh b/tcr-rust/tcr.sh deleted file mode 100755 index 1e17bf4..0000000 --- a/tcr-rust/tcr.sh +++ /dev/null @@ -1 +0,0 @@ -./scripts/buildIt.sh && (./scripts/test.sh && ./scripts/commit.sh || ./scripts/revert.sh) \ No newline at end of file diff --git a/tcr-rust/watch.sh b/tcr-rust/watch.sh deleted file mode 100755 index 3e32228..0000000 --- a/tcr-rust/watch.sh +++ /dev/null @@ -1,5 +0,0 @@ -while true -do - inotifywait -r -e modify ./src Cargo.toml - ./tcr.sh -done \ No newline at end of file