1
- name : Haskell CI using Cabal
1
+ name : Haskell CI
2
2
3
3
on :
4
4
push :
@@ -19,183 +19,96 @@ jobs:
19
19
- os : macos-latest
20
20
ghc : " 8.10.7"
21
21
22
- env :
23
- # we need the LD_LIBRARY_PATH env var here because we ended up installing libsecp256k1 into /usr/local,
24
- # pkg-config, *does* return the proper location, but the library does not appear to be properly referenced.
25
- # FIXME: this is arguably a bug, and pkg-config should return the right values!
26
- LD_LIBRARY_PATH : ${{ (matrix.os != 'windows-latest' && '/usr/local/lib') || '' }}
27
-
28
22
steps :
29
- - name : " WIN: Install System Dependencies via pacman (msys2)"
30
- if : runner.os == 'Windows'
31
- run : |
32
- # ghcup should be installed on current GHA Windows runners. Let's use ghcup to run
33
- # pacman, to install the necessary dependencies, ...
34
- ghcup run --mingw-path -- pacman --noconfirm -S `
35
- mingw-w64-x86_64-pkg-config `
36
- mingw-w64-x86_64-pcre `
37
- mingw-w64-x86_64-libsodium `
38
- base-devel `
39
- autoconf-wrapper `
40
- autoconf `
41
- automake `
42
- libtool `
43
- make
44
-
45
- # this seems to break something. It _must_ come after the pacman setup
46
- # above. It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and
47
- # as such we'd need pacman.exe instead.
48
- - name : Setup Haskell
49
- if : runner.os == 'Linux'
50
- run : |
51
- # Use GHCUP to manage ghc/cabal
52
- ghcup install ghc --set ${{ matrix.ghc }}
53
- ghcup install cabal --set 3.10.1.0
54
-
55
- ghc --version
56
- cabal --version
57
-
58
- - name : " MAC: Setup Haskell"
59
- if : runner.os == 'macOS'
23
+ - name : Install Haskell
60
24
uses : input-output-hk/actions/haskell@latest
25
+ id : setup-haskell
61
26
with :
62
27
ghc-version : ${{ matrix.ghc }}
63
28
cabal-version : 3.12.1.0
64
29
65
- - name : " WIN: fixup cabal config"
66
- if : runner.os == 'Windows'
67
- run : |
68
- # make sure cabal knows about msys64, and mingw64 tools. Not clear why C:/cabal/config is empty
69
- # and C:/cabal doesn't even exist. The ghcup bootstrap file should have create it in the image:
70
- # See https://github.com/haskell/ghcup-hs/blob/787edc17af4907dbc51c85e25c490edd8d68b80b/scripts/bootstrap/bootstrap-haskell#L591
71
- # So we'll do it by hand here for now.
72
- #
73
- # We'll _not_ add extra-include-dirs, or extra-lib-dirs, and rely on what's shipped with GHC.
74
- # https://github.com/msys2/MINGW-packages/issues/10837#issuecomment-1047105402
75
- # https://gitlab.haskell.org/ghc/ghc/-/issues/21111
76
- # if we _do_ want them, this would be the lines to add below
77
-
78
- $ghcMingwDir = Join-Path -Path $(ghc --print-libdir) `
79
- -ChildPath ../mingw/x86_64-*-mingw32/lib/ `
80
- -Resolve
81
-
82
- cabal user-config -a "extra-prog-path: C:/msys64/mingw64/bin, C:/msys64/usr/bin" `
83
- -a "extra-include-dirs: C:/msys64/mingw64/include" `
84
- -a ("extra-lib-dirs: {0}, C:/msys64/mingw64/lib" -f $ghcMingwDir) `
85
- -f init
86
-
87
- - name : Set cache version
88
- run : echo "CACHE_VERSION=grFfw7r" >> $GITHUB_ENV
89
-
90
- - uses : actions/checkout@v2
91
-
92
- - name : " [PowerShell] Add build script path"
93
- if : runner.os == 'Windows'
94
- shell : pwsh
95
- run : Add-Content $env:GITHUB_PATH "$(pwd)/.github/bin"
96
-
97
- - name : " [Bash] Add build script path"
98
- if : runner.os != 'Windows'
99
- run : echo "$(pwd)/.github/bin" >> $GITHUB_PATH
100
-
101
- - name : " LINUX: Install build environment (apt-get)"
102
- if : runner.os == 'Linux'
103
- run : |
104
- sudo apt-get update
105
- sudo apt-get -y install libsodium23 libsodium-dev
106
- sudo apt-get -y remove --purge software-properties-common
107
- sudo apt-get -y autoremove
108
-
109
- - name : " MAC: Install build environment (brew)"
110
- if : runner.os == 'macOS'
111
- run : |
112
- brew reinstall libsodium
113
- brew install pcre
30
+ - uses : actions/checkout@v4
114
31
115
32
- name : Cabal update
116
33
run : cabal update
117
34
118
- - name : " Setup cabal-store"
119
- id : cabal-store
120
- shell : bash
121
- run : |
122
- cabal_config_file="$(cabal help user-config | tail -n 1 | xargs)"
123
-
124
- if [[ '${{ runner.os }}' != 'Windows' ]]; then
125
- echo "cabal-store=$(dirname "$cabal_config_file")/store" | tee -a "$GITHUB_OUTPUT"
126
- else
127
- echo "cabal-store=C:\\cabal\\store" | tee -a "$GITHUB_OUTPUT"
128
- fi
129
-
130
- - name : " Check cabal-store"
131
- shell : bash
132
- run : echo '${{ steps.cabal-store.outputs.cabal-store }}'
133
-
134
35
- name : Configure build
135
36
shell : bash
136
37
run : |
137
- if [ "${{github.event.inputs.tests}}" == "all" ]; then
138
- echo "Reconfigure cabal projects to run tests for all dependencies"
139
- sed -i 's|tests: False|tests: True|g' cabal.project
140
- fi
141
-
142
38
cp ".github/workflows/cabal.project.local.ci.$(uname -s)" cabal.project.local
143
-
144
39
echo "# cabal.project.local"
145
40
cat cabal.project.local
146
41
42
+ # A dry run `build all` operation does *NOT* download anything, it just looks at the package
43
+ # indices to generate an install plan.
44
+ - name : Build dry run
45
+ run : cabal build all --enable-tests --dry-run --minimize-conflict-set
46
+
47
+ # From the install plan a dependency list is generated here.
147
48
- name : Record dependencies
148
49
id : record-deps
149
50
run : |
150
- cabal build all --dry-run
51
+ # The tests call out to msys2 commands. We generally do not want to mix toolchains, so
52
+ # we are very deliberate about only adding msys64 to the path where absolutely necessary.
53
+ ${{ (runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)') || '' }}
151
54
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
152
55
153
- - name : " OUTPUT Record weeknum"
154
- shell : bash
155
- run : echo "weeknum=$(/usr/bin/date -u "+%W")" >> $GITHUB_OUTPUT
156
-
157
- - name : Cache Cabal store
158
- uses : actions/cache@v4
159
- with :
160
- path : ${{ steps.cabal-store.outputs.cabal-store }}
161
- key : cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
162
- restore-keys : |
163
- cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
164
- cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
165
-
166
- - name : " Cache `dist-newstyle`"
167
- uses : actions/cache@v4
56
+ # From the dependency list the cached dependencies is restored.
57
+ # The hash of `dependencies.txt` is used as a part of the cache key because that will be stable
58
+ # until the `index-state` values in the `cabal.project` file changes.
59
+ - name : Restore cached dependencies
60
+ uses : actions/cache/restore@v4
61
+ id : cache
168
62
with :
169
63
path : |
64
+ ${{ steps.setup-haskell.outputs.cabal-store }}
170
65
dist-newstyle
171
- !dist-newstyle/**/.git
172
- key : cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ steps.record-deps.outputs.weeknum }}
173
- restore-keys : cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
66
+ key : cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
174
67
68
+ # The dependencies are installed. If the cache is found and restored in the previous step,
69
+ # this should be a no-op. If the cache key is not found the build assets are produced for the
70
+ # caching in the next step.
175
71
- name : Install dependencies
176
- run : cabal build all --only-dependencies
72
+ run : cabal build all --enable-tests -- only-dependencies -j --ghc-option=-j4
177
73
178
- - name : Build
179
- run : cabal build all
74
+ # Always store the cabal cache.
75
+ # This may benignly fail if the cache key is already populated.
76
+ - name : Cache Cabal store
77
+ uses : actions/cache/save@v4
78
+ with :
79
+ path : |
80
+ ${{ steps.setup-haskell.outputs.cabal-store }}
81
+ dist-newstyle
82
+ key : cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
180
83
181
- - name : Run unit tests
182
- shell : bash
84
+ - name : Build Windows
85
+ if : runner.os == 'Windows'
86
+ id : build-step-windows
183
87
run : |
184
- if [ "${{ runner.os }}" != "Windows" ] || [ "${{ matrix.ghc }}" != "9.6.5" ]; then
185
- # This test is currently broken with GHC 9.6 on windows.
186
- # This could be related to:
187
- # * UTF8 encoding and the use of emoji's in the output.
188
- # * unhandled PEi386 relocation type 14 (less likely).
189
- cabal test
190
- fi
88
+ cabal build all --enable-tests -j --ghc-option=-j4
89
+
90
+ if ( "${{ runner.os }}" -eq "Windows" ) {
91
+ echo "exe-location=D:\a\cardano-addresses\cardano-addresses\dist-newstyle\build\x86_64-windows\ghc-${{ matrix.ghc }}\cardano-addresses-4.0.0\x\cardano-address\build\cardano-address\cardano-address.exe" >> $env:GITHUB_OUTPUT
92
+ }
93
+
94
+ - name : Build Linux/Macos
95
+ if : runner.os != 'Windows'
96
+ run : cabal build all --enable-tests -j --ghc-option=-j4
97
+
98
+ - name : Running all tests
99
+ env :
100
+ # these two are msys2 env vars, they have no effect on non-msys2 installs.
101
+ MSYS2_PATH_TYPE : inherit
102
+ MSYSTEM : MINGW64
103
+ run : cabal test all --enable-tests --test-show-details=direct -j1
191
104
192
105
- name : Upload Windows artifact
193
106
uses : actions/upload-artifact@v4
194
107
if : runner.os == 'Windows'
195
108
with :
196
109
name : cardano-address-${{ matrix.os }}-${{ matrix.ghc }}-exe
197
- path : ${{ steps.cabal-store .outputs.cabal-store }}
198
- retention-days : 2
110
+ path : ${{ steps.build-step-windows .outputs.exe-location }}
111
+ retention-days : 1
199
112
200
113
- name : Preparing Linux/Macos artifact
201
114
if : runner.os != 'Windows'
@@ -219,9 +132,9 @@ jobs:
219
132
echo "artifactPath=artifacts/$(artifactName)" >> $GITHUB_ENV
220
133
221
134
- name : Upload Linux/Macos artifact
222
- uses : actions/upload-artifact@v4
223
135
if : runner.os != 'Windows'
136
+ uses : actions/upload-artifact@v4
224
137
with :
225
138
name : cardano-address-${{ matrix.os }}-${{ matrix.ghc }}
226
139
path : ${{ env.artifactPath }}
227
- retention-days : 2
140
+ retention-days : 1
0 commit comments