Skip to content

Commit 590c129

Browse files
committed
CI: while we can't test on Windows, we still can build on it
1 parent 13ce16c commit 590c129

File tree

1 file changed

+77
-11
lines changed

1 file changed

+77
-11
lines changed

.github/workflows/validate.yml

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,71 @@ env:
3030
COMMON_FLAGS: '-j 2 -v'
3131

3232
jobs:
33+
windows-build:
34+
name: Windows, ghc-${{ matrix.ghc }}
35+
runs-on: "windows-latest"
36+
outputs:
37+
GHC_FOR_RELEASE: ${{ format('["{0}"]', env.GHC_FOR_RELEASE) }}
38+
strategy:
39+
matrix:
40+
ghc: ["9.6.1", "9.4.2", "9.2.3", "9.0.2"]
41+
steps:
42+
43+
- uses: actions/checkout@v3
44+
45+
- uses: haskell/actions/setup@v2
46+
id: setup-haskell
47+
with:
48+
ghc-version: ${{ matrix.ghc }}
49+
cabal-version: '3.8.1.0' # can't use 3.10, see
50+
# https://github.com/haskell/actions/issues/202#issuecomment-1465856373
51+
# this will force us to not configure/run tests
52+
53+
# The '+exe' constraint below is important, otherwise cabal-install
54+
# might decide to build the library but not the executable which is
55+
# what we need.
56+
- name: Install cabal-plan
57+
run: |
58+
cd $(mktemp -d)
59+
cabal install cabal-plan --allow-newer="base" --constraint='cabal-plan +exe'
60+
echo "$HOME/.cabal/bin:$HOME/.local/bin" >> $GITHUB_PATH
61+
62+
- name: Allow newer dependencies when built with latest GHC
63+
if: ${{ matrix.ghc }} == '9.6.1'
64+
run: |
65+
echo "allow-newer: *:base" >> cabal.project.release
66+
67+
- name: Validate print-config
68+
run: sh validate.sh $FLAGS -s print-config
69+
70+
- name: Validate print-tool-versions
71+
run: sh validate.sh $FLAGS -s print-tool-versions
72+
73+
- name: Release build
74+
run: cabal build all --project-file=cabal.project.release
75+
76+
- name: Tar cabal head executable
77+
if: matrix.ghc == env.GHC_FOR_RELEASE
78+
run: |
79+
CABAL_EXEC=$(cabal-plan list-bin cabal-install:exe:cabal)
80+
# We have to tar the executable to preserve executable permissions
81+
# see https://github.com/actions/upload-artifact/issues/38
82+
#
83+
# `cabal-plan` gives us a windows path but tar needs the posix one
84+
CABAL_EXEC=$(cygpath $CABAL_EXEC)
85+
tar -cvf cabal-head.tar -C $(dirname "$CABAL_EXEC") $(basename "$CABAL_EXEC")
86+
echo "CABAL_EXEC_TAR=cabal-head.tar" >> $GITHUB_ENV
87+
88+
# We upload the cabal executable built with the ghc used in the release for:
89+
# - Reuse it in the dogfooding job (although we could use the cached build dir)
90+
# - Make it available in the workflow to make easier testing it locally
91+
- name: Upload cabal-install executable to workflow artifacts
92+
if: matrix.ghc == env.GHC_FOR_RELEASE
93+
uses: actions/upload-artifact@v3
94+
with:
95+
name: cabal-${{ runner.os }}-${{ matrix.ghc }}
96+
path: ${{ env.CABAL_EXEC_TAR }}
97+
3398
validate:
3499
name: Validate ${{ matrix.os }} ghc-${{ matrix.ghc }}
35100
runs-on: ${{ matrix.os }}
@@ -57,12 +122,12 @@ jobs:
57122
# lot of segfaults caused by ghc bugs
58123
- os: "windows-latest"
59124
ghc: "8.8.4"
60-
# it also throws segfaults randomly
61-
- os: "windows-latest"
62-
ghc: "8.4.4"
63125
# it often randomly does "C:\Users\RUNNER~1\AppData\Local\Temp\ghcFEDE.c: DeleteFile "\\\\?\\C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\ghcFEDE.c": permission denied (Access is denied.)"
64126
- os: "windows-latest"
65127
ghc: "8.6.5"
128+
# it also throws segfaults randomly
129+
- os: "windows-latest"
130+
ghc: "8.4.4"
66131

67132
steps:
68133

@@ -101,6 +166,7 @@ jobs:
101166
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-20231920-
102167

103168
- name: Did we get a cache hit
169+
if: ${{ runner.os != 'Windows' }}
104170
continue-on-error: true
105171
run: echo "GHA cache hit:" ${{ steps.cache-haskell.outputs.cache-hit }}
106172

@@ -166,7 +232,7 @@ jobs:
166232
run: sh validate.sh $FLAGS -s build
167233

168234
- name: Tar cabal head executable
169-
if: matrix.cmoewmoewli != 'false' && matrix.ghc == env.GHC_FOR_RELEASE
235+
if: matrix.cli != 'false' && matrix.ghc == env.GHC_FOR_RELEASE
170236
run: |
171237
CABAL_EXEC=$(cabal-plan list-bin --builddir=dist-newstyle-validate-ghc-${{ matrix.ghc }} cabal-install:exe:cabal)
172238
# We have to tar the executable to preserve executable permissions
@@ -246,10 +312,10 @@ jobs:
246312
with:
247313
# validate.sh uses a special build dir
248314
path: |
249-
${{ steps.setup-haskell.outputs.cabal-store }}
315+
# TODO: need cabal store path; where does ghcup put it?
250316
dist-*
251-
key: ${{ runner.os }}-${{ matrix.ghc }}-20231920-${{ github.sha }}
252-
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-20231920-
317+
key: ${{ runner.os }}-prerelease-20231920-${{ github.sha }}
318+
restore-keys: ${{ runner.os }}-prerelease-20231920-
253319

254320
# See https://github.com/haskell/cabal/pull/8739
255321
- name: Sudo chmod to permit ghcup to update its cache
@@ -327,7 +393,8 @@ jobs:
327393
env:
328394
# `rawSystemStdInOut reports text decoding errors`
329395
# test does not find ghc without the full path in windows
330-
GHCPATH: ${{ steps.setup-haskell.outputs.ghc-exe }}
396+
GHCPATH: ${{ steps.setup-haskell.outputs.ghc-exe }} # TODO: we don't
397+
# use setup-haskell here, so above variable is not set
331398
run: sh validate.sh $FLAGS -s lib-tests
332399

333400
- name: Validate lib-suite
@@ -385,7 +452,6 @@ jobs:
385452
- uses: actions/cache@v3
386453
with:
387454
path: |
388-
${{ steps.setup-haskell.outputs.cabal-store }}
389455
dist-*
390456
key: ${{ runner.os }}-${{ matrix.ghc }}-20231920-${{ github.sha }}
391457
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-20231920-
@@ -421,7 +487,7 @@ jobs:
421487
dogfooding:
422488
name: Dogfooding ${{ matrix.os }} ghc-${{ matrix.ghc }}
423489
runs-on: ${{ matrix.os }}
424-
needs: validate
490+
needs: [validate, windows-build]
425491
strategy:
426492
matrix:
427493
os: ["ubuntu-20.04", "macos-latest", "windows-latest"]
@@ -481,7 +547,7 @@ jobs:
481547
name: Validate post job
482548
runs-on: ubuntu-20.04
483549
# IMPORTANT! Any job added to the workflow should be added here too
484-
needs: [validate, validate-old-ghcs, dogfooding]
550+
needs: [validate, windows-build, validate-old-ghcs, dogfooding]
485551

486552
steps:
487553
- run: |

0 commit comments

Comments
 (0)