Skip to content

Commit 9a6323b

Browse files
committed
refactor: add hspec, nix, and switch to cabal
+ Use hspec with the existing golden tests + Use cabal instead of stack, and give deps some sensible constraints + Use nix flake to get cabal, ghc, etc.
1 parent 72d536a commit 9a6323b

File tree

10 files changed

+819
-283
lines changed

10 files changed

+819
-283
lines changed

.github/workflows/haskell.yml

Lines changed: 32 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@ name: Haskell CI
22

33
on:
44
push:
5-
branches:
6-
- '*'
7-
pull_request:
8-
branches: [ "master" ]
5+
workflow_dispatch:
96

107
permissions:
118
contents: read
129

1310
jobs:
1411
fourmolu:
15-
1612
runs-on: ubuntu-latest
17-
13+
1814
steps:
19-
- uses: actions/checkout@v3
20-
- uses: haskell-actions/run-fourmolu@v9
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
- uses: haskell-actions/run-fourmolu@3b7702b41516aa428dfe6e295dc73476ae58f69e # v11
2117
with:
2218
version: "0.14.0.0"
2319
build:
@@ -27,104 +23,58 @@ jobs:
2723
fail-fast: false
2824
matrix:
2925
os: [windows-latest, macos-latest, ubuntu-latest]
30-
ghc-version: ['9.6', '9.4', '9.2', '9.0']
26+
ghc-version: ["9.12", "9.10", "9.8", "9.6", "9.4", "9.2"]
3127

3228
steps:
33-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3430

3531
- name: Set up GHC ${{ matrix.ghc-version }}
36-
uses: haskell/actions/setup@v2
32+
uses: haskell-actions/setup@96f3dafd067155f32643c2a0757ab71d2910e2c2 # v2.8.0
3733
id: setup
3834
with:
3935
ghc-version: ${{ matrix.ghc-version }}
40-
enable-stack: true
4136

4237
- name: Installed minor versions of GHC, Cabal, and Stack
4338
shell: bash
4439
run: |
4540
GHC_VERSION=$(ghc --numeric-version)
4641
CABAL_VERSION=$(cabal --numeric-version)
47-
STACK_VERSION=$(stack --numeric-version)
4842
echo "GHC_VERSION=${GHC_VERSION}" >> "${GITHUB_ENV}"
4943
echo "CABAL_VERSION=${CABAL_VERSION}" >> "${GITHUB_ENV}"
50-
echo "STACK_VERSION=${STACK_VERSION}" >> "${GITHUB_ENV}"
44+
45+
- name: Check cabal file
46+
run: cabal check
5147

5248
- name: Configure the build
5349
run: |
54-
# cabal configure --enable-tests --enable-benchmarks --disable-documentation
55-
# cabal build --dry-run
56-
stack build --test --bench --no-haddock --dry-run
57-
# The last step generates dist-newstyle/cache/plan.json for the cache key.
58-
59-
- name: Restore .stack-work cache
60-
uses: actions/cache/restore@v3
61-
id: cache-restore-stack-work
62-
with:
63-
path: .stack-work
64-
key: ${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
65-
restore-keys: |
66-
${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-work-
67-
68-
- name: Restore ~/.stack cache (Unix)
69-
uses: actions/cache/restore@v3
70-
id: cache-restore-stack-global-unix
71-
if: runner.os == 'Linux' || runner.os == 'macOS'
72-
with:
73-
path: ~/.stack
74-
key: ${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
75-
restore-keys: |
76-
${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-global-
77-
78-
- name: Restore %APPDATA%\stack, %LOCALAPPDATA%\Programs\stack cache (Windows)
79-
uses: actions/cache/restore@v3
80-
id: cache-restore-stack-global-windows
81-
if: runner.os == 'Windows'
50+
cabal configure --enable-tests --enable-benchmarks --disable-documentation
51+
cabal build --dry-run
52+
53+
- name: Restore cached dependencies
54+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
55+
id: cache
56+
env:
57+
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
8258
with:
83-
path: |
84-
~\AppData\Roaming\stack
85-
~\AppData\Local\Programs\stack
86-
key: ${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
87-
restore-keys: |
88-
${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-stack-${{ env.STACK_VERSION }}-stack-global-
59+
path: ${{ steps.setup.outputs.cabal-store }}
60+
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
61+
restore-keys: ${{ env.key }}-
8962

9063
- name: Build dependencies
91-
run: stack build --only-dependencies
64+
run: cabal build --only-dependencies
9265

93-
- name: Build the package
94-
run: stack build
95-
96-
- name: Save .stack-work cache
97-
uses: actions/cache/save@v3
98-
id: cache-save-stack-work
99-
if: steps.cache-restore-stack-work.outputs.cache-hit != 'true'
100-
with:
101-
path: .stack-work
102-
key: ${{ steps.cache-restore-stack-work.outputs.cache-primary-key }}
103-
104-
- name: Save %APPDATA%\stack, %LOCALAPPDATA%\Programs\stack cache (Windows)
105-
uses: actions/cache/save@v3
106-
if: runner.os == 'Windows'
107-
&& steps.cache-restore-stack-global-windows.outputs.cache-hit != 'true'
66+
- name: Save cached dependencies
67+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
68+
if: steps.cache.outputs.cache-hit != 'true'
10869
with:
109-
path: |
110-
~\AppData\Roaming\stack
111-
~\AppData\Local\Programs\stack
112-
key: ${{ steps.cache-restore-stack-global-windows.outputs.cache-primary-key }}
113-
114-
- name: Save ~/.stack cache (Unix)
115-
uses: actions/cache/save@v3
116-
id: cache-save-stack-global
117-
if: (runner.os == 'Linux' || runner.os == 'macOS')
118-
&& steps.cache-restore-stack-global-unix.outputs.cache-hit != 'true'
119-
with:
120-
path: ~/.stack
121-
key: ${{ steps.cache-restore-stack-global-unix.outputs.cache-primary-key }}
70+
path: ${{ steps.setup.outputs.cabal-store }}
71+
key: ${{ steps.cache.outputs.cache-primary-key }}
12272

123-
- name: Run tests
124-
run: stack test
73+
- name: Build the package
74+
run: cabal build all
12575

126-
- name: Check cabal file
127-
run: cabal check
76+
- name: Run tests
77+
run: cabal test all
12878

12979
- name: Build documentation
130-
run: stack haddock
80+
run: cabal haddock all --disable-documentation

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased changes
44

5+
- Use Hspec for tests
6+
- Add nix flake
7+
58
## [v0.2.0.0](https://github.com/rasheedja/LPPaver/tree/v0.2.0.0)
69

710
- Setup CI

0 commit comments

Comments
 (0)