Skip to content

Commit 078d611

Browse files
authored
Switch to Cabal (#4)
* Enable CI on every branch * Use model cabal workflow + From https://github.com/haskell/actions/tree/f334d58da81a3d707ada2ce33c610252737af896/setup#model-cabal-workflow-with-caching * Remove stack * Upgrade cabal-version, move extensions to cabal file
1 parent 20960f3 commit 078d611

File tree

8 files changed

+81
-156
lines changed

8 files changed

+81
-156
lines changed

.github/workflows/haskell.yml

Lines changed: 72 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ name: Haskell CI
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches:
6+
- '*'
67
pull_request:
78
branches: [ "master" ]
89

@@ -18,33 +19,76 @@ jobs:
1819
- uses: actions/checkout@v3
1920
- uses: haskell-actions/run-ormolu@v11
2021
build:
22+
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os: [ubuntu-latest]
28+
ghc-version: ['9.6', '9.4', '9.2', '9.0', '8.10']
2129

22-
runs-on: ubuntu-latest
30+
include:
31+
- os: windows-latest
32+
ghc-version: '9.6'
33+
- os: macos-latest
34+
ghc-version: '9.6'
2335

2436
steps:
25-
- uses: actions/checkout@v3
26-
- uses: actions/setup-haskell@v1
27-
with:
28-
ghc-version: '8.10.3'
29-
cabal-version: '3.2'
30-
31-
- name: Cache
32-
uses: actions/cache@v3
33-
env:
34-
cache-name: cache-cabal
35-
with:
36-
path: ~/.cabal
37-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
38-
restore-keys: |
39-
${{ runner.os }}-build-${{ env.cache-name }}-
40-
${{ runner.os }}-build-
41-
${{ runner.os }}-
42-
43-
- name: Install dependencies
44-
run: |
45-
cabal update
46-
cabal build --only-dependencies --enable-tests --enable-benchmarks
47-
- name: Build
48-
run: cabal build --enable-tests --enable-benchmarks all
49-
- name: Run tests
50-
run: cabal test all
37+
- uses: actions/checkout@v3
38+
39+
- name: Set up GHC ${{ matrix.ghc-version }}
40+
uses: haskell/actions/setup@v2
41+
id: setup
42+
with:
43+
ghc-version: ${{ matrix.ghc-version }}
44+
# Defaults, added for clarity:
45+
cabal-version: 'latest'
46+
cabal-update: true
47+
48+
- name: Installed minor versions of GHC and Cabal
49+
shell: bash
50+
run: |
51+
GHC_VERSION=$(ghc --numeric-version)
52+
CABAL_VERSION=$(cabal --numeric-version)
53+
echo "GHC_VERSION=${GHC_VERSION}" >> "${GITHUB_ENV}"
54+
echo "CABAL_VERSION=${CABAL_VERSION}" >> "${GITHUB_ENV}"
55+
56+
- name: Configure the build
57+
run: |
58+
cabal configure --enable-tests --enable-benchmarks --disable-documentation
59+
cabal build --dry-run
60+
# The last step generates dist-newstyle/cache/plan.json for the cache key.
61+
62+
- name: Restore cached dependencies
63+
uses: actions/cache/restore@v3
64+
id: cache
65+
with:
66+
path: ${{ steps.setup.outputs.cabal-store }}
67+
key: ${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-cabal-${{ env.CABAL_VERSION }}-plan-${{ hashFiles('**/plan.json') }}
68+
restore-keys: |
69+
${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-cabal-${{ env.CABAL_VERSION }}-
70+
71+
- name: Install dependencies
72+
run: cabal build all --only-dependencies
73+
74+
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
75+
- name: Save cached dependencies
76+
uses: actions/cache/save@v3
77+
# Caches are immutable, trying to save with the same key would error.
78+
if: ${{ !steps.cache.outputs.cache-hit
79+
|| steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }}
80+
with:
81+
path: ${{ steps.setup.outputs.cabal-store }}
82+
key: ${{ steps.cache.outputs.cache-primary-key }}
83+
84+
- name: Build
85+
run: cabal build all
86+
87+
- name: Run tests
88+
run: cabal test all
89+
90+
- name: Check cabal file
91+
run: cabal check
92+
93+
- name: Build documentation
94+
run: cabal haddock all

Setup.hs

Lines changed: 0 additions & 3 deletions
This file was deleted.

package.yaml

Lines changed: 0 additions & 33 deletions
This file was deleted.

simplex-method.cabal

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cabal-version: 1.12
1+
cabal-version: 3.6
22

33
-- This file has been generated from package.yaml by hpack version 0.34.4.
44
--
@@ -14,7 +14,7 @@ bug-reports: https://github.com/rasheedja/simplex-method/issues
1414
author: Junaid Rasheed
1515
maintainer: [email protected]
1616
copyright: BSD-3
17-
license: BSD3
17+
license: BSD-3-Clause
1818
license-file: LICENSE
1919
build-type: Simple
2020
extra-source-files:
@@ -25,26 +25,30 @@ source-repository head
2525
type: git
2626
location: https://github.com/rasheedja/simplex-method
2727

28+
common common-extensions
29+
default-extensions:
30+
LambdaCase
31+
TupleSections
32+
2833
library
34+
import: common-extensions
2935
exposed-modules:
3036
Linear.Simplex.Prettify
3137
Linear.Simplex.Simplex
3238
Linear.Simplex.Types
3339
Linear.Simplex.Util
34-
other-modules:
35-
Paths_simplex_method
3640
hs-source-dirs:
3741
src
3842
build-depends:
3943
base >=4.7 && <5
4044
default-language: Haskell2010
4145

4246
test-suite simplex-haskell-test
47+
import: common-extensions
4348
type: exitcode-stdio-1.0
4449
main-is: Spec.hs
4550
other-modules:
4651
TestFunctions
47-
Paths_simplex_method
4852
hs-source-dirs:
4953
test
5054
build-depends:

src/Linear/Simplex/Simplex.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
{-# LANGUAGE LambdaCase #-}
2-
{-# LANGUAGE TupleSections #-}
3-
41
-- |
52
-- Module : Linear.Simplex.Simplex
63
-- Description : Implements the twoPhaseSimplex method

src/Linear/Simplex/Util.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
{-# LANGUAGE LambdaCase #-}
2-
31
-- |
42
-- Module : Linear.Simplex.Util
53
-- Description : Helper functions

stack.yaml

Lines changed: 0 additions & 69 deletions
This file was deleted.

stack.yaml.lock

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)