Skip to content

Commit 1ac41e8

Browse files
committed
Fix Windows CI
1 parent d15ff2b commit 1ac41e8

File tree

2 files changed

+81
-84
lines changed

2 files changed

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

.github/workflows/haskell.yml

Lines changed: 65 additions & 84 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:
@@ -39,25 +35,6 @@ jobs:
3935
PKG_CONFIG_PATH: ${{ matrix.os == 'macos-latest' && '/usr/local/opt/[email protected]/lib/pkgconfig' || '' }}
4036

4137
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-
6138
- name: "LINUX,MAC: Setup haskell"
6239
if: runner.os != 'Windows'
6340
uses: haskell/actions/setup@v1
@@ -66,45 +43,78 @@ jobs:
6643
ghc-version: ${{ matrix.ghc }}
6744
cabal-version: 3.8.1.0
6845

69-
- name: "WIN: Setup Haskell"
70-
id: win-setup-haskell
46+
- name: "WIN: Install ghcup"
7147
if: runner.os == 'Windows'
7248
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
49+
# ghcup should be installed on current GHA Windows runners. Let's use ghcup to run
50+
# pacman, to install the necessary dependencies, ...
51+
ghcup run -- pacman --noconfirm -S `
52+
mingw-w64-x86_64-pkg-config `
53+
mingw-w64-x86_64-libsodium `
54+
base-devel `
55+
autoconf-wrapper `
56+
autoconf `
57+
automake `
58+
libtool `
59+
make
60+
# ... and also the ghc and cabal combination we want.
61+
ghcup install ghc --set ${{ matrix.ghc }}
62+
ghcup install cabal --set 3.6.2.0
9763
9864
ghc --version
9965
cabal --version
100-
echo "cabal-store=$(cabal --help | tail -1 | tr -d ' ' | rev | cut -d '/' -f2- | rev)\\store" >> $GITHUB_OUTPUT
66+
# make sure cabal knows about msys64, and mingw64 tools. Not clear why C:/cabal/config is empty
67+
# and C:/cabal doesn't even exist. The ghcup bootstrap file should have create it in the image:
68+
# See https://github.com/haskell/ghcup-hs/blob/787edc17af4907dbc51c85e25c490edd8d68b80b/scripts/bootstrap/bootstrap-haskell#L591
69+
# So we'll do it by hand here for now.
70+
#
71+
# We'll _not_ add extra-include-dirs, or extra-lib-dirs, and rely on what's shipped with GHC.
72+
# https://github.com/msys2/MINGW-packages/issues/10837#issuecomment-1047105402
73+
# https://gitlab.haskell.org/ghc/ghc/-/issues/21111
74+
# if we _do_ want them, this would be the lines to add below
75+
76+
$ghcMingwDir = Join-Path -Path $(ghc --print-libdir) `
77+
-ChildPath ../mingw/x86_64-*-mingw32/lib/ `
78+
-Resolve
79+
80+
cabal user-config -a "extra-prog-path: C:/msys64/mingw64/bin, C:/msys64/usr/bin" `
81+
-a "extra-include-dirs: C:/msys64/mingw64/include" `
82+
-a ("extra-lib-dirs: {0}, C:/msys64/mingw64/lib" -f $ghcMingwDir) `
83+
-f init
84+
- name: "OUTPUT Record cabal-store"
85+
id: win-setup-haskell
86+
shell: bash
87+
if: runner.os == 'Windows'
88+
run: echo "cabal-store=$(dirname $(cabal --help | tail -1 | tr -d ' '))\\store" >> $GITHUB_OUTPUT
10189

10290
- name: Set cache version
10391
run: echo "CACHE_VERSION=grFfw8r" >> $GITHUB_ENV
10492

10593
- uses: actions/checkout@v2
10694

95+
96+
# TODO: this really should come from a pre-built location
97+
- name: "WIN: Install secp256k1"
98+
if: runner.os == 'Windows'
99+
# Same env as tmate action
100+
env:
101+
MSYS2_PATH_TYPE: inherit
102+
MSYSTEM: MINGW64
103+
CHERE_INVOKING: 1
104+
# install secp into /mingw64 prefix, which is where pkg-config will look
105+
# by default.
106+
CI_SECP_FLAGS: "--prefix=/mingw64"
107+
run: C:\\msys64\\usr\\bin\\bash.exe .github/workflows/build-secp256k1.bash
108+
109+
- name: "LINUX: Install secp256k1"
110+
if: runner.os != 'Windows'
111+
env:
112+
CI_SECP_FLAGS: "--prefix=/usr"
113+
CI_SECP_INSTALL_CMD: sudo
114+
run: bash .github/workflows/build-secp256k1.bash
115+
107116
- name: Add build script path
117+
shell: bash
108118
run: |
109119
if [ "${{ runner.os }}" == "Windows" ]; then
110120
# MSYS2 doesn't inherit $GITHUB_PATH, so this workaround is needed
@@ -126,10 +136,7 @@ jobs:
126136
127137
- name: "LINUX: Install build environment (for secp256k1)"
128138
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
139+
run: sudo apt-get -y install autoconf automake libtool
133140

134141
- name: "MAC: Install build environment (brew)"
135142
if: runner.os == 'macOS'
@@ -140,34 +147,6 @@ jobs:
140147
if: runner.os == 'macOS'
141148
run: brew install autoconf automake libtool
142149

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
170-
171150
- name: Cabal update
172151
run: retry 2 cabal update
173152

@@ -188,8 +167,10 @@ jobs:
188167
run: |
189168
cabal build all --dry-run
190169
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
170+
171+
- name: "OUTPUT Record weeknum"
172+
shell: bash
173+
run: echo "weeknum=$(/usr/bin/date -u "+%W")" >> $GITHUB_OUTPUT
193174

194175
- name: Cache Cabal store
195176
uses: actions/cache@v2

0 commit comments

Comments
 (0)