Skip to content

Commit 56f8905

Browse files
committed
hackport.cabal: Fix doctest-v2
build-tool-depends doesn't play nice with Setup.hs installs, and tries to rebuild cabal-install/doctest locally. This has recently caused some compilation errors when it tries to build cabal-install, so we'll just remove it from build-tool-depends on the assumption that whoever is running doctest-v2 probably has /usr/bin/cabal on their system. Switch to `cabal-version: 'latest'` instead of a matrix of cabal versions for github action. Use template from haskell/actions/setup homepage where possible: https://github.com/haskell/actions/tree/main/setup#model-cabal-workflow-with-caching This reverts commit 51bc8c1. See: gentoo-haskell/gentoo-haskell#1074 See: haskell/cabal#8434 Signed-off-by: hololeap <[email protected]>
1 parent d80f12e commit 56f8905

File tree

2 files changed

+59
-51
lines changed

2 files changed

+59
-51
lines changed

.github/workflows/haskell.yml

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,76 @@
11
name: Haskell CI
2-
32
on:
43
push:
5-
branches: [ master ]
4+
branches: [main, master]
65
pull_request:
7-
branches: [ master ]
6+
branches: [main, master]
7+
8+
permissions:
9+
contents: read
810

911
jobs:
1012
build:
11-
12-
runs-on: ubuntu-latest
13+
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
1315
strategy:
16+
fail-fast: false
1417
matrix:
15-
cabal:
16-
[ "3.4"
17-
, "3.6"
18-
, "3.8"
19-
]
20-
ghc:
18+
os: [ubuntu-latest]
19+
ghc-version:
2120
[ "8.8"
2221
, "8.10"
2322
, "9.0"
2423
, "9.2"
2524
, "9.4"
2625
]
27-
exclude:
28-
- cabal: "3.4"
29-
ghc: "9.2"
30-
- cabal: "3.4"
31-
ghc: "9.4"
32-
- cabal: "3.6"
33-
ghc: "9.4"
26+
3427
steps:
35-
- uses: actions/checkout@v3
36-
with:
37-
submodules: 'recursive'
38-
- uses: haskell/actions/setup@v2
39-
with:
40-
ghc-version: ${{ matrix.ghc }}
41-
cabal-version: ${{ matrix.cabal }}
28+
- uses: actions/checkout@v3
29+
with:
30+
submodules: 'recursive'
31+
32+
- name: Set up GHC ${{ matrix.ghc-version }}
33+
uses: haskell/actions/setup@v2
34+
id: setup
35+
with:
36+
ghc-version: ${{ matrix.ghc-version }}
37+
# Defaults, added for clarity:
38+
cabal-version: 'latest'
39+
cabal-update: true
40+
41+
- name: Check cabal file
42+
run: cabal check
43+
44+
- name: Configure the build
45+
run: |
46+
cabal configure --enable-tests --enable-benchmarks --disable-documentation --flag=pedantic
47+
cabal build --dry-run
48+
# The last step generates dist-newstyle/cache/plan.json for the cache key.
49+
50+
- name: Restore cached dependencies
51+
uses: actions/cache/restore@v3
52+
id: cache
53+
env:
54+
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
55+
with:
56+
path: ${{ steps.setup.outputs.cabal-store }}
57+
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
58+
restore-keys: ${{ env.key }}-
59+
60+
- name: Install dependencies
61+
run: cabal build all --only-dependencies
62+
63+
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
64+
- name: Save cached dependencies
65+
uses: actions/cache/save@v3
66+
# Caches are immutable, trying to save with the same key would error.
67+
if: ${{ steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }}
68+
with:
69+
path: ${{ steps.setup.outputs.cabal-store }}
70+
key: ${{ steps.cache.outputs.cache-primary-key }}
4271

43-
- name: Cache
44-
uses: actions/cache@v3
45-
env:
46-
cache-name: cache-cabal
47-
with:
48-
path: ~/.cabal
49-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
50-
restore-keys: |
51-
${{ runner.os }}-build-${{ env.cache-name }}-
52-
${{ runner.os }}-build-
53-
${{ runner.os }}-
72+
- name: Build
73+
run: cabal build all
5474

55-
- name: Configure
56-
run: |
57-
cabal update
58-
cabal configure --enable-tests --enable-benchmarks --flag=pedantic
59-
- name: Install dependencies
60-
run: |
61-
cabal build --only-dependencies
62-
- name: Build
63-
run: cabal build
64-
- name: Run spec test
65-
run: cabal test --test-option=--color --test-show-details=streaming spec
75+
- name: Run tests
76+
run: cabal test all --test-option=--color --test-show-details=streaming

hackport.cabal

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,9 +1026,6 @@ test-suite doctests
10261026

10271027
test-suite doctests-v2
10281028
import: warnings
1029-
-- doctests-v2 is causing problems, looking for ghc lib and alex on
1030-
-- github CI. This may be fixable.
1031-
buildable: False
10321029
type: exitcode-stdio-1.0
10331030
default-language: Haskell98
10341031
hs-source-dirs: tests/doctests-v2
@@ -1038,7 +1035,7 @@ test-suite doctests-v2
10381035
, process
10391036

10401037
build-tool-depends:
1041-
, cabal-install:cabal >=3.4
1038+
-- cabal-install should already be installed if this is being built...
10421039
, doctest:doctest >=0.8
10431040

10441041
if flag(cabal-v1)

0 commit comments

Comments
 (0)