Skip to content

Commit 33f980a

Browse files
committed
Use msys2 on Windows in github actions
1 parent e9037f0 commit 33f980a

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

.github/workflows/haskell.yml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,70 @@ jobs:
1212
ghc: ["8.10.7", "9.2.2"]
1313
os: [ubuntu-latest, macos-latest, windows-latest]
1414

15+
defaults:
16+
run:
17+
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
18+
1519
steps:
20+
- name: "WIN: Setup MSYS2 and libraries"
21+
if: runner.os == 'Windows'
22+
uses: msys2/setup-msys2@v2
23+
with:
24+
update: true
25+
install: >-
26+
base-devel
27+
autoconf-wrapper
28+
autoconf
29+
automake
30+
libtool
31+
make
32+
git
33+
mingw-w64-x86_64-jq
34+
1635
- name: Set cache version
1736
run: echo "CACHE_VERSION=pu4Aevoo" >> $GITHUB_ENV
1837

19-
- name: "Setup Haskell"
38+
- name: "LINUX: Setup Haskell"
2039
uses: haskell/actions/setup@v1
40+
if: runner.os != 'Windows'
2141
id: setup-haskell
2242
with:
2343
ghc-version: ${{ matrix.ghc }}
2444
cabal-version: 3.6.2.0
2545

46+
- name: "WIN: Setup Haskell"
47+
id: win-setup-haskell
48+
if: runner.os == 'Windows'
49+
run: |
50+
# see https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/scripts/bootstrap/bootstrap-haskell
51+
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \
52+
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
53+
BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=1 \
54+
BOOTSTRAP_HASKELL_ADJUST_BASHRC=1 \
55+
BOOTSTRAP_HASKELL_GHC_VERSION="${{ matrix.ghc }}" \
56+
BOOTSTRAP_HASKELL_CABAL_VERSION="3.6.2.0" \
57+
sh
58+
59+
# MSYS2 doesn't inherit $GITHUB_PATH so this is needed
60+
cat <(echo "source /c/ghcup/env") ~/.bashrc > ~/.bashrc.new
61+
mv ~/.bashrc.new ~/.bashrc
62+
63+
source ~/.bashrc
64+
65+
# There is an issue with crt libraries, fixed by prepending the ghc
66+
# mingw32 libraries directory to every other library directory.
67+
echo "# Original cabal config extra-lib-dirs"
68+
grep extra-lib-dirs /c/cabal/config
69+
70+
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
71+
72+
echo "# Modified cabal config extra-lib-dirs"
73+
grep extra-lib-dirs /c/cabal/config
74+
75+
ghc --version
76+
cabal --version
77+
echo "::set-output name=cabal-store::$(dirname $(cabal --help | tail -1 | tr -d ' '))\\store"
78+
2679
- uses: actions/checkout@v2
2780

2881
- name: "Configure cabal.project.local"

0 commit comments

Comments
 (0)