From c060e2d89381cf5b4e234582af02ed4757980ee7 Mon Sep 17 00:00:00 2001 From: martyall Date: Sun, 2 Jun 2024 01:29:43 -0700 Subject: [PATCH] ci --- .github/workflows/cabal.yml | 72 ++++++++++++++++++++++++++++++++++++ .github/workflows/ormolu.yml | 16 ++++++++ factors/test/Main.hs | 4 +- wasm-solver/app/Main.hs | 4 +- 4 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/cabal.yml create mode 100644 .github/workflows/ormolu.yml diff --git a/.github/workflows/cabal.yml b/.github/workflows/cabal.yml new file mode 100644 index 0000000..4a1e3b1 --- /dev/null +++ b/.github/workflows/cabal.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/ormolu.yml b/.github/workflows/ormolu.yml new file mode 100644 index 0000000..79a171a --- /dev/null +++ b/.github/workflows/ormolu.yml @@ -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" \ No newline at end of file diff --git a/factors/test/Main.hs b/factors/test/Main.hs index 3e0938f..f57b4e8 100644 --- a/factors/test/Main.hs +++ b/factors/test/Main.hs @@ -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 @@ -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 -> diff --git a/wasm-solver/app/Main.hs b/wasm-solver/app/Main.hs index eff3aea..db24902 100644 --- a/wasm-solver/app/Main.hs +++ b/wasm-solver/app/Main.hs @@ -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) @@ -80,4 +80,4 @@ getWitnessSize = Circom._getWitnessSize env foreign export ccall getWitness :: Int -> IO () getWitness :: Int -> IO () -getWitness = Circom._getWitness env stateRef \ No newline at end of file +getWitness = Circom._getWitness env stateRef