Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #37 from smartcitiesdata/pre_commit
Browse files Browse the repository at this point in the history
Add pre commit hook script to check credo, format, and deps versions
  • Loading branch information
dickthedev committed Jul 1, 2019
2 parents 658cd44 + 8cc4166 commit 5fa4aa0
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -19,7 +19,7 @@ install:
script:
- mix format --check-formatted
- mix credo
- mix hex.outdated
- mix hex.outdated || true
- mix test
- mix test.integration
deploy:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -14,7 +14,7 @@ This package can be installed by adding `smart_city_registry` to your list of de

```elixir
def deps do
[{:smart_city_registry, "~> 3.3.0"}]
[{:smart_city_registry, "~> 3.3.1"}]
end
```

Expand Down
2 changes: 1 addition & 1 deletion 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"
2 changes: 1 addition & 1 deletion mix.exs
Expand Up @@ -4,7 +4,7 @@ defmodule SmartCity.Registry.MixProject do
def project do
[
app: :smart_city_registry,
version: "3.3.0",
version: "3.3.1",
elixir: "~> 1.8",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down
6 changes: 3 additions & 3 deletions mix.lock
Expand Up @@ -3,7 +3,7 @@
"checkov": {:hex, :checkov, "0.4.0", "a1974a5885f62f8943a9059f0d5252b222271e0e58dd872ffb60323f2e376433", [:mix], [], "hexpm"},
"credo": {:hex, :credo, "1.1.0", "e0c07b2fd7e2109495f582430a1bc96b2c71b7d94c59dfad120529f65f19872f", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
"divo": {:hex, :divo, "1.1.7", "db7b9fa08682c454c1d1888403bcd0afa10d09ec8fb08214fcdad3a6bf9d8e30", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:patiently, "~> 0.2", [hex: :patiently, repo: "hexpm", optional: false]}], "hexpm"},
"divo": {:hex, :divo, "1.1.9", "6f91b0a02bd97800eb9a99abd771b4c9b67d282b67abc223eb2832b93f557b7e", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:patiently, "~> 0.2", [hex: :patiently, repo: "hexpm", optional: false]}], "hexpm"},
"earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.20.2", "1bd0dfb0304bade58beb77f20f21ee3558cc3c753743ae0ddbb0fd7ba2912331", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"file_system": {:hex, :file_system, "0.2.7", "e6f7f155970975789f26e77b8b8d8ab084c59844d8ecfaf58cbda31c494d14aa", [:mix], [], "hexpm"},
Expand All @@ -15,8 +15,8 @@
"mix_test_watch": {:hex, :mix_test_watch, "0.9.0", "c72132a6071261893518fa08e121e911c9358713f62794a90c95db59042af375", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"},
"patiently": {:hex, :patiently, "0.2.0", "67eb139591e10c4b363ae0198e832552f191c58894731efd3bf124ec4722267a", [:mix], [], "hexpm"},
"placebo": {:hex, :placebo, "1.2.1", "303ebb597279fd77b1f6d38ec377be4932f73246351f181d6128d0a58d3f74e9", [:mix], [{:meck, "~> 0.8.9", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
"placebo": {:hex, :placebo, "1.2.2", "a3d47906b01844bfd04ab0351a605620619fdb8f011225e406696f96a88ff380", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
"redix": {:hex, :redix, "0.10.2", "a9eabf47898aa878650df36194aeb63966d74f5bd69d9caa37babb32dbb93c5d", [:mix], [{:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
"smart_city": {:hex, :smart_city, "2.1.5", "48c9f9e7de21d6c5584bc578bfdad85ff9242d4cb84653260420901a2d690cc6", [:mix], [], "hexpm"},
"smart_city": {:hex, :smart_city, "2.1.6", "88180173faa62032feddcc427d80465e056c46e8b17609a86633070ff44f86a1", [:mix], [], "hexpm"},
"telemetry": {:hex, :telemetry, "0.4.0", "8339bee3fa8b91cb84d14c2935f8ecf399ccd87301ad6da6b71c09553834b2ab", [:rebar3], [], "hexpm"},
}
38 changes: 38 additions & 0 deletions 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
13 changes: 0 additions & 13 deletions scripts/set_release_number.sh

This file was deleted.

0 comments on commit 5fa4aa0

Please sign in to comment.