Skip to content

Commit e9037f0

Browse files
committed
Added stylish-haskell to github-actions
1 parent f855a4a commit e9037f0

File tree

2 files changed

+66
-5
lines changed

2 files changed

+66
-5
lines changed

.github/workflows/haskell.yml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set cache version
1717
run: echo "CACHE_VERSION=pu4Aevoo" >> $GITHUB_ENV
1818

19-
- name: "Setup haskell"
19+
- name: "Setup Haskell"
2020
uses: haskell/actions/setup@v1
2121
id: setup-haskell
2222
with:
@@ -38,7 +38,7 @@ jobs:
3838
echo "::set-output name=weeknum::$(/bin/date -u "+%W")"
3939
4040
- uses: actions/cache@v3
41-
name: "Cache `cabal store`"
41+
name: "Cache cabal store"
4242
with:
4343
path: ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.setup-haskell.outputs.cabal-store }}
4444
key: cache-dependencies-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
@@ -65,3 +65,62 @@ jobs:
6565
- name: io-sim [test]
6666
run: cabal run io-sim:test
6767

68+
stylish-haskell:
69+
runs-on: ubuntu-22.04
70+
71+
steps:
72+
- name: Set cache version
73+
run: |
74+
echo "CACHE_VERSION=hi5eTh3A" >> $GITHUB_ENV
75+
echo "STYLISH_HASKELL_VERSION=0.13.0.0" >> $GITHUB_ENV
76+
77+
- name: "Install build environment (apt-get)"
78+
run: |
79+
sudo apt-get update
80+
sudo apt-get -y install fd-find
81+
82+
- name: "Setup Haskell"
83+
uses: haskell/actions/setup@v1
84+
id: setup-haskell
85+
with:
86+
ghc-version: 8.10.7
87+
cabal-version: 3.6.2.0
88+
89+
- name: "Setup cabal bin path"
90+
run: |
91+
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
92+
93+
- uses: actions/cache@v3
94+
name: "Cache cabal store"
95+
with:
96+
path: ${{ steps.setup-haskell.outputs.cabal-store }}
97+
key: cache-dependencies-${{ env.CACHE_VERSION }}
98+
99+
- uses: actions/cache@v3
100+
name: "Cache `stylish-haskell`"
101+
with:
102+
path: ~/.cabal/bin/stylish-haskell
103+
key: cabal-path-${{ env.STYLISH_HASKELL_VERSION }}
104+
105+
# Install stylish-haskell unless the right version is already available
106+
# from the cache
107+
- name: "Install `stylish-haskell`"
108+
run: |
109+
if [[ -x $(which stylish-haskell) && $(stylish-haskell --version) == "stylish-haskell ${{ env.STYLISH_HASKELL_VERSION }}" ]];
110+
then
111+
echo "Using cached `stylish-haskell`"
112+
else
113+
cabal install stylish-haskell-${{ env.STYLISH_HASKELL_VERSION }}
114+
fi
115+
116+
- name: "`stylish-haskell` version"
117+
run: |
118+
which stylish-haskell
119+
stylish-haskell --version
120+
121+
- uses: actions/checkout@v2
122+
123+
- name: "Run `stylish-haskell`"
124+
run: |
125+
./scripts/check-stylish.sh
126+
git diff --exit-code

scripts/check-stylish.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
set -euo pipefail
44
export LC_ALL=C.UTF-8
55

6-
fd . './io-sim' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell.yaml -i
7-
fd . './io-classes' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell.yaml -i
8-
fd . './strict-stm' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell.yaml -i
6+
[[ -x '/usr/bin/fd' ]] && FD="fd" || FD="fdfind"
7+
8+
$FD . './io-sim' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell.yaml -i
9+
$FD . './io-classes' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell.yaml -i
10+
$FD . './strict-stm' -e hs -E Setup.hs -X stylish-haskell -c .stylish-haskell.yaml -i

0 commit comments

Comments
 (0)