diff --git a/.travis.yml b/.travis.yml index 0737b44..62193fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ install: script: - mix format --check-formatted - mix credo - - mix hex.outdated + - mix hex.outdated || true - mix test deploy: skip_cleanup: true diff --git a/README.md b/README.md index 138d0b5..fbdfa18 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ To add to your mix dependencies, add the following block to your mix.exs deps: ```elixir def deps do [ - {:streaming_metrics, "~> 2.1.7"} + {:streaming_metrics, "~> 2.1.9"} ] end ``` diff --git a/config/dev.exs b/config/dev.exs index 555abb0..4768b2c 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,4 +1,4 @@ use Mix.Config config :husky, - pre_commit: "mix format --check-formatted && mix credo && mix hex.outdated" + pre_commit: "./scripts/git_pre_commit_hook.sh" diff --git a/mix.exs b/mix.exs index 40fee22..9301ad5 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule StreamingMetrics.MixProject do def project do [ app: :streaming_metrics, - version: "2.1.8", + version: "2.1.9", elixir: "~> 1.8", start_permanent: Mix.env() == :prod, deps: deps(), diff --git a/scripts/git_pre_commit_hook.sh b/scripts/git_pre_commit_hook.sh new file mode 100755 index 0000000..9843e47 --- /dev/null +++ b/scripts/git_pre_commit_hook.sh @@ -0,0 +1,38 @@ +#! /bin/bash +RED='\033[0;31m' +NC='\033[0m' # No Color +exit_code=0 + +#Check that version in README.md matches what is in mix.exs +build_output=$(mix hex.build) +current_version=$(echo "$build_output" | grep 'Version:' | awk '{print $2}') +app_name=$(echo "$build_output" | grep 'Building' | awk '{print $2}') +grep -q "{:$app_name, \"~> $current_version" README.md +if [ $? == 1 ]; then + echo -e "${RED}Update the version number in README.md to $current_version\r\n" + exit_code=1 +fi + +mix format + +echo -e "${NC}mix credo - compiling code there may be a delay" +compile_output=$(mix compile 2>/dev/null) ##Supress compile output and warnings + +credo_output=$(mix credo --format=oneline) +if [ $? != 0 ]; then + echo -e "${RED}$credo_output${NC}\r\n" + exit_code=1 +fi + +outdated_output=$(mix hex.outdated) +if [ $? == 1 ]; then + echo -e "${NC}Outdated dependencies" + echo -e "$outdated_output" | grep "Dependency" + echo -en "${RED}" + echo -e "$outdated_output" | grep " No" + echo -e "$outdated_output" | grep " Yes" + echo -e "${NC}" + exit_code=1 +fi + +exit $exit_code \ No newline at end of file diff --git a/scripts/set_release_number.sh b/scripts/set_release_number.sh deleted file mode 100755 index 8404ff4..0000000 --- a/scripts/set_release_number.sh +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/bash -current_version=$(mix hex.build | grep 'Version:' | awk '{print $2}') -echo "Current Application Version is: " $current_version -read -p "Enter new version number: " new_version -files=( - mix.exs - README.md -) -for file in "${files[@]}"; do - sed -i '' "s/$current_version/$new_version/g" "$file" -done - -echo "You will need commit the changed files"