diff --git a/.github/workflows/cabal.project.local.ci.Darwin b/.github/workflows/cabal.project.local.ci similarity index 58% rename from .github/workflows/cabal.project.local.ci.Darwin rename to .github/workflows/cabal.project.local.ci index 725d39f7e..ceb009c9c 100644 --- a/.github/workflows/cabal.project.local.ci.Darwin +++ b/.github/workflows/cabal.project.local.ci @@ -1,6 +1,3 @@ -package cardano-crypto-praos - flags: -external-libsodium-vrf - package HsOpenSSL flags: +use-pkg-config diff --git a/.github/workflows/cabal.project.local.ci.Linux b/.github/workflows/cabal.project.local.ci.Linux deleted file mode 100644 index 725d39f7e..000000000 --- a/.github/workflows/cabal.project.local.ci.Linux +++ /dev/null @@ -1,8 +0,0 @@ -package cardano-crypto-praos - flags: -external-libsodium-vrf - -package HsOpenSSL - flags: +use-pkg-config - -package pcre-light - flags: +use-pkg-config diff --git a/.github/workflows/cabal.project.local.ci.MINGW64_NT-10.0-20348 b/.github/workflows/cabal.project.local.ci.MINGW64_NT-10.0-20348 deleted file mode 100644 index 725d39f7e..000000000 --- a/.github/workflows/cabal.project.local.ci.MINGW64_NT-10.0-20348 +++ /dev/null @@ -1,8 +0,0 @@ -package cardano-crypto-praos - flags: -external-libsodium-vrf - -package HsOpenSSL - flags: +use-pkg-config - -package pcre-light - flags: +use-pkg-config diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index e8d953adb..1178f1f74 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -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 @@ -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 }} diff --git a/cabal.project b/cabal.project index 0febcb0f4..9df8ab195 100644 --- a/cabal.project +++ b/cabal.project @@ -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 @@ -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 @@ -68,4 +68,3 @@ constraints: , optparse-applicative >= 0.18.1.0 tests: True -test-show-details: direct diff --git a/flake.lock b/flake.lock index 6ef5e09da..fd725c2c0 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1717745122, - "narHash": "sha256-RW0mbVghzN/ywg3CVsdHPB3WCj8KAEAS0egV4PFro/4=", + "lastModified": 1723730199, + "narHash": "sha256-0A7eS9bHkk65jmOcOWPRnaRdpRGMkMWTkZh1NDFM240=", "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "a8d2c3e2b819e2f331aae71de5544a855a267e65", + "rev": "de3964f328b8d543ed3e2c167297a5d5ddf6fac4", "type": "github" }, "original": { @@ -169,51 +169,14 @@ "type": "github" } }, - "ghc910X": { - "flake": false, - "locked": { - "lastModified": 1714520650, - "narHash": "sha256-4uz6RA1hRr0RheGNDM49a/B3jszqNNU8iHIow4mSyso=", - "ref": "ghc-9.10", - "rev": "2c6375b9a804ac7fca1e82eb6fcfc8594c67c5f5", - "revCount": 62663, - "submodules": true, - "type": "git", - "url": "https://gitlab.haskell.org/ghc/ghc" - }, - "original": { - "ref": "ghc-9.10", - "submodules": true, - "type": "git", - "url": "https://gitlab.haskell.org/ghc/ghc" - } - }, - "ghc911": { - "flake": false, - "locked": { - "lastModified": 1714817013, - "narHash": "sha256-m2je4UvWfkgepMeUIiXHMwE6W+iVfUY38VDGkMzjCcc=", - "ref": "refs/heads/master", - "rev": "fc24c5cf6c62ca9e3c8d236656e139676df65034", - "revCount": 62816, - "submodules": true, - "type": "git", - "url": "https://gitlab.haskell.org/ghc/ghc" - }, - "original": { - "submodules": true, - "type": "git", - "url": "https://gitlab.haskell.org/ghc/ghc" - } - }, "hackage": { "flake": false, "locked": { - "lastModified": 1717807055, - "narHash": "sha256-CCqRhadPKQUkB/ncLBGHHt7XT8VbSR532sfpjbPNcZI=", + "lastModified": 1723941124, + "narHash": "sha256-NobZFR+0sXRpKfx9q1cFkCdVlyfZQIxV/4ZL9t+cZ44=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "edb78b8087db9d494ee3eeb9105c7650e44d009f", + "rev": "c44c06c3d2c763e8790173f09ee8fe748bd14ff3", "type": "github" }, "original": { @@ -231,8 +194,6 @@ "cardano-shell": "cardano-shell", "flake-compat": "flake-compat", "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", - "ghc910X": "ghc910X", - "ghc911": "ghc911", "hackage": "hackage", "hls-1.10": "hls-1.10", "hls-2.0": "hls-2.0", @@ -243,6 +204,7 @@ "hls-2.6": "hls-2.6", "hls-2.7": "hls-2.7", "hls-2.8": "hls-2.8", + "hls-2.9": "hls-2.9", "hpc-coveralls": "hpc-coveralls", "hydra": "hydra", "iserv-proxy": "iserv-proxy", @@ -256,16 +218,17 @@ "nixpkgs-2211": "nixpkgs-2211", "nixpkgs-2305": "nixpkgs-2305", "nixpkgs-2311": "nixpkgs-2311", + "nixpkgs-2405": "nixpkgs-2405", "nixpkgs-unstable": "nixpkgs-unstable", "old-ghc-nix": "old-ghc-nix", "stackage": "stackage" }, "locked": { - "lastModified": 1717846179, - "narHash": "sha256-iSGepzdSLyvYafn+OvXCGN50ZsWQiGcJIKq4s+sg4nY=", + "lastModified": 1723942254, + "narHash": "sha256-hBSLp1IhWq0S1RMvOqimehS7zyfXB39WrF/B6VNkVig=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "8f50d10aa7ce71f2dcb6c8eb25c2352294ddc854", + "rev": "80d9d079d86b33bdf8e09faa5af0f1ffc99ef920", "type": "github" }, "original": { @@ -427,6 +390,23 @@ "type": "github" } }, + "hls-2.9": { + "flake": false, + "locked": { + "lastModified": 1718469202, + "narHash": "sha256-THXSz+iwB1yQQsr/PY151+2GvtoJnTIB2pIQ4OzfjD4=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "40891bccb235ebacce020b598b083eab9dda80f1", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.9.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, "hpc-coveralls": { "flake": false, "locked": { @@ -641,11 +621,11 @@ }, "nixpkgs-2305": { "locked": { - "lastModified": 1701362232, - "narHash": "sha256-GVdzxL0lhEadqs3hfRLuj+L1OJFGiL/L7gCcelgBlsw=", + "lastModified": 1705033721, + "narHash": "sha256-K5eJHmL1/kev6WuqyqqbS1cdNnSidIZ3jeqJ7GbrYnQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d2332963662edffacfddfad59ff4f709dde80ffe", + "rev": "a1982c92d8980a0114372973cbdfe0a307f1bdea", "type": "github" }, "original": { @@ -657,11 +637,11 @@ }, "nixpkgs-2311": { "locked": { - "lastModified": 1701386440, - "narHash": "sha256-xI0uQ9E7JbmEy/v8kR9ZQan6389rHug+zOtZeZFiDJk=", + "lastModified": 1719957072, + "narHash": "sha256-gvFhEf5nszouwLAkT9nWsDzocUTqLWHuL++dvNjMp9I=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "293822e55ec1872f715a66d0eda9e592dc14419f", + "rev": "7144d6241f02d171d25fba3edeaf15e0f2592105", "type": "github" }, "original": { @@ -671,6 +651,22 @@ "type": "github" } }, + "nixpkgs-2405": { + "locked": { + "lastModified": 1720122915, + "narHash": "sha256-Nby8WWxj0elBu1xuRaUcRjPi/rU3xVbkAt2kj4QwX2U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "835cf2d3f37989c5db6585a28de967a667a75fb1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-24.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-regression": { "locked": { "lastModified": 1643052045, @@ -689,17 +685,17 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1694822471, - "narHash": "sha256-6fSDCj++lZVMZlyqOe9SIOL8tYSBz1bI8acwovRwoX8=", + "lastModified": 1720181791, + "narHash": "sha256-i4vJL12/AdyuQuviMMd1Hk2tsGt02hDNhA0Zj1m16N8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "47585496bcb13fb72e4a90daeea2f434e2501998", + "rev": "4284c2b73c8bce4b46a6adf23e16d9e2ec8da4bb", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", - "rev": "47585496bcb13fb72e4a90daeea2f434e2501998", "type": "github" } }, @@ -769,11 +765,11 @@ "stackage": { "flake": false, "locked": { - "lastModified": 1717806268, - "narHash": "sha256-QUGjB0OLnmXrS+u4jCdvawfWfngv+R99qmbFvpRaW4I=", + "lastModified": 1723939964, + "narHash": "sha256-wrreJAx4GHsAoTOrrViQEMWqQYN9l70P9e+MDTTTGBk=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "6c6db491b4a4aab289fe0a5ada8bb9bfb842b23c", + "rev": "95c340a96bc5e5002a22b33fb776e552fbec2219", "type": "github" }, "original": { diff --git a/jsapi/test/Main.hs b/jsapi/test/Main.hs index 7c62abf91..ae4b87369 100644 --- a/jsapi/test/Main.hs +++ b/jsapi/test/Main.hs @@ -31,8 +31,8 @@ foreign import javascript interruptible "testStart($1, $c);" initComplete #else initComplete :: Object -> JSM () initComplete api = - void $ api ^. js1 "version" (fun $ \ _ _ [ver] -> - fromJSValUnchecked ver >>= (liftIO . putStrLn)) + void $ api ^. js1 "version" (fun $ \ _ _ xs -> + fromJSValUnchecked (head xs) >>= (liftIO . putStrLn)) #endif -- When runing the native version, point a browser at http://localhost:3757/