Skip to content

Commit

Permalink
Windows Github Actions now use MSYS2
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Jul 15, 2022
1 parent 53edc88 commit e4c66cb
Showing 1 changed file with 70 additions and 74 deletions.
144 changes: 70 additions & 74 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

defaults:
run:
shell: bash
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}

strategy:
fail-fast: false
Expand All @@ -21,21 +21,64 @@ jobs:
SECP256K1_REF: ac83be33d0956faf6b7f61a60ab524ef7d6a473a

steps:
- name: Install Haskell
- name: "WIN: Setup MSYS2 and libraries"
if: matrix.os == 'windows-latest'
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
base-devel
autoconf-wrapper
autoconf
automake
libtool
make
git
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-libsodium
mingw-w64-x86_64-cmake
mingw-w64-x86_64-jq
- name: "LINUX: Setup haskell"
if: matrix.os != 'windows-latest'
uses: haskell/actions/setup@v1
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 3.6.2.0

- name: Show Haskell tool versions
- name: "WIN: Setup Haskell"
if: matrix.os == 'windows-latest'
run: |
# see https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/scripts/bootstrap/bootstrap-haskell
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=1 \
BOOTSTRAP_HASKELL_ADJUST_BASHRC=1 \
BOOTSTRAP_HASKELL_GHC_VERSION="${{ matrix.ghc }}" \
BOOTSTRAP_HASKELL_CABAL_VERSION="3.6.2.0" \
sh
cat <(echo "source /c/ghcup/env") ~/.bashrc > ~/.bashrc.new
mv ~/.bashrc.new ~/.bashrc
source ~/.bashrc
echo "# Original cabal config extra-lib-dirs"
grep extra-lib-dirs /c/cabal/config
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
echo "# Modified cabal config extra-lib-dirs"
grep extra-lib-dirs /c/cabal/config
ghc --version
cabal --version
- name: Select build directory
run: |
if [ "$OS" == Windows_NT ]; then
if [ ${{ matrix.os }} == 'windows-latest' ]; then
CABAL_BUILDDIR="D:\\a\\_temp\\dist"
else
CABAL_BUILDDIR="dist-newstyle"
Expand All @@ -47,40 +90,7 @@ jobs:
- name: Set cache version
run: echo "CACHE_VERSION=9w76Z3Q" >> $GITHUB_ENV

- name: Install pkgconfiglite
if: matrix.os == 'windows-latest'
run: choco install -y pkgconfiglite --allow-empty-checksums

- name: Install libsodium (Windows)
if: matrix.os == 'windows-latest'
env:
RUNNER_TEMP: ${{ runner.temp }}
run: |
echo "RUNNER_TEMP=$RUNNER_TEMP"
cd "$RUNNER_TEMP"
RUNNER_TEMP_FWD="$(echo "$RUNNER_TEMP" | sed 's|\\|/|g')"
curl -Ls \
--connect-timeout 5 \
--max-time 10 \
--retry 5 \
--retry-delay 0 \
--retry-max-time 40 \
https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-mingw.tar.gz -o libsodium-1.0.18-mingw.tar.gz
tar zxvf libsodium-1.0.18-mingw.tar.gz
sed -i "s|/d/a/1/s/|$RUNNER_TEMP_FWD\/|g" libsodium-win64/lib/pkgconfig/libsodium.pc
export PKG_CONFIG_PATH="$(readlink -f libsodium-win64/lib/pkgconfig | sed 's|^/d|D:|g' | tr / '\\')"
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
export LIBSODIUM_PATH="$(readlink -f libsodium-win64/bin | sed 's|^/d|D:|g' | tr / '\\')"
echo "LIBSODIUM_PATH=$LIBSODIUM_PATH"
echo "$LIBSODIUM_PATH" >> $GITHUB_PATH
- name: Install build environment
- name: "LINUX: Install build environment (apt-get)"
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
Expand All @@ -89,49 +99,35 @@ jobs:
sudo apt-get -y remove --purge software-properties-common
sudo apt-get -y autoremove
- name: Install secp256k1 (Linux)
- name: "LINUX: Install build environment (secp256k1)"
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get -y install autoconf automake libtool
mkdir secp256k1-sources
cd secp256k1-sources
git clone https://github.com/bitcoin-core/secp256k1.git
cd secp256k1
git reset --hard $SECP256K1_REF
./autogen.sh
./configure --prefix=/usr --enable-module-schnorrsig --enable-experimental
make
make check
sudo make install
cd ../..
- name: Install secp256k1 (Windows)
( cd secp256k1
git reset --hard $SECP256K1_REF
./autogen.sh
./configure --prefix=/usr --enable-module-schnorrsig --enable-experimental
make
make check
sudo make install
)
- name: "WIN: Install build environment (secp256k1)"
if: matrix.os == 'windows-latest'
env:
RUNNER_TEMP: ${{ runner.temp }}
run: |
echo "RUNNER_TEMP=$RUNNER_TEMP"
cd "$RUNNER_TEMP"
RUNNER_TEMP_FWD="$(echo "$RUNNER_TEMP" | sed 's|\\|/|g')"
curl -Ls \
--connect-timeout 5 \
--max-time 10 \
--retry 5 \
--retry-delay 0 \
--retry-max-time 40 \
https://hydra.iohk.io/job/Cardano/haskell-nix/windows-secp256k1/latest/download/1 -o secp256k1.zip
mkdir secp256k1
cd secp256k1
unzip ../secp256k1.zip
cd ..
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH;$(readlink -f secp256k1/lib/pkgconfig | sed 's|^/d|D:|g' | tr / '\\')"
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
export SECP256K1_PATH="$(readlink -f secp256k1/bin | sed 's|^/d|D:|g' | tr / '\\')"
echo "SECP256K1_PATH=$SECP256K1_PATH"
echo "$SECP256K1_PATH" >> $GITHUB_PATH
git clone https://github.com/bitcoin-core/secp256k1
( cd secp256k1
git switch $SECP256K1_REF --detach
./autogen.sh
./configure --enable-module-schnorrsig --enable-experimental
make
make check
make install
)
rm -rf secp256k1
- name: Set up temp directory
env:
Expand All @@ -157,7 +153,7 @@ jobs:
- uses: actions/cache@v2
name: Cache cabal store
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
path: ${{ matrix.os == 'windows-latest' && '/c/cabal/store' || steps.setup-haskell.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') }}
Expand Down

0 comments on commit e4c66cb

Please sign in to comment.