Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it build with ghc 9.8 #269

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
package cardano-crypto-praos
flags: -external-libsodium-vrf

package HsOpenSSL
flags: +use-pkg-config

Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/cabal.project.local.ci.Linux

This file was deleted.

This file was deleted.

184 changes: 56 additions & 128 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,128 +7,57 @@ on:

jobs:
build:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.sys.os }}

strategy:
fail-fast: false
matrix:
ghc: ["8.10.7", "9.6.5"]
ghc: ["8.10.7", "9.6", "9.8"]
cabal: ["3.12"]
# os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, windows-latest]
sys:
- { os: windows-latest, shell: 'C:/msys64/usr/bin/bash.exe -e {0}' }
- { os: ubuntu-latest, shell: bash }

env:
# we need the LD_LIBRARY_PATH env var here because we ended up installing libsecp256k1 into /usr/local,
# pkg-config, *does* return the proper location, but the library does not appear to be properly referenced.
# FIXME: this is arguably a bug, and pkg-config should return the right values!
LD_LIBRARY_PATH: ${{ (matrix.os != 'windows-latest' && '/usr/local/lib') || '' }}
defaults:
run:
shell: ${{ matrix.sys.shell }}

steps:
- name: "WIN: Install System Dependencies via pacman (msys2)"
if: runner.os == 'Windows'
run: |
# ghcup should be installed on current GHA Windows runners. Let's use ghcup to run
# pacman, to install the necessary dependencies, ...
ghcup run -- pacman --noconfirm -S `
mingw-w64-x86_64-pkg-config `
mingw-w64-x86_64-pcre `
mingw-w64-x86_64-libsodium `
base-devel `
autoconf-wrapper `
autoconf `
automake `
libtool `
make

# this seems to break something. It _must_ come after the pacman setup
# above. It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and
# as such we'd need pacman.exe instead.
- name: Setup Haskell
run: |
# Use GHCUP to manage ghc/cabal
ghcup install ghc --set ${{ matrix.ghc }}
ghcup install cabal --set 3.10.1.0

ghc --version
cabal --version
- name: Install system dependencies
uses: input-output-hk/actions/base@latest
with:
use-sodium-vrf: true

- name: Install Haskell
uses: input-output-hk/actions/haskell@latest
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- name: "WIN: fixup cabal config"
- name: WINDOWS Install libs
if: runner.os == 'Windows'
run: |
# make sure cabal knows about msys64, and mingw64 tools. Not clear why C:/cabal/config is empty
# and C:/cabal doesn't even exist. The ghcup bootstrap file should have create it in the image:
# See https://github.com/haskell/ghcup-hs/blob/787edc17af4907dbc51c85e25c490edd8d68b80b/scripts/bootstrap/bootstrap-haskell#L591
# So we'll do it by hand here for now.
#
# We'll _not_ add extra-include-dirs, or extra-lib-dirs, and rely on what's shipped with GHC.
# https://github.com/msys2/MINGW-packages/issues/10837#issuecomment-1047105402
# https://gitlab.haskell.org/ghc/ghc/-/issues/21111
# if we _do_ want them, this would be the lines to add below

$ghcMingwDir = Join-Path -Path $(ghc --print-libdir) `
-ChildPath ../mingw/x86_64-*-mingw32/lib/ `
-Resolve

cabal user-config -a "extra-prog-path: C:/msys64/mingw64/bin, C:/msys64/usr/bin" `
-a "extra-include-dirs: C:/msys64/mingw64/include" `
-a ("extra-lib-dirs: {0}, C:/msys64/mingw64/lib" -f $ghcMingwDir) `
-f init
/usr/bin/pacman --noconfirm -S mingw-w64-x86_64-pcre

- name: Set cache version
run: echo "CACHE_VERSION=grFfw7r" >> $GITHUB_ENV

- uses: actions/checkout@v2

- name: "[PowerShell] Add build script path"
if: runner.os == 'Windows'
shell: pwsh
run: Add-Content $env:GITHUB_PATH "$(pwd)/.github/bin"

- name: "[Bash] Add build script path"
if: runner.os != 'Windows'
run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH

- name: "LINUX: Install build environment (apt-get)"
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get -y install libsodium23 libsodium-dev
sudo apt-get -y remove --purge software-properties-common
sudo apt-get -y autoremove

- name: "MAC: Install build environment (brew)"
if: runner.os == 'macOS'
run: |
brew install libsodium
brew install pcre
- uses: actions/checkout@v4

- name: Cabal update
run: cabal update

- name: "Setup cabal-store"
id: cabal-store
shell: bash
run: |
cabal_config_file="$(cabal help user-config | tail -n 1 | xargs)"

if [[ '${{ runner.os }}' != 'Windows' ]]; then
echo "cabal-store=$(dirname "$cabal_config_file")/store" | tee -a "$GITHUB_OUTPUT"
else
echo "cabal-store=C:\\cabal\\store" | tee -a "$GITHUB_OUTPUT"
fi

- name: "Check cabal-store"
shell: bash
run: echo '${{ steps.cabal-store.outputs.cabal-store }}'

- name: Configure build
shell: bash
run: |
if [ "${{github.event.inputs.tests}}" == "all" ]; then
echo "Reconfigure cabal projects to run tests for all dependencies"
sed -i 's|tests: False|tests: True|g' cabal.project
fi

cp ".github/workflows/cabal.project.local.ci.$(uname -s)" cabal.project.local
cp ".github/workflows/cabal.project.local.ci" cabal.project.local

echo "# cabal.project.local"
cat cabal.project.local
Expand All @@ -137,51 +66,50 @@ jobs:
id: record-deps
run: |
cabal build all --dry-run
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt

- name: "OUTPUT Record weeknum"
shell: bash
run: echo "weeknum=$(/usr/bin/date -u "+%W")" >> $GITHUB_OUTPUT

- name: Cache Cabal store
uses: actions/cache@v2
with:
path: ${{ steps.cabal-store.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') }}
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}

- uses: actions/cache@v2
name: "Cache `dist-newstyle`"
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[] | select(.style != "local") | .id' | sort | uniq > dependencies.txt

# Use a fresh cache each month
- name: Store month number as environment variable used in cache version
run: echo "MONTHNUM=$(date -u '+%m')" >> $GITHUB_ENV

# From the dependency list we restore the cached dependencies.
# We use the hash of `dependencies.txt` as part of the cache key because that will be stable
# until the `index-state` values in the `cabal.project` file changes.
- name: Restore cached dependencies
uses: actions/cache/restore@v4
id: cache
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-newstyle
!dist-newstyle/**/.git
key: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ steps.record-deps.outputs.weeknum }}
restore-keys: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
key:
cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.MONTHNUM }}-${{ hashFiles('dependencies.txt') }}
# try to restore previous cache from this month if there's no cache for the dependencies set
restore-keys: |
cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.MONTHNUM }}-

- name: Install dependencies
run: cabal build all --only-dependencies

# Always store the cabal cache.
- name: Cache Cabal store
uses: actions/cache/save@v4
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-newstyle
key:
${{ steps.cache.outputs.cache-primary-key }}

- name: Build
run: cabal build all

- name: Run unit tests
shell: bash
run: |
cabal test cardano-addresses
if [ "${{ runner.os }}" != "Windows" ] || [ "${{ matrix.ghc }}" != "9.6.5" ]; then
# This test is currently broken with GHC 9.6 on windows.
# This could be related to:
# * UTF8 encoding and the use of emoji's in the output.
# * unhandled PEi386 relocation type 14 (less likely).
cabal test cardano-addresses-cli
fi
run: cabal test cardano-addresses cardano-addresses-cli

- name: Upload Windows Artifact
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: ${{ matrix.os }}-exe
path: ${{ steps.cabal-store.outputs.cabal-store }}
name: ${{ matrix.sys.os }}-${{ matrix.ghc }}-exe
path: ${{ steps.setup-haskell.outputs.cabal-store }}
9 changes: 4 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ repository cardano-haskell-packages
c00aae8461a256275598500ea0e187588c35a5d5d7454fb57eac18d9edb86a56
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee

index-state:
, hackage.haskell.org 2024-08-18T16:26:35Z
, cardano-haskell-packages 2024-08-15T12:55:30Z

-- See CONTRIBUTING for information about these, including some Nix commands
-- you need to run if you change them

Expand Down Expand Up @@ -54,10 +58,6 @@ else

active-repositories: hackage.haskell.org, cardano-haskell-packages

index-state:
, hackage.haskell.org 2024-06-05T16:48:53Z
, cardano-haskell-packages 2024-06-05T16:48:53Z

packages:
command-line/cardano-addresses-cli.cabal
core/cardano-addresses.cabal
Expand All @@ -68,4 +68,3 @@ constraints:
, optparse-applicative >= 0.18.1.0

tests: True
test-show-details: direct
Loading
Loading