on master help sign in
Stylize Travis
commit25c94dfa92d0d93444141529082dc494e09ee4a6 authorEcho Nolan <echo@echonolan.net> dateMon 3 Oct 2016, 18:54 (10 years ago) parentb5d05d6
3 files changed+202
.stylish-haskell.yaml+154 .travis.yml+2 check-stylish.sh+46
.stylish-haskell.yamlnew file+154
@@ -0,0 +1,154 @@
1+# stylish-haskell configuration file
2+# ==================================
3+
4+# The stylish-haskell tool is mainly configured by specifying steps. These steps
5+# are a list, so they have an order, and one specific step may appear more than
6+# once (if needed). Each file is processed by these steps in the given order.
7+steps:
8+ # Convert some ASCII sequences to their Unicode equivalents. This is disabled
9+ # by default.
10+ # - unicode_syntax:
11+ # # In order to make this work, we also need to insert the UnicodeSyntax
12+ # # language pragma. If this flag is set to true, we insert it when it's
13+ # # not already present. You may want to disable it if you configure
14+ # # language extensions using some other method than pragmas. Default:
15+ # # true.
16+ # add_language_pragma: true
17+
18+ # Import cleanup
19+ - imports:
20+ # There are different ways we can align names and lists.
21+ #
22+ # - global: Align the import names and import list throughout the entire
23+ # file.
24+ #
25+ # - file: Like global, but don't add padding when there are no qualified
26+ # imports in the file.
27+ #
28+ # - group: Only align the imports per group (a group is formed by adjacent
29+ # import lines).
30+ #
31+ # - none: Do not perform any alignment.
32+ #
33+ # Default: global.
34+ align: none
35+
36+ # Folowing options affect only import list alignment.
37+ #
38+ # List align has following options:
39+ #
40+ # - after_alias: Import list is aligned with end of import including
41+ # 'as' and 'hiding' keywords.
42+ #
43+ # > import qualified Data.List as List (concat, foldl, foldr, head,
44+ # > init, last, length)
45+ #
46+ # - with_alias: Import list is aligned with start of alias or hiding.
47+ #
48+ # > import qualified Data.List as List (concat, foldl, foldr, head,
49+ # > init, last, length)
50+ #
51+ # - new_line: Import list starts always on new line.
52+ #
53+ # > import qualified Data.List as List
54+ # > (concat, foldl, foldr, head, init, last, length)
55+ #
56+ # Default: after_alias
57+ list_align: after_alias
58+
59+ # Long list align style takes effect when import is too long. This is
60+ # determined by 'columns' setting.
61+ #
62+ # - inline: This option will put as much specs on same line as possible.
63+ #
64+ # - new_line: Import list will start on new line.
65+ #
66+ # - new_line_multiline: Import list will start on new line when it's
67+ # short enough to fit to single line. Otherwise it'll be multiline.
68+ #
69+ # - multiline: One line per import list entry.
70+ # Type with contructor list acts like single import.
71+ #
72+ # > import qualified Data.Map as M
73+ # > ( empty
74+ # > , singleton
75+ # > , ...
76+ # > , delete
77+ # > )
78+ #
79+ # Default: inline
80+ long_list_align: inline
81+
82+ # List padding determines indentation of import list on lines after import.
83+ # This option affects 'list_align' and 'long_list_align'.
84+ list_padding: 4
85+
86+ # Separate lists option affects formating of import list for type
87+ # or class. The only difference is single space between type and list
88+ # of constructors, selectors and class functions.
89+ #
90+ # - true: There is single space between Foldable type and list of it's
91+ # functions.
92+ #
93+ # > import Data.Foldable (Foldable (fold, foldl, foldMap))
94+ #
95+ # - false: There is no space between Foldable type and list of it's
96+ # functions.
97+ #
98+ # > import Data.Foldable (Foldable(fold, foldl, foldMap))
99+ #
100+ # Default: true
101+ separate_lists: false
102+
103+ # Language pragmas
104+ - language_pragmas:
105+ # We can generate different styles of language pragma lists.
106+ #
107+ # - vertical: Vertical-spaced language pragmas, one per line.
108+ #
109+ # - compact: A more compact style.
110+ #
111+ # - compact_line: Similar to compact, but wrap each line with
112+ # `{-#LANGUAGE #-}'.
113+ #
114+ # Default: vertical.
115+ style: compact
116+
117+ # Align affects alignment of closing pragma brackets.
118+ #
119+ # - true: Brackets are aligned in same collumn.
120+ #
121+ # - false: Brackets are not aligned together. There is only one space
122+ # between actual import and closing bracket.
123+ #
124+ # Default: true
125+ align: true
126+
127+ # stylish-haskell can detect redundancy of some language pragmas. If this
128+ # is set to true, it will remove those redundant pragmas. Default: true.
129+ remove_redundant: true
130+
131+ # Align the types in record declarations
132+ # - records: {}
133+
134+ # Replace tabs by spaces. This is disabled by default.
135+ # - tabs:
136+ # # Number of spaces to use for each tab. Default: 8, as specified by the
137+ # # Haskell report.
138+ # spaces: 8
139+
140+ # Remove trailing whitespace
141+ - trailing_whitespace: {}
142+
143+# A common setting is the number of columns (parts of) code will be wrapped
144+# to. Different steps take this into account. Default: 80.
145+columns: 80
146+
147+# Sometimes, language extensions are specified in a cabal file or from the
148+# command line instead of using language pragmas in the file. stylish-haskell
149+# needs to be aware of these, so it can parse the file correctly.
150+#
151+# No language extensions are enabled by default.
152+# language_extensions:
153+ # - TemplateHaskell
154+ # - QuasiQuotes
.travis.yml+2
@@ -8,6 +8,7 @@ env:
88
99matrix:
1010 include:
11+ - env: STYLISH=YES
1112 - os: osx
1213 env: CABALVER="1.24" GHCVER="8.0.1" TESTS="test_c"
1314 compiler: ": #GHC 8.0.1"
@@ -66,6 +67,7 @@ before_install:
6667 export ZCAT=gzcat;
6768 export PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig:$PKG_CONFIG_PATH;
6869 fi
70+ - if [ -n "$STYLISH" ]; then ./check-stylish.sh; exit $?; fi
6971
7072install:
7173 - cabal --version
check-stylish.shnew file+46
@@ -0,0 +1,46 @@
1+#!/bin/bash
2+
3+set -e
4+
5+function fail_maybe_explain {
6+ if [ -n "$TRAVIS" ];
7+ then
8+ echo "Run ./check-stylish.sh locally to stylize your files / debug this"
9+ fi
10+ exit 1
11+}
12+
13+if [ -n "$TRAVIS" ];
14+then
15+ # It takes a while to compile, let's not tax Travis' infrastructure for no
16+ # reason. We can't cache it via cabsnap because that's based on the install-
17+ # plan for Idris, which of course doesn't have stylish-haskell as a
18+ # dependency.
19+ STYLISH_EXE=$(mktemp)
20+ wget -O $STYLISH_EXE "https://s3-us-west-2.amazonaws.com/idris-travis-binaries/stylish-haskell"
21+ chmod +x $STYLISH_EXE
22+else
23+ STYLISH_EXE=stylish-haskell
24+fi
25+
26+
27+find . -name \*.hs -and \( -not -name Setup.hs \) | xargs $STYLISH_EXE -i > stylish-out 2>&1
28+
29+# It doesn't do exit codes properly, so we just check if it outputted anything.
30+if [ -s stylish-out ];
31+then
32+ echo "Stylish-haskell reported an error :("
33+ cat stylish-out
34+ fail_maybe_explain
35+fi
36+
37+rm stylish-out
38+
39+if git status --porcelain|grep .; # true if there was any output
40+then
41+ echo "Running stylish-haskell changed 1 or more files :(";
42+ fail_maybe_explain
43+else
44+ echo "Stylish is happy :)";
45+ exit 0;
46+fi