Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
martyall committed Jun 2, 2024
1 parent 8e82a54 commit c060e2d
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 4 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/cabal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Cabal CI

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

# INFO: The following configuration block ensures that only one build runs per branch,
# which may be desirable for projects with a costly build process.
# Remove this block from the CI workflow to let each CI job run to completion.
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
ghc-version: ['9.8', '9.6']

steps:
- uses: actions/checkout@v4

- name: Set up GHC ${{ matrix.ghc-version }}
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc-version }}
# Defaults, added for clarity:
cabal-version: 'latest'
cabal-update: true

- name: Configure the build
run: |
cabal configure --enable-tests --enable-benchmarks --disable-documentation
cabal build all --dry-run
# The last step generates dist-newstyle/cache/plan.json for the cache key.

- name: Restore cached dependencies
uses: actions/cache/restore@v3
id: cache
env:
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-

- name: Install dependencies
# If we had an exact cache hit, the dependencies will be up to date.
if: steps.cache.outputs.cache-hit != 'true'
run: cabal build all --only-dependencies

# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
- name: Save cached dependencies
uses: actions/cache/save@v3
# If we had an exact cache hit, trying to save the cache would error because of key clash.
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Build
run: cabal build all

- name: Test
run: cabal test all
16 changes: 16 additions & 0 deletions .github/workflows/ormolu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Ormolu CI

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
ormolu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/run-ormolu@v15
with:
version: "0.7.2.0"
4 changes: 2 additions & 2 deletions factors/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import Circom.R1CS (witnessFromCircomWitness)
import Circom.Solver (CircomProgram (..), mkCircomProgram, nativeGenWitness)
import Circuit
import Circuit.Language
import Data.Binary (decode, encode)
import qualified Data.Map as Map
import Protolude
import R1CS (Witness (..))
import Test.Hspec
import Test.QuickCheck
import ZK.Factors (Fr, factors)
import Data.Binary (encode, decode)

main :: IO ()
main = hspec $ do
Expand All @@ -21,7 +21,7 @@ main = hspec $ do
it "can serialize/deserialize the program" $ do
let a = decode (encode program)
cpCircuit a `shouldBe` cpCircuit program

it "should accept valid factorizations" $
property $
\x y ->
Expand Down
4 changes: 2 additions & 2 deletions wasm-solver/app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Main where

import Data.Binary (decodeFile)
import Circom.Solver qualified as Circom
import Data.Binary (decodeFile)
import Data.IORef (IORef, newIORef)
import Protolude
import System.IO.Unsafe (unsafePerformIO)
Expand Down Expand Up @@ -80,4 +80,4 @@ getWitnessSize = Circom._getWitnessSize env
foreign export ccall getWitness :: Int -> IO ()

getWitness :: Int -> IO ()
getWitness = Circom._getWitness env stateRef
getWitness = Circom._getWitness env stateRef

0 comments on commit c060e2d

Please sign in to comment.