Skip to content

Commit

Permalink
Use setup-haskell action
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Jan 1, 2023
1 parent 29d3103 commit db7ed18
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 94 deletions.
27 changes: 7 additions & 20 deletions .github/workflows/github-page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
fail-fast: false
matrix:
ghc: ["8.10.7"]
cabal: ["3.8.1.0"]
os: [ubuntu-latest]

env:
Expand All @@ -36,26 +37,12 @@ jobs:
LD_LIBRARY_PATH: ${{ (matrix.os != 'windows-latest' && '/usr/local/lib') || '' }}

steps:
# 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.8.1.0
ghc --version
cabal --version
- name: "Setup cabal-store"
id: cabal-store
shell: bash
run: |
cabal help user-config
cabal_config_file="$(cabal help user-config | grep -A 1 'You can edit the cabal configuration file to set defaults' | tail -n 1 | xargs)"
echo "cabal-store=$(dirname "$cabal_config_file")/store" | tee -a "$GITHUB_OUTPUT"
- name: Install Haskell
uses: input-output-hk/setup-haskell@v1
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- uses: actions/checkout@v2

Expand Down
93 changes: 19 additions & 74 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
n: [1]

ghc: ["8.10.7"]
cabal: ["3.8.1.0"]
os: [ubuntu-latest, macos-latest, windows-latest]

env:
Expand All @@ -49,78 +50,22 @@ jobs:
CACHE_VERSION: "2022-12-28"

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-libsodium `
mingw-w64-x86_64-openssl `
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.8.1.0
ghc --version
cabal --version
- name: "WIN: fixup cabal config"
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
# Unify the computation of the cabal store directory to a single step. This makes referencing the cabal
# store in later steps easier.
#
# We know on cabal store is located in the following locations by OS:
#
# Linux: /home/runner/.cabal/store
# MacOS: /Users/runner/.cabal/store
# Windows: C:\cabal\store
#
# However, we compute these as best be can from information cabal provides in case this changes in the future.
- name: "Setup cabal-store"
id: cabal-store
shell: bash
run: |
cabal help user-config
cabal_config_file="$(cabal help user-config | grep -A 1 'You can edit the cabal configuration file to set defaults' | 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: Install Haskell
uses: input-output-hk/setup-haskell@v1
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
pacman-packages: >
mingw-w64-x86_64-pkg-config
mingw-w64-x86_64-libsodium
mingw-w64-x86_64-openssl
base-devel
autoconf-wrapper
autoconf
automake
libtool
make
- uses: actions/checkout@v2

Expand Down Expand Up @@ -228,7 +173,7 @@ jobs:
with:
region: ${{ secrets.BINARY_CACHE_REGION }}
dist-dir: dist-newstyle
store-path: ${{ steps.cabal-store.outputs.cabal-store }}
store-path: ${{ steps.setup-haskell.outputs.cabal-store }}
threads: 16
archive-uri: ${{ secrets.BINARY_CACHE_URI }}/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}
skip: "${{ secrets.BINARY_CACHE_URI == '' }}"
Expand All @@ -246,7 +191,7 @@ jobs:
uses: action-works/cabal-cache-s3@v1
with:
dist-dir: dist-newstyle
store-path: ${{ steps.cabal-store.outputs.cabal-store }}
store-path: ${{ steps.setup-haskell.outputs.cabal-store }}
threads: 16
archive-uri: https://iohk.cache.haskellworks.io/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}
skip: "${{ secrets.BINARY_CACHE_URI != '' }}"
Expand Down

0 comments on commit db7ed18

Please sign in to comment.