Merge pull request #113 from jehoshua02/elm-format

Run Elm Test in CI
This commit is contained in:
Erik Simmler 2016-08-26 13:27:43 -04:00 committed by GitHub
commit 1e71d6c3f9
4 changed files with 52 additions and 22 deletions

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
.DS_Store
bin/configlet
bin/configlet.exe
bin/elm-format
elm-stuff
CHECKLIST
build.js

View file

@ -9,6 +9,8 @@ install:
- nvm use 6
- npm install -g elm@0.17.1 elm-test@0.17.3
- elm package install -y
- bin/install-elm-format linux
- export PATH=$PATH:$PWD/bin
script:
- bin/fetch-configlet

View file

@ -1,10 +1,38 @@
#!/usr/bin/env bash
# FORMAT
echo '-------------------------------------------------------'
echo "Checking Formatting"
which elm-format > /dev/null
if [ $? -ne 0 ]; then
echo "elm-format not found"
exit 1
fi
elm-format --yes --validate exercises/**/*{.example,Tests.elm}
if [ $? -ne 0 ]; then
echo "*******************************************************************"
echo "*******************************************************************"
echo "** elm-format failed **"
echo "** perhaps some of your changes are not formatted? **"
echo "** Please run elm-format before pushing. **"
echo "*******************************************************************"
echo "*******************************************************************"
exit 1
else
echo "formatting looks good!"
fi
# TEST
declare -i TEST_RESULT=0
FAILED_EXERCISES=''
elm-package install
for example_file in exercises/**/*.example
do
exercise_dir=$(dirname $example_file)
@ -27,11 +55,6 @@ do
# be kind, rewind
mv $exercise_dir/elm-package.json.disabled $exercise_dir/elm-package.json
if [ $WITH_FORMAT ]; then
elm-format $exercise_dir/*.elm --yes
fi
mv "$exercise_dir/$exercise.elm" "$exercise_dir/$exercise.example"
mv "$exercise_dir/$exercise.impl" "$exercise_dir/$exercise.elm"
done
@ -41,18 +64,3 @@ if [ $TEST_RESULT -ne 0 ]; then
printf $FAILED_EXERCISES
exit $TEST_RESULT
fi
if [ $WITH_FORMAT ]; then
git diff --quiet --exit-code
if [ $? -ne 0 ]; then
echo "*******************************************************************"
echo "*******************************************************************"
echo "**Git diff found - perhaps some of your changes are not formatted?*"
echo "** Please inspect the diffs before pushing. **"
echo "*******************************************************************"
echo "*******************************************************************"
exit 1
fi
fi

19
bin/install-elm-format Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
OS=$(
case $(uname) in
(Darwin*)
echo "mac";;
(Linux*)
echo "linux";;
(Windows*)
echo "windows";;
(*)
echo "linux";;
esac)
URL=https://github.com/avh4/elm-format/releases/download/0.4.0-alpha/elm-format-0.17-0.4.0-alpha-$OS-x64.tgz
curl -L $URL | tar -xvzO > bin/elm-format
chmod u+x bin/elm-format