From ecb6e88d147cb0c8f692608c9dc5503a71b55367 Mon Sep 17 00:00:00 2001 From: Joshua Stoutenburg Date: Fri, 26 Aug 2016 01:59:03 -0600 Subject: [PATCH 1/2] Run Elm Test in CI --- .gitignore | 1 + .travis.yml | 2 ++ bin/build.sh | 52 ++++++++++++++++++++++++------------------ bin/install-elm-format | 23 +++++++++++++++++++ 4 files changed, 56 insertions(+), 22 deletions(-) create mode 100755 bin/install-elm-format diff --git a/.gitignore b/.gitignore index 8303c89..798b577 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .DS_Store bin/configlet bin/configlet.exe +bin/elm-format elm-stuff CHECKLIST build.js diff --git a/.travis.yml b/.travis.yml index 5928b77..ad10645 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/bin/build.sh b/bin/build.sh index 1cb053f..6a84349 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -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 - diff --git a/bin/install-elm-format b/bin/install-elm-format new file mode 100755 index 0000000..b483460 --- /dev/null +++ b/bin/install-elm-format @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# choose file for system +# Example: +# bin/install-elm-format linux +# bin/install-elm-format mac +case $1 in + mac) + FILE=https://github.com/avh4/elm-format/releases/download/0.4.0-alpha/elm-format-0.17-0.4.0-alpha-mac-x64.tgz + ;; + linux) + FILE=https://github.com/avh4/elm-format/releases/download/0.4.0-alpha/elm-format-0.17-0.4.0-alpha-linux-x64.tgz + ;; + *) + echo "please specify operating system" + exit 1 +esac + +# download file into bin +curl -L $FILE | tar -xvzO > bin/elm-format + +# give user execute +chmod u+x bin/elm-format From 359ad21a086cd2ff35bd7d19211c833441360030 Mon Sep 17 00:00:00 2001 From: Joshua Stoutenburg Date: Fri, 26 Aug 2016 10:50:55 -0600 Subject: [PATCH 2/2] Detect OS for Elm Format Download --- bin/install-elm-format | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/bin/install-elm-format b/bin/install-elm-format index b483460..b5a7bb2 100755 --- a/bin/install-elm-format +++ b/bin/install-elm-format @@ -1,23 +1,19 @@ #!/usr/bin/env bash -# choose file for system -# Example: -# bin/install-elm-format linux -# bin/install-elm-format mac -case $1 in - mac) - FILE=https://github.com/avh4/elm-format/releases/download/0.4.0-alpha/elm-format-0.17-0.4.0-alpha-mac-x64.tgz - ;; - linux) - FILE=https://github.com/avh4/elm-format/releases/download/0.4.0-alpha/elm-format-0.17-0.4.0-alpha-linux-x64.tgz - ;; - *) - echo "please specify operating system" - exit 1 -esac +OS=$( +case $(uname) in + (Darwin*) + echo "mac";; + (Linux*) + echo "linux";; + (Windows*) + echo "windows";; + (*) + echo "linux";; +esac) -# download file into bin -curl -L $FILE | tar -xvzO > bin/elm-format +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 -# give user execute chmod u+x bin/elm-format