Skip to content

Commit

Permalink
Use msys2 on Windows in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
coot committed Aug 10, 2022
1 parent b6d12c3 commit 9685075
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion .github/workflows/haskell.yml
Expand Up @@ -12,17 +12,70 @@ jobs:
ghc: ["8.10.7", "9.2.2"]
os: [ubuntu-latest, macos-latest, windows-latest]

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

steps:
- name: "WIN: Setup MSYS2 and libraries"
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
base-devel
autoconf-wrapper
autoconf
automake
libtool
make
git
mingw-w64-x86_64-jq
- name: Set cache version
run: echo "CACHE_VERSION=pu4Aevoo" >> $GITHUB_ENV

- name: "Setup Haskell"
- name: "LINUX: Setup Haskell"
uses: haskell/actions/setup@v1
if: runner.os != 'Windows'
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 3.6.2.0

- name: "WIN: Setup Haskell"
id: win-setup-haskell
if: runner.os == 'Windows'
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
# MSYS2 doesn't inherit $GITHUB_PATH so this is needed
cat <(echo "source /c/ghcup/env") ~/.bashrc > ~/.bashrc.new
mv ~/.bashrc.new ~/.bashrc
source ~/.bashrc
# There is an issue with crt libraries, fixed by prepending the ghc
# mingw32 libraries directory to every other library directory.
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
echo "::set-output name=cabal-store::$(dirname $(cabal --help | tail -1 | tr -d ' '))\\store"
- uses: actions/checkout@v2

- name: "Configure cabal.project.local"
Expand Down

0 comments on commit 9685075

Please sign in to comment.