-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from zkFold/build-and-ci
Configure build and ci
- Loading branch information
Showing
18 changed files
with
251 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
name: CI Pull Request | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
|
||
permissions: | ||
contents: write | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
on-main-pull-request: | ||
|
||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
cabal: [3.10.2.1] | ||
ghc: [9.6.3] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Haskell | ||
uses: haskell-actions/[email protected] | ||
id: setup | ||
with: | ||
ghc-version: ${{ matrix.ghc }} | ||
cabal-version: ${{ matrix.cabal }} | ||
cabal-update: true | ||
|
||
- name: Set up rustup nightly | ||
run: | | ||
rustup toolchain install nightly | ||
- name: Set up cargo-c | ||
run: | | ||
cargo install cargo-c | ||
- name: Configure Cabal | ||
run: | | ||
cabal update | ||
cabal configure --enable-tests --enable-benchmarks --enable-documentation | ||
- name: Generate cache key | ||
# Creates plan.json file | ||
run: | | ||
cabal build all --dry-run | ||
- name: Restore cached dependencies | ||
uses: actions/cache/[email protected] | ||
id: cache | ||
env: | ||
key: ${{ matrix.os }}-ghc-${{ matrix.ghc }}-cabal-${{ matrix.cabal }} | ||
with: | ||
path: ${{ steps.setup.outputs.cabal-store }} | ||
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} | ||
restore-keys: ${{ env.key }}- | ||
|
||
- name: Install stylish-haskell | ||
run: | | ||
cabal install stylish-haskell-0.14.5.0 | ||
- name: Cargo clippy | ||
run: | | ||
cargo clippy --manifest-path rust-wrapper/Cargo.toml -- -D warnings | ||
- name: Rust format | ||
run: | | ||
cargo fmt --manifest-path rust-wrapper/Cargo.toml | ||
- name: Lint Haskell | ||
run: | | ||
find . -name '*.hs' -exec sh -c 'for file do stylish-haskell --inplace "$file"; done' sh {} + | ||
- name: Auto-commit lint | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: stylish-haskell auto-commit | ||
commit_user_name: GitHub Action | ||
commit_user_email: [email protected] | ||
branch: ${{ github.head_ref }} | ||
|
||
- 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/[email protected] | ||
# 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 -f Pedantic | ||
# - name: Test | ||
# run: cabal test all | ||
|
||
# - name: Check cabal file | ||
# run: cabal check | ||
|
||
# - name: Document package | ||
# run: cabal haddock all | ||
|
||
# - name: Prepare package for publishing | ||
# run: cabal sdist all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: CI Push | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
workflow_dispatch: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
on-main-update: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
- uses: haskell-actions/[email protected] | ||
with: | ||
ghc-version: '9.6.3' | ||
cabal-version: '3.10.2.1' | ||
|
||
- name: Set up cargo-c | ||
run: | | ||
cargo install cargo-c | ||
- name: Cache | ||
uses: actions/[email protected] | ||
env: | ||
cache-name: cache-cabal | ||
with: | ||
path: ~/.cabal | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Build package | ||
shell: bash | ||
run: | | ||
cabal update | ||
cabal build all -f Pedantic | ||
# - name: Upload package | ||
# env: | ||
# HACKAGE_PASSWORD: ${{ secrets.HACKAGE_PASSWORD }} | ||
# shell: bash | ||
# run: | | ||
# cabal sdist symbolic-base | ||
# cabal upload --username=VladimirSinyakov --password="$HACKAGE_PASSWORD" dist-newstyle/sdist/*.tar.gz | ||
|
||
# cabal v2-haddock symbolic-base --haddock-for-hackage --enable-doc | ||
# cabal upload --documentation --username=VladimirSinyakov --password="$HACKAGE_PASSWORD" dist-newstyle/*-docs.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
import Distribution.Simple | ||
import System.Process | ||
import Control.Monad | ||
import Distribution.Types.HookedBuildInfo | ||
import System.Exit | ||
import Control.Exception (throwIO) | ||
import Control.Monad | ||
import Data.Char (isSpace) | ||
import Data.List (dropWhile, isPrefixOf) | ||
import Distribution.Simple | ||
import Distribution.Types.HookedBuildInfo | ||
import System.Directory | ||
import System.Exit | ||
import System.Process (readProcess, system) | ||
|
||
main :: IO () | ||
main = defaultMainWithHooks simpleUserHooks | ||
{ preConf = runMyScript | ||
|
||
{ preConf = buildRustLib | ||
} | ||
|
||
runMyScript :: Args -> a -> IO HookedBuildInfo | ||
runMyScript args flags = do | ||
putStrLn "Running pre-script..." | ||
executeShellCommand "source ./run.sh" | ||
return $ emptyHookedBuildInfo | ||
|
||
executeShellCommand cmd = putStrLn ("EXEC: " ++ cmd) >> system cmd >>= check | ||
where | ||
check ExitSuccess = return () | ||
check (ExitFailure n) = error $ "cmd: " ++ cmd ++ " failure code " ++ show n | ||
buildRustLib :: Args -> a -> IO HookedBuildInfo | ||
buildRustLib _ flags = do | ||
|
||
buildResult <- system "cargo +nightly cbuild --release --manifest-path rust-wrapper/Cargo.toml" | ||
case buildResult of | ||
ExitSuccess -> return () | ||
ExitFailure exitCode -> throwIO $ userError $ "Build rust library failed with exit code " <> show exitCode | ||
|
||
output <- readProcess "rustc" ["--version", "--verbose"] "" | ||
case filter ("host: " `isPrefixOf`) (lines output) of | ||
[line] -> do | ||
let host = dropWhile isSpace $ drop 5 line | ||
pathToLib = "rust-wrapper/target/" <> host <> "/release/librust_wrapper.so" | ||
|
||
libExist <- doesFileExist pathToLib | ||
unless libExist $ throwIO $ userError "Can't find rust library" | ||
|
||
copyFile pathToLib "./lib.so" | ||
|
||
_ -> throwIO $ userError "Can't find default rust target" | ||
return emptyHookedBuildInfo |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.