-
-
Notifications
You must be signed in to change notification settings - Fork 3
136 lines (114 loc) · 3.32 KB
/
code-style.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Code Style
on:
push:
jobs:
hlint:
runs-on: ubuntu-20.04
env:
HLINT_VERSION: '3.5'
steps:
# (1) -> Init
- name: Checkout git repository
uses: actions/checkout@v4
- name: Prepare ~/.local/bin
run: |
mkdir -p ~/.local/bin
export PATH=~/.local/bin:$PATH
# (2) -> Setup cache
- name: Cache ~/.local/bin
id: cache-local-bin
uses: actions/cache@v3
with:
path: ~/.local/bin
key: local-bin-${{ env.HLINT_VERSION }}
# (3) -> Prepare and install dependencies
- name: Setup hlint
if: steps.cache-local-bin.outputs.cache-hit != 'true'
run: |
curl -L $HLINT_URL | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/hlint'
env:
HLINT_URL: https://github.com/ndmitchell/hlint/releases/download/v${{ env.HLINT_VERSION }}/hlint-${{ env.HLINT_VERSION }}-x86_64-linux.tar.gz
# (4) -> Run hlint
- name: Run hlint
run: |
hlint shared-common
hlint registry-public
hlint registry-server
hlint wizard-common
hlint wizard-public
hlint wizard-server
fourmolu:
runs-on: ubuntu-20.04
env:
FOURMOLU_VERSION: '0.8.2.0'
HPACK_VERSION: '0.34.2'
steps:
# (1) -> Init
- name: Checkout git repository
uses: actions/checkout@v4
- name: Prepare ~/.local/bin
run: |
mkdir -p ~/.local/bin
export PATH=~/.local/bin:$PATH
# (2) -> Setup cache
- name: Cache ~/.local/bin
id: cache-local-bin
uses: actions/cache@v3
with:
path: ~/.local/bin
key: local-bin-${{ env.FOURMOLU_VERSION }}-${{ env.HPACK_VERSION }}
# (3) -> Prepare and install dependencies
- name: Setup hpack && fourmolu
if: steps.cache-local-bin.outputs.cache-hit != 'true'
run: |
curl -L $HPACK_URL --output hpack.gz
gzip -d hpack.gz
chmod +x hpack
cp ./hpack ~/.local/bin/hpack
curl -L $FOURMOLU_URL --output fourmolu
chmod +x fourmolu
cp ./fourmolu ~/.local/bin/fourmolu
env:
HPACK_URL: https://github.com/sol/hpack/releases/download/${{ env.HPACK_VERSION}}/hpack_linux.gz
FOURMOLU_URL: https://github.com/fourmolu/fourmolu/releases/download/v${{ env.FOURMOLU_VERSION }}/fourmolu-${{ env.FOURMOLU_VERSION }}-linux-x86_64
# (4) -> Generate cabal files
- name: Generate cabal files
run: |
cd shared-common
hpack --force
cd ..
cd registry-public
hpack --force
cd ..
cd registry-server
hpack --force
cd ..
cd wizard-common
hpack --force
cd ..
cd wizard-public
hpack --force
cd ..
cd wizard-server
hpack --force
cd ..
# (5) -> Run fourmolu
- name: Run fourmolu
run: |
FILES=$(find \
shared-common/src \
registry-public/src \
registry-server/src registry-server/test \
wizard-common/src wizard-common/test \
wizard-public/src \
wizard-server/src wizard-server/test \
-name '*.hs'
)
RET=0
for FILE in $FILES; do
if ! fourmolu --mode check $FILE; then
echo "Unformatted file: " . $FILE
RET=1
fi
done
exit $RET