Skip to content

Commit 54e36ad

Browse files
committed
Use setup-haskell action
1 parent cd8f02a commit 54e36ad

File tree

2 files changed

+26
-112
lines changed

2 files changed

+26
-112
lines changed

.github/workflows/github-page.yml

+7-29
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
ghc: ["8.10.7"]
17+
cabal: ["3.8.1.0"]
1718
os: [ubuntu-latest]
1819

1920
env:
@@ -26,36 +27,13 @@ jobs:
2627
# current ref from: 27.02.2022
2728
SECP256K1_REF: ac83be33d0956faf6b7f61a60ab524ef7d6a473a
2829

29-
# OpenSSL is installed in a non-standard location in MacOS. See
30-
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md
31-
PKG_CONFIG_PATH: ${{ (matrix.os == 'macos-latest' && '/usr/lib/pkgconfig:/usr/local/opt/[email protected]/lib/pkgconfig') || (matrix.os == 'ubuntu-latest' && '/usr/lib/pkgconfig:/usr/local/lib/pkgconfig') || '' }}
32-
33-
# we need the LD_LIBRARY_PATH env var here because we ended up installing libsecp256k1 into /usr/local,
34-
# pkg-config, *does* return the proper location, but the library does not appear to be properly referenced.
35-
# FIXME: this is arguably a bug, and pkg-config should return the right values!
36-
LD_LIBRARY_PATH: ${{ (matrix.os != 'windows-latest' && '/usr/local/lib') || '' }}
37-
3830
steps:
39-
# this seems to break something. It _must_ come after the pacman setup
40-
# above. It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and
41-
# as such we'd need pacman.exe instead.
42-
- name: Setup Haskell
43-
run: |
44-
# Use GHCUP to manage ghc/cabal
45-
ghcup install ghc --set ${{ matrix.ghc }}
46-
ghcup install cabal --set 3.8.1.0
47-
48-
ghc --version
49-
cabal --version
50-
51-
- name: "Setup cabal-store"
52-
id: cabal-store
53-
shell: bash
54-
run: |
55-
cabal help user-config
56-
cabal_config_file="$(cabal help user-config | grep -A 1 'You can edit the cabal configuration file to set defaults' | tail -n 1 | xargs)"
57-
58-
echo "cabal-store=$(dirname "$cabal_config_file")/store" | tee -a "$GITHUB_OUTPUT"
31+
- name: Install Haskell
32+
uses: input-output-hk/setup-haskell@v1
33+
id: setup-haskell
34+
with:
35+
ghc-version: ${{ matrix.ghc }}
36+
cabal-version: ${{ matrix.cabal }}
5937

6038
- uses: actions/checkout@v2
6139

.github/workflows/haskell.yml

+19-83
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
n: [1]
2626

2727
ghc: ["8.10.7"]
28+
cabal: ["3.8.1.0"]
2829
os: [ubuntu-latest, macos-latest, windows-latest]
2930

3031
env:
@@ -37,88 +38,23 @@ jobs:
3738
# current ref from: 27.02.2022
3839
SECP256K1_REF: ac83be33d0956faf6b7f61a60ab524ef7d6a473a
3940

40-
# OpenSSL is installed in a non-standard location in MacOS. See
41-
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md
42-
PKG_CONFIG_PATH: ${{ (matrix.os == 'macos-latest' && '/usr/lib/pkgconfig:/usr/local/opt/[email protected]/lib/pkgconfig') || (matrix.os == 'ubuntu-latest' && '/usr/lib/pkgconfig:/usr/local/lib/pkgconfig') || '' }}
43-
44-
# we need the LD_LIBRARY_PATH env var here because we ended up installing libsecp256k1 into /usr/local,
45-
# pkg-config, *does* return the proper location, but the library does not appear to be properly referenced.
46-
# FIXME: this is arguably a bug, and pkg-config should return the right values!
47-
LD_LIBRARY_PATH: ${{ (matrix.os != 'windows-latest' && '/usr/local/lib') || '' }}
48-
4941
steps:
50-
- name: "WIN: Install System Dependencies via pacman (msys2)"
51-
if: runner.os == 'Windows'
52-
run: |
53-
# ghcup should be installed on current GHA Windows runners. Let's use ghcup to run
54-
# pacman, to install the necessary dependencies, ...
55-
ghcup run -- pacman --noconfirm -S `
56-
mingw-w64-x86_64-pkg-config `
57-
mingw-w64-x86_64-libsodium `
58-
mingw-w64-x86_64-openssl `
59-
base-devel `
60-
autoconf-wrapper `
61-
autoconf `
62-
automake `
63-
libtool `
64-
make
65-
66-
# this seems to break something. It _must_ come after the pacman setup
67-
# above. It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and
68-
# as such we'd need pacman.exe instead.
69-
- name: Setup Haskell
70-
run: |
71-
# Use GHCUP to manage ghc/cabal
72-
ghcup install ghc --set ${{ matrix.ghc }}
73-
ghcup install cabal --set 3.8.1.0
74-
75-
ghc --version
76-
cabal --version
77-
78-
- name: "WIN: fixup cabal config"
79-
if: runner.os == 'Windows'
80-
run: |
81-
# make sure cabal knows about msys64, and mingw64 tools. Not clear why C:/cabal/config is empty
82-
# and C:/cabal doesn't even exist. The ghcup bootstrap file should have create it in the image:
83-
# See https://github.com/haskell/ghcup-hs/blob/787edc17af4907dbc51c85e25c490edd8d68b80b/scripts/bootstrap/bootstrap-haskell#L591
84-
# So we'll do it by hand here for now.
85-
#
86-
# We'll _not_ add extra-include-dirs, or extra-lib-dirs, and rely on what's shipped with GHC.
87-
# https://github.com/msys2/MINGW-packages/issues/10837#issuecomment-1047105402
88-
# https://gitlab.haskell.org/ghc/ghc/-/issues/21111
89-
# if we _do_ want them, this would be the lines to add below
90-
91-
$ghcMingwDir = Join-Path -Path $(ghc --print-libdir) `
92-
-ChildPath ../mingw/x86_64-*-mingw32/lib/ `
93-
-Resolve
94-
95-
cabal user-config -a "extra-prog-path: C:/msys64/mingw64/bin, C:/msys64/usr/bin" `
96-
-a "extra-include-dirs: C:/msys64/mingw64/include" `
97-
-a ("extra-lib-dirs: {0}, C:/msys64/mingw64/lib" -f $ghcMingwDir) `
98-
-f init
99-
100-
# Unify the computation of the cabal store directory to a single step. This makes referencing the cabal
101-
# store in later steps easier.
102-
#
103-
# We know on cabal store is located in the following locations by OS:
104-
#
105-
# Linux: /home/runner/.cabal/store
106-
# MacOS: /Users/runner/.cabal/store
107-
# Windows: C:\cabal\store
108-
#
109-
# However, we compute these as best be can from information cabal provides in case this changes in the future.
110-
- name: "Setup cabal-store"
111-
id: cabal-store
112-
shell: bash
113-
run: |
114-
cabal help user-config
115-
cabal_config_file="$(cabal help user-config | grep -A 1 'You can edit the cabal configuration file to set defaults' | tail -n 1 | xargs)"
116-
117-
if [[ '${{ runner.os }}' != 'Windows' ]]; then
118-
echo "cabal-store=$(dirname "$cabal_config_file")/store" | tee -a "$GITHUB_OUTPUT"
119-
else
120-
echo "cabal-store=C:\\cabal\\store" | tee -a "$GITHUB_OUTPUT"
121-
fi
42+
- name: Install Haskell
43+
uses: input-output-hk/setup-haskell@v1
44+
id: setup-haskell
45+
with:
46+
ghc-version: ${{ matrix.ghc }}
47+
cabal-version: ${{ matrix.cabal }}
48+
pacman-packages: >
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
12258
12359
- uses: actions/checkout@v2
12460

@@ -197,7 +133,7 @@ jobs:
197133
with:
198134
region: ${{ secrets.BINARY_CACHE_REGION }}
199135
dist-dir: dist-newstyle
200-
store-path: ${{ steps.cabal-store.outputs.cabal-store }}
136+
store-path: ${{ steps.setup-haskell.outputs.cabal-store }}
201137
threads: 16
202138
archive-uri: ${{ secrets.BINARY_CACHE_URI }}/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}
203139
skip: "${{ secrets.BINARY_CACHE_URI == '' }}"
@@ -215,7 +151,7 @@ jobs:
215151
uses: action-works/cabal-cache-s3@v1
216152
with:
217153
dist-dir: dist-newstyle
218-
store-path: ${{ steps.cabal-store.outputs.cabal-store }}
154+
store-path: ${{ steps.setup-haskell.outputs.cabal-store }}
219155
threads: 16
220156
archive-uri: https://iohk.cache.haskellworks.io/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}
221157
skip: "${{ secrets.BINARY_CACHE_URI != '' }}"

0 commit comments

Comments
 (0)