17
17
build :
18
18
runs-on : ${{ matrix.os }}
19
19
20
- defaults :
21
- run :
22
- shell : ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
23
-
24
20
strategy :
25
21
fail-fast : false
26
22
matrix :
@@ -36,84 +32,88 @@ jobs:
36
32
SECP256K1_REF : ac83be33d0956faf6b7f61a60ab524ef7d6a473a
37
33
# OpenSSL is installed in a non-standard location in MacOS. See
38
34
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md
39
- PKG_CONFIG_PATH :
${{ matrix.os == 'macos-latest' && '/usr/local/opt/[email protected] /lib/pkgconfig' || '' }}
35
+ PKG_CONFIG_PATH :
${{ (matrix.os == 'macos-latest' && '/usr/lib/pkgconfig:/usr/local/opt/[email protected] /lib/pkgconfig') || (matrix.os == 'ubuntu-latest' && '/usr/lib/pkgconfig') || '' }}
36
+
37
+ # we need the LD_LIBRARY_PATH env var here because we ended up installing libsecp256k1 into /usr/local,
38
+ # pkg-config, *does* return the proper location, but the library does not appear to be properly referenced.
39
+ # FIXME: this is arguably a bug, and pkg-config should return the right values!
40
+ LD_LIBRARY_PATH : ${{ (matrix.os != 'windows-latest' && '/usr/local/lib') || '' }}
40
41
41
42
steps :
42
-
43
- - name : " WIN: Setup MSYS2 and libraries"
44
- if : runner.os == 'Windows'
45
- uses : msys2/setup-msys2@v2
46
- with :
47
- update : true
48
- install : >-
49
- base-devel
50
- autoconf-wrapper
51
- autoconf
52
- automake
53
- libtool
54
- make
55
- git
56
- mingw-w64-x86_64-pkg-config
57
- mingw-w64-x86_64-toolchain
58
- mingw-w64-x86_64-libsodium
59
- mingw-w64-x86_64-jq
60
-
61
- - name : " LINUX,MAC: Setup haskell"
62
- if : runner.os != 'Windows'
63
- uses : haskell/actions/setup@v1
64
- id : setup-haskell
65
- with :
66
- ghc-version : ${{ matrix.ghc }}
67
- cabal-version : 3.8.1.0
68
-
69
- - name : " WIN: Setup Haskell"
70
- id : win-setup-haskell
43
+ - name : " WIN: Install System Dependencies via pacman (msys2)"
71
44
if : runner.os == 'Windows'
72
45
run : |
73
- # see https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/scripts/bootstrap/bootstrap-haskell
74
- curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \
75
- BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
76
- BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=1 \
77
- BOOTSTRAP_HASKELL_ADJUST_BASHRC=1 \
78
- BOOTSTRAP_HASKELL_GHC_VERSION="${{ matrix.ghc }}" \
79
- BOOTSTRAP_HASKELL_CABAL_VERSION="3.6.2.0" \
80
- sh
81
-
82
- # MSYS2 doesn't inherit $GITHUB_PATH so this is needed
83
- cat <(echo "source /c/ghcup/env") ~/.bashrc > ~/.bashrc.new
84
- mv ~/.bashrc.new ~/.bashrc
85
-
86
- source ~/.bashrc
87
-
88
- # There is an issue with crt libraries, fixed by prepending the ghc
89
- # mingw32 libraries directory to every other library directory.
90
- echo "# Original cabal config extra-lib-dirs"
91
- grep extra-lib-dirs /c/cabal/config
92
-
93
- sed -i 's/C:\\msys64\\mingw64\\lib/C:\\ghcup\\ghc\\8.10.7\\mingw\\x86_64-w64-mingw32\\lib, C:\\msys64\\mingw64\\lib/g' /c/cabal/config
94
-
95
- echo "# Modified cabal config extra-lib-dirs"
96
- grep extra-lib-dirs /c/cabal/config
46
+ # ghcup should be installed on current GHA Windows runners. Let's use ghcup to run
47
+ # pacman, to install the necessary dependencies, ...
48
+ ghcup run -- pacman --noconfirm -S `
49
+ mingw-w64-x86_64-pkg-config `
50
+ mingw-w64-x86_64-libsodium `
51
+ mingw-w64-x86_64-openssl `
52
+ base-devel `
53
+ autoconf-wrapper `
54
+ autoconf `
55
+ automake `
56
+ libtool `
57
+ make
58
+
59
+ # this seems to break something. It _must_ come after the pacman setup
60
+ # above. It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and
61
+ # as such we'd need pacman.exe instead.
62
+ - name : Setup Haskell
63
+ run : |
64
+ # Use GHCUP to manage ghc/cabal
65
+ ghcup install ghc --set ${{ matrix.ghc }}
66
+ ghcup install cabal --set 3.6.2.0
97
67
98
68
ghc --version
99
69
cabal --version
100
- echo "cabal-store=$(cabal --help | tail -1 | tr -d ' ' | rev | cut -d '/' -f2- | rev)\\store" >> $GITHUB_OUTPUT
70
+
71
+ - name : " WIN: fixup cabal config"
72
+ if : runner.os == 'Windows'
73
+ run : |
74
+ # make sure cabal knows about msys64, and mingw64 tools. Not clear why C:/cabal/config is empty
75
+ # and C:/cabal doesn't even exist. The ghcup bootstrap file should have create it in the image:
76
+ # See https://github.com/haskell/ghcup-hs/blob/787edc17af4907dbc51c85e25c490edd8d68b80b/scripts/bootstrap/bootstrap-haskell#L591
77
+ # So we'll do it by hand here for now.
78
+ #
79
+ # We'll _not_ add extra-include-dirs, or extra-lib-dirs, and rely on what's shipped with GHC.
80
+ # https://github.com/msys2/MINGW-packages/issues/10837#issuecomment-1047105402
81
+ # https://gitlab.haskell.org/ghc/ghc/-/issues/21111
82
+ # if we _do_ want them, this would be the lines to add below
83
+
84
+ $ghcMingwDir = Join-Path -Path $(ghc --print-libdir) `
85
+ -ChildPath ../mingw/x86_64-*-mingw32/lib/ `
86
+ -Resolve
87
+
88
+ cabal user-config -a "extra-prog-path: C:/msys64/mingw64/bin, C:/msys64/usr/bin" `
89
+ -a "extra-include-dirs: C:/msys64/mingw64/include" `
90
+ -a ("extra-lib-dirs: {0}, C:/msys64/mingw64/lib" -f $ghcMingwDir) `
91
+ -f init
92
+
93
+ - name : " OUTPUT Record cabal-store (Linux)"
94
+ id : lin-setup-haskell
95
+ if : runner.os != 'Windows'
96
+ run : echo "cabal-store=/home/runner/.cabal/store" >> $GITHUB_OUTPUT
97
+
98
+ - name : " OUTPUT Record cabal-store (Windows)"
99
+ id : win-setup-haskell
100
+ if : runner.os == 'Windows'
101
+ shell : bash
102
+ run : echo "cabal-store=C:\\cabal\\store" >> $GITHUB_OUTPUT
101
103
102
104
- name : Set cache version
103
105
run : echo "CACHE_VERSION=grFfw8r" >> $GITHUB_ENV
104
106
105
107
- uses : actions/checkout@v2
106
108
107
- - name : Add build script path
108
- run : |
109
- if [ "${{ runner.os }}" == "Windows" ]; then
110
- # MSYS2 doesn't inherit $GITHUB_PATH, so this workaround is needed
111
- cat <(echo "export PATH=$PATH:$(pwd)/.github/bin") ~/.bashrc > ~/.bashrc.new
112
- mv ~/.bashrc.new ~/.bashrc
113
- else
114
- # MacOS and Linux use $GITUB_PATH
115
- echo "$(pwd)/.github/bin" >> $GITHUB_PATH
116
- fi
109
+ - name : " [PowerShell] Add build script path"
110
+ if : runner.os == 'Windows'
111
+ shell : pwsh
112
+ run : Add-Content $env:GITHUB_PATH "$(pwd)/.github/bin"
113
+
114
+ - name : " [Bash] Add build script path"
115
+ if : runner.os != 'Windows'
116
+ run : echo "$(pwd)/.github/bin" >> $GITHUB_PATH
117
117
118
118
- name : " LINUX: Install build environment (apt-get)"
119
119
if : runner.os == 'Linux'
@@ -126,10 +126,7 @@ jobs:
126
126
127
127
- name : " LINUX: Install build environment (for secp256k1)"
128
128
if : runner.os == 'Linux'
129
- run : |
130
- sudo apt-get -y install autoconf automake libtool
131
- echo "CI_SECP_FLAGS=--prefix=/usr" >> $GITHUB_ENV
132
- echo "CI_SECP_INSTALL_CMD=sudo" >> $GITHUB_ENV
129
+ run : sudo apt-get -y install autoconf automake libtool
133
130
134
131
- name : " MAC: Install build environment (brew)"
135
132
if : runner.os == 'macOS'
@@ -140,38 +137,32 @@ jobs:
140
137
if : runner.os == 'macOS'
141
138
run : brew install autoconf automake libtool
142
139
143
- - name : " Install secp256k1"
144
- run : |
145
- git clone https://github.com/bitcoin-core/secp256k1.git
146
- ( cd secp256k1
147
- git reset --hard $SECP256K1_REF
148
- ./autogen.sh
149
- ./configure $CI_SECP_FLAGS --enable-module-schnorrsig --enable-experimental
150
- make
151
- make check
152
- $CI_SECP_INSTALL_CMD make install
153
- )
154
-
155
- - name : " List all pkg-config packages"
156
- run : |
157
- if [ "${{ runner.os }}" == "macOS" ]; then
158
- echo "=== Not printing every package detail in MacOS"
159
- # due to the location of the installed libraries this fails on MacOS with stuff not related to us
160
- else
161
- echo "=== Package list ==="
162
- pkg-config --list-all
163
-
164
- echo "=== Package details ==="
165
- for x in $(pkg-config --list-all | cut -d ' ' -f 1); do
166
- echo "# $x"
167
- pkg-config "$x" --cflags --libs
168
- done
169
- fi
140
+ - name : " LINUX: Install secp256k1"
141
+ if : runner.os != 'Windows'
142
+ shell : bash
143
+ env :
144
+ CI_SECP_FLAGS : " --prefix=/usr/local"
145
+ CI_SECP_INSTALL_CMD : sudo
146
+ run : bash .github/workflows/build-secp256k1.bash
147
+
148
+ # TODO: this really should come from a pre-built location
149
+ - name : " WIN: Install secp256k1"
150
+ if : runner.os == 'Windows'
151
+ # Same env as tmate action
152
+ env :
153
+ MSYS2_PATH_TYPE : inherit
154
+ MSYSTEM : MINGW64
155
+ CHERE_INVOKING : 1
156
+ # install secp into /mingw64 prefix, which is where pkg-config will look
157
+ # by default.
158
+ CI_SECP_FLAGS : " --prefix=/mingw64"
159
+ run : C:\\msys64\\usr\\bin\\bash.exe .github/workflows/build-secp256k1.bash
170
160
171
161
- name : Cabal update
172
- run : retry 2 cabal update
162
+ run : cabal update
173
163
174
164
- name : Configure build
165
+ shell : bash
175
166
run : |
176
167
if [ "${{github.event.inputs.tests}}" == "all" ]; then
177
168
echo "Reconfigure cabal projects to run tests for all dependencies"
@@ -187,14 +178,16 @@ jobs:
187
178
id : record-deps
188
179
run : |
189
180
cabal build all --dry-run
190
- cat ${{ env.PLAN_JSON }} | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
191
- date > date.txt
192
- echo "weeknum=$(/bin/date -u "+%W")" >> $GITHUB_OUTPUT
181
+ cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
182
+
183
+ - name : " OUTPUT Record weeknum"
184
+ shell : bash
185
+ run : echo "weeknum=$(/usr/bin/date -u "+%W")" >> $GITHUB_OUTPUT
193
186
194
187
- name : Cache Cabal store
195
188
uses : actions/cache@v2
196
189
with :
197
- path : ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.setup-haskell.outputs.cabal-store }}
190
+ path : ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.lin- setup-haskell.outputs.cabal-store }}
198
191
key : cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}-${{ hashFiles('date.txt') }}
199
192
restore-keys : |
200
193
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
@@ -212,22 +205,32 @@ jobs:
212
205
- name : Build
213
206
run : cabal build cardano-node cardano-cli cardano-node-chairman cardano-submit-api
214
207
215
- - name : Run tests
208
+ - name : Run tests (all)
209
+ if : github.event.inputs.tests == 'all'
210
+ env :
211
+ TMPDIR : ${{ runner.temp }}
212
+ TMP : ${{ runner.temp }}
213
+ KEEP_WORKSPACE : 1
216
214
run : |
217
- if [ "${{github.event.inputs.tests}}" == "all" ]; then
218
- TMPDIR="${{ runner.temp }}" TMP="${{ runner.temp }}" KEEP_WORKSPACE=1 cabal test all;
219
- else
220
- TMPDIR="${{ runner.temp }}" TMP="${{ runner.temp }}" KEEP_WORKSPACE=1 cabal test \
221
- cardano-testnet \
222
- cardano-api \
223
- cardano-node \
224
- cardano-node-chairman \
225
- cardano-cli \
226
- cardano-submit-api
227
- fi
215
+ # The tests call out to msys2 commands. We generally do not want to mix toolchains, so
216
+ # we are very deliberate about only adding msys64 to the path where absolutely necessary.
217
+ ${{ runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)' }}
218
+ cabal test all
228
219
220
+ - name : Run tests
221
+ if : github.event.inputs.tests != 'all'
222
+ env :
223
+ TMPDIR : ${{ runner.temp }}
224
+ TMP : ${{ runner.temp }}
225
+ KEEP_WORKSPACE : 1
226
+ run : |
227
+ # The tests call out to msys2 commands. We generally do not want to mix toolchains, so
228
+ # we are very deliberate about only adding msys64 to the path where absolutely necessary.
229
+ ${{ runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)' }}
230
+ cabal test cardano-testnet cardano-api cardano-node cardano-node-chairman cardano-cli cardano-submit-api
229
231
230
232
- name : " Tar artifacts"
233
+ shell : bash
231
234
run : |
232
235
mkdir -p artifacts
233
236
@@ -252,6 +255,7 @@ jobs:
252
255
253
256
- name : Delete socket files in chairman tests in preparation for uploading artifacts
254
257
if : ${{ always() }}
258
+ shell : bash
255
259
run : |
256
260
if [ -d "${{ runner.temp }}/chairman" ]; then
257
261
find "${{ runner.temp }}/chairman" -type s -exec rm -f {} \;
@@ -264,6 +268,15 @@ jobs:
264
268
name : chairman-test-artifacts-${{ matrix.os }}-${{ matrix.n }}-${{ matrix.ghc }}
265
269
path : ${{ runner.temp }}/chairman/
266
270
271
+ # Uncomment the following back in for debugging. Remember to launch a `pwsh` from
272
+ # the tmux session to debug `pwsh` issues. And be reminded that the `/msys2` and
273
+ # `/msys2/mingw64` paths are not in PATH by default for the workflow, but tmate
274
+ # will put them in.
275
+ #
276
+ - name : Setup tmate session
277
+ if : ${{ failure() }}
278
+ uses : mxschmitt/action-tmate@v3
279
+
267
280
release :
268
281
needs : [build]
269
282
if : ${{ startsWith(github.ref, 'refs/tags') }}
0 commit comments