forked from depressed-pho/HsOpenSSL
-
Notifications
You must be signed in to change notification settings - Fork 33
196 lines (167 loc) · 7.12 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
191
192
193
194
195
196
name: Haskell CI
on:
push:
create:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Add more elements to this list to run multiple instances of the build in CI. Increasing the
# number instances is a good way to trigger flaky build failures
n: [1]
ghc:
- "8.0.2"
- "8.2.2"
- "8.4.4"
- "8.6.5"
- "8.8.4"
- "8.10.7"
- "9.0.2"
- "9.2.8"
- "9.4.8"
- "9.6.6"
- "9.8.2"
- "9.10.1"
# FIXME: Add windows-latest back to CI once it is passing.
os: [ubuntu-latest, macos-latest]
# Action fails to install GHC < 8.10 on OSX with a generic error
# messsage:
#
# Error: All install methods for ghc 8.0.2 failed
#
# On the other hand, 8.10 and 9.0 fail due to LLVM:
#
# Warning: Couldn't figure out LLVM version!
# Make sure you have installed LLVM between [9 and 13)
exclude:
- {ghc: "8.0.2", os: "macos-latest"}
- {ghc: "8.2.2", os: "macos-latest"}
- {ghc: "8.4.4", os: "macos-latest"}
- {ghc: "8.6.5", os: "macos-latest"}
- {ghc: "8.8.4", os: "macos-latest"}
- {ghc: "8.10.7", os: "macos-latest"}
- {ghc: "9.0.2", os: "macos-latest"}
env:
# OpenSSL is installed in a non-standard location in MacOS. See
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-latest-Readme.md
PKG_CONFIG_PATH: ${{ (matrix.os == 'macos-latest' && '/usr/lib/pkgconfig:/usr/local/opt/[email protected]/lib/pkgconfig') || (matrix.os == 'ubuntu-latest' && '/usr/lib/pkgconfig:/usr/local/lib/pkgconfig') || '' }}
# FIXME: this is arguably a bug, and pkg-config should return the right values!
LD_LIBRARY_PATH: ${{ (matrix.os != 'windows-latest' && '/usr/local/lib') || '' }}
steps:
- uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
- name: "WIN: Install System Dependencies via pacman (msys2)"
if: runner.os == 'Windows'
run: |
# ghcup should be installed on current GHA Windows runners. Let's use ghcup to run
# pacman, to install the necessary dependencies, ...
ghcup run -- pacman --noconfirm -S `
mingw-w64-x86_64-pkg-config `
mingw-w64-x86_64-openssl `
base-devel `
autoconf-wrapper `
autoconf `
automake `
libtool `
make
# this seems to break something. It _must_ come after the pacman setup
# above. It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and
# as such we'd need pacman.exe instead.
- name: "WIN: Setup Haskell"
if: runner.os == 'Windows'
run: |
# Use GHCUP to manage ghc/cabal
ghcup install ghc --set ${{ matrix.ghc }}
ghcup install cabal --set 3.6.2.0
ghc --version
cabal --version
- name: "WIN: fixup cabal config"
if: runner.os == 'Windows'
run: |
# make sure cabal knows about msys64, and mingw64 tools. Not clear why C:/cabal/config is empty
# and C:/cabal doesn't even exist. The ghcup bootstrap file should have create it in the image:
# See https://github.com/haskell/ghcup-hs/blob/787edc17af4907dbc51c85e25c490edd8d68b80b/scripts/bootstrap/bootstrap-haskell#L591
# So we'll do it by hand here for now.
#
# We'll _not_ add extra-include-dirs, or extra-lib-dirs, and rely on what's shipped with GHC.
# https://github.com/msys2/MINGW-packages/issues/10837#issuecomment-1047105402
# https://gitlab.haskell.org/ghc/ghc/-/issues/21111
# if we _do_ want them, this would be the lines to add below
$ghcMingwDir = Join-Path -Path $(ghc --print-libdir) `
-ChildPath ../mingw/x86_64-*-mingw32/lib/ `
-Resolve
cabal user-config -a "extra-prog-path: C:/msys64/mingw64/bin, C:/msys64/usr/bin" `
-a "extra-include-dirs: C:/msys64/mingw64/include" `
-a ("extra-lib-dirs: {0}, C:/msys64/mingw64/lib" -f $ghcMingwDir) `
-f init
- name: "Setup cabal-store"
id: cabal-store
shell: bash
run: |
cabal_config_file="$(cabal help user-config | tail -n 1 | xargs)"
if [[ '${{ runner.os }}' != 'Windows' ]]; then
echo "cabal-store=$(dirname "$cabal_config_file")/store" | tee -a "$GITHUB_OUTPUT"
else
echo "cabal-store=C:\\cabal\\store" | tee -a "$GITHUB_OUTPUT"
fi
- name: "Check cabal-store"
shell: bash
run: echo '${{ steps.cabal-store.outputs.cabal-store }}'
- uses: actions/checkout@v2
- name: "[PowerShell] Add build script path"
if: runner.os == 'Windows'
shell: pwsh
run: Add-Content $env:GITHUB_PATH "$(pwd)/.github/bin"
- name: "[Bash] Add build script path"
if: runner.os != 'Windows'
run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH
- name: "LINUX: Install build environment (apt-get)"
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get -y install libsystemd0 libsystemd-dev
sudo apt-get -y remove --purge software-properties-common
sudo apt-get -y autoremove
- name: "MAC: Install build environment"
if: runner.os == 'macOS'
run: brew install autoconf automake libtool openssl@3
- name: Cabal update
run: cabal update
- name: Configure build
shell: bash
run: |
if [ "${{github.event.inputs.tests}}" == "all" ]; then
echo "Reconfigure cabal projects to run tests for all dependencies"
sed -i 's|tests: False|tests: True|g' cabal.project
fi
cp ".github/workflows/cabal.project.local.ci" cabal.project.local
echo "# cabal.project.local"
cat cabal.project.local
- 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
- name: Cache Cabal store
uses: actions/cache@v2
with:
path: ${{ steps.cabal-store.outputs.cabal-store }}
key: cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
restore-keys: |
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
- name: Build
run: cabal build all --enable-tests
- name: Run tests
env:
TMPDIR: ${{ runner.temp }}
TMP: ${{ runner.temp }}
KEEP_WORKSPACE: 1
run: |
# The tests call out to msys2 commands. We generally do not want to mix toolchains, so
# we are very deliberate about only adding msys64 to the path where absolutely necessary.
${{ (runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)') || '' }}
cabal test all --enable-tests