-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33baba1
commit f88fc2b
Showing
5 changed files
with
175 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
%{ | ||
configs: [ | ||
%{ | ||
name: "default", | ||
check_for_updates: false, | ||
files: %{ | ||
included: ["lib/", "src/", "web/", "apps/", "test/"], | ||
excluded: [~r"/_build/", ~r"/deps/"] | ||
}, | ||
checks: [ | ||
{Credo.Check.Consistency.ExceptionNames}, | ||
{Credo.Check.Consistency.LineEndings}, | ||
{Credo.Check.Consistency.SpaceAroundOperators}, | ||
{Credo.Check.Consistency.SpaceInParentheses}, | ||
{Credo.Check.Consistency.TabsOrSpaces}, | ||
|
||
{Credo.Check.Design.AliasUsage, false}, | ||
|
||
{Credo.Check.Design.DuplicatedCode, excluded_macros: [:schema, :setup, :test]}, | ||
|
||
{Credo.Check.Design.TagTODO, exit_status: 0}, | ||
{Credo.Check.Design.TagFIXME, exit_status: 0}, | ||
|
||
{Credo.Check.Readability.FunctionNames}, | ||
{Credo.Check.Readability.LargeNumbers}, | ||
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 90, exit_status: 0}, | ||
{Credo.Check.Readability.ModuleAttributeNames}, | ||
{Credo.Check.Readability.ModuleDoc, false}, | ||
{Credo.Check.Readability.ModuleNames}, | ||
{Credo.Check.Readability.ParenthesesInCondition}, | ||
{Credo.Check.Readability.PredicateFunctionNames}, | ||
{Credo.Check.Readability.TrailingBlankLine}, | ||
{Credo.Check.Readability.TrailingWhiteSpace}, | ||
{Credo.Check.Readability.VariableNames}, | ||
|
||
{Credo.Check.Refactor.ABCSize}, | ||
{Credo.Check.Refactor.CondStatements}, | ||
{Credo.Check.Refactor.FunctionArity}, | ||
{Credo.Check.Refactor.MatchInCondition}, | ||
{Credo.Check.Refactor.PipeChainStart}, | ||
{Credo.Check.Refactor.CyclomaticComplexity}, | ||
{Credo.Check.Refactor.NegatedConditionsInUnless}, | ||
{Credo.Check.Refactor.NegatedConditionsWithElse}, | ||
{Credo.Check.Refactor.Nesting}, | ||
{Credo.Check.Refactor.UnlessWithElse}, | ||
|
||
{Credo.Check.Warning.IExPry}, | ||
{Credo.Check.Warning.IoInspect}, | ||
{Credo.Check.Warning.NameRedeclarationByAssignment}, | ||
{Credo.Check.Warning.NameRedeclarationByCase}, | ||
{Credo.Check.Warning.NameRedeclarationByDef}, | ||
{Credo.Check.Warning.NameRedeclarationByFn}, | ||
{Credo.Check.Warning.OperationOnSameValues}, | ||
{Credo.Check.Warning.BoolOperationOnSameValues}, | ||
{Credo.Check.Warning.UnusedEnumOperation}, | ||
{Credo.Check.Warning.UnusedKeywordOperation}, | ||
{Credo.Check.Warning.UnusedListOperation}, | ||
{Credo.Check.Warning.UnusedStringOperation}, | ||
{Credo.Check.Warning.UnusedTupleOperation}, | ||
{Credo.Check.Warning.OperationWithConstantResult}, | ||
] | ||
} | ||
] | ||
} |
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 |
---|---|---|
|
@@ -9,4 +9,4 @@ sudo: false | |
before_script: | ||
- mix deps.get --only test | ||
script: | ||
- mix test | ||
- ./bin/checks.sh |
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,3 @@ | ||
#!/bin/sh | ||
|
||
MIX_ENV=test mix credo --strict && MIX_ENV=test mix test |
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,89 @@ | ||
#!/bin/bash | ||
|
||
# Based on https://github.com/fmahnke/shell-semver | ||
# The MIT License (MIT) | ||
# Copyright (c) 2014 Fritz Mahnke | ||
# Increment a version string using Semantic Versioning (SemVer) terminology. | ||
# Parse command line options. | ||
|
||
|
||
while getopts ":Mmp" Option | ||
do | ||
case $Option in | ||
M ) major=true;; | ||
m ) minor=true;; | ||
p ) patch=true;; | ||
esac | ||
done | ||
|
||
shift $(($OPTIND - 1)) | ||
|
||
STAGED_COUNT=$(git diff --cached --numstat | wc -l) | ||
UNSTAGED_COUNT=$(git diff --numstat | wc -l) | ||
|
||
## TODO check we are on master | ||
if [ $STAGED_COUNT -ne "0" ]; then | ||
echo "you have staged changes. Aborting". | ||
exit 1 | ||
fi | ||
|
||
if [ $UNSTAGED_COUNT -ne "0" ]; then | ||
echo "you have unstaged changes. Aborting". | ||
exit 1 | ||
fi | ||
|
||
version="$(mix run --no-compile --no-start -e ":io.format('~s', [PrometheusPhoenix.Mixfile.project()[:version]])")" | ||
|
||
echo "Old version: ${version}" | ||
|
||
# Build array from version string. | ||
oa=( ${version//./ } ) | ||
a=( ${version//./ } ) | ||
|
||
# If version string is missing or has the wrong number of members, show usage message. | ||
|
||
if [ ${#a[@]} -ne 3 ] | ||
then | ||
echo "usage: $(basename $0) [-Mmp] TAG_MESSAGE(optional)" | ||
exit 1 | ||
fi | ||
|
||
# Increment version numbers as requested. | ||
|
||
if [ ! -z $major ] | ||
then | ||
((a[0]++)) | ||
a[1]=0 | ||
a[2]=0 | ||
fi | ||
|
||
if [ ! -z $minor ] | ||
then | ||
((a[1]++)) | ||
a[2]=0 | ||
fi | ||
|
||
if [ ! -z $patch ] | ||
then | ||
((a[2]++)) | ||
fi | ||
|
||
new_version="${a[0]}.${a[1]}.${a[2]}" | ||
|
||
echo "New version: ${new_version}" | ||
|
||
sed -i s/\"${oa[0]}\.${oa[1]}\.${oa[2]}\"/\"${a[0]}\.${a[1]}\.${a[2]}\"/g mix.exs | ||
sed -i s/\~\>\ ${oa[0]}\.${oa[1]}/\~\>\ ${a[0]}\.${a[1]}/g README.md | ||
|
||
git add mix.exs | ||
git add README.md | ||
git add doc | ||
git commit -m "Bump to v${new_version}" | ||
|
||
TAG_MESSAGE=${1:-"New version: v${new_version}"} | ||
|
||
git tag -a "v${new_version}" -m "${TAG_MESSAGE}" | ||
git push origin master | ||
git push origin "v${new_version}" | ||
|
||
mix hex.publish |
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,18 @@ | ||
#!/bin/sh | ||
if [ $# -eq 0 ]; then | ||
git stash -q --keep-index | ||
./bin/checks.sh | ||
RESULT=$? | ||
git stash pop -q | ||
[ $RESULT -ne 0 ] && exit 1 | ||
exit 0 | ||
else | ||
if [ $1 = "install" ]; then | ||
ln -s `pwd`/bin/pre-commit.sh .git/hooks/pre-commit | ||
elif [ $1 = "uninstall" ]; then | ||
rm .git/hooks/pre-commit | ||
else | ||
echo "Unknown argument $1" | ||
exit 1 | ||
fi | ||
fi |