-
Notifications
You must be signed in to change notification settings - Fork 16
190 lines (150 loc) · 5.54 KB
/
haskell.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Haskell CI
on:
push:
branches: ["main"]
pull_request:
merge_group:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ghc: ["8.10.7", "9.2.8", "9.4.4", "9.6.2"]
cabal: ["3.8.1.0"]
os: [ubuntu-latest, macos-latest, windows-latest]
defaults:
run:
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
steps:
- name: "WIN: Setup MSYS2 and libraries"
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
base-devel
autoconf-wrapper
autoconf
automake
libtool
make
git
mingw-w64-x86_64-jq
- name: Set cache version
run: echo "CACHE_VERSION=pu4Aevoo_v1" >> $GITHUB_ENV
- name: "LINUX: Setup Haskell"
uses: haskell/actions/setup@v2
if: runner.os != 'Windows'
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- name: "WIN: Setup Haskell"
id: win-setup-haskell
if: runner.os == 'Windows'
run: |
# see https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/scripts/bootstrap/bootstrap-haskell
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=1 \
BOOTSTRAP_HASKELL_ADJUST_BASHRC=1 \
BOOTSTRAP_HASKELL_GHC_VERSION="${{ matrix.ghc }}" \
BOOTSTRAP_HASKELL_CABAL_VERSION="${{ matrix.cabal }}" \
sh
# MSYS2 doesn't inherit $GITHUB_PATH so this is needed
cat <(echo "source /c/ghcup/env") ~/.bashrc > ~/.bashrc.new
mv ~/.bashrc.new ~/.bashrc
source ~/.bashrc
# There is an issue with crt libraries, fixed by prepending the ghc
# mingw32 libraries directory to every other library directory.
echo "# Original cabal config extra-lib-dirs"
grep extra-lib-dirs /c/cabal/config
sed -i 's/C:\\msys64\\mingw64\\lib/C:\\ghcup\\ghc\\${{matrix.ghc}}\\mingw\\x86_64-w64-mingw32\\lib, C:\\msys64\\mingw64\\lib/g' /c/cabal/config
echo "# Modified cabal config extra-lib-dirs"
grep extra-lib-dirs /c/cabal/config
ghc --version
cabal --version
echo "cabal-store=$(dirname $(cabal --help | tail -1 | tr -d ' '))\\store" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- name: "Configure cabal.project.local"
run: |
cat ./.github/workflows/cabal.project.local > ./cabal.project.local
cat ./cabal.project.local
- name: "Cabal update"
run: cabal update
- name: Record dependencies
id: record-deps
run: |
cabal build all --dry-run
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
echo "weeknum=$(/bin/date -u "+%W")" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: "Cache cabal store"
with:
path: ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.setup-haskell.outputs.cabal-store }}
key: cache-dependencies-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
restore-keys: cache-dependencies-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
- uses: actions/cache@v3
name: "Cache `dist-newstyle`"
with:
path: |
dist-newstyle
!dist-newstyle/**/.git
key: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ steps.record-deps.outputs.weeknum }}
restore-keys: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
- name: Build dependencies
run: |
cabal build --only-dependencies all
- name: Build projects [build]
run: cabal build all
- name: Build documentation [haddock]
run: cabal haddock all
- name: io-sim [test]
run: cabal run io-sim:test
- name: si-timers [test]
run: cabal run si-timers:test
- name: strict-mvar [test]
run: cabal run strict-mvar:test
stylish-haskell:
runs-on: ubuntu-22.04
env:
STYLISH_HASKELL_VERSION: "0.14.4.0"
steps:
- name: Set cache version
run: |
echo "CACHE_VERSION=hi5eTh3A" >> $GITHUB_ENV
- name: "Install build environment (apt-get)"
run: |
sudo apt-get update
sudo apt-get -y install fd-find
- name: "Setup Haskell"
uses: haskell/actions/setup@v2
id: setup-haskell
with:
ghc-version: 9.2.8
cabal-version: 3.8.1.0
- name: "Setup cabal bin path"
run: |
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
- uses: actions/cache@v3
name: "Cache cabal store"
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: cache-dependencies-${{ env.CACHE_VERSION }}
- name: Download stylish-haskell
run: |
version="${{ env.STYLISH_HASKELL_VERSION }}"
curl -sL \
"https://github.com/haskell/stylish-haskell/releases/download/v$version/stylish-haskell-v$version-linux-x86_64.tar.gz" \
| tar -C "/tmp" -xz
echo "PATH=/tmp/stylish-haskell-v$version-linux-x86_64:$PATH" >> $GITHUB_ENV
- name: "`stylish-haskell` version"
run: |
which stylish-haskell
stylish-haskell --version
- uses: actions/checkout@v3
- name: "Run `stylish-haskell`"
run: |
./scripts/check-stylish.sh
git diff --exit-code