Skip to content

Commit 4a8ef27

Browse files
committed
Various minor changes
- Re-enabling mate on failure - Use windows default shell - split up win setup - harmonize ghc install - tmate on failure only - PKG_CONFIG_PATH mutilation on unixy things only with export - fix cache store path. - missing env var
1 parent 55ccfb3 commit 4a8ef27

File tree

1 file changed

+69
-62
lines changed

1 file changed

+69
-62
lines changed

.github/workflows/haskell.yml

Lines changed: 69 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ jobs:
1717
build:
1818
runs-on: ${{ matrix.os }}
1919

20-
defaults:
21-
run:
22-
shell: bash
23-
2420
strategy:
2521
fail-fast: false
2622
matrix:
@@ -40,40 +36,38 @@ jobs:
4036

4137
steps:
4238
- name: "View pkg-config"
43-
run: |
44-
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
45-
46-
- name: "LINUX,MAC: Setup haskell"
47-
if: runner.os != 'Windows'
48-
uses: haskell/actions/setup@v1
49-
id: setup-haskell
50-
with:
51-
ghc-version: ${{ matrix.ghc }}
52-
cabal-version: 3.8.1.0
39+
run: echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
5340

54-
- name: "WIN: Install ghcup"
55-
shell: pwsh
41+
- name: "WIN: Install System Dependencies via pacman (msys2)"
5642
if: runner.os == 'Windows'
5743
run: |
58-
# ghcup should be installed on current GHA Windows runners. Let's use ghcup to run
59-
# pacman, to install the necessary dependencies, ...
60-
ghcup run -- pacman --noconfirm -S `
61-
mingw-w64-x86_64-pkg-config `
62-
mingw-w64-x86_64-libsodium `
63-
base-devel `
64-
autoconf-wrapper `
65-
autoconf `
66-
automake `
67-
libtool `
68-
make `
69-
openssl-devel
70-
71-
# ... and also the ghc and cabal combination we want.
44+
# ghcup should be installed on current GHA Windows runners. Let's use ghcup to run
45+
# pacman, to install the necessary dependencies, ...
46+
ghcup run -- pacman --noconfirm -S `
47+
mingw-w64-x86_64-pkg-config `
48+
mingw-w64-x86_64-libsodium `
49+
base-devel `
50+
autoconf-wrapper `
51+
autoconf `
52+
automake `
53+
libtool `
54+
make
55+
56+
# this seems to break something. It _must_ come after the pacman setup
57+
# above. It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and
58+
# as such we'd need pacman.exe instead.
59+
- name: Setup Haskell
60+
run: |
61+
# Use GHCUP to manage ghc/cabal
7262
ghcup install ghc --set ${{ matrix.ghc }}
7363
ghcup install cabal --set 3.6.2.0
7464
7565
ghc --version
7666
cabal --version
67+
68+
- name: "WIN: fixup cabal config"
69+
if: runner.os == 'Windows'
70+
run: |
7771
# make sure cabal knows about msys64, and mingw64 tools. Not clear why C:/cabal/config is empty
7872
# and C:/cabal doesn't even exist. The ghcup bootstrap file should have create it in the image:
7973
# See https://github.com/haskell/ghcup-hs/blob/787edc17af4907dbc51c85e25c490edd8d68b80b/scripts/bootstrap/bootstrap-haskell#L591
@@ -97,29 +91,30 @@ jobs:
9791
run: |
9892
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
9993
100-
- name: "OUTPUT Record cabal-store"
94+
- name: "OUTPUT Record cabal-store (Linux)"
95+
id: lin-setup-haskell
96+
if: runner.os != 'Windows'
97+
run: echo "cabal-store=/home/runner/.cabal/store" >> $GITHUB_OUTPUT
98+
99+
- name: "OUTPUT Record cabal-store (Windows)"
101100
id: win-setup-haskell
102-
shell: bash
103101
if: runner.os == 'Windows'
104-
run: echo "cabal-store=$(dirname $(cabal --help | tail -1 | tr -d ' '))\\store" >> $GITHUB_OUTPUT
102+
shell: bash
103+
run: echo "cabal-store=C:\\cabal\\store" >> $GITHUB_OUTPUT
105104

106105
- name: Set cache version
107106
run: echo "CACHE_VERSION=grFfw8r" >> $GITHUB_ENV
108107

109108
- uses: actions/checkout@v2
110109

111-
- name: Add build script path
112-
shell: bash
113-
run: |
114-
touch ~/.bashrc
115-
if [ "${{ runner.os }}" == "Windows" ]; then
116-
# MSYS2 doesn't inherit $GITHUB_PATH, so this workaround is needed
117-
cat <(echo "export PATH=$PATH:$(pwd)/.github/bin") ~/.bashrc > ~/.bashrc.new
118-
mv ~/.bashrc.new ~/.bashrc
119-
else
120-
# MacOS and Linux use $GITUB_PATH
121-
echo "$(pwd)/.github/bin" >> $GITHUB_PATH
122-
fi
110+
- name: "[PowerShell] Add build script path"
111+
if: runner.os == 'Windows'
112+
shell: pwsh
113+
run: Add-Content $env:GITHUB_PATH "$(pwd)/.github/bin"
114+
115+
- name: "[Bash] Add build script path"
116+
if: runner.os != 'Windows'
117+
run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH
123118

124119
- name: "LINUX: Install build environment (apt-get)"
125120
if: runner.os == 'Linux'
@@ -169,6 +164,7 @@ jobs:
169164
run: cabal update
170165

171166
- name: Configure build
167+
shell: bash
172168
run: |
173169
if [ "${{github.event.inputs.tests}}" == "all" ]; then
174170
echo "Reconfigure cabal projects to run tests for all dependencies"
@@ -180,14 +176,18 @@ jobs:
180176
echo "# cabal.project.local"
181177
cat cabal.project.local
182178
183-
- name: Record dependencies
184-
id: record-deps
179+
- name: Update pkg-config paths
180+
if: runner.os != 'Windows'
185181
run: |
186182
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
187183
export PKG_CONFIG_PATH="/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
188184
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
185+
186+
- name: Record dependencies
187+
id: record-deps
188+
run: |
189189
cabal build all --dry-run
190-
cat ${{ env.PLAN_JSON }} | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
190+
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
191191
192192
- name: "OUTPUT Record weeknum"
193193
shell: bash
@@ -196,7 +196,7 @@ jobs:
196196
- name: Cache Cabal store
197197
uses: actions/cache@v2
198198
with:
199-
path: ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.setup-haskell.outputs.cabal-store }}
199+
path: ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.lin-setup-haskell.outputs.cabal-store }}
200200
key: cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}-${{ hashFiles('date.txt') }}
201201
restore-keys: |
202202
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
@@ -213,27 +213,33 @@ jobs:
213213

214214
- name: Build
215215
run: |
216-
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
217-
export PKG_CONFIG_PATH="/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
218-
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
216+
env | grep PKG_CONFIG_PATH
219217
cabal build cardano-node cardano-cli cardano-node-chairman cardano-submit-api
220218
219+
- name: Run tests (all)
220+
if: github.event.inputs.tests == "all"
221+
env:
222+
TMPDIR: ${{ runner.temp }}
223+
TMP: ${{ runner.temp }}
224+
KEEP_WORKSPACE: 1
225+
run: cabal test all
226+
221227
- name: Run tests
222-
run: |
223-
if [ "${{github.event.inputs.tests}}" == "all" ]; then
224-
TMPDIR="${{ runner.temp }}" TMP="${{ runner.temp }}" KEEP_WORKSPACE=1 cabal test all;
225-
else
226-
TMPDIR="${{ runner.temp }}" TMP="${{ runner.temp }}" KEEP_WORKSPACE=1 cabal test \
228+
if: github.event.inputs.tests != "all"
229+
env:
230+
TMPDIR: ${{ runner.temp }}
231+
TMP: ${{ runner.temp }}
232+
KEEP_WORKSPACE: 1
233+
run: cabal test \
227234
cardano-testnet \
228235
cardano-api \
229236
cardano-node \
230237
cardano-node-chairman \
231238
cardano-cli \
232239
cardano-submit-api
233-
fi
234-
235240

236241
- name: "Tar artifacts"
242+
shell: bash
237243
run: |
238244
mkdir -p artifacts
239245
@@ -258,6 +264,7 @@ jobs:
258264

259265
- name: Delete socket files in chairman tests in preparation for uploading artifacts
260266
if: ${{ always() }}
267+
shell: bash
261268
run: |
262269
if [ -d "${{ runner.temp }}/chairman" ]; then
263270
find "${{ runner.temp }}/chairman" -type s -exec rm -f {} \;
@@ -275,9 +282,9 @@ jobs:
275282
# `/msys2/mingw64` paths are not in PATH by default for the workflow, but tmate
276283
# will put them in.
277284
#
278-
# - name: Setup tmate session
279-
# if: ${{ matrix.os == 'windows-latest' }}
280-
# uses: mxschmitt/action-tmate@v3
285+
- name: Setup tmate session
286+
if: ${{ failure() }}
287+
uses: mxschmitt/action-tmate@v3
281288

282289
release:
283290
needs: [build]

0 commit comments

Comments
 (0)