Skip to content

Commit 59621fe

Browse files
authored
Cabal ci (#1)
* added flake file * using modular arithmetic package and tests pass * temp disable tests * remove tests * problem with rules * Empty-Commit * remove nix files * builds with 9.8 9.6 * ormolu * add tests * changelog and bump package version
1 parent 8e1361d commit 59621fe

26 files changed

+776
-841
lines changed

.github/workflows/cabal.yml

+61-41
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,71 @@
1-
name: Cabal CI
2-
1+
name: build
32
on:
43
push:
5-
branches:
6-
- master
4+
branches: [main, master]
75
pull_request:
6+
branches: [main, master]
7+
8+
# INFO: The following configuration block ensures that only one build runs per branch,
9+
# which may be desirable for projects with a costly build process.
10+
# Remove this block from the CI workflow to let each CI job run to completion.
11+
concurrency:
12+
group: build-${{ github.ref }}
13+
cancel-in-progress: true
814

915
jobs:
1016
build:
11-
name: cabal-${{ matrix.cabal}} ${{ matrix.ghc }} ${{ matrix.os }}
17+
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
18+
runs-on: ${{ matrix.os }}
1219
strategy:
20+
fail-fast: false
1321
matrix:
14-
os: [ubuntu-latest, macOS-latest]
15-
ghc: ["8.10.1", "8.8.1", "8.6.5", "8.6.4", "8.6.3", "8.6.2"]
16-
cabal: ["3.0", "3.2"]
22+
os: [ubuntu-latest]
23+
ghc-version: ['9.8', '9.6']
1724

18-
runs-on: ${{ matrix.os }}
1925
steps:
20-
- uses: actions/checkout@v1
21-
- uses: actions/setup-haskell@v1
22-
name: Setup Haskell
23-
with:
24-
ghc-version: ${{ matrix.ghc }}
25-
cabal-version: ${{ matrix.cabal }}
26-
27-
- uses: actions/cache@v1
28-
name: Cache ~/.cabal/packages
29-
with:
30-
path: ~/.cabal/packages
31-
key: cabal-packages-${{ matrix.ghc }}
32-
33-
- uses: actions/cache@v1
34-
name: Cache ~/.cabal/store
35-
with:
36-
path: ~/.cabal/store
37-
key: cabal-store-${{ matrix.ghc }}
38-
39-
- uses: actions/cache@v1
40-
name: Cache dist-newstyle
41-
with:
42-
path: dist-newstyle
43-
key: dist-newstyle-${{ matrix.ghc }}
44-
45-
- name: Install dependencies
46-
run: |
47-
cabal update
48-
- name: Build
49-
run: |
50-
cabal new-install tasty-discover
51-
cabal new-build
26+
- uses: actions/checkout@v4
27+
28+
- name: Set up GHC ${{ matrix.ghc-version }}
29+
uses: haskell-actions/setup@v2
30+
id: setup
31+
with:
32+
ghc-version: ${{ matrix.ghc-version }}
33+
# Defaults, added for clarity:
34+
cabal-version: 'latest'
35+
cabal-update: true
36+
37+
- name: Configure the build
38+
run: |
39+
cabal configure --enable-tests --enable-benchmarks --disable-documentation
40+
cabal build all --dry-run
41+
# The last step generates dist-newstyle/cache/plan.json for the cache key.
42+
43+
- name: Restore cached dependencies
44+
uses: actions/cache/restore@v3
45+
id: cache
46+
env:
47+
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
48+
with:
49+
path: ${{ steps.setup.outputs.cabal-store }}
50+
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
51+
restore-keys: ${{ env.key }}-
52+
53+
- name: Install dependencies
54+
# If we had an exact cache hit, the dependencies will be up to date.
55+
if: steps.cache.outputs.cache-hit != 'true'
56+
run: cabal build all --only-dependencies
57+
58+
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
59+
- name: Save cached dependencies
60+
uses: actions/cache/save@v3
61+
# If we had an exact cache hit, trying to save the cache would error because of key clash.
62+
if: steps.cache.outputs.cache-hit != 'true'
63+
with:
64+
path: ${{ steps.setup.outputs.cabal-store }}
65+
key: ${{ steps.cache.outputs.cache-primary-key }}
66+
67+
- name: Build
68+
run: cabal build all
69+
70+
- name: Test
71+
run: cabal test all

.github/workflows/stack.yml

-60
This file was deleted.

ChangeLog.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change log for galois-field
22

3+
## 2.0.0
4+
5+
* Bump GHC versions to support 9.6 and 9.8 (9.4 seems to not be possible with certain
6+
uses of RULES, see [GHC #22761](https://gitlab.haskell.org/ghc/ghc/-/issues/22761))
7+
* Added CI with build matrix
8+
* Bump various dep version bounds
9+
* Switched to use `mod` package
10+
* Removed the INLINE pragmas for `pow`, they were broken on all GHC version (see [GHC #22716](https://gitlab.haskell.org/ghc/ghc/-/issues/22716))
11+
* Formatted with Ormolu
12+
313
## 1.0.3
414

515
* Add `fromU` for RootsOfUnity

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
</a>
55
</p>
66

7-
![Stack CI](https://github.com/adjoint-io/galois-field/workflows/Stack%20CI/badge.svg)
87
![Cabal CI](https://github.com/adjoint-io/galois-field/workflows/Cabal%20CI/badge.svg)
98
[![Hackage](https://img.shields.io/hackage/v/galois-field.svg)](https://hackage.haskell.org/package/galois-field)
109

bench/Bench/Binary.hs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
module Bench.Binary where
22

3-
import Protolude
4-
3+
import Bench.Galois
54
import Control.Monad.Random
65
import Criterion.Main
76
import Data.Field.Galois
8-
9-
import Bench.Galois
7+
import Protolude
108

119
type F2m = Binary 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425
1210

bench/Bench/Extension.hs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
module Bench.Extension where
22

3-
import Protolude
4-
3+
import Bench.Galois
4+
import Bench.Prime
55
import Control.Monad.Random
66
import Criterion.Main
77
import Data.Field.Galois
8-
9-
import Bench.Galois
10-
import Bench.Prime
8+
import Protolude
119

1210
data PU
11+
1312
instance IrreducibleMonic PU Fq where
1413
poly _ = X2 + 1
14+
1515
type Fq2 = Extension PU Fq
1616

1717
data PV
18+
1819
instance IrreducibleMonic PV Fq2 where
1920
poly _ = X3 - 9 - Y X
21+
2022
type Fq6 = Extension PV Fq2
2123

2224
data PW
25+
2326
instance IrreducibleMonic PW Fq6 where
2427
poly _ = X2 - Y X
28+
2529
type Fq12 = Extension PW Fq6
2630

2731
fq12 :: Fq12

bench/Bench/Galois.hs

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
module Bench.Galois where
22

3-
import Protolude
4-
53
import Criterion.Main
6-
import Data.Field.Galois hiding (recip, (/))
4+
import Data.Field.Galois
75
import GHC.Base
6+
import Protolude
87

9-
benchmark :: GaloisField k => String -> k -> k -> Benchmark
10-
benchmark s a b = bgroup s
11-
[ bench "Addition" $
12-
nf (uncurry (+)) (a, b)
13-
, bench "Multiplication" $
14-
nf (uncurry (*)) (a, b)
15-
, bench "Negation" $
16-
nf negate a
17-
, bench "Subtraction" $
18-
nf (uncurry (-)) (a, b)
19-
, bench "Inversion" $
20-
nf recip a
21-
, bench "Division" $
22-
nf (uncurry (/)) (a, b)
23-
, bench "Frobenius endomorphism" $
24-
nf frob a
25-
, bench "Square root" $
26-
nf sr a
27-
]
8+
benchmark :: (GaloisField k) => String -> k -> k -> Benchmark
9+
benchmark s a b =
10+
bgroup
11+
s
12+
[ bench "Addition" $
13+
nf (uncurry (+)) (a, b),
14+
bench "Multiplication" $
15+
nf (uncurry (*)) (a, b),
16+
bench "Negation" $
17+
nf negate a,
18+
bench "Subtraction" $
19+
nf (uncurry (-)) (a, b),
20+
bench "Inversion" $
21+
nf recip a,
22+
bench "Division" $
23+
nf (uncurry (/)) (a, b),
24+
bench "Frobenius endomorphism" $
25+
nf frob a,
26+
bench "Square root" $
27+
nf sr a
28+
]

bench/Bench/Prime.hs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
module Bench.Prime where
22

3-
import Protolude
4-
3+
import Bench.Galois
54
import Control.Monad.Random
65
import Criterion.Main
76
import Data.Field.Galois
8-
9-
import Bench.Galois
7+
import Protolude
108

119
type Fq = Prime 21888242871839275222246405745257275088696311157297823662689037894645226208583
1210

bench/Main.hs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
module Main where
22

3-
import Protolude
4-
5-
import Criterion.Main
6-
73
import Bench.Binary
84
import Bench.Extension
95
import Bench.Prime
6+
import Criterion.Main
7+
import Protolude
108

119
main :: IO ()
12-
main = defaultMain
13-
[benchBinary, benchExtension, benchPrime]
10+
main =
11+
defaultMain
12+
[benchBinary, benchExtension, benchPrime]

cabal.project

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests: True
2+
benchmarks: True
3+
4+
packages: .
5+
6+
source-repository-package
7+
type: git
8+
location: https://github.com/chessai/semirings.git
9+
tag: 2631c542b57abc9bc9e92db273ab8e80ae88048c
10+
--sha256: j/zGFd2aeowzJfgCCBmJYmG8mDsfF0irqj/cPOw9ulE=

0 commit comments

Comments
 (0)