Skip to content

Commit 492e356

Browse files
Try #4650:
2 parents 7150a68 + 2adb312 commit 492e356

File tree

3 files changed

+154
-135
lines changed

3 files changed

+154
-135
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# I don't understand why this just vanishes.
3+
export PATH=/usr/bin:$PATH
4+
5+
echo ======== env =======
6+
env | grep CI_
7+
echo ========
8+
echo $PATH
9+
echo ========
10+
git clone https://github.com/bitcoin-core/secp256k1
11+
cd secp256k1
12+
git switch $SECP256K1_REF --detach
13+
./autogen.sh
14+
./configure $CI_SECP_FLAGS --enable-module-schnorrsig --enable-experimental
15+
make
16+
make check
17+
$CI_SECP_INSTALL_CMD make install
18+
cd ..

.github/workflows/cabal.project.local.ci.MINGW64_NT-10.0-20348

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,4 @@ package cardano-crypto-praos
22
flags: -external-libsodium-vrf
33

44
package HsOpenSSL
5-
extra-include-dirs: D:/a/_temp/msys64/mingw64/include
6-
extra-lib-dirs: D:/a/_temp/msys64/mingw64/lib
75
flags: +use-pkg-config
8-
9-
package secp256k1-haskell
10-
extra-include-dirs: D:/a/_temp/msys64/mingw64/include
11-
extra-lib-dirs: D:/a/_temp/msys64/mingw64/lib
12-
13-
package basement
14-
extra-include-dirs: D:/a/_temp/msys64/mingw64/include
15-
extra-lib-dirs: D:/a/_temp/msys64/mingw64/lib
16-
17-
package cardano-crypto-class
18-
extra-include-dirs: D:/a/_temp/msys64/mingw64/include
19-
extra-lib-dirs: D:/a/_temp/msys64/mingw64/lib
20-
21-
package cardano-crypto-praos
22-
extra-include-dirs: D:/a/_temp/msys64/mingw64/include
23-
extra-lib-dirs: D:/a/_temp/msys64/mingw64/lib

.github/workflows/haskell.yml

Lines changed: 136 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ jobs:
1717
build:
1818
runs-on: ${{ matrix.os }}
1919

20-
defaults:
21-
run:
22-
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
23-
2420
strategy:
2521
fail-fast: false
2622
matrix:
@@ -36,84 +32,88 @@ jobs:
3632
SECP256K1_REF: ac83be33d0956faf6b7f61a60ab524ef7d6a473a
3733
# OpenSSL is installed in a non-standard location in MacOS. See
3834
# 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') || '' }}
4041

4142
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)"
7144
if: runner.os == 'Windows'
7245
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
9767
9868
ghc --version
9969
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
101103

102104
- name: Set cache version
103105
run: echo "CACHE_VERSION=grFfw8r" >> $GITHUB_ENV
104106

105107
- uses: actions/checkout@v2
106108

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
117117

118118
- name: "LINUX: Install build environment (apt-get)"
119119
if: runner.os == 'Linux'
@@ -126,10 +126,7 @@ jobs:
126126
127127
- name: "LINUX: Install build environment (for secp256k1)"
128128
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
133130

134131
- name: "MAC: Install build environment (brew)"
135132
if: runner.os == 'macOS'
@@ -140,38 +137,32 @@ jobs:
140137
if: runner.os == 'macOS'
141138
run: brew install autoconf automake libtool
142139

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
170160

171161
- name: Cabal update
172-
run: retry 2 cabal update
162+
run: cabal update
173163

174164
- name: Configure build
165+
shell: bash
175166
run: |
176167
if [ "${{github.event.inputs.tests}}" == "all" ]; then
177168
echo "Reconfigure cabal projects to run tests for all dependencies"
@@ -187,14 +178,16 @@ jobs:
187178
id: record-deps
188179
run: |
189180
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
193186

194187
- name: Cache Cabal store
195188
uses: actions/cache@v2
196189
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 }}
198191
key: cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}-${{ hashFiles('date.txt') }}
199192
restore-keys: |
200193
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
@@ -212,22 +205,32 @@ jobs:
212205
- name: Build
213206
run: cabal build cardano-node cardano-cli cardano-node-chairman cardano-submit-api
214207

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
216214
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
228219
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
229231
230232
- name: "Tar artifacts"
233+
shell: bash
231234
run: |
232235
mkdir -p artifacts
233236
@@ -252,6 +255,7 @@ jobs:
252255

253256
- name: Delete socket files in chairman tests in preparation for uploading artifacts
254257
if: ${{ always() }}
258+
shell: bash
255259
run: |
256260
if [ -d "${{ runner.temp }}/chairman" ]; then
257261
find "${{ runner.temp }}/chairman" -type s -exec rm -f {} \;
@@ -264,6 +268,21 @@ jobs:
264268
name: chairman-test-artifacts-${{ matrix.os }}-${{ matrix.n }}-${{ matrix.ghc }}
265269
path: ${{ runner.temp }}/chairman/
266270

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+
# You may also want to run
276+
#
277+
# $env:PATH=("C:\Program Files\PowerShell\7;{0}" -f $env:ORIGINAL_PATH)
278+
#
279+
# to restore the original path. Do note that some test might need msys2
280+
# and will silently fail if msys2 is not in path. See the "Run tests" step.
281+
#
282+
# - name: Setup tmate session
283+
# if: ${{ failure() }}
284+
# uses: mxschmitt/action-tmate@v3
285+
267286
release:
268287
needs: [build]
269288
if: ${{ startsWith(github.ref, 'refs/tags') }}

0 commit comments

Comments
 (0)